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 ;
using System.Text.RegularExpressions ;
namespace NP.Base.Controllers
{
/// <summary>
/// 관리자권한, antitoken필요로하는 ajax호출
/// </summary>
[NP.Base.Auth.CFilter]
public partial class ACommonController : 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=알수없는오류" ) ;
}
}
[HttpPost]
public JsonResult SaveUserAuth ( String authname )
{
return JsonOK ( Dao . Save ( "sys.userauth.save" , new Hashtable ( ) { { "authname" , authname } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ) ;
}
[HttpPost]
public JsonResult SaveAuthName ( String authname , int usertype )
{
return JsonOK ( Dao . Save ( "sys.authname.save" , new Hashtable ( ) { { "authname" , authname } , { "usertype" , usertype } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ) ;
}
[HttpPost]
public JsonResult DelUserAuth ( int usertype , String authname )
{
return JsonOK ( Dao . Save ( "sys.userauth.del" , new Hashtable ( ) { { "usertype" , usertype } , { "authname" , authname } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ) ;
}
[HttpPost]
public JsonResult GetMenu ( int mno )
{
return JsonBack < Menu > ( Dao . Get < Menu > ( "sys.menu" , new Hashtable ( ) { { "menuno" , mno } } ) . FirstOrDefault ( ) ) ;
}
[HttpPost]
public JsonResult SaveMenu ( VMSystem vm )
{
if ( ! string . IsNullOrEmpty ( vm . savedata ) )
{
var sd = vm . savedata . Split ( ':' ) ;
vm . menu = new Menu ( ) { menuno = Convert . ToInt32 ( sd [ 0 ] ) , pmenuno = Convert . ToInt32 ( sd [ 1 ] ) , menuorder = Convert . ToInt32 ( sd [ 2 ] ) , uip = GetUserIP ( ) , uno = SUserInfo . UserNo } ;
int rtn = Dao . Save ( "sys.menu.chageposition" , vm . menu ) ;
if ( rtn > 0 )
{
ResetMenuBase ( ) ;
}
return JsonOK ( rtn , false ) ;
}
else if ( vm . menu ! = null )
{
vm . menu . uip = GetUserIP ( ) ;
vm . menu . uno = SUserInfo . UserNo ;
if ( vm . menu . menuno > 0 )
{
int rtn = Dao . Save ( "sys.menu.update" , vm . menu ) ;
if ( rtn > 0 )
{
ResetMenuBase ( ) ;
}
return JsonOK ( rtn , false ) ;
}
return JsonOK ( Dao . Insert < Menu , int > ( "sys.menu.insert" , vm . menu ) , false ) ;
}
return JsonNoAuth ( ) ;
}
[HttpPost]
public JsonResult DeleteMenu ( VMSystem vm )
{
if ( vm . menu ! = null & & vm . menu . menuno > 0 )
{
int rtn = Dao . Delete ( "sys.menu.delete" , vm . menu . menuno ) ;
if ( rtn > 0 )
{
ResetMenuBase ( ) ;
NP . Base . Logger . Delete ( "ip>" + GetUserIP ( ) + ", userno>" + SUserInfo . UserNo + ", queryid>" + "sys.menu.delete" + ", data>" + ( new System . Web . Script . Serialization . JavaScriptSerializer ( ) . Serialize ( vm . menu ) ) ) ;
}
return JsonOK ( rtn , false ) ;
}
return JsonNoAuth ( ) ;
}
[HttpPost]
public JsonResult SaveMenuAuth ( VMSystem vm )
{
if ( vm . intval > 0 )
{
Menu m = new Menu ( ) ;
m . usertype = vm . intval ;
m . authname = vm . stringval ;
m . menunos = MakeSaveData ( vm . savedata ) ;
m . isdel = 0 ;
m . uip = GetUserIP ( ) ;
m . uno = SUserInfo . UserNo ;
AuthSet ( new AuthLog ( ) { uno = SUserInfo . UserNo , uip = GetUserIP ( ) , logtype = 0 , usertypeorg = m . usertype , usertypenew = m . usertype } ) ;
Dao . Save ( "sys.authmenu.save" , m ) ;
ResetMenuBase ( ) ;
return JsonOK ( 1 , true ) ;
}
return JsonNoAuth ( ) ;
}
[HttpPost]
public JsonResult GetAuthMenu ( int ano , String aName )
{
return JsonBackList < Menu > ( Dao . Get < Menu > ( "sys.authmenu" , ano ) ) ;
}
public JsonResult MENURESET ( String ddd )
{
if ( SUserInfo . IsAdmin | | "rhksflwkfhrmdls999" . Equals ( ddd ) )
{
ResetMenuBase ( ) ;
return JsonOK ( 1 , true ) ;
}
return JsonOK ( 1 , true ) ;
}
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 ( new ActLog ( ) { logtype = 90 , logtarget = 91 , userno = fno , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) ;
}
//string fileurl = Server.MapPath(file.fullurl);
//var cds = new System.Net.Mime.ContentDisposition
//{
// //FileName = Server.UrlEncode(file.orgname), // 파일의 원래이름(등록할때의 이름)
// FileName = HttpUtility.UrlEncode(file.orgname, System.Text.Encoding.UTF8), // 파일의 원래이름(등록할때의 이름)
// Inline = false,
//};
//Response.ClearContent();
//Response.AppendHeader("Content-Disposition", cds.ToString());
//Response.AppendHeader("Content-Length", file.FileSize.ToString());
//Response.TransmitFile(string.Format("{0}", fileurl));
//Response.Flush();
Response . ClearContent ( ) ;
Response . Clear ( ) ;
Response . ContentType = "text/plain" ;
Response . AddHeader ( "Content-Disposition" , "attachment; filename=" + HttpUtility . UrlEncode ( file . orgname , System . Text . Encoding . UTF8 ) + ";" ) ;
Response . TransmitFile ( Server . MapPath ( issubject = = 1 ? file . fullurl2 : file . fullurl ) ) ;
Response . Flush ( ) ;
Response . End ( ) ;
}
[HttpPost]
public JsonResult DeleteFile ( Int64 key = 0 , String fName = "" , Int64 fgno = 0 , int isSingleFile = 0 , String log = "" )
{
var rtn = DropFile ( key , fName ) ;
if ( rtn < 1 )
{
throw new System . ArgumentNullException ( "nodata" ) ;
}
else
{
if ( log ! = "" )
{
//로그 남김
//LogSet(GetLong(log.Split('|')[0]), null, key, GetInt(log.Split('|')[1]), 4, null, null, null);
}
return JsonOK ( 1 , false ) ;
}
}
[HttpPost]
public JsonResult DeleteQuestionItem ( Int64 qino )
{
//이미 응시한 데이터 존재하는지 확인
if ( Dao . Get < int > ( "cm.questionitem.valid" , qino ) . First ( ) < 1 )
{
QuestionItem qi = new QuestionItem ( ) { qino = qino , uip = GetUserIP ( ) , uno = SUserInfo . UserNo } ;
return JsonOK ( Dao . Save ( "cm.questionitem.del" , qi ) , false ) ;
}
return JsonOK ( 0 , false ) ;
}
[HttpPost]
public JsonResult UploadEditorImageUrl ( String fd )
{
if ( ! string . IsNullOrEmpty ( Request . Files [ "img" ] . FileName ) )
{
return SetFileNoDB ( Request . Files , fd ) ;
}
return JsonNoApply ( ) ;
}
[HttpPost]
public ActionResult GetUserList ( int ut , int cno )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = Dao . Get < Users > ( "cl.users" , new Hashtable ( ) { { "UserType" , ut } , { "ClientNo" , cno } } ) } ) ;
}
[HttpPost]
public JsonResult GetComment ( int commenttype , Int64 ? baseno , bool getuserinfo = false )
{
return JsonBack < Comment > ( Dao . Get < Comment > ( "common.basecomments" , new Hashtable ( ) { { "cmttype" , commenttype } , { "baseno" , baseno } } ) . ToList ( ) ) ;
}
[HttpPost]
public JsonResult SaveComment ( int commenttype , Int64 ? baseno , string memotype , String memo , Int64 ? fgno , Int64 cmtno , Int64 ? pcmtno , bool IsPassFile = true )
{
//if (!"resume".Equals(commenttype) && Request.Files.Count > 0 && !string.IsNullOrEmpty(Request.Files["file"].FileName))
if ( ! IsPassFile & & Request . Files . GetMultiple ( "file" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
fgno = SetFile ( Request . Files . GetMultiple ( "file" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , fgno ? ? 0 , "cmt" , "fgno" ) ;
fgno = fgno = = 0 ? ( Int64 ? ) null : fgno ;
}
switch ( commenttype )
{
case 0 :
//고객사
return JsonOK ( Dao . Save ( "common.comment.save" , new Hashtable ( ) { { "cmttype" , 0 } , { "cmtno" , cmtno } , { "pcmtno" , pcmtno } , { "baseno" , baseno } , { "userno" , SUserInfo . UserNo } , { "memo" , memo } , { "memotype" , memotype } , { "fgno" , fgno } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ) ;
//case "order":
// return JsonOK(Dao.Save("common.comment.save", new Hashtable() { { "CMTType", 0 }, { "CMTNo", cmtno }, { "PCMTNo", pcmtno }, { "BaseNo", baseno }, { "UserNo", SUserInfo.UserNo }, { "Memo", memo }, { "FGNo", fgno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
//case "resume":
// return JsonOK(Dao.Save("common.comment.save", new Hashtable() { { "CMTType", 1 }, { "CMTNo", cmtno }, { "PCMTNo", pcmtno }, { "BaseNo", baseno }, { "UserNo", SUserInfo.UserNo },{"MemoType", memotype }, { "Memo", memo }, { "FGNo", fgno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
//case "board":
// return JsonOK(Dao.Save("common.comment.save", new Hashtable() { { "CMTType", 2 }, { "CMTNo", cmtno }, { "PCMTNo", pcmtno }, { "BaseNo", baseno }, { "UserNo", SUserInfo.UserNo }, { "Memo", memo }, { "FGNo", fgno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
default :
return JsonOK ( 0 ) ;
}
}
[HttpPost]
public JsonResult DeleteComment ( Int64 cmtno )
{
return JsonOK ( Dao . Save ( "common.comment.delete" , new Hashtable ( ) { { "cmtno" , cmtno } , { "isadmin" , SUserInfo . IsAdmin ? "1" : null } , { "cno" , SUserInfo . UserNo } } ) ) ;
}
[HttpPost]
public JsonResult SaveOrderFile ( int ono , Int64 ? fgno )
{
var orgfgno = fgno ? ? 0 ;
fgno = SetFile ( Request . Files , fgno ? ? 0 , "Order" , "Order.FGNo" ) ;
fgno = fgno < 1 ? ( Int64 ? ) null : fgno ;
if ( fgno ! = null )
{
if ( orgfgno > 0 )
{
return JsonOK ( fgno . Value ) ;
}
else
{
return JsonOK ( Dao . Save ( "ass.orderfile.set" , new Hashtable ( ) { { "ONo" , ono } , { "FGNo" , fgno } , { "uno" , SUserInfo . UserNo } , { "uip" , GetUserIP ( ) } } ) ) ;
}
}
return JsonOK ( 0 ) ;
}
/// <summary>
/// 쪽지발송
/// </summary>
/// <param name="unos">콤마로 구분한 수신자번호 1,2,3</param>
/// <param name="mm">쪽지내용</param>
/// <param name="mt">쪽지제목</param>
/// <param name="rcvug">0: 운영자대상, 1: 사용자대상</param>
/// <returns></returns>
[HttpPost]
public JsonResult NewMemo ( String unos , String mm , String mt , int rcvug , Int64 ? refno = null , Int64 ? suno = null , String refdesc = "" )
{
Int64 ? fgno = null ;
if ( Request . Files . Count > 0 )
{
fgno = SetFile ( Request . Files , fgno ? ? 0 , "memo" , "memo.fgno" ) ;
fgno = fgno = = 0 ? Convert . ToInt64 ( null ) : fgno ;
}
var rtn = 0 ;
if ( "ut34" . Equals ( unos ) )
{
rtn = Dao . Save ( "common.memo.inserttousertype" , new Memo ( ) { usernos = unos , mtitle = mt , mcontents = mm , fgno = fgno , cno = suno = = null ? SUserInfo . UserNo : suno . Value , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) ;
}
else
{
rtn = Dao . Save ( "common.memo.insert" , new Memo ( ) { usernos = unos , mtitle = mt , mcontents = mm , fgno = fgno , cno = suno = = null ? SUserInfo . UserNo : suno . Value , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) ;
}
return JsonOK ( rtn ) ;
}
/// <summary>
/// 0: 이메일사용가능, 0>? 이메일사용중
/// </summary>
/// <param name="email"></param>
/// <param name="uts"></param>
/// <returns></returns>
[HttpPost]
public JsonResult EmailCheck ( Int64 ? UserNo , String email , bool islogin )
{
UserNo = ( UserNo ? ? 0 ) < 1 ? ( Int64 ? ) null : UserNo ;
return JsonOK ( Dao . Get < int > ( "users.emailcheck" , new Hashtable ( ) { { "UserNo" , UserNo } , { "Email" , email } , { islogin ? "IsLoginUser" : "IsResumeUser" , 1 } } ) . First ( ) , true ) ;
}
[HttpPost]
public JsonResult ComCode ( String cg , String cn )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "cgroup" , cg } , { "cnamelike" , cn } , { "orderby" , "a.cname" } } ) } ) ;
}
[HttpPost]
public JsonResult DelMemo ( String sendrcv , String mnos = "0" , bool isall = false )
{
var mm = new Memo ( ) { uno = SUserInfo . UserNo , uip = GetUserIP ( ) , mno = mnos . Contains ( "," ) ? 0 : GetInt ( mnos ) , mnos = mnos . Contains ( "," ) ? mnos : null } ;
if ( "R" . Equals ( sendrcv ) )
{
if ( isall )
{
return JsonOK ( Dao . Save ( "common.memo.alldelete" + sendrcv , mm ) ) ;
}
return JsonOK ( Dao . Save ( "common.memo.delete" + sendrcv , mm ) ) ;
}
else
{
if ( isall )
{
return JsonOK ( Dao . Save ( "common.memo.alldelete" + sendrcv , mm ) ) ;
}
return JsonOK ( Dao . Save ( "common.memo.delete" + sendrcv , mm ) ) ;
}
}
[HttpPost]
public JsonResult SaveMemo ( Memo m )
{
if ( m . cmno ! = null )
{
//강좌수강생들에게 이메일 발송
var data = Dao . Get < Lect > ( "lect.users" , new Hashtable ( ) { { "cmno" , m . cmno } , { "status" , 1 } } ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonOK ( - 1 ) ;
}
m . usernos = string . Join ( "," , data . Select ( s = > s . userno ) ) ;
}
Int64 ? fgno = null ;
if ( Request . Files . GetMultiple ( "file" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
fgno = SetFile ( Request . Files . GetMultiple ( "file" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , fgno ? ? 0 , "Memo" , "Memo.FGNo" ) ;
fgno = fgno = = 0 ? Convert . ToInt64 ( null ) : fgno ;
}
m . fgno = fgno ;
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
return JsonOK ( Dao . Save ( "common.memo.insertmulti" , m ) ) ;
}
[HttpPost]
public JsonResult SaveSms ( Memo m )
{
m . Users = new List < MemoUser > ( ) { } ;
if ( m . cmno ! = null )
{
//강좌수강생들에게 메시지 발송
var data = Dao . Get < Lect > ( "lect.users" , new Hashtable ( ) { { "cmno" , m . cmno } , { "status" , 1 } } ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonOK ( - 1 ) ;
}
foreach ( var u in data )
{
2020-12-02 15:15:09 +09:00
m . Users . Add ( new MemoUser ( ) { userno = u . userno , smstype = "S" , isok = string . IsNullOrEmpty ( u . mobile ) ? - 1 : 1 , mobile = ( u . mobile ? ? "" ) . Replace ( "-" , "" ) } ) ;
2020-10-12 14:39:23 +09:00
}
}
else
{
var data = Dao . Get < Users > ( "users.byusernos" , m . usernos ) ;
foreach ( var u in data )
{
2020-12-02 15:15:09 +09:00
m . Users . Add ( new MemoUser ( ) { userno = u . userno , smstype = "S" , isok = string . IsNullOrEmpty ( u . mobile ) ? - 1 : 1 , mobile = ( u . mobile ? ? "" ) . Replace ( "-" , "" ) } ) ;
2020-10-12 14:39:23 +09:00
}
}
2020-12-03 16:29:27 +09:00
2020-12-02 15:15:09 +09:00
//m.mcontents = m.mcontents.Length > 1000 ? m.mcontents.Substring(0, 1000) : m.mcontents;
2020-10-12 14:39:23 +09:00
var us = m . Users . Where ( w = > w . isok = = 1 ) . ToList ( ) ;
if ( us . Count ( ) > 0 )
{
2020-12-03 16:29:27 +09:00
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
Dao . Insert ( "common.sms.in" , m ) ;
2020-12-02 15:15:09 +09:00
System . Text . StringBuilder sb = new System . Text . StringBuilder ( "" ) ;
var cbnum = GetConfig ( "mtssendnum" ) ;
2020-12-03 16:29:27 +09:00
var ismms = System . Text . Encoding . Default . GetBytes ( m . mcontents ) . Length > 90 ;
2020-10-12 14:39:23 +09:00
for ( var i = 0 ; i < us . Count ( ) ; i + + )
{
2020-12-03 16:29:27 +09:00
sb . Append ( string . Format ( ",('{0}','{1}','{2}', now(),{5},'{3}','{4}')" , us [ i ] . mobile , cbnum , m . mcontents , m . mno , us [ i ] . userno , ismms ? 4 : 0 ) ) ;
2020-12-02 15:15:09 +09:00
}
var strConn = GetConfig ( "mtsdb" ) ;
using ( var conn = new MySql . Data . MySqlClient . MySqlConnection ( strConn ) )
{
conn . Open ( ) ;
2020-12-03 16:29:27 +09:00
var cmd = new MySql . Data . MySqlClient . MySqlCommand ( "insert into mts_" + ( ismms ? "m" : "s" ) + "ms_msg(tran_phone,tran_callback,tran_msg,tran_date,tran_type,tran_etc1,tran_etc2) values" + sb . ToString ( ) . Substring ( 1 ) , conn ) ;
2020-12-02 15:15:09 +09:00
cmd . ExecuteNonQuery ( ) ;
2020-10-12 14:39:23 +09:00
}
2020-12-03 16:29:27 +09:00
return JsonOK ( Dao . Save ( "common.smsuser.in" , m ) ) ;
2020-10-12 14:39:23 +09:00
}
2020-12-03 16:29:27 +09:00
return JsonOK ( 0 ) ;
2020-10-12 14:39:23 +09:00
}
[HttpPost]
public JsonResult GetComCode ( String gcode , int? ccode , int? pcode , int? isuse )
{
if ( ccode ! = null )
{
return JsonBack < ComCode > ( Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "cgroup" , gcode } , { "ccode" , ccode } , { isuse = = null ? "all" : "isuse" , isuse = = null ? 1 : isuse } } ) . FirstOrDefault ( ) ) ;
}
else if ( pcode ! = null )
{
return JsonBackList < ComCode > ( Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "cgroup" , gcode } , { "pcode" , pcode } , { isuse = = null ? "all" : "isuse" , isuse = = null ? 1 : isuse } } ) ) ;
}
return JsonBackList < ComCode > ( Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "cgroup" , gcode } , { "ccode" , ccode } , { isuse = = null ? "all" : "isuse" , isuse = = null ? 1 : isuse } } ) ) ;
}
[HttpPost]
public JsonResult UpdateCgroup ( String cgroup , String cgroupname )
{
return JsonOK ( Dao . Save ( "mm.comcode.groupupdate" , new Hashtable ( ) { { "cgroup" , cgroup } , { "cgroupname" , cgroupname } } ) , false ) ;
}
[HttpPost]
public JsonResult SaveNewcCode ( String cg , string cn , int co = 0 , int iu = 1 )
{
return JsonOK ( Dao . Save ( "mm.comcode.insert" , new ComCode ( ) { cname = cn , cgroup = cg , isuse = iu , corder = co , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) ) ;
}
[HttpPost]
public JsonResult SaveCCode ( int cc , string cn , int? co = null , int? iu = null )
{
return JsonOK ( Dao . Save ( "mm.comcode.update" , new ComCode ( ) { ccode = cc , cname = cn , corder = co ? ? - 1 , isuse = iu ? ? - 1 , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) ) ;
}
[HttpPost]
[ValidateInput(false)]
public JsonResult SavePopup ( int pno , String ptitle , int leftpx , int toppx , int zindex , int pwidth , int pheight , int isopen , String purl , String pcontents )
{
if ( Dao . Save ( "mm.popup.save" , new Popup ( ) { pno = pno , ptitle = ptitle , leftpx = leftpx , toppx = toppx , zindex = zindex , pwidth = pwidth , pheight = pheight , isopen = isopen , purl = purl , pcontents = pcontents , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ) = = 1 )
{
FrontMenu ( "Popups" ) ;
return JsonOK ( 1 ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult SaveBanner ( Banner b )
{
if ( Request . Files . GetMultiple ( "fgnoimg" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
b . fgno = SetFile ( Request . Files . GetMultiple ( "fgnoimg" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , 0 , "banner" , "fgno" ) . Value ;
}
if ( Request . Files . GetMultiple ( "fgnoimg2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
b . fgno2 = SetFile ( Request . Files . GetMultiple ( "fgnoimg2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , 0 , "banner" , "fgno2" ) . Value ;
}
b . uno = SUserInfo . UserNo ;
b . uip = GetUserIP ( ) ;
if ( Dao . Save ( "mm.banner.save" , b ) = = 1 )
{
FrontMenu ( "Banners" ) ;
return JsonOK ( 1 ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult Popup ( int pno )
{
return JsonBack < Popup > ( Dao . Get < Popup > ( "mm.popups" , new System . Collections . Hashtable ( ) { { "pno" , pno } } ) . First ( ) ) ;
}
[HttpPost]
public JsonResult Banner ( int bno )
{
return JsonBack < Banner > ( Dao . Get < Banner > ( "mm.banners" , new System . Collections . Hashtable ( ) { { "bno" , bno } } ) . First ( ) ) ;
}
[HttpPost]
[ValidateInput(false)]
public JsonResult SaveMenuPage ( MenuPage m )
{
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
if ( Dao . Save ( "mm.menupage.save" , m ) = = 1 )
{
FrontMenu ( "Menus" ) ;
return JsonOK ( 1 ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult MenuPage ( int pno )
{
return JsonBack < MenuPage > ( Dao . Get < MenuPage > ( "mm.pages" , new System . Collections . Hashtable ( ) { { "pno" , pno } } ) . First ( ) ) ;
}
[HttpPost]
[ValidateInput(false)]
public JsonResult EmailSend ( VMCC vm )
{
vm . EmailSend . uno = SUserInfo . UserNo ;
vm . EmailSend . uip = GetUserIP ( ) ;
var data = new List < Lect > ( ) { } ;
if ( vm . EmailSend . cmno ! = null )
{
//강좌수강생들에게 이메일 발송
data = Dao . Get < Lect > ( "lect.users" , new Hashtable ( ) { { "cmno" , vm . EmailSend . cmno } , { "status" , 1 } } ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonOK ( - 1 ) ;
}
}
else
{
data = Dao . Get < Lect > ( "users.getlectbyusernos" , vm . savedata ) . ToList ( ) ;
}
//for(var i = 0; i < data.Count(); i++)
//{
// if (!IsEmail(data[i].email))
// {
// return JsonBack(new JsonRtn() { code = 1000, obj = -4, msg = (i+1).ToString() });
// }
//}
if ( Request . Files . GetMultiple ( "file2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
vm . EmailSend . fgno = SetFile ( Request . Files . GetMultiple ( "file2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , vm . EmailSend . fgno ? ? 0 , "EmailSend" , "EmailSend.FGNo" ) ;
}
var okcount = 0 ;
vm . EmailSend . rcvcount = data . Count ( ) ;
vm . EmailSend . rcvs = string . Join ( ";" , data . Select ( s = > string . Format ( "{0}:{1}" , s . username . Replace ( ":" , "" ) . Replace ( ";" , "" ) , s . email ) ) ) ;
vm . EmailSend . uno = SUserInfo . UserNo ;
vm . EmailSend . uip = GetUserIP ( ) ;
vm . EmailSend . reademails = "" ;
Dao . Insert ( "common.emailsend.in" , vm . EmailSend ) ;
var bans = Dao . Get < EmailSend > ( "common.emailbanpool" , string . Join ( "," , data . Select ( s = > string . Format ( "'{0}'" , s . email ) ) ) ) ;
string fname = "" ;
if ( ( vm . EmailSend . fgno ? ? 0 ) > 0 )
{
fname = vm . Files + GetFiles ( vm . EmailSend . fgno . Value ) . First ( ) . fileurl ;
}
vm . EmailSend . sendeds = "" ;
vm . EmailSend . bans = "" ;
int bancount = 0 ;
vm . EmailSend . ehtml = vm . EmailSend . ehtml . Replace ( "^fronturl^" , GetConfig ( "fronturl" ) ) . Replace ( "../img/mail" , GetConfig ( "fronturl" ) + "/img/mail" ) ;
var sender = Dao . Get < Users > ( "users.me" , SUserInfo . UserNo ) . First ( ) ;
String [ ] contents = { vm . EmailSend . ehtml ? ? "" } ;
var masteremail = GetConfig ( "masteremail" ) ;
var senderemail = Request . IsLocal | | string . IsNullOrEmpty ( sender . email ) | | ! IsEmail ( sender . email ) ? masteremail . Split ( ';' ) [ 0 ] : sender . email ;
foreach ( var u in data )
{
if ( string . IsNullOrEmpty ( u . email ) | | ! IsEmail ( u . email ) | | u . isacceptemail = = 0 | | bans . Where ( w = > w . semail = = u . email ) . FirstOrDefault ( ) ! = null )
{
bancount + + ;
vm . EmailSend . bans + = ";" + u . email ;
}
2020-10-12 15:32:10 +09:00
else if ( SendMailTemplate ( "3" , senderemail , "영남건설기술교육원" , u . email , vm . EmailSend . etitle , contents , fname = = "" ? "" : Server . MapPath ( fname ) , null ) > 0 )
2020-10-12 14:39:23 +09:00
{
okcount + + ;
vm . EmailSend . sendeds + = ";" + u . email ;
}
}
if ( okcount > 0 )
{
vm . EmailSend . readcount = okcount ;
vm . EmailSend . sendeds = vm . EmailSend . sendeds . Substring ( 1 ) ;
Dao . Save ( "common.emailsendok" , vm . EmailSend ) ;
}
vm . EmailSend . Ds = new List < EmailSend > ( ) { } ;
if ( bancount > 0 )
{
var banemails = vm . EmailSend . bans . Substring ( 1 ) . Split ( ';' ) ;
foreach ( var b in banemails )
{
vm . EmailSend . Ds . Add (
new EmailSend ( )
{
sendno = vm . EmailSend . sendno ,
bans = b ,
uno = SUserInfo . UserNo ,
uip = GetUserIP ( )
}
) ;
}
//Dao.Save("common.emailban", vm.EmailSend);
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = okcount , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />수신거부/이메일주소오류: {2}" , data . Count ( ) , okcount , bancount ) } ) ;
}
[HttpPost]
[ValidateInput(false)]
public JsonResult EmailSendForEncourage ( VMLect vm )
{
vm . EmailSend . uno = SUserInfo . UserNo ;
vm . EmailSend . uip = GetUserIP ( ) ;
var data = Dao . Get < Lect > ( "users.getlectbyusernos" , vm . stringval15 ) . ToList ( ) ;
if ( Request . Files . GetMultiple ( "file2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . Count ( ) > 0 )
{
vm . EmailSend . fgno = SetFile ( Request . Files . GetMultiple ( "file2" ) . Where ( w = > ! string . IsNullOrEmpty ( w . FileName ) ) . ToList ( ) , vm . EmailSend . fgno ? ? 0 , "EmailSend" , "EmailSend.FGNo" ) ;
}
var okcount = 0 ;
vm . EmailSend . rcvcount = data . Count ( ) ;
vm . EmailSend . rcvs = string . Join ( ";" , data . Select ( s = > string . Format ( "{0}:{1}" , s . username . Replace ( ":" , "" ) . Replace ( ";" , "" ) , s . email ) ) ) ;
vm . EmailSend . uno = SUserInfo . UserNo ;
vm . EmailSend . uip = GetUserIP ( ) ;
vm . EmailSend . reademails = "" ;
Dao . Insert ( "common.emailsend.in" , vm . EmailSend ) ;
var bans = Dao . Get < EmailSend > ( "common.emailbanpool" , string . Join ( "," , data . Select ( s = > string . Format ( "'{0}'" , s . email ) ) ) ) ;
string fname = "" ;
if ( ( vm . EmailSend . fgno ? ? 0 ) > 0 )
{
fname = vm . Files + GetFiles ( vm . EmailSend . fgno . Value ) . First ( ) . fileurl ;
}
vm . EmailSend . sendeds = "" ;
vm . EmailSend . bans = "" ;
int bancount = 0 ;
vm . EmailSend . ehtml = vm . EmailSend . ehtml . Replace ( "^fronturl^" , GetConfig ( "fronturl" ) ) . Replace ( "../img/mail" , GetConfig ( "fronturl" ) + "/img/mail" ) ;
var sender = Dao . Get < Users > ( "users.me" , SUserInfo . UserNo ) . First ( ) ;
String [ ] contents = { vm . EmailSend . ehtml ? ? "" } ;
var masteremail = GetConfig ( "masteremail" ) ;
var senderemail = Request . IsLocal | | string . IsNullOrEmpty ( sender . email ) | | ! IsEmail ( sender . email ) ? masteremail . Split ( ';' ) [ 0 ] : sender . email ;
foreach ( var u in data )
{
if ( string . IsNullOrEmpty ( u . email ) | | ! IsEmail ( u . email ) | | u . isacceptemail = = 0 | | bans . Where ( w = > w . semail = = u . email ) . FirstOrDefault ( ) ! = null )
{
bancount + + ;
vm . EmailSend . bans + = ";" + u . email ;
}
2020-10-12 15:32:10 +09:00
else if ( SendMailTemplate ( "3" , senderemail , "영남건설기술교육원" , u . email , vm . EmailSend . etitle , contents , fname = = "" ? "" : Server . MapPath ( fname ) , null ) > 0 )
2020-10-12 14:39:23 +09:00
{
okcount + + ;
vm . EmailSend . sendeds + = ";" + u . email ;
}
}
if ( okcount > 0 )
{
vm . EmailSend . readcount = okcount ;
vm . EmailSend . sendeds = vm . EmailSend . sendeds . Substring ( 1 ) ;
Dao . Save ( "common.emailsendok" , vm . EmailSend ) ;
}
vm . EmailSend . Ds = new List < EmailSend > ( ) { } ;
if ( bancount > 0 )
{
var banemails = vm . EmailSend . bans . Substring ( 1 ) . Split ( ';' ) ;
foreach ( var b in banemails )
{
vm . EmailSend . Ds . Add (
new EmailSend ( )
{
sendno = vm . EmailSend . sendno ,
bans = b ,
uno = SUserInfo . UserNo ,
uip = GetUserIP ( )
}
) ;
}
Dao . Save ( "common.emailban" , vm . EmailSend ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = okcount , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />수신거부/이메일주소오류: {2}" , data . Count ( ) , okcount , bancount ) } ) ;
}
[HttpPost]
public JsonResult GetEmail ( Int64 no , string type = "" )
{
return JsonBack < EmailSend > ( Dao . Get < EmailSend > ( "common.emailsend.get" + type , no ) . First ( ) ) ;
}
[HttpPost]
public JsonResult LeftMenuToggle ( bool b )
{
if ( b )
{
CookieSet ( "leftmenutoggle" , "active" ) ;
}
else
{
CookieClear ( "leftmenutoggle" ) ;
}
return JsonOK ( 1 ) ;
}
[HttpPost]
public JsonResult SendPW ( Int64 uno , String mno )
{
Random r = new Random ( ) ;
var up = "ad" + r . Next ( 111111 , 999999 ) . ToString ( ) + "~" ;
if ( Dao . Save ( "users.adminpass" , new Hashtable ( ) { { "AdminNo" , uno } , { "UserPass" , NP . Base . Lib . KISA_SHA256 . SHA256Hash ( up ) } } ) = = 1 )
{
SendSms ( null , mno , null , "[YOU&PARTNERS] 임시비밀번호를 알려드립니다(확인 후 삭제 요망) [ up ]" , null ) ;
return JsonOK ( up + ":" + NP . Base . Lib . KISA_SHA256 . SHA256Hash ( up ) , false ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult UploadExcel ( String uploadjob , String p , HttpPostedFileBase uploadfile , int intval = - 1 , int intval2 = - 1 )
{
try
{
if ( uploadfile ! = null )
{
switch ( uploadjob )
{
case "examuserregbatch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < ExamUser > ( 2 , 1 ) . ToList ( ) ;
var eus = Dao . Get < ExamUser > ( "exam.examusers" , new System . Collections . Hashtable ( ) { { "exno" , intval } } ) ;
//입력된 정보 검증
if ( data . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "데이터가 없습니다." } ) ;
}
int i = 1 ;
foreach ( var d in data )
{
d . rno = i + + ;
d . value = "정상" ;
if ( string . IsNullOrEmpty ( d . userid . Trim ( ) ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = ( i - 1 ) + "번째 데이터의 id가 공란입니다." } ) ;
}
else if ( data . Where ( w = > w . userid = = d . userid ) . Count ( ) > 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = ( i ) + "번째 데이터의 대상자가 중복됩니다." } ) ;
}
else if ( eus . Where ( w = > w . userid = = d . userid ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = ( i - 1 ) + "번째 데이터의 회원이 이미 등록되어 있습니다." } ) ;
}
}
//수강생 id 검증
var users = Dao . Get < Users > ( "users.usersbyuserids" , new Hashtable ( ) { { "usertype" , 1 } , { "userids" , string . Join ( "," , data . Where ( w = > w . value = = "정상" ) . Select ( s = > string . Format ( "'{0}'" , s . userid ) ) ) } } ) ;
foreach ( var d in data . Where ( w = > w . value = = "정상" ) )
{
var u = users . Where ( w = > w . userid = = d . userid ) . FirstOrDefault ( ) ;
if ( u = = null | | ( SUserInfo . IsSiteAdmin & & SUserInfo . ASNo ! = u . asno ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = ( i - 1 ) + "번째 데이터의 id가 시스템에 등록된 id가 아닙니다." } ) ;
}
else
{
d . username = u . username ;
d . userno = u . userno ;
}
}
var Exam = Dao . Get < Exam > ( "exam.exams" , new System . Collections . Hashtable ( ) { { "exno" , intval } } ) . First ( ) ;
var reu = new ExamUser ( ) { exno = intval , uip = GetUserIP ( ) , certdate = Exam . certdate , certindate = Exam . certindate , uno = SUserInfo . UserNo , Ds = new List < ExamUser > ( ) { } } ;
foreach ( var d in data . Where ( w = > w . value = = "정상" ) )
{
if ( d . userno > 0 )
{
reu . Ds . Add ( new ExamUser ( )
{
userno = d . userno ,
status = 1 ,
pstatus = 4 ,
avrg = 0
} ) ;
}
}
return JsonOK ( Dao . Save ( "exam.examuser.regbatch" , reu ) ) ;
}
case "examuserbatch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < ExamUser > ( 2 , 1 ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "데이터가 없습니다." } ) ;
}
else if ( data . Count ( ) > 1000 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "1000개 이하의 데이터만 업로드해주세요." , obj = "" } ) ;
}
var eus = Dao . Get < ExamUser > ( "exam.examusers" , new System . Collections . Hashtable ( ) { { "exno" , intval } , { "pstatus" , 1 } } ) ;
int i = 1 ;
foreach ( var d in data )
{
d . rno = i + + ;
d . value = "정상" ;
d . username = d . username2 ;
d . userid = d . userid2 ;
if ( eus . Where ( w = > w . userid = = d . userid ) . Count ( ) < 1 )
{
d . value = "대상자 아님" ;
}
else if ( data . Where ( w = > w . userid2 = = d . userid ) . Count ( ) > 1 )
{
d . value = "대상자 중복" ;
}
else if ( string . IsNullOrEmpty ( d . username2 ) | | string . IsNullOrEmpty ( d . userid2 ) )
{
d . value = "이름/ID 불량" ;
}
else if ( string . IsNullOrEmpty ( d . ispass2 ) | | ( "합격" ! = d . ispass2 & & "불합격" ! = d . ispass2 ) )
{
d . value = "합격여부 불량" ;
}
else if ( string . IsNullOrEmpty ( d . epoint21 ) | | string . IsNullOrEmpty ( d . epoint22 ) | | string . IsNullOrEmpty ( d . epoint23 ) )
{
d . value = "점수 불량" ;
}
else
{
d . userno = eus . Where ( w = > w . userid = = d . userid ) . ToList ( ) . Where ( w = > w . username = = d . username ) . ToList ( ) . Select ( s = > s . userno ) . FirstOrDefault ( ) ;
d . ispass = d . ispass2 = = "합격" ? 1 : 0 ;
d . epoint1 = ( float ) GetDouble ( ( d . epoint21 ? ? "" ) ) ;
d . epoint2 = ( float ) GetDouble ( ( d . epoint22 ? ? "" ) ) ;
d . epoint3 = ( float ) GetDouble ( ( d . epoint23 ? ? "" ) ) ;
}
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
case "lectbatch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < Lect > ( 2 , 1 ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "데이터가 없습니다." } ) ;
}
int i = 1 ;
int tot = data . Count ( ) ;
foreach ( var d in data )
{
d . rno = i + + ;
d . pagetotalcount = tot ;
d . value = "정상" ;
d . userid = d . userid . Replace ( " " , "" ) ;
d . payamt = GetInt ( ( d . payamt2 ? ? "" ) . Replace ( "," , "" ) ) ;
d . payamtcash = GetInt ( ( d . payamtcash2 ? ? "" ) . Replace ( "," , "" ) ) ;
d . payamtcard = GetInt ( ( d . payamtcard2 ? ? "" ) . Replace ( "," , "" ) ) ;
d . pcno = GetInt ( d . pcno2 ? ? "" ) < 1 ? ( int? ) null : GetInt ( d . pcno2 ? ? "" ) ;
d . cmno = ( string . IsNullOrEmpty ( d . cmno2 ) ? 0 : GetInt ( d . cmno2 ) ) ;
if ( d . cmno < 1 & & d . pcno = = null )
{
d . value = "강좌ID, 패키지ID 공란" ;
}
else if ( string . IsNullOrEmpty ( d . userid ) | | d . userid . Trim ( ) = = "" )
{
d . value = "ID 불량" ;
}
else if ( data . Where ( w = > w . value = = "정상" & & w . pcno2 = = d . pcno2 & & w . cmno2 = = d . cmno2 & & w . userid = = d . userid ) . Count ( ) > 1 )
{
d . value = "업로드 중복" ;
}
else if ( ! string . IsNullOrEmpty ( d . ptypename ) & & SUserInfo . IsSiteAdmin )
{
d . value = "업로드양식 불량" ;
}
else if ( ! SUserInfo . IsSiteAdmin & & ( string . IsNullOrEmpty ( d . ptypename ) | | d . ptypename . Trim ( ) = = "" ) )
{
d . value = "결제방법 불량" ;
}
else if ( ( d . ptypename = = "현금+카드" & & d . payamt ! = ( d . payamtcash + d . payamtcard ) ) | | ( d . ptypename = = "무료" & & d . payamt > 0 ) )
{
d . value = "결제금액 불량" ;
}
if ( SUserInfo . IsSiteAdmin )
{
d . ptype = 9 ;
d . ptypename = "위탁계약" ;
}
else
{
d . ptype = d . ptypename = = "신용카드" ? 1 : d . ptypename = = "계좌이체" ? 2 : d . ptypename = = "가상계좌" ? 3 : d . ptypename = = "현금" ? 4 : d . ptypename = = "현금+카드" ? 5 : d . ptypename = = "무료" ? 6 : d . ptypename = = "위탁계약" ? 9 : 0 ;
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ; }
//수강생검증
var users = Dao . Get < Users > ( "users.usersbyuserids" , new Hashtable ( ) { { "usertype" , 1 } , { "userids" , string . Join ( "," , data . Where ( w = > w . value = = "정상" ) . Select ( s = > string . Format ( "'{0}'" , s . userid ) ) ) } } ) ;
foreach ( var d in data . Where ( w = > w . value = = "정상" ) )
{
var u = users . Where ( w = > w . userid = = d . userid ) . FirstOrDefault ( ) ;
if ( u = = null | | ( SUserInfo . IsSiteAdmin & & SUserInfo . ASNo ! = u . asno ) )
{
d . value = "등록된 ID 없음" ;
}
else
{
d . username = u . username ;
d . userno = u . userno ;
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
//패키지ID검증
var cms = Dao . Get < CM > ( "cm.cmpcsbycmnos" , new Hashtable ( ) { { "pcnos" , string . Join ( "," , data . Where ( w = > w . value = = "정상" & & w . pcno ! = null ) . Select ( s = > s . pcno . Value ) ) } } ) ;
foreach ( var d in data . Where ( w = > w . value = = "정상" & & w . pcno ! = null ) )
{
var cm = cms . Where ( w = > w . pcno = = d . pcno . Value ) . FirstOrDefault ( ) ;
if ( cm = = null )
{
d . value = "패키지코드 없음" ;
}
else
{
d . pcname = cm . pcname ;
//패키지코드만 입력한 경우 수강생 검증
if ( string . IsNullOrEmpty ( d . cmno2 . Trim ( ) ) )
{
var checkpckuser = Dao . Get < Lect > ( "lect.checkuser3" , new Hashtable ( ) { { "cmnos" , string . Join ( "," , cms . Where ( w = > w . pcno = = d . pcno ) . Select ( s = > s . cmno ) ) } } ) ;
for ( i = 0 ; i < checkpckuser . Count ( ) ; i + + )
{
if ( d . userno = = checkpckuser [ i ] . userno & & d . pcno = = cm . pcno & & String . IsNullOrEmpty ( d . cmno2 . Trim ( ) ) )
{
d . value = "이미 등록된 수강생입니다." ;
}
}
}
}
if ( ! string . IsNullOrEmpty ( d . cmno2 . Trim ( ) ) )
{
cm = cms . Where ( w = > w . pcno = = d . pcno . Value & & w . cmno = = d . cmno ) . FirstOrDefault ( ) ;
if ( cm = = null )
{
d . value = "패키지강좌코드 없음" ;
}
else
{
d . cname = cm . cname ;
//패키지코드 + 강좌코드 입력한 경우 수강생 검증
var checkpckuser = Dao . Get < Lect > ( "lect.checkuser2" , new Hashtable ( ) { { "cmnos" , cm . cmno } } ) ;
for ( i = 0 ; i < checkpckuser . Count ( ) ; i + + )
{
if ( d . userno = = checkpckuser [ i ] . userno & & d . cmno = = checkpckuser [ i ] . cmno & & d . pcno = = cm . pcno )
{
d . value = "이미 등록된 수강생입니다." ;
}
}
}
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ; }
//강좌ID검증
var cms2 = data . Where ( w = > w . value = = "정상" & & w . pcno = = null ) ;
if ( cms2 . Count ( ) > 0 )
{
cms = Dao . Get < CM > ( "cm.cmsbycmnos" , new Hashtable ( ) { { "ismaster" , 0 } , { "cmnos" , string . Join ( "," , cms2 . Select ( s = > s . cmno ) ) } } ) ;
foreach ( var d in cms2 )
{
var cm = cms . Where ( w = > w . cmno = = d . cmno ) . FirstOrDefault ( ) ;
if ( cm = = null )
{
d . value = "일반강좌코드 없음" ;
}
else
{
d . cname = cm . cname ;
}
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
//등록된 수강생 검증
var checklectuser = Dao . Get < Lect > ( "lect.checkuser2" , new Hashtable ( ) { { "cmnos" , string . Join ( "," , cms2 . Select ( s = > s . cmno ) ) } } ) ;
if ( checklectuser . Count > 0 )
{
foreach ( var d in data . Where ( w = > w . value = = "정상" & & w . pcno = = null ) )
{
if ( checklectuser . Where ( w = > w . userno = = d . userno & & w . cmno = = d . cmno ) . Count ( ) > 0 )
{
d . value = "이미 등록된 수강생 입니다." ;
}
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
case "ncs4batch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < NCS > ( 2 , 1 ) . ToList ( ) ;
if ( data . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "데이터가 없습니다." } ) ;
}
int i = 1 ;
int tot = data . Count ( ) ;
foreach ( var n in data )
{
n . rno = i + + ;
n . pagetotalcount = tot ;
n . value = "정상" ;
if ( string . IsNullOrEmpty ( n . dacode ) | | n . dacode . Trim ( ) . Length ! = 8 )
{
n . value = "상위분류코드 불량" ;
}
else if ( string . IsNullOrEmpty ( n . ncscode ) | | n . ncscode . Trim ( ) = = "" )
{
n . value = "능력단위코드 불량" ;
}
else if ( string . IsNullOrEmpty ( n . ncsname ) | | n . ncsname . Trim ( ) = = "" )
{
n . value = "능력단위명 불량" ;
}
else if ( data . Where ( w = > w . value = = "정상" & & w . dacode = = n . dacode & & w . ncscode = = n . ncscode ) . Count ( ) > 1 )
{
n . value = "업로드 중복" ;
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
//상위분류 검증
var ncs3 = Dao . Get < NCS > ( "cm.ncs3.check" , new Hashtable ( ) { { "ntype" , intval } , { "dacodes" , string . Join ( "," , data . Where ( w = > w . value = = "정상" ) . Select ( s = > string . Format ( "'{0}'" , s . dacode ) ) ) } } ) ;
foreach ( var n in data . Where ( w = > w . value = = "정상" ) )
{
var n3 = ncs3 . Where ( w = > w . dacode = = n . dacode ) . FirstOrDefault ( ) ;
if ( n3 = = null )
{
n . value = "상위분류코드 없음" ;
}
else
{
n . ndno = n3 . ndno ;
n . dname = n3 . dname ;
}
}
if ( data . Where ( w = > w . value = = "정상" ) . Count ( ) < 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
//중복 검증
var ndnos = data . Where ( w = > w . value = = "정상" ) . Select ( s = > s . ndno ) . Distinct ( ) ;
foreach ( var n in ndnos )
{
var n4s = Dao . Get < NCS > ( "cm.ncs4.check" , new Hashtable ( ) { { "ndno" , n } , { "ucodes" , string . Join ( "," , data . Where ( w = > w . ndno = = n ) . Select ( s = > string . Format ( "'{0}'" , s . ncscode ) ) ) } } ) ;
if ( n4s . Count ( ) > 0 )
{
var ucodes = "," + string . Join ( "," , n4s . Select ( s = > s . ucode ) ) + "," ;
foreach ( var d in data . Where ( w = > w . ndno = = n & & ucodes . Contains ( "," + w . ncscode + "," ) ) )
{
d . value = "중복" ;
}
}
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = data } ) ;
}
case "userbatch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < Users > ( 2 , 1 ) . ToList ( ) ;
//if (data.Count() > 1000)
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "1000개 이하의 데이터만 업로드해주세요.", obj = "" });
//}
2020-10-19 13:30:54 +09:00
if ( data . Where ( w = > string . IsNullOrEmpty ( w . username ) | | string . IsNullOrEmpty ( w . userid ) | | string . IsNullOrEmpty ( w . email ) | | string . IsNullOrEmpty ( w . mobile ) ) . Count ( ) > 0 )
2020-10-12 14:39:23 +09:00
{
2020-10-19 13:30:54 +09:00
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "이름/ID/이메일/핸드폰은 필수입력입니다. 확인 후 다시 업로드해주세요. " , obj = "" } ) ;
2020-10-12 14:39:23 +09:00
}
foreach ( var user in data )
{
var id = user . userid ;
var mobile = user . mobile ;
var telno = user . telno ;
var chk = 0 ;
2020-10-19 13:30:54 +09:00
2020-10-12 14:39:23 +09:00
if ( id . ToString ( ) . Trim ( ) . Length < 4 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "ID의 길이는 4자이상이여야 합니다. 확인 후 다시 업로드해주세요. " , obj = "" } ) ;
}
if ( ! string . IsNullOrEmpty ( user . mobile . Trim ( ) ) & & ! int . TryParse ( ( mobile . Trim ( ) ? ? "" ) . Replace ( "-" , "" ) , out chk ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "핸드폰 번호는 - 를 제외한 숫자만 입력하여야 합니다. 확인 후 다시 업로드해주세요. " , obj = "" } ) ;
}
if ( ! string . IsNullOrEmpty ( user . telno . Trim ( ) ) & & ! int . TryParse ( ( telno . Trim ( ) ? ? "" ) . Replace ( "-" , "" ) , out chk ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "연락처는 - 를 제외한 숫자만 입력하여야 합니다. 확인 후 다시 업로드해주세요. " , obj = "" } ) ;
}
2020-10-19 13:30:54 +09:00
2020-10-12 14:39:23 +09:00
}
2020-10-19 13:30:54 +09:00
var list = Dao . Get < Users > ( "users.usersall" , new Hashtable ( ) { } ) ;
2020-10-12 14:39:23 +09:00
var userids = string . Join ( "," , data . Select ( s = > "'" + s . userid + "'" ) . Distinct ( ) ) ;
list = Dao . Get < Users > ( "users.batchcheck" , new Hashtable ( ) { { "userids" , userids } } ) ;
if ( list . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "이미 등록된 아이디가 있습니다.<br />" + string . Join ( "," , list . Select ( s = > s . userid ) ) , obj = "" } ) ;
}
var emails = string . Join ( "," , data . Select ( s = > "'" + s . email + "'" ) . Distinct ( ) ) ;
list = Dao . Get < Users > ( "users.batchcheck" , new Hashtable ( ) { { "emails" , emails } } ) ;
if ( list . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "이미 등록된 이메일주소가 있습니다.<br />" + string . Join ( "," , list . Select ( s = > s . email ) ) , obj = "" } ) ;
}
foreach ( var u in data )
{
u . userpass = NP . Base . Lib . KISA_SHA256 . SHA256Hash ( u . mobile . Trim ( ) . Replace ( "-" , "" ) ) ;
u . userid = u . userid . Trim ( ) ;
u . email = u . email . Trim ( ) ;
u . telno = u . telno ;
u . mobile = ( u . mobile . Trim ( ) ? ? "" ) . Replace ( "-" , "" ) . Length = = 10 ?
string . Format ( "{0}-{1}-{2}" , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 0 , 3 ) , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 3 , 3 ) , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 6 ) ) :
( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Length = = 11 ?
string . Format ( "{0}-{1}-{2}" , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 0 , 3 ) , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 3 , 4 ) , ( u . mobile ? ? "" ) . Replace ( "-" , "" ) . Substring ( 7 ) ) : u . mobile ;
2020-10-19 13:30:54 +09:00
u . asno = string . IsNullOrEmpty ( u . asno2 ) ? ( int? ) null : ( int? ) Convert . ToInt32 ( u . asno2 ) ;
u . depart = string . IsNullOrEmpty ( u . depart ) ? "" : u . depart ;
u . uduty = string . IsNullOrEmpty ( u . uduty ) ? "" : u . uduty ;
2020-10-12 14:39:23 +09:00
}
var muser = new Users ( ) { Us = data , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ;
return JsonOK ( Dao . Save ( "users.batch" , muser ) , false ) ;
}
case "cminningbatch" :
{
//수강신청이 존재하는지 확인한다.
if ( intval2 = = 0 )
{
if ( Dao . Get < int > ( "lect.check.count" , new Hashtable ( ) { { "cmno" , intval } } ) . First ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "수강신청인원이 있을 경우 사용이 불가능합니다. 개별회차 등록/수정기능을 이용해주세요." , obj = "" } ) ;
}
}
//먼저 학습데이터가 존재하는지 확인 한다.
//if ((Dao.Get<Int64?>("lect.check.lectinning.hascminning", new Hashtable() { { "cmno", intval } }).FirstOrDefault() ?? 0) > 0)
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "수강정보가 생성된 과정은 일괄등록 할 수 없습니다.", obj = "" });
//}
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < ExcelUpload > ( 3 , 1 ) . ToList ( ) ;
if ( data . Count ( ) > 1000 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "1000개 이하의 데이터만 업로드해주세요." , obj = "" } ) ;
}
var cmi = new CMInning ( ) { cmno = intval , uno = SUserInfo . UserNo , uip = GetUserIP ( ) , Ds = new List < CMInning > ( ) { } } ;
int i = 0 ;
//검증용데이터(강사아이디)
var cd = Dao . Get < Data > ( "cm.datafor.cminningcheck" , new Hashtable ( ) { { "cmno" , intval } , { "ccode" , string . IsNullOrEmpty ( string . Join ( "," , data . Where ( w = > ! string . IsNullOrEmpty ( w . col11 ) ) . Select ( s = > "'" + s . col11 + "'" ) ) ) ? "'박효동박건'" : string . Join ( "," , data . Where ( w = > ! string . IsNullOrEmpty ( w . col11 ) ) . Select ( s = > "'" + s . col11 + "'" ) ) } , { "isuse" , 1 } } ) ;
2020-12-24 12:41:26 +09:00
//교육일정이 존재하는지 조회
var scd = Dao . Get < int > ( "cm.cminnigscd.exists" , new Hashtable ( ) { { "cmno" , intval } } ) ;
2020-10-12 14:39:23 +09:00
var cmseq = "" ;
2020-10-20 15:42:40 +09:00
var cshape = Dao . Get < CM > ( "cm.cmcshape" , new Hashtable ( ) { { "cmno" , intval } } ) . FirstOrDefault ( ) ;
2020-10-12 14:39:23 +09:00
foreach ( var d in data )
{
i + + ;
cmseq = d . col1 ;
if ( intval2 = = 0 & & d . col2 = = "오프라인" )
{
DateTime dt1 ;
if ( DateTime . TryParse ( d . col16 , out dt1 ) )
{
d . col16 = dt1 . ToString ( "yyyy-MM-dd" ) ;
}
else
{
d . col16 = "" ;
}
}
2020-12-24 12:41:26 +09:00
if ( scd . FirstOrDefault ( ) > 0 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "교육일정이 등록되어 있어 회차 일괄등록이 불가합니다." } ) ; }
2020-10-22 10:12:30 +09:00
if ( d . col2 = = "오프라인" & & cshape . cshape = = 2 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 학습방식을 확인해주세요. 혼합(온라인 + 오프라인)교육시 오프라인 회차는 등록 할 수 없습니다." } ) ; }
2020-10-12 14:39:23 +09:00
if ( data . Where ( w = > w . col1 = = cmseq ) . Count ( ) > 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 회차가 중복됩니다." } ) ; }
if ( GetInt ( d . col1 ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 회차를 확인해주세요." } ) ; }
if ( d . col2 ! = "온라인" & & d . col2 ! = "오프라인" ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 학습방식을 확인해주세요." } ) ; }
if ( string . IsNullOrEmpty ( d . col3 ) ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 강의주제를 확인해주세요." } ) ; }
2020-10-20 15:42:40 +09:00
if ( cd . Where ( w = > w . dtype = = 1 & & w . strval = = d . col4 ) . Count ( ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 강사ID를 확인해주세요. 등록되지 않은 강사입니다." } ) ; }
2020-10-12 14:39:23 +09:00
if ( d . col2 = = "오프라인" & & string . IsNullOrEmpty ( d . col5 ) ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 강의내용을 확인해주세요." } ) ; }
if ( ( intval2 = = 1 | | intval2 = = 0 ) & & d . col2 = = "오프라인" & & GetInt ( d . col6 ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 학습시점을 확인해주세요." } ) ; }
if ( ( intval2 = = 1 | | intval2 = = 0 ) & & d . col2 = = "오프라인" & & d . col16 = = "" ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 학습시점을 확인해주세요." } ) ; }
if ( d . col2 = = "온라인" & & cd . Where ( w = > w . dtype = = 2 & & w . strval = = d . col11 ) . Count ( ) < 1 ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 콘텐츠ID를 확인해주세요." } ) ; }
if ( d . col2 = = "온라인" & & ( GetInt ( d . col13 ) > GetInt ( d . col12 ) | | GetInt ( d . col14 ) > = GetInt ( d . col12 ) ) ) { return JsonBack ( new JsonRtn ( ) { code = 1 , msg = i + "번째 데이터의 중간팝업시간을 확인해주세요." } ) ; }
if ( "온라인" . Equals ( d . col2 ) )
{
cmi . Ds . Add ( new CMInning ( )
{
week = 1 , iseq = GetInt ( d . col1 ) , isonline = 1 , ititle = d . col3 ,
userno = cd . Where ( w = > w . dtype = = 1 & & w . strval = = d . col4 ) . First ( ) . intval ,
ctno = cd . Where ( w = > w . dtype = = 2 & & w . strval = = d . col11 ) . First ( ) . intval ,
sttime = GetInt ( d . col12 ) , atime = GetInt ( d . col13 ) , mstime = GetInt ( d . col14 ) , metime = GetInt ( d . col15 )
} ) ;
}
else
{
cmi . Ds . Add ( new CMInning ( )
{
week = 1 ,
iseq = GetInt ( d . col1 ) ,
ititle = d . col3 ,
userno = cd . Where ( w = > w . dtype = = 1 & & w . strval = = d . col4 ) . First ( ) . intval ,
icontent = d . col5 ,
iday = GetInt ( d . col6 ) ,
idate = DateTime . Parse ( d . col16 ) ,
ist = GetInt ( d . col7 ) . ToString ( "00" ) + GetInt ( d . col8 ) . ToString ( "00" ) ,
iet = GetInt ( d . col9 ) . ToString ( "00" ) + GetInt ( d . col10 ) . ToString ( "00" ) ,
} ) ;
}
}
return JsonOK ( Dao . Save ( "cm.cminning.batch" , cmi ) ) ;
}
case "questionbatch" :
{
var seq = 1 ;
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < Question > ( 2 , 1 ) . ToList ( ) ;
if ( data . Count ( ) > 1000 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "1000개 이하의 데이터만 업로드해주세요." , obj = "" } ) ;
}
//과정 확인
var cmnos = string . Join ( "" , Dao . Get < CM > ( "cm.cms" , new System . Collections . Hashtable ( ) { { "ismaster" , 1 } , { "orderby" , "a.cname" } } ) . Select ( s = > "," + s . cmno + "," ) ) ? ? "" ;
if ( cmnos ! = "" & & data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! cmnos . Contains ( "," + w . cmno2 + "," ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "존재하지 않는 과정코드입니다." + string . Join ( ", " , data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! cmnos . Contains ( "," + w . cmno2 + "," ) ) . Select ( s = > s . cmno2 ) ) , obj = "" } ) ;
}
foreach ( var d in data . ToList ( ) )
{
//사용여부 입력
//if (d.isuse < 0)
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "사용여부는 필수값입니다. "+ seq+"행을 확인해주세요"});
//}
//문제유형 입력
//if (d.atype < 0)
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "문제유형은 필수값입니다. " + seq + "행을 확인해주세요" });
//}
//기본점수 입력
//if (d.dpoint <0)
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "기본점수는 필수값입니다. " + seq + "행을 확인해주세요" });
//}
if ( string . IsNullOrEmpty ( d . qtext ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "문제는 필수값입니다. " + seq + "번째 문제를 확인해주세요" } ) ;
}
//객관식 보기 기입 확인
if ( d . atype = = 0 & & ( string . IsNullOrEmpty ( d . qitext1 . Replace ( " " , "" ) ) | | string . IsNullOrEmpty ( d . qitext2 . Replace ( " " , "" ) ) | | ( string . IsNullOrEmpty ( d . isrights . Replace ( " " , "" ) ) ) ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "객관식은 최소한 보기 2개와 답을 입력해야합니다. " + seq + "번째 문제를 확인해주세요" } ) ;
}
//주관식 단답 정답 기입 확인
2020-12-11 15:31:15 +09:00
if ( d . atype = = 1 & & ( string . IsNullOrEmpty ( d . qitext1 . Replace ( " " , "" ) ) ) )
2020-10-12 14:39:23 +09:00
{
2020-12-11 15:31:15 +09:00
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "주관식과 단답형은 답을 입력해야합니다. " + seq + "번째 문제를 확인해주세요" } ) ;
2020-10-12 14:39:23 +09:00
}
////주관식 단답 정답 기입 확인
//if (d.atype > 0 && (string.IsNullOrEmpty(d.qitext1.Replace(" ", ""))))
//{
// return JsonBack(new JsonRtn() { code = 1, msg = "주관식과 단답형은 답을 입력해야합니다. " + seq + "번째 문제를 확인해주세요" });
//}
seq + + ;
}
//문제코드 확인
var cc = Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "all" , 1 } } ) ;
var qds = data . Where ( w = > ! string . IsNullOrEmpty ( w . qdiffname . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . qdiffname ) . Distinct ( ) ;
var qp1 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname1 . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . ccname1 ) . Distinct ( ) ;
var qp2 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname2 . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . ccname2 ) . Distinct ( ) ;
var qp3 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname3 . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . ccname3 ) . Distinct ( ) ;
var qp4 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname4 . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . ccname4 ) . Distinct ( ) ;
var qp5 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname5 . Trim ( ) ) ) . ToList ( ) . Select ( s = > s . ccname5 ) . Distinct ( ) ;
String eQD = "" ;
String eQP1 = "" ;
String eQP2 = "" ;
String eQP3 = "" ;
String eQP4 = "" ;
String eQP5 = "" ;
foreach ( var qd in qds ) { if ( cc . Where ( w = > w . cgroup = = "ccdiff" & & w . cname = = qd . Trim ( ) ) . Count ( ) < 1 ) { eQD + = ", " + qd ; } }
foreach ( var qp in qp1 ) { if ( cc . Where ( w = > w . cgroup = = "cc1" & & w . cname = = qp . Trim ( ) ) . Count ( ) < 1 ) { eQP1 + = ", " + qp ; } }
foreach ( var qp in qp2 ) { if ( cc . Where ( w = > w . cgroup = = "cc2" & & w . cname = = qp . Trim ( ) ) . Count ( ) < 1 ) { eQP2 + = ", " + qp ; } }
foreach ( var qp in qp3 ) { if ( cc . Where ( w = > w . cgroup = = "cc3" & & w . cname = = qp . Trim ( ) ) . Count ( ) < 1 ) { eQP3 + = ", " + qp ; } }
foreach ( var qp in qp4 ) { if ( cc . Where ( w = > w . cgroup = = "cc4" & & w . cname = = qp . Trim ( ) ) . Count ( ) < 1 ) { eQP4 + = ", " + qp ; } }
foreach ( var qp in qp5 ) { if ( cc . Where ( w = > w . cgroup = = "cc5" & & w . cname = = qp . Trim ( ) ) . Count ( ) < 1 ) { eQP5 + = ", " + qp ; } }
eQD = eQD ! = "" ? eQD . Substring ( 2 ) : eQD ;
eQP1 = eQP1 ! = "" ? eQP1 . Substring ( 2 ) : eQP1 ;
eQP2 = eQP2 ! = "" ? eQP2 . Substring ( 2 ) : eQP2 ;
eQP3 = eQP3 ! = "" ? eQP3 . Substring ( 2 ) : eQP3 ;
eQP4 = eQP4 ! = "" ? eQP4 . Substring ( 2 ) : eQP4 ;
eQP5 = eQP5 ! = "" ? eQP5 . Substring ( 2 ) : eQP5 ;
if ( eQP1 ! = "" | | eQP2 ! = "" | | eQP3 ! = "" | | eQP4 ! = "" | | eQP5 ! = "" )
{
return JsonBack ( new JsonRtn ( ) { code = 123 , msg = /*eQD + ";" + */ eQP1 + ";" + eQP2 + ";" + eQP3 + ";" + eQP4 + ";" + eQP5 } ) ;
}
else
{
foreach ( var d in data . ToList ( ) )
{
d . cmno = ! string . IsNullOrEmpty ( d . cmno2 ) ? GetInt ( d . cmno2 ) : ( int? ) null ;
d . qtext = d . qtext . Replace ( "\n" , "<br />" ) . Replace ( "\\n" , "<br />" ) . Replace ( "\r\n" , "<br />" ) . Replace ( "\\r\\n" , "<br />" ) ;
d . qtextstring = StripHtml ( d . qtext . Replace ( "\n" , "<br />" ) . Replace ( "\\n" , "<br />" ) . Replace ( "\r\n" , "<br />" ) . Replace ( "\\r\\n" , "<br />" ) ) ;
d . qdiff = ( cc . Where ( w = > w . cgroup = = "ccdiff" & & w . cname = = d . qdiffname ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . cc1 = ( cc . Where ( w = > w . cgroup = = "cc1" & & w . cname = = d . ccname1 ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . cc2 = ( cc . Where ( w = > w . cgroup = = "cc2" & & w . cname = = d . ccname2 ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . cc3 = ( cc . Where ( w = > w . cgroup = = "cc3" & & w . cname = = d . ccname3 ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . cc4 = ( cc . Where ( w = > w . cgroup = = "cc4" & & w . cname = = d . ccname4 ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . cc5 = ( cc . Where ( w = > w . cgroup = = "cc5" & & w . cname = = d . ccname5 ) . FirstOrDefault ( ) ? ? new ComCode ( ) { } ) . ccode ;
d . uno = SUserInfo . UserNo ;
d . uip = GetUserIP ( ) ;
d . QIs = new List < QuestionItem > ( ) ;
if ( ! string . IsNullOrEmpty ( d . qitext1 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",1," ) ? 1 : 0 , qitext = d . qitext1 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext2 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",2," ) ? 1 : 0 , qitext = d . qitext2 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext3 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",3," ) ? 1 : 0 , qitext = d . qitext3 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext4 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",4," ) ? 1 : 0 , qitext = d . qitext4 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext5 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",5," ) ? 1 : 0 , qitext = d . qitext5 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext6 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",6," ) ? 1 : 0 , qitext = d . qitext6 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext7 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",7," ) ? 1 : 0 , qitext = d . qitext7 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext8 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",8," ) ? 1 : 0 , qitext = d . qitext8 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext9 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",9," ) ? 1 : 0 , qitext = d . qitext9 } ) ; }
if ( ! string . IsNullOrEmpty ( d . qitext10 ) ) { d . QIs . Add ( new QuestionItem ( ) { qno = d . qno , isright = d . atype = = 1 ? 1 : ( "," + ( d . isrights ? ? "xxx" ) . Trim ( ) + "," ) . Contains ( ",10," ) ? 1 : 0 , qitext = d . qitext10 } ) ; }
d . rightcount = d . QIs . Where ( w = > w . isright = = 1 ) . Count ( ) ;
}
return JsonOK ( Dao . SaveQuestionBatch ( data , SUserInfo . UserNo , GetUserIP ( ) ) , false ) ;
}
}
case "contentsbatch" :
{
var data = new Lib . ExcelToEntity ( uploadfile ) . Read < CT > ( 2 , 1 ) . ToList ( ) ;
if ( data . Count ( ) > 1000 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "1000개 이하의 데이터만 업로드해주세요." , obj = "" } ) ;
}
//과정 확인
var cmnos = string . Join ( "" , Dao . Get < CM > ( "cm.cms" , new System . Collections . Hashtable ( ) { { "ismaster" , 1 } , { "orderby" , "a.cname" } , { "cshapes" , "0,2" } } ) . Select ( s = > "," + s . cmno + "," ) ) ? ? "" ;
if ( cmnos ! = "" & & data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! cmnos . Contains ( "," + w . cmno2 + "," ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "존재하지 않는 과정코드입니다." + string . Join ( ", " , data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! cmnos . Contains ( "," + w . cmno2 + "," ) ) . Select ( s = > s . cmno2 ) ) , obj = "" } ) ;
}
else if ( data . Where ( w = > string . IsNullOrEmpty ( w . cpname ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "페이지제목이 비어있는 행이 있습니다." } ) ;
}
else if ( data . Where ( w = > string . IsNullOrEmpty ( w . srcp ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "PC URL이 비어있는 행이 있습니다." } ) ;
}
else if ( data . Where ( w = > string . IsNullOrEmpty ( w . srcm ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "Mobile URL이 비어있는 행이 있습니다." } ) ;
}
else if ( data . Where ( w = > ! string . IsNullOrEmpty ( w . ctindex ) & & string . IsNullOrEmpty ( w . isuse2 ) ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "콘텐츠 사용여부가 비어있는 행이 있습니다." } ) ;
}
//공통코드 확인
var cc = Dao . Get < ComCode > ( "sys.comcode.list" , new Hashtable ( ) { { "all" , 1 } } ) ;
var qds = data . Where ( w = > ! string . IsNullOrEmpty ( w . qdiffname ) ) . ToList ( ) . Select ( s = > s . qdiffname ) . Distinct ( ) ;
var qp1 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname1 ) ) . ToList ( ) . Select ( s = > s . ccname1 ) . Distinct ( ) ;
var qp2 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname2 ) ) . ToList ( ) . Select ( s = > s . ccname2 ) . Distinct ( ) ;
var qp3 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname3 ) ) . ToList ( ) . Select ( s = > s . ccname3 ) . Distinct ( ) ;
var qp4 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname4 ) ) . ToList ( ) . Select ( s = > s . ccname4 ) . Distinct ( ) ;
var qp5 = data . Where ( w = > ! string . IsNullOrEmpty ( w . ccname5 ) ) . ToList ( ) . Select ( s = > s . ccname5 ) . Distinct ( ) ;
String eQD = "" ;
String eQP1 = "" ;
String eQP2 = "" ;
String eQP3 = "" ;
String eQP4 = "" ;
String eQP5 = "" ;
foreach ( var qd in qds ) { if ( cc . Where ( w = > w . cgroup = = "ccdiff" & & w . cname = = qd ) . Count ( ) < 1 ) { eQD + = ", " + qd ; } }
foreach ( var qp in qp1 ) { if ( cc . Where ( w = > w . cgroup = = "cc1" & & w . cname = = qp ) . Count ( ) < 1 ) { eQP1 + = ", " + qp ; } }
foreach ( var qp in qp2 ) { if ( cc . Where ( w = > w . cgroup = = "cc2" & & w . cname = = qp ) . Count ( ) < 1 ) { eQP2 + = ", " + qp ; } }
foreach ( var qp in qp3 ) { if ( cc . Where ( w = > w . cgroup = = "cc3" & & w . cname = = qp ) . Count ( ) < 1 ) { eQP3 + = ", " + qp ; } }
foreach ( var qp in qp4 ) { if ( cc . Where ( w = > w . cgroup = = "cc4" & & w . cname = = qp ) . Count ( ) < 1 ) { eQP4 + = ", " + qp ; } }
foreach ( var qp in qp5 ) { if ( cc . Where ( w = > w . cgroup = = "cc5" & & w . cname = = qp ) . Count ( ) < 1 ) { eQP5 + = ", " + qp ; } }
eQD = eQD ! = "" ? eQD . Substring ( 2 ) : eQD ;
eQP1 = eQP1 ! = "" ? eQP1 . Substring ( 2 ) : eQP1 ;
eQP2 = eQP2 ! = "" ? eQP2 . Substring ( 2 ) : eQP2 ;
eQP3 = eQP3 ! = "" ? eQP3 . Substring ( 2 ) : eQP3 ;
eQP4 = eQP4 ! = "" ? eQP4 . Substring ( 2 ) : eQP4 ;
eQP5 = eQP5 ! = "" ? eQP5 . Substring ( 2 ) : eQP5 ;
if ( eQD ! = "" | | eQP1 ! = "" | | eQP2 ! = "" | | eQP3 ! = "" | | eQP4 ! = "" | | eQP5 ! = "" )
{
return JsonBack ( new JsonRtn ( ) { code = 123 , msg = eQD + ";" + eQP1 + ";" + eQP2 + ";" + eQP3 + ";" + eQP4 + ";" + eQP5 } ) ;
}
//콘텐츠코드 중복확인
if ( data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! string . IsNullOrEmpty ( w . ccode ) ) . GroupBy ( g = > g . ccode ) . Where ( w = > w . Count ( ) > 1 ) . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "콘텐츠코드가 중복입니다." + string . Join ( ", " , data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & w . ccode ! = null ) . GroupBy ( g = > g . ccode ) . Where ( w = > w . Count ( ) > 1 ) . Select ( s = > s . Key ) ) } ) ;
}
IList < Data > ccodes = new List < Data > ( ) ;
if ( data . Where ( w = > ! string . IsNullOrEmpty ( w . ccode ) ) . Count ( ) > 0 )
{
ccodes = Dao . Get < Data > ( "cm.check.ctccode" , new Hashtable ( ) { { "ccodes" , string . Join ( "," , data . Where ( w = > ! string . IsNullOrEmpty ( w . cmno2 ) & & ! string . IsNullOrEmpty ( w . ccode ) ) . Select ( s = > "'" + s . ccode + "'" ) . Distinct ( ) ) } } ) ;
}
if ( ccodes . Count ( ) > 0 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "이미 등록된 콘텐츠코드입니다." + string . Join ( ", " , ccodes . Select ( s = > s . strval ) ) } ) ;
}
else
{
var cts = new List < CT > ( ) { } ;
//비어있는 행일 경우 첫행의 정보 이용
int scmno = - 1 ;
var uip = GetUserIP ( ) ;
foreach ( var d in data . ToList ( ) )
{
if ( ! string . IsNullOrEmpty ( d . ctindex ) & & GetInt ( d . ctindex ) ! = scmno )
{
//비어있는 행이 아닌 경우(cmno바뀜) 해당 행의 정보 저장
scmno = GetInt ( d . ctindex ) ;
cts . Add ( new CT ( ) { cmno = GetInt ( d . cmno2 ) ,
qdiff = string . IsNullOrEmpty ( d . qdiffname ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "ccdiff" & & w . cname = = d . qdiffname ) . First ( ) . ccode ,
cc1 = string . IsNullOrEmpty ( d . ccname1 ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "cc1" & & w . cname = = d . ccname1 ) . First ( ) . ccode ,
cc2 = string . IsNullOrEmpty ( d . ccname2 ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "cc2" & & w . cname = = d . ccname2 ) . First ( ) . ccode ,
cc3 = string . IsNullOrEmpty ( d . ccname3 ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "cc3" & & w . cname = = d . ccname3 ) . First ( ) . ccode ,
cc4 = string . IsNullOrEmpty ( d . ccname4 ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "cc4" & & w . cname = = d . ccname4 ) . First ( ) . ccode ,
cc5 = string . IsNullOrEmpty ( d . ccname5 ) ? ( int? ) null : cc . Where ( w = > w . cgroup = = "cc5" & & w . cname = = d . ccname5 ) . First ( ) . ccode ,
ctype = 3 , ccode = string . IsNullOrEmpty ( d . ccode ) ? null : d . ccode , ctname = d . ctname , tfurl = d . tfurl , ismenu = GetInt ( d . ismenu2 ) , isuse = GetInt ( d . isuse2 ) ,
uno = SUserInfo . UserNo , uip = uip } ) ;
cts [ cts . Count - 1 ] . Ds = new List < CTPage > ( ) { } ;
}
cts [ cts . Count - 1 ] . Ds . Add ( new CTPage ( ) { pseq = d . pseq , cpname = d . cpname , srcp = d . srcp , srcm = d . srcm } ) ;
//페이지순번 중복 검증
var pseqs = "," ;
int pseq = 0 ;
foreach ( var dsp in cts [ cts . Count - 1 ] . Ds )
{
pseq + + ;
if ( pseqs = = "," & & dsp . pseq ! = 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "페이지순서는 1부터 시작해야합니다." } ) ;
}
else if ( pseqs . Contains ( "," + dsp . pseq + "," ) )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "페이지순서가 중복되었습니다." } ) ;
}
else if ( pseq ! = dsp . pseq )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "페이지순서는 순차값이어야합니다." } ) ;
}
pseqs + = dsp . pseq + "," ;
}
}
return JsonOK ( Dao . SaveContentsBatch ( cts ) , false ) ;
}
}
}
}
}
catch ( Exception ex )
{
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = ex . Message , obj = "" } ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1 , msg = "엑셀파일을 확인하세요." , obj = "" } ) ;
}
[HttpPost]
public JsonResult GetSms ( Int64 mno )
{
return JsonBack ( Dao . Get < MemoUser > ( "common.smssend.get" , mno ) ) ;
}
[HttpPost]
public JsonResult NCSSave ( NCS n )
{
if ( n . ndepth < 4 )
{
n . ncscode = GetInt ( n . ncscode ) . ToString ( "00" ) ;
}
n . uno = SUserInfo . UserNo ;
n . uip = GetUserIP ( ) ;
n . pno = n . ndepth = = 0 ? n . ntype : n . ndepth = = 1 ? n . ntno : n . ndepth = = 2 ? n . nmno : n . ndepth = = 3 ? n . nbno : n . ndepth = = 4 ? n . ndno : 0 ;
n . notno = n . ncsno < 1 ? ( int? ) null : n . ncsno ;
//동일코드 체크
if ( n . ndepth = = 0 & & Dao . Get < NCS , int > ( "cm.ncst.check" , n ) . First ( ) > 0 )
{
return JsonOK ( - 1 ) ;
}
else if ( n . ndepth > 0 & & Dao . Get < NCS , int > ( "cm.ncs.check" , n ) . First ( ) > 0 )
{
return JsonOK ( - 1 ) ;
}
if ( n . ndepth = = 0 )
{
return JsonOK ( Dao . Save ( "cm.ncst" + "." + ( n . ncsno < 1 ? "in" : "up" ) , n ) ) ;
}
//hierarchy get
n . acode = n . ncscode ;
if ( n . ndepth < 4 )
{
n . acode = Dao . Get < String > ( "cm.ncs.hierarchy" , new Hashtable ( ) { { "ndepth" , n . ndepth } , { "pno" , n . pno } } ) . First ( ) + n . ncscode ;
}
return JsonOK ( Dao . Save ( "cm.ncs" + "." + ( n . ncsno < 1 ? "in" : "up" ) , n ) ) ;
}
public JsonResult NCSGet ( NCS n )
{
return JsonBack ( Dao . Get < NCS , NCS > ( "cm.ncs.child" , n ) ) ;
}
public JsonResult NCSGetHierarchy ( NCS n )
{
var ht = new Hashtable ( ) { } ;
if ( n . ndepth = = 0 )
{
ht [ "ncs" ] = Dao . Get < NCS , NCS > ( "cm.ncst.get" , n ) . First ( ) ;
}
else
{
ht [ "ncs" ] = Dao . Get < NCS , NCS > ( "cm.ncs.get" , n ) . First ( ) ;
}
if ( n . ndepth > 0 )
{
ht [ "ncss" ] = Dao . Get < NCS > ( "cm.ncs.parents." + n . ndepthname , n . ncsno ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = ht } ) ;
}
public JsonResult NCSDel ( NCS n )
{
var ht = new Hashtable ( ) { } ;
var nmnos = "" ; var nbnos = "" ; var ndnos = "" ; var nunos = "" ;
IList < NCS > NCSs ;
if ( n . ndepth < 4 )
{
ht . Add ( "ncs" + n . ndepthname , n . ncsno ) ;
if ( Dao . Get < NCS > ( "cm.ncs.union.check" , ht ) . Count ( ) > 1 )
{
return JsonBack ( new JsonRtn ( ) { code = 1 } ) ;
}
//하위분류가 있는 ncs\
NCSs = Dao . Get < NCS > ( "cm.ncs.ncss" , ht ) ;
ht = new Hashtable ( ) { } ;
ht . Add ( "ndepthname" , n . ndepthname ) ;
ht . Add ( "ncsno" , n . ncsno ) ;
if ( NCSs . Count > 0 )
{
switch ( n . ndepth )
{
case 3 :
nunos + = "," + NCSs . Where ( w = > w . nuno > 0 ) . Select ( w = > w . nuno ) ;
break ;
case 2 :
nunos + = "," + NCSs . Where ( w = > w . nuno > 0 ) . Select ( w = > w . nuno ) ;
ndnos + = "," + NCSs . Where ( w = > w . ndno > 0 ) . Select ( w = > w . ndno ) ;
break ;
case 1 :
nunos + = "," + NCSs . Where ( w = > w . nuno > 0 ) . Select ( w = > w . nuno ) ;
ndnos + = "," + NCSs . Where ( w = > w . ndno > 0 ) . Select ( w = > w . ndno ) ;
nbnos + = "," + NCSs . Where ( w = > w . nbno > 0 ) . Select ( w = > w . nbno ) ;
break ;
default :
nunos + = "," + NCSs . Where ( w = > w . nuno > 0 ) . Select ( w = > w . nuno ) ;
ndnos + = "," + NCSs . Where ( w = > w . ndno > 0 ) . Select ( w = > w . ndno ) ;
nbnos + = "," + NCSs . Where ( w = > w . nbno > 0 ) . Select ( w = > w . nbno ) ;
nmnos + = "," + NCSs . Where ( w = > w . nmno > 0 ) . Select ( w = > w . nmno ) ;
break ;
}
if ( ! String . IsNullOrEmpty ( nunos ) ) { ht . Add ( "nunos" , nunos . Substring ( 1 ) ) ; }
if ( ! String . IsNullOrEmpty ( ndnos ) ) { ht . Add ( "ndnos" , ndnos . Substring ( 1 ) ) ; }
if ( ! String . IsNullOrEmpty ( nbnos ) ) { ht . Add ( "nbnos" , nbnos . Substring ( 1 ) ) ; }
if ( ! String . IsNullOrEmpty ( nmnos ) ) { ht . Add ( "nmnos" , nmnos . Substring ( 1 ) ) ; }
return JsonOK ( Dao . Save ( "cm.ncs.del2" , ht ) ) ;
}
}
//하위분류가 없는 ncs
return JsonOK ( Dao . Save ( "cm.ncs.del" , n ) ) ;
}
public JsonResult NCSBatch ( String datas )
{
var ncs = new NCS ( ) { inquery = "" , uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ;
foreach ( var s in datas . Split ( ';' ) )
{
ncs . inquery + = ",(" + s . Split ( ':' ) [ 0 ] + ",'" +
s . Split ( ':' ) [ 1 ] . Replace ( "박효동$박건" , ";" ) . Replace ( "박효동$박하선" , ":" ) + "','" +
s . Split ( ':' ) [ 1 ] . Replace ( "박효동$박건" , ";" ) . Replace ( "박효동$박하선" , ":" ) + "','" +
s . Split ( ':' ) [ 2 ] . Replace ( "박효동$박건" , ";" ) . Replace ( "박효동$박하선" , ":" ) + "',now()," + ncs . uno + ",now()," + ncs . uno + ",'" + ncs . uip + "')" ;
}
return JsonOK ( Dao . Save ( "cm.ncs4.in.batch" , ncs . inquery . Substring ( 1 ) ) ) ;
}
public JsonResult SEM ( int type , String usernos , String title , String msg )
{
var m = new Memo ( ) { mcontents = msg , uno = SUserInfo . UserNo , uip = GetUserIP ( ) , Users = new List < MemoUser > ( ) { } } ;
if ( type = = 0 )
{
//알림톡
var data = Dao . Get < Users > ( "users.byusernos" , usernos ) ;
foreach ( var u in data )
{
m . Users . Add ( new MemoUser ( ) { userno = u . userno , smstype = "A" , isok = string . IsNullOrEmpty ( u . mobile ) ? - 1 : 1 , mobile = ( u . mobile ? ? "" ) . Replace ( "-" , "" ) } ) ;
}
//알림톡 발송
var t = GetConfig ( "talk" ) ;
var talkurl = t . Split ( ',' ) [ 0 ] ;
var talkid = t . Split ( ',' ) [ 1 ] ;
var talkpw = t . Split ( ',' ) [ 2 ] ;
var talkaccountkey = t . Split ( ',' ) [ 3 ] ;
var talkaccountid = t . Split ( ',' ) [ 4 ] ;
var talkprofilekey = t . Split ( ',' ) [ 5 ] ;
System . Text . StringBuilder sb = new System . Text . StringBuilder ( ) ;
m . mcontents = m . mcontents . Length > 1000 ? m . mcontents . Substring ( 0 , 1000 ) : m . mcontents ;
var us = m . Users . Where ( w = > w . isok = = 1 ) . ToList ( ) ;
if ( us . Count ( ) > 0 )
{
for ( var i = 0 ; i < us . Count ( ) ; i + + )
{
if ( ( i + 1 ) % 100 = = 1 )
{
sb . Clear ( ) ;
sb . Append ( "[" ) ;
}
sb . Append ( "{\"message_type\": \"AT\", \"" +
"phn\": \"" + us [ i ] . mobile . Replace ( "-" , "" ) + "\", \"" +
"profile\": \"" + talkprofilekey + "\", \"" +
"reserveDt\": \"00000000000000\", \"" +
//"msg\": \"" + m.mcontents + "\",\"" +
"msg\": \"" + m . mcontents + "\", \"" +
"tmplId\": \"alimtalktest_001\",\"" +
"smsKind\": \"N\"" +
//"msgSms\":\"" + m.mcontents + "\",\"" +
//"smsSender\":\"\"}");
"}," ) ;
if ( ( i + 1 ) % 100 = = 0 | | i = = us . Count ( ) - 1 )
{
String rtntalk = "" ;
System . Net . HttpWebRequest request = ( System . Net . HttpWebRequest ) System . Net . WebRequest . Create ( talkurl ) ;
request . Method = "POST" ;
request . ContentType = "application/json" ;
request . Accept = "application/json" ;
request . Headers . Add ( "userid" , talkaccountid ) ;
rtntalk = ApiCall ( request , sb . ToString ( ) . Substring ( 0 , sb . Length - 1 ) + "]" ) ;
if ( rtntalk . StartsWith ( "nptecherr:" ) )
{
foreach ( var d in us )
{
d . isok = - 2 ;
}
}
else
{
System . Web . Script . Serialization . JavaScriptSerializer js = new System . Web . Script . Serialization . JavaScriptSerializer ( ) ;
TalkRtn [ ] rtn = js . Deserialize < TalkRtn [ ] > ( rtntalk . StartsWith ( "[" ) ? rtntalk : ( "[" + rtntalk + "]" ) ) ;
foreach ( var d in rtn )
{
if ( d . data = = null )
{
foreach ( var u2 in us )
{
u2 . isok = 0 ;
}
}
else
{
var u = us . Where ( w = > w . mobile . Replace ( "-" , "" ) = = d . data . phn ) . FirstOrDefault ( ) ;
if ( u ! = null )
{
u . msgid = d . data . msgid ;
u . message = d . message ;
if ( "fail" . Equals ( d . code . ToLower ( ) ) )
{
u . isok = 0 ;
}
}
}
}
}
}
}
}
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
Dao . Insert ( "common.sms.in" , m ) ;
Dao . Save ( "common.smsuser.in" , m ) ;
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = us . Where ( w = > w . isok = = 1 ) . Count ( ) , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />휴대폰번호오류: {2}" , data . Count ( ) , us . Where ( w = > w . isok = = 1 ) . Count ( ) , us . Where ( w = > w . isok ! = 1 ) . Count ( ) ) } ) ;
}
else if ( type = = 3 )
{
//SMS
var data = Dao . Get < Users > ( "users.byusernos" , usernos ) ;
foreach ( var u in data )
{
m . Users . Add ( new MemoUser ( ) { userno = u . userno , smstype = "S" , isok = string . IsNullOrEmpty ( u . mobile ) ? - 1 : 1 , mobile = ( u . mobile ? ? "" ) . Replace ( "-" , "" ) } ) ;
}
//SMS 발송
var t = GetConfig ( "talk" ) ;
var talkurl = t . Split ( ',' ) [ 0 ] ;
var talkid = t . Split ( ',' ) [ 1 ] ;
var talkpw = t . Split ( ',' ) [ 2 ] ;
var talkaccountkey = t . Split ( ',' ) [ 3 ] ;
var talkaccountid = t . Split ( ',' ) [ 4 ] ;
var talkprofilekey = t . Split ( ',' ) [ 5 ] ;
var talksender = t . Split ( ',' ) [ 6 ] ;
System . Text . StringBuilder sb = new System . Text . StringBuilder ( ) ;
m . mcontents = ( m . mcontents . Length > 1000 ? m . mcontents . Substring ( 0 , 1000 ) : m . mcontents ) . Replace ( "\"" , "'" ) ;
var us = m . Users . Where ( w = > w . isok = = 1 ) . ToList ( ) ;
if ( us . Count ( ) > 0 )
{
for ( var i = 0 ; i < us . Count ( ) ; i + + )
{
if ( ( i + 1 ) % 100 = = 1 )
{
sb . Clear ( ) ;
sb . Append ( "[" ) ;
}
sb . Append ( "{\"message_type\": \"AT\", \"" +
"phn\": \"" + us [ i ] . mobile . Replace ( "-" , "" ) + "\", \"" +
"profile\": \"" + talkprofilekey + "\", \"" +
"reserveDt\": \"00000000000000\", \"" +
2020-10-12 15:32:10 +09:00
"smsLmsTit\": \"[영남건설기술교육원 알림톡]\", \"" +
2020-10-12 14:39:23 +09:00
"msg\": \"" + m . mcontents + "\",\"" +
"smsKind\": \"" + ( System . Text . Encoding . Default . GetBytes ( m . mcontents ) . Length > 90 ? "L" : "S" ) + "\", \"" +
"msgSms\": \"" + m . mcontents + "\", \"" +
"smsSender\": \"" + talksender + "\", \"" +
"smsOnly\": \"Y\"" +
"}," ) ;
if ( ( i + 1 ) % 100 = = 0 | | i = = us . Count ( ) - 1 )
{
String rtntalk = "" ;
System . Net . HttpWebRequest request = ( System . Net . HttpWebRequest ) System . Net . WebRequest . Create ( talkurl ) ;
request . Method = "POST" ;
request . ContentType = "application/json" ;
request . Accept = "application/json" ;
request . Headers . Add ( "userid" , talkaccountid ) ;
rtntalk = ApiCall ( request , sb . ToString ( ) . Substring ( 0 , sb . Length - 1 ) + "]" ) ;
if ( rtntalk . StartsWith ( "nptecherr:" ) )
{
foreach ( var d in us )
{
d . isok = - 2 ;
}
}
else
{
System . Web . Script . Serialization . JavaScriptSerializer js = new System . Web . Script . Serialization . JavaScriptSerializer ( ) ;
TalkRtn [ ] rtn = js . Deserialize < TalkRtn [ ] > ( rtntalk . StartsWith ( "[" ) ? rtntalk : ( "[" + rtntalk + "]" ) ) ;
foreach ( var d in rtn )
{
if ( d . data = = null )
{
foreach ( var u2 in us )
{
u2 . isok = 0 ;
}
}
else
{
var u = us . Where ( w = > w . mobile . Replace ( "-" , "" ) = = d . data . phn ) . FirstOrDefault ( ) ;
if ( u ! = null )
{
u . msgid = d . data . msgid ;
u . message = d . message ;
if ( "fail" . Equals ( d . code . ToLower ( ) ) )
{
u . isok = 0 ;
}
}
}
}
}
}
}
}
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
Dao . Insert ( "common.sms.in" , m ) ;
Dao . Save ( "common.smsuser.in" , m ) ;
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = us . Where ( w = > w . isok = = 1 ) . Count ( ) , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />휴대폰번호오류: {2}" , data . Count ( ) , us . Where ( w = > w . isok = = 1 ) . Count ( ) , us . Where ( w = > w . isok ! = 1 ) . Count ( ) ) } ) ;
}
else if ( type = = 1 )
{
//메일
var EmailSend = new EmailSend ( ) { uno = SUserInfo . UserNo , uip = GetUserIP ( ) } ;
var data = Dao . Get < Lect > ( "users.getlectbyusernos" , usernos ) . ToList ( ) ;
var okcount = 0 ;
EmailSend . rcvcount = data . Count ( ) ;
EmailSend . rcvs = string . Join ( ";" , data . Select ( s = > string . Format ( "{0}:{1}" , s . username . Replace ( ":" , "" ) . Replace ( ";" , "" ) , s . email ) ) ) ;
EmailSend . uno = SUserInfo . UserNo ;
EmailSend . uip = GetUserIP ( ) ;
EmailSend . reademails = "" ;
if ( ! string . IsNullOrEmpty ( title ) ) { EmailSend . etitle = "[" + title + "]" ; }
//EmailSend.etitle = "[수강신청안내]";
EmailSend . ehtml = msg . Replace ( "\n" , "<br>" ) ;
Dao . Insert ( "common.emailsend.in" , EmailSend ) ;
var bans = Dao . Get < EmailSend > ( "common.emailbanpool" , string . Join ( "," , data . Select ( s = > string . Format ( "'{0}'" , s . email ) ) ) ) ;
EmailSend . sendeds = "" ;
int bancount = 0 ;
EmailSend . ehtml = EmailSend . ehtml . Replace ( "^fronturl^" , GetConfig ( "fronturl" ) ) . Replace ( "../img/mail" , GetConfig ( "fronturl" ) + "/img/mail" ) ;
var sender = Dao . Get < Users > ( "users.me" , SUserInfo . UserNo ) . First ( ) ;
var masteremail = GetConfig ( "masteremail" ) ;
var senderemail = Request . IsLocal | | string . IsNullOrEmpty ( sender . email ) | | ! IsEmail ( sender . email ) ? masteremail . Split ( ';' ) [ 0 ] : sender . email ;
foreach ( var u in data )
{
if ( string . IsNullOrEmpty ( u . email ) | | ! IsEmail ( u . email ) | | u . isacceptemail = = 0 | | bans . Where ( w = > w . semail = = u . email ) . FirstOrDefault ( ) ! = null )
{
bancount + + ;
}
else if ( SendEmail ( masteremail . Split ( ';' ) [ 1 ] , GetInt ( masteremail . Split ( ';' ) [ 2 ] ) , masteremail . Split ( ';' ) [ 3 ] , masteremail . Split ( ';' ) [ 4 ] , 999 , u . email , senderemail , SUserInfo . UserName , EmailSend . etitle , EmailSend . ehtml , "" , "0:" + EmailSend . sendno ) > 0 )
{
okcount + + ;
EmailSend . sendeds + = ";" + u . email ;
}
}
if ( okcount > 0 )
{
EmailSend . readcount = okcount ;
EmailSend . sendeds = EmailSend . sendeds . Substring ( 1 ) ;
Dao . Save ( "common.emailsendok" , EmailSend ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = okcount , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />수신거부/이메일주소오류: {2}" , data . Count ( ) , okcount , bancount ) } ) ;
}
else if ( type = = 2 )
{
//쪽지
if ( ! string . IsNullOrEmpty ( title ) ) { m . mtitle = "[" + title + "]" ; }
//m.mtitle = "[수강신청안내]";
m . mcontents = msg ;
m . usernos = usernos ;
m . uno = SUserInfo . UserNo ;
m . uip = GetUserIP ( ) ;
var rtn = Dao . Save ( "common.memo.insertmulti" , m ) - 1 ;
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = rtn , msg = string . Format ( "<br />전체대상: {0}<br />발송성공: {1}<br />수신거부/이메일주소오류: {2}" , usernos . Split ( ',' ) . Length , rtn , 0 ) } ) ;
}
return JsonOK ( 0 ) ;
}
[HttpPost]
public JsonResult AuthKey ( int authtype , String jobkey )
{
Random r = new Random ( ) ;
var randkey = r . Next ( 10000000 , 99999999 ) ;
return JsonOK ( Dao . Save ( "common.authkey.save" , new Hashtable ( ) { { "authtype" , authtype } , { "userno" , SUserInfo . UserNo } , { "jobkey" , jobkey } , { "randkey" , randkey } } ) > 0 ? randkey : 0 ) ;
}
[HttpPost]
public JsonResult SetAuthKey ( Data d )
{
d . intval30 = GetRand ( ) ;
return JsonOK ( Dao . Save ( "common.authkey.set" , d ) > 0 ? d . intval30 : 0 ) ;
}
[HttpPost]
public JsonResult DayTerm ( DateTime s , DateTime e )
{
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = ( e - s ) . TotalDays } ) ;
}
[HttpPost]
public JsonResult NCSDelCheck ( int ndepth , int ncsno )
{
var d = Dao . Get < Data > ( "sys.ncs.check." + ( ndepth = = 0 ? "t" : ndepth = = 1 ? "m" : ndepth = = 2 ? "b" : ndepth = = 3 ? "d" : "x" ) , ncsno ) . First ( ) ;
if ( d . intval > 0 )
{
return JsonOK ( - 1 ) ;
}
return JsonBack ( new JsonRtn ( ) { code = 1000 , obj = d . intval2 } ) ;
}
[HttpPost]
public JsonResult NCSDelNew ( int ndepth , int ncsno )
{
return JsonOK ( Dao . Save ( "sys.ncs.delall" , new Hashtable ( ) { { "ndepth" , ndepth } , { "ncsno" , ncsno } } ) ) ;
}
}
}