331 lines
16 KiB
C#
331 lines
16 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 관리자권한, antitoken필요로하는 ajax호출
|
|
/// </summary>
|
|
[NP.Base.Auth.CFilter]
|
|
public partial class FCommonController : 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 FileDel(Int64 fileno = 0, String filename = "", Int64 fgno = 0, int issinglefile = 0, String log = "",String datakey=null)
|
|
{
|
|
var rtn = DropFile(fileno, filename,datakey);
|
|
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 UploadEditorImageUrl(String fd)
|
|
{
|
|
if (!string.IsNullOrEmpty(Request.Files["img"].FileName))
|
|
{
|
|
return SetFileNoDB(Request.Files, fd);
|
|
}
|
|
return JsonNoApply();
|
|
}
|
|
[HttpPost]
|
|
public JsonResult BuyCheck(int cmno)
|
|
{
|
|
//신청가능확인(기간,제한인원,동일강좌,유사강좌)
|
|
var cms = Dao.Get<CM>("cm.cmcheck.forbuy", new Hashtable() { { "cmno", cmno }, { "userno", SUserInfo.UserNo } });
|
|
if (cms.Where(w=>w.rno == 1).Count() < 1)
|
|
{
|
|
//수강신청기간이 아님
|
|
return JsonOK(0, true);
|
|
}
|
|
else if (cms.Where(w=>w.rno == 1).First().lectstatus > 0)
|
|
{
|
|
//1: 수강중, 3:심사중, 4: 승인(결제대기)
|
|
return JsonOK(cms.Where(w => w.rno == 1).First().lectstatus);
|
|
}
|
|
else if (cms.Where(w => w.rno == 1).First().quota != 0 && cms.Where(w => w.rno == 1).First().countlect >= cms.Where(w => w.rno == 1).First().quota)
|
|
{
|
|
return JsonOK(999);
|
|
}
|
|
else if (cms.Where(w=>w.rno == 2).Count() > 0)
|
|
{
|
|
return JsonOK(1000);
|
|
}
|
|
return JsonOK(11);
|
|
}
|
|
[HttpPost]
|
|
public JsonResult AssignSave(String brno, String asname,String ceoname)
|
|
{
|
|
var ht = new Hashtable() { { "asno", 0}, { "isjoin", 0 }, { "joinprice", 0 }, { "asname", asname }, { "brno", brno.Replace("-", "") },{"ceoname",ceoname }, { "salesamount", 0 }, { "mcount", 0 }, { "status", 1 }, { "isdel", 0 }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } };
|
|
Dao.Insert("users.assign.in", ht);
|
|
return JsonOK(GetInt(ht["asno"]));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult UserFind(int asno, String username, String email, int? pno)
|
|
{
|
|
return JsonBack(Dao.Get<Users>("users.users", new Hashtable() { { "asno", asno }, { "username", username == "" ? null : username }, { "email", email==""?null:email }, { "pagenum", pno }, { "pagerowsize", 10 } }));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult UserGet(int userno)
|
|
{
|
|
return JsonBack(Dao.Get<Users>("users.users", new Hashtable() { { "userno", userno } }).First());
|
|
}
|
|
[HttpPost]
|
|
public JsonResult UserNew(Users user)
|
|
{
|
|
user.uno = SUserInfo.UserNo; user.uip = GetUserIP();
|
|
user.usertype = 1;
|
|
if (user.userno < 1) { user.userpass = NP.Base.Lib.KISA_SHA256.SHA256Hash(user.telno.Replace("-", "")); }
|
|
var telno = user.telno.Replace("-", "");
|
|
user.telno = telno.Length == 11 ? string.Format("{0}-{1}-{2}", telno.Substring(0, 3), telno.Substring(3, 4), telno.Substring(7, 4)) :
|
|
telno.Length == 10 ? string.Format("{0}-{1}-{2}", telno.Substring(0, 3), telno.Substring(3, 3), telno.Substring(6, 4)) :
|
|
telno.Length == 9 ? string.Format("{0}-{1}-{2}", telno.Substring(0, 2), telno.Substring(2, 3), telno.Substring(5, 4)) :
|
|
telno.Length == 8 ? string.Format("{0}-{1}", telno.Substring(0, 4), telno.Substring(4, 4)) :
|
|
telno.Length == 7 ? string.Format("{0}-{1}", telno.Substring(0, 3), telno.Substring(3, 4)) : user.telno;
|
|
user.userid = user.email = user.email.Trim();
|
|
var check = Dao.Get<int>("users.checkuser", new Hashtable() { { "usernonot", user.userno > 0 ? user.userno : (int?)null }, { "userid", user.userno > 0 ? null : user.userid }, { "email", user.email } }).First();
|
|
if (check < 9)
|
|
{
|
|
return JsonOK(check * -1);
|
|
}
|
|
user.savefrontbuy = 1;
|
|
if (user.userno < 1)
|
|
{
|
|
user.status = 1;
|
|
Dao.Insert("users.in", user);
|
|
return JsonOK(user.userno);
|
|
}
|
|
else
|
|
{
|
|
user.email = user.userid = user.username = null;
|
|
LogSet(new ActLog() { logtype = 30, logtarget = 21, logdata = user.username + "(" + user.userid + ")", userno = user.userno, uno = SUserInfo.UserNo, uip = GetUserIP() });
|
|
return JsonOK(Dao.Save("users.up", user));
|
|
}
|
|
}
|
|
[HttpPost]
|
|
public JsonResult EduB2BSave(EduB2B e)
|
|
{
|
|
e.brno = (e.brno ?? "").Replace("-", "");
|
|
e.userno = SUserInfo.UserNo;
|
|
e.uno = SUserInfo.UserNo;
|
|
e.uip = GetUserIP();
|
|
if (Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).Count() > 0)
|
|
{
|
|
e.fgno = SetFile(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), e.fgno ?? 0, "edub2b", "fgno");
|
|
}
|
|
return JsonOK(Dao.Save("lect.edub2b", e));
|
|
}
|
|
|
|
|
|
//[HttpPost]
|
|
//public JsonResult SaveUserFile(String type, Int64? fgno)
|
|
//{
|
|
// var orgfgno = fgno??0;
|
|
// if (orgfgno > 0 && type == "FGNoProfile")
|
|
// {
|
|
// //프로필 시존 삭제
|
|
// Dao.Save("users.profileclear", SUserInfo.UserNo);
|
|
// }
|
|
// Int64 fileno = 0;
|
|
// fgno = SetFile2(Request.Files, fgno??0, "User", "Users." + type, out fileno);
|
|
// fgno = fgno < 1 ? (Int64?)null : fgno;
|
|
// if (fgno != null && fileno > 0)
|
|
// {
|
|
// if (orgfgno > 0)
|
|
// {
|
|
// return JsonBack<File>(Dao.GetFilesByKey(fileno).First());
|
|
// }
|
|
// else
|
|
// {
|
|
// if (Dao.Save("users.files.set", new Hashtable() { { "UserNo", SUserInfo.UserNo }, { type, fgno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }) == 1)
|
|
// {
|
|
// return JsonBack<File>(Dao.GetFilesByKey(fileno).First());
|
|
// }
|
|
// }
|
|
// }
|
|
// return JsonOK(0);
|
|
//}
|
|
|
|
|
|
//[HttpPost]
|
|
//public JsonResult DeleteFile(Int64 key = 0, String fName = "", Int64 fgno = 0, int isSingleFile = 0, String log = "", String datakey = "")
|
|
//{
|
|
// var rtn = DropFile(key, fName, datakey);
|
|
// if (rtn < 1)
|
|
// {
|
|
// //throw new System.ArgumentNullException("nodata");
|
|
// return JsonOK(0);
|
|
// }
|
|
// else
|
|
// {
|
|
// if (log != "")
|
|
// {
|
|
// //로그 남김
|
|
// LogSet(new ActLog() { logtype = 90, logtarget = 92, userno = key, uno = SUserInfo.UserNo, uip = GetUserIP() });
|
|
// }
|
|
// return JsonOK(1, false);
|
|
// }
|
|
//}
|
|
|
|
//[HttpPost]
|
|
//public JsonResult MoreMemo(int pno, int prc, int type = 0)
|
|
//{
|
|
// if (type == 0)
|
|
// {
|
|
// return JsonBackList<Memo>(Dao.Get<Memo>("common.mymemos", new Hashtable() { { "PAGEROWSIZE", prc }, { "PAGENUM", pno }, { "UserNo", SUserInfo.UserNo } }));
|
|
// }
|
|
// var ht = new Hashtable() { { "PAGEROWSIZE", prc }, { "PAGENUM", pno }, { "UserNo", SUserInfo.UserNo }, { "SendUserGroup", 1 } };
|
|
// var rtn = new Hashtable() { };
|
|
// var Memos =Dao.Get<Memo>("common.list.send", ht);
|
|
// var Memos2 = new List<Memo>() { };
|
|
// if (Memos.Count() > 0)
|
|
// {
|
|
// Memos2 = Dao.Get<Memo>("common.list.senddata", new System.Collections.Hashtable() { { "MNos", string.Join(",", Memos.Select(s => s.mno.ToString())) } }).ToList();
|
|
// }
|
|
// rtn.Add("Memos", Memos);
|
|
// rtn.Add("Memos2", Memos2);
|
|
// return JsonBack(rtn);
|
|
//}
|
|
//[HttpPost]
|
|
//public JsonResult GetMemo(Int64 mno, int type = 0)
|
|
//{
|
|
// if (type == 0)
|
|
// {
|
|
// return JsonBack<Memo>(Dao.Get<Memo>("common.mymemo", new Hashtable() { { "UserNo", SUserInfo.UserNo }, { "MNo", mno } }).First());
|
|
// }
|
|
// var rtn = new Hashtable() { };
|
|
// var Memo = Dao.Get<Memo>("common.mysendmemo", new Hashtable() { { "UserNo", SUserInfo.UserNo }, { "MNo", mno } }).First();
|
|
// rtn.Add("Memo", Memo);
|
|
// rtn.Add("MemoUsers", Dao.Get<Memo>("common.list.senddata", new System.Collections.Hashtable() { { "MNo", mno } }));
|
|
// return JsonBack(rtn);
|
|
//}
|
|
//[HttpPost]
|
|
//public JsonResult MemoDel(Int64 mno, int type)
|
|
//{
|
|
// if (mno > 0 && type == 0)
|
|
// {
|
|
// return JsonOK(Dao.Save("common.memo.deleteR", new Hashtable() { {"MNo",mno },{"uno",SUserInfo.UserNo }, {"uip",GetUserIP() } }));
|
|
// }
|
|
// else if (mno == 0 && type == -1)
|
|
// {
|
|
// return JsonOK(Dao.Save("common.memo.alldeleteR", new Hashtable() { { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
|
|
// }
|
|
// else if (mno > 0 && type == 1)
|
|
// {
|
|
// return JsonOK(Dao.Save("common.memo.deleteS", new Hashtable() { { "MNo", mno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
|
|
// }
|
|
// else if (mno == 0 && type == 9)
|
|
// {
|
|
// return JsonOK(Dao.Save("common.memo.alldeleteS", new Hashtable() { { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
|
|
// }
|
|
// return JsonOK(0);
|
|
//}
|
|
//[HttpPost]
|
|
//public JsonResult SendMemo(Int64 userno, String mtitle, String mcontents, Int64? pmno)
|
|
//{
|
|
// pmno = (pmno??0) < 1 ? (Int64?)null : pmno;
|
|
// return JsonOK(Dao.Save("common.memo.insert", new Memo() { usernos = userno.ToString(), pmno = pmno, mtitle = mtitle, mcontents = mcontents, uno = SUserInfo.UserNo, uip = GetUserIP(), cno = SUserInfo.UserNo }));
|
|
//}
|
|
[HttpPost]
|
|
public JsonResult savePPLog(VMCourse vm)
|
|
{
|
|
int rtn = 0;
|
|
PPLog ppllog = new PPLog();
|
|
ppllog.uno = SUserInfo.UserNo;
|
|
ppllog.uip = GetUserIP();
|
|
ppllog.cmno = vm.cmno;
|
|
ppllog.userno = vm.User.userno;
|
|
ppllog.asno = vm.Assign.asno;
|
|
ppllog.isready = Request["applicableCM"].ToString() == "정상접수" ? 0 : 1;
|
|
ppllog.cgcode = vm.stringval;
|
|
if (!string.IsNullOrEmpty(vm.stringval2))
|
|
ppllog.cshape = Convert.ToInt32(vm.stringval2);
|
|
if (vm.stringval == "0")
|
|
{
|
|
ppllog.typeman = !string.IsNullOrEmpty(vm.stringval3) ? Convert.ToInt32(vm.stringval3) : (int?)null;
|
|
ppllog.typeedu = !string.IsNullOrEmpty(vm.stringval4) ? Convert.ToInt32(vm.stringval4) : (int?)null;
|
|
ppllog.typegrade = !string.IsNullOrEmpty(vm.stringval5) ? Convert.ToInt32(vm.stringval5) : (int?)null;
|
|
ppllog.typejob = !string.IsNullOrEmpty(vm.stringval6) ? Convert.ToInt32(vm.stringval6) : (int?)null;
|
|
}
|
|
else
|
|
{
|
|
ppllog.cgno = !string.IsNullOrEmpty(vm.stringval3) ? Convert.ToInt32(vm.stringval3) : (int?)null;
|
|
}
|
|
if (!string.IsNullOrEmpty(Request["cmisno"]))
|
|
ppllog.cmisno = Convert.ToInt64(Request["cmisno"]);
|
|
if (!string.IsNullOrEmpty(Request["isrebate"]))
|
|
ppllog.isrebate = Convert.ToInt32(Request["isrebate"]);
|
|
if (!string.IsNullOrEmpty(Request["rbankname"]))
|
|
ppllog.rbankname = Request["rbankname"].ToString();
|
|
if (!string.IsNullOrEmpty(Request["rbankacc"]))
|
|
ppllog.rbankacc = Request["rbankacc"].ToString();
|
|
if (!string.IsNullOrEmpty(Request["rbankowner"]))
|
|
ppllog.rbankowner = Request["rbankowner"].ToString();
|
|
|
|
ppllog.asname = vm.Assign.asname;
|
|
ppllog.brno = vm.Assign.brno.IndexOf("-") > 0 ? vm.Assign.brno.Replace("-", "") : vm.Assign.brno;
|
|
ppllog.ceoname = vm.Assign.ceoname;
|
|
ppllog.post = vm.Assign.post;
|
|
ppllog.address1 = vm.Assign.address1;
|
|
ppllog.address2 = vm.Assign.address2;
|
|
ppllog.btype = vm.Assign.btype;
|
|
ppllog.bkind = vm.Assign.bkind;
|
|
|
|
Int64? fgnobno = (Int64?)null;
|
|
if (Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).Count() > 0)
|
|
{
|
|
fgnobno = SetFile(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), fgnobno ?? 0, "assign", "fgnobno");
|
|
}
|
|
ppllog.fgnobno = fgnobno;
|
|
ppllog.eino = vm.Assign.eino;
|
|
ppllog.mname = vm.Assign.mname;
|
|
ppllog.mphone = string.Format("{0}-{1}-{2}", vm.Assign.mphone1, vm.Assign.mphone2, vm.Assign.mphone3);
|
|
ppllog.taxemail = string.Format("{0}@{1}", vm.Assign.taxemail1, vm.Assign.taxemail2);
|
|
if (!string.IsNullOrEmpty(vm.User.userpno1) && !string.IsNullOrEmpty(vm.User.userpno2))
|
|
{
|
|
ppllog.userpno = string.Format("{0}-{1}", vm.User.userpno1, vm.User.userpno2);
|
|
}
|
|
ppllog.mobile = string.Format("{0}-{1}-{2}", vm.User.mobile1, vm.User.mobile2, vm.User.mobile3);
|
|
ppllog.email = string.Format("{0}@{1}", vm.User.email1, vm.User.email2);
|
|
ppllog.upost = vm.User.post;
|
|
ppllog.uaddress1 = vm.User.address1;
|
|
ppllog.uaddress2 = vm.User.address2;
|
|
ppllog.isassignuser = vm.User.isassignuser;
|
|
ppllog.uduty = vm.User.uduty;
|
|
ppllog.slevel = vm.User.slevel;
|
|
|
|
Dao.Save("cm.assign.applyedu.up", ppllog);
|
|
Dao.Save("cm.users.applyedu.up", ppllog);
|
|
Dao.Insert("cm.pplog.applyedu.in", ppllog);
|
|
if (ppllog.pplno > 0)
|
|
{
|
|
return JsonOK(ppllog.pplno);
|
|
}
|
|
return JsonOK(rtn);
|
|
|
|
}
|
|
}
|
|
|
|
} |