2020-10-12 14:39:23 +09:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web ;
using System.Web.Mvc ;
using NP.Model ;
using System.Collections ;
using NP.Base.Auth ;
using NP.Base.ENUM ;
namespace NP.Base.Controllers
{
public partial class FOCommonController : NP . Base . BaseController
{
protected override void OnActionExecuting ( ActionExecutingContext filterContext )
{
base . OnActionExecuting ( filterContext ) ;
}
protected override void OnException ( ExceptionContext filterContext )
{
base . OnException ( filterContext ) ;
if ( Request . IsAjaxRequest ( ) )
{
filterContext . Result = new RedirectResult ( "/Account/NoPermit?_code=" + NP . Base . ENUM . JSONCode . Error + "&_msg=알수없는오류" ) ;
}
else
{
filterContext . Result = new RedirectResult ( "/Account/Error?_code=" + NP . Base . ENUM . JSONCode . Error + "&_msg=알수없는오류" ) ;
}
}
public JsonResult Html ( int pno )
{
return JsonBack ( Dao . Get < MenuPage > ( "mm.pages" , new Hashtable ( ) { { "pno" , pno } } ) . First ( ) ) ;
}
public JsonResult HidePop ( int pno )
{
var p = CookieGet ( "popup" , "" ) ;
CookieSet ( "popup" , p = = "" ? pno . ToString ( ) : ( p + "p" + pno ) , 7 ) ;
return JsonOK ( 1 ) ;
}
public void DownFile ( Int64 fno , int getdel = 0 , String loginfo = "" , int issubject = 0 )
{
Dao . Save ( "sys.file.down" , fno ) ;
var file = Dao . Get < File > ( "sys.file.get" + ( getdel > 0 ? "all" : "" ) , fno ) . FirstOrDefault ( ) ;
//if (!string.IsNullOrEmpty(loginfo))
//{
// LogSet(GetLong(loginfo.Split('|')[0]), null, fno, GetInt(loginfo.Split('|')[1]), 5, null);
//}
//if (((file.tablename ?? "").ToUpper() +"."+ (file.columnname??"").ToUpper()).Equals("삭제체크테이블.삭제체크컬럼"))
//{
// //프로젝트파일 권한 확인
// if (Dao.Get<int>("sys.file.authcheck.orderfgno", new Hashtable() { {"FGNo", file.fgno }, {"UserNo", SUserInfo.UserNo } }).First() < 1)
// {
// return;
// }
//}
//else if ((file.UsingTable ?? "").ToUpper().Equals("users.fgno"))
//{
// //이력서파일 권한 확인
// if (Dao.Get<int>("sys.file.authcheck.usersfgno", new Hashtable() { { "FGNo", file.FGNo }, { "UserNo", SUserInfo.UserNo } }).First() < 1)
// {
// return;
// }
//}
if ( Request . UrlReferrer = = null | | ( ! SUserInfo . IsAdmin & & file . tablename = = "lectsd" & & file . columnname = = "fgno" & & SUserInfo . UserNo ! = file . cno ) )
{
//Response.AppendHeader("Content-Disposition", cds.ToString());
//return File(string.Format("{0}\\{1}", uploadDir, entity.SaveFileName), "application/file");
Response . Clear ( ) ;
Response . ClearHeaders ( ) ;
Response . ClearContent ( ) ;
Response . ContentType = "Application/octet-stream" ;
Response . AppendHeader ( "Content-Disposition" , "attachment;filename=" + Server . UrlEncode ( "권한없음.png" ) ) ;
//Response.AppendHeader("Content-Length", file.filesize.ToString());
Response . TransmitFile ( string . Format ( "{0}" , Server . MapPath ( "/img/repute_tail.png" ) ) ) ;
Response . Flush ( ) ;
Response . End ( ) ;
}
else
{
string fileurl = Server . MapPath ( ( issubject = = 1 ? file . fullurl2 : file . fullurl ) ) ;
//var cds = new System.Net.Mime.ContentDisposition
//{
// FileName = Server.UrlEncode(file.orgname), // 파일의 원래이름(등록할때의 이름)
// Inline = false,
//};
//Response.AppendHeader("Content-Disposition", cds.ToString());
//return File(string.Format("{0}\\{1}", uploadDir, entity.SaveFileName), "application/file");
Response . Clear ( ) ;
Response . ClearHeaders ( ) ;
Response . ClearContent ( ) ;
Response . ContentType = "Application/octet-stream" ;
Response . AppendHeader ( "Content-Disposition" , "attachment;filename=" + Server . UrlEncode ( file . orgname ) ) ;
Response . AppendHeader ( "Content-Length" , file . filesize . ToString ( ) ) ;
Response . TransmitFile ( string . Format ( "{0}" , fileurl ) ) ;
Response . Flush ( ) ;
Response . End ( ) ;
}
}
[HttpPost]
public JsonResult Login ( String uid , String upw , bool issaveid )
{
if ( issaveid )
{
CookieSet ( "savedid" , uid ) ;
}
else
{
CookieClear ( "savedid" ) ;
}
if ( ! string . IsNullOrEmpty ( uid ) & & ! string . IsNullOrEmpty ( upw ) )
{
var u = GoLogin ( uid , upw ) ;
if ( u ! = null )
{
if ( u . userno < 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = - 1 , msg = u . subdomain } ) ;
}
return JsonOK ( u . userno ) ;
}
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult GetBoards ( int btype , int pn , int prc , String sc )
{
return JsonBackList < Board > ( Dao . Get < Board > ( "board.list" , new Hashtable ( ) { { "BType" , btype } , { "SubjectContents" , sc . Trim ( ) = = "" ? null : sc . Trim ( ) } , { "PAGENUM" , pn } , { "PAGEROWSIZE" , prc } } ) ) ;
}
[HttpPost]
public JsonResult CMInnings ( int cmno )
{
return JsonBack ( Dao . Get < CMInning > ( "cm.cminnings" , new System . Collections . Hashtable ( ) { { "cmno" , cmno } } ) ) ;
}
[HttpPost]
public JsonResult CMRelays ( int cmno )
{
var cms = Dao . Get < CM > ( "cm.cmrelays" , new System . Collections . Hashtable ( ) { { "cmno" , cmno } , { "userno" , SUserInfo . UserNo } } ) ;
return JsonBack ( new Hashtable ( ) { { "pre" , cms . Where ( w = > w . ispre = = 1 ) . ToList ( ) } , { "after" , cms . Where ( w = > w . ispre = = 0 ) . ToList ( ) } } ) ;
}
[HttpPost]
public JsonResult AssignFind ( String brno , int? pno )
{
brno = ( brno ? ? "" ) . Replace ( "-" , "" ) ;
return JsonBack ( Dao . Get < Assign > ( "users.assigns" , new Hashtable ( ) { { "brno" , brno } , { "pagenum" , pno } , { "pagerowsize" , 10 } } ) ) ;
}
[HttpPost]
2020-10-28 10:30:00 +09:00
public JsonResult AssignSave ( String brno , String asname , String ceoname )
2020-10-12 14:39:23 +09:00
{
2020-10-28 10:30:00 +09:00
var ht = new Hashtable ( ) { { "asno" , 0 } , { "isjoin" , 0 } , { "ascode" , Dao . Get < int > ( "users.assign.newascode" , 1 ) . First ( ) } , { "joinprice" , 0 } , { "asname" , asname } , { "brno" , brno . Replace ( "-" , "" ) } , { "ceoname" , ceoname } , { "salesamount" , 0 } , { "mcount" , 0 } , { "status" , 1 } , { "isdel" , 0 } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ;
2020-10-12 14:39:23 +09:00
Dao . Insert ( "users.assign.in" , ht ) ;
return JsonOK ( GetInt ( ht [ "asno" ] ) ) ;
}
[HttpPost]
public JsonResult Join ( Users u )
{
u . uip = GetUserIP ( ) ;
//이메일, 아이디 중복 체크
2020-10-28 10:06:43 +09:00
var u129 = Dao . Get < int > ( "users.checkuser" , new Hashtable ( ) { { "userid" , u . userid } , { "email" , u . email } , { "mobile" , u . mobile } } ) . First ( ) ;
2020-10-12 14:39:23 +09:00
if ( u129 ! = 9 )
{
return JsonOK ( u129 * - 1 ) ;
}
u . userpass = NP . Base . Lib . KISA_SHA256 . SHA256Hash ( u . userpass . Trim ( ) ) ;
2020-10-28 14:36:43 +09:00
u . birthday = u . birthday ! = null & & u . birthday . Length = = 8 ? ( u . birthday ? ? "" ) . Substring ( 0 , 4 ) + "-" + ( u . birthday ? ? "" ) . Substring ( 4 , 2 ) + "-" + ( u . birthday ? ? "" ) . Substring ( 6 , 2 ) : null ;
2020-10-12 14:39:23 +09:00
u . usertype = u . status = 1 ;
Dao . Insert ( "users.in" , u ) ;
return JsonOK ( u . userno ) ;
}
[HttpPost]
public JsonResult FindMe ( String email )
{
if ( string . IsNullOrEmpty ( email ) ) { return JsonOK ( - 1 ) ; }
email = email . Replace ( " " , "" ) . Replace ( " " , "" ) ;
List < Users > users = new List < Users > ( ) { } ;
bool IsEmail = false ;
if ( email . Contains ( "@" ) )
{
IsEmail = true ;
users = Dao . Get < Users > ( "users.findme" , new Hashtable ( ) { { "email" , email } } ) . ToList ( ) ;
}
//else
//{
// users = Dao.Get<Users>("users.findme", new Hashtable() { { "Mobile1", em }, { "Mobile2", em.Replace("-", "") } }).ToList();
//}
if ( users . Count ( ) ! = 1 )
{
//검색결과 2개 개정이라면 보내면 안됨..다른사람일 수도
return JsonOK ( - 1 ) ;
}
var user = users . First ( ) ;
//메시지 전송시간 기록
Random r = new Random ( ) ;
int pwcallno = r . Next ( 1 , 30000 ) ;
Dao . Save ( "users.pwcalltime" , new Hashtable ( ) { { "userno" , user . userno } , { "pwcallno" , pwcallno } } ) ;
var masteremail = GetConfig ( "masteremail" ) ;
String fronturl = GetConfig ( "fronturl" ) ;
//if (IsEmail)
//{
//var et = Dao.Get<MailTP>("mm.mailtp.get", 1).FirstOrDefault();
//var MHtml = "";
//if (et != null)
//{
// MHtml = et.MHtml.Replace("src=\"/Files/Editor", "src=\"" + fronturl + "/Files/Editor").Replace("^비밀번호링크^", fronturl + "/Account/FindMe?PWCallNo=" + pwcallno + "&UserNo=" + user.UserNo).Replace("^회원명^", user.UserName).Replace("../img/", fronturl + "/img/").Replace("^fronturl^", fronturl);
//}
//else
//{
2020-10-26 13:17:58 +09:00
var MHtml = "<img src=\"" + fronturl + "/img/common/gnb_logo.gif\" alt=\"\" /><br /><br />안녕하세요, " + user . username + "님,<br />당신의 영남건설기술교육원 비밀번호를 재설정하기 위한 링크를 전달합니다.<br />" +
2020-10-12 14:39:23 +09:00
"아래 링크를 클릭하셔서 비밀번호를 재설정해주세요.<br /><br />" +
"<a href=\"" + fronturl + "/Account/FindMe?pwcallno=" + pwcallno + "&userno=" + user . userno + "\" target=\"_blank\" style=\"color: #0094ff;\">비밀번호 재설정</a><br /><br />이 링크는 24시간 뒤 만료됩니다." ;
//}
//return JsonOK(SendEmail(0, user.userid, null, null, user.username + "님, 유앤파트너즈 비밀번호를 재설정할 수 있는 링크를 전달합니다.", MHtml));
2020-10-12 15:32:10 +09:00
return JsonOK ( SendEmail ( masteremail . Split ( ';' ) [ 1 ] , GetInt ( masteremail . Split ( ';' ) [ 2 ] ) , masteremail . Split ( ';' ) [ 3 ] , masteremail . Split ( ';' ) [ 4 ] , 999 , user . email , masteremail . Split ( ';' ) [ 0 ] , "영남건설기술교육원 운영자" , "[영남건설기술교육원] 비밀번호 찾기 안내" , MHtml , "" , "0:0" ) ) ;
2020-10-12 14:39:23 +09:00
//}
//else
//{
// var html = "회원님의 이메일주소는 " + user.UserId + " 아래 링크를 클릭해주셔서 인증을 완료해주세요. [" + fronturl + "/Account/FindMe?PWCallNo=" + pwcallno + "&UserNo=" + user.UserNo + "]";
// return JsonOK(SendSms(null, user.Mobile, "[유앤파트너즈] 계정찾기", html, null, true, "7"));
// //Sms.Save("test", new Hashtable() { });
// //return JsonOK(1);
//}
}
[HttpPost]
public JsonResult FindMeFinal ( VMUser vm )
{
if ( vm . userno > 0 & & vm . pwcallno > 0 & & ! string . IsNullOrEmpty ( vm . User . userpass ) & & vm . User . userpass . Trim ( ) ! = "" )
{
if ( Dao . Save ( "users.resetuser" , new Hashtable ( ) { { "userpass" , NP . Base . Lib . KISA_SHA256 . SHA256Hash ( vm . User . userpass ) } , { "userno" , vm . userno } , { "pwcallno" , vm . pwcallno } } ) = = 1 )
{
//자동로그인처리
var u = GoLogin ( vm . User . userid , vm . User . userpass ) ;
if ( u ! = null )
{
return JsonOK ( 1 ) ;
}
}
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult MyPageLeftMenu ( String on )
{
CookieSet ( "mypageleftmenutoggle" , on ) ;
return JsonOK ( 1 ) ;
}
[HttpPost]
public JsonResult CRoomPageLeftMenu ( String on )
{
CookieSet ( "croompageleftmenutoggle" , on ) ;
return JsonOK ( 1 ) ;
}
[HttpPost]
public JsonResult IsAuth ( )
{
if ( SUserInfo . UserNo > 0 )
{
return JsonOK ( 1 ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult StudyLog ( Int64 logno , Int64 lectno , Int64 cmino , int cpno , int studysec , int ispc , int nextcpno , int getiframe , int issample = 0 , int psec = 0 )
{
if ( SUserInfo . UserNo > 0 | | issample > 0 )
{
int rtn = 0 ;
if ( issample < 1 )
{
rtn = Dao . Save ( "cr.studylog" , new Hashtable ( ) { { "logno" , logno } , { "lectno" , lectno } , { "cmino" , cmino } , { "userno" , SUserInfo . UserNo } ,
{ "psec" , psec } ,
{ "cpno" , cpno } , { "studysec" , studysec } , { "ispc" , ispc } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ;
}
if ( nextcpno > 0 )
{
String ua = "" ;
try
{
ua = ( Request . UserAgent ? ? "" ) . ToLower ( ) ;
}
catch ( Exception ex )
{
Logger . Error ( "ExamStart Get UserAgent Info Error" + ex . StackTrace ) ;
}
var lip = new LectInningPage ( ) { lectno = lectno , cmino = cmino , cpno = nextcpno , userno = SUserInfo . UserNo , uno = SUserInfo . UserNo , uip = GetUserIP ( ) , ispc = ispc , webkitinfo = ua } ;
if ( issample < 1 )
{
Dao . Insert ( "cr.lectinningpage.in" , lip ) ;
if ( lip . logno < 1 | | getiframe = = 0 )
{
return JsonOK ( lip . logno ) ;
}
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , msg = Dao . Get < String > ( "cr.ctpage.iframe" , new Hashtable ( ) { { "cpno" , nextcpno } , { "src" , ispc > 1 ? "srcp" : "srcm" } } ) . First ( ) , obj = lip . logno } ) ;
}
return JsonOK ( rtn ) ;
}
else
{
return JsonOK ( 0 ) ;
}
}
[HttpPost]
public JsonResult StudyLogMid ( Int64 lectno , Int64 cmino )
{
if ( SUserInfo . UserNo > 0 )
{
return JsonOK ( Dao . Save ( "cr.studymid" , new Hashtable ( ) { { "lectno" , lectno } , { "cmino" , cmino } } ) ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult CheckInningChange ( Int64 lectno , Int64 cmino , bool ispre )
{
if ( SUserInfo . UserNo > 0 )
{
var cmi = Dao . Get < LectInning > ( "cr.inningchange." + ( ispre ? "pre" : "next" ) , new Hashtable ( ) { { "lectno" , lectno } , { "cmino" , cmino } } ) . FirstOrDefault ( ) ;
if ( cmi = = null )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = - 1 } ) ;
}
else if ( cmi . iseq > 1 & & cmi . precmino > 0 & & cmi . isseq = = 1 & & cmi . preistatus ! = 2 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = - 2 } ) ;
}
else if ( cmi . isrebate = = 1 )
{
var intval = Dao . Get < LectInning > ( "cr.lectinnings" , new System . Collections . Hashtable ( ) { { "lectno" , lectno } , { "isfinishtoday" , 1 } } ) . Count ( ) ;
if ( intval > 5 & & cmi . istatus < 2 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = - 3 } ) ;
}
}
return JsonOK ( cmi . cmino ) ;
}
return JsonOK ( 0 ) ;
}
2020-10-28 10:06:43 +09:00
[HttpPost]
public JsonResult idchk ( String id )
{
//이메일, 아이디 중복 체크
var u129 = Dao . Get < Users > ( "users.usersbyuserids" , new Hashtable ( ) { { "userids" , "'" + id + "'" } , { "usertype" , 1 } } ) ;
if ( u129 . Count ( ) > 0 )
{
return JsonOK ( - 1 ) ;
}
return JsonOK ( 1 ) ;
}
2020-10-12 14:39:23 +09:00
}
}