YNICTE/Base/Controller/FCommon.cs

378 lines
18 KiB
C#
Raw Normal View History

2020-10-12 14:39:23 +09:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NP.Model;
using System.Collections;
using NP.Base.Auth;
using NP.Base.ENUM;
namespace NP.Base.Controllers
{
/// <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)
2020-10-12 14:39:23 +09:00
{
var rtn = DropFile(fileno, filename, datakey);
2020-10-12 14:39:23 +09:00
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)
2020-10-12 14:39:23 +09:00
{
//수강신청기간이 아님
return JsonOK(0, true);
}
else if (cms.Where(w => w.rno == 1).First().lectstatus > 0)
2020-10-12 14:39:23 +09:00
{
//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)
2020-10-12 14:39:23 +09:00
{
return JsonOK(1000);
}
return JsonOK(11);
}
[HttpPost]
public JsonResult AssignSave(String brno, String asname, String ceoname)
2020-10-12 14:39:23 +09:00
{
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() } };
2020-10-12 14:39:23 +09:00
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 } }));
2020-10-12 14:39:23 +09:00
}
[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));
}
2020-11-06 18:04:55 +09:00
2020-10-12 14:39:23 +09:00
//[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 }));
//}
2020-11-06 18:04:55 +09:00
[HttpPost]
public JsonResult savePPLog(VMCourse vm)
{
2020-11-09 13:29:54 +09:00
int rtn = 0;
2021-06-04 18:01:04 +09:00
PPLog pplog = new PPLog();
pplog.uno = SUserInfo.UserNo;
pplog.uip = GetUserIP();
pplog.cmno = vm.cmno;
pplog.userno = vm.User.userno;
pplog.asno = vm.Assign != null ? vm.Assign.asno : (long?)null;
pplog.isready = Request["applicableCM"].ToString() == "정상접수" ? 0 : 1;
pplog.cgcode = vm.stringval;
pplog.cshape = !string.IsNullOrEmpty(vm.stringval2) ? Convert.ToInt32(vm.stringval2) : (int?)null;
pplog.asname = string.Empty;
2020-11-06 18:04:55 +09:00
if (vm.stringval == "0")
{
2021-06-04 18:01:04 +09:00
pplog.typeman = !string.IsNullOrEmpty(vm.stringval3) ? Convert.ToInt32(vm.stringval3) : (int?)null;
pplog.typeedu = !string.IsNullOrEmpty(vm.stringval4) ? Convert.ToInt32(vm.stringval4) : (int?)null;
pplog.typegrade = !string.IsNullOrEmpty(vm.stringval5) ? Convert.ToInt32(vm.stringval5) : (int?)null;
pplog.typejob = !string.IsNullOrEmpty(vm.stringval6) ? Convert.ToInt32(vm.stringval6) : (int?)null;
2020-11-06 18:04:55 +09:00
}
else
{
2021-06-04 18:01:04 +09:00
pplog.cgno = !string.IsNullOrEmpty(vm.stringval3) ? Convert.ToInt32(vm.stringval3) : (int?)null;
2020-11-06 18:04:55 +09:00
}
2021-06-04 18:01:04 +09:00
pplog.cmisno = !string.IsNullOrEmpty(Request["cmisno"]) ? Convert.ToInt64(Request["cmisno"]) : (long?)null;
pplog.isrebate = !string.IsNullOrEmpty(Request["isrebate"]) ? Convert.ToInt32(Request["isrebate"]) : (int?)null;
pplog.isaccommodation = !string.IsNullOrEmpty(Request["isaccommodation"]) ? Convert.ToInt32(Request["isaccommodation"].ToString()) : (int?)null;
#region
2021-06-04 18:01:04 +09:00
if (pplog.isrebate == 1)
{
2021-06-04 18:01:04 +09:00
pplog.rbankname = !string.IsNullOrEmpty(Request["rbankname"]) ? Request["rbankname"].ToString() : null;
pplog.rbankacc = !string.IsNullOrEmpty(Request["rbankacc"]) ? Request["rbankacc"].ToString() : null;
pplog.rbankowner = !string.IsNullOrEmpty(Request["rbankowner"]) ? Request["rbankowner"].ToString() : null;
}
#endregion
#region
var isCompany = !string.IsNullOrEmpty(Request["isCompany"]) ? Convert.ToInt32(Request["isCompany"]) : (int?)null;
if (isCompany == 0) //개인
{
2021-06-04 18:01:04 +09:00
pplog.asno = null;
vm.Assign = null;
}
else if (isCompany == 1) //업체
{
//업체인데 회사정보가 안넘어오면 에러처리
if (vm.Assign == null)
{
return JsonNoData();
}
}
#endregion
#region Assign
if (vm.Assign != null)
{
2021-06-04 18:01:04 +09:00
pplog.asname = vm.Assign.asname;
pplog.brno = vm.Assign.brno.IndexOf("-") > 0 ? vm.Assign.brno.Replace("-", "") : vm.Assign.brno;
pplog.ceoname = vm.Assign.ceoname;
pplog.post = vm.Assign.post;
pplog.address1 = vm.Assign.address1;
pplog.address2 = vm.Assign.address2;
pplog.btype = vm.Assign.btype;
pplog.bkind = vm.Assign.bkind;
2020-11-06 18:04:55 +09:00
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");
}
2021-06-04 18:01:04 +09:00
pplog.fgnobno = fgnobno;
2020-10-12 14:39:23 +09:00
2021-06-04 18:01:04 +09:00
pplog.eino = vm.Assign.eino;
pplog.mname = vm.Assign.mname;
pplog.mphone = string.Format("{0}-{1}-{2}", vm.Assign.mphone1, vm.Assign.mphone2, vm.Assign.mphone3);
pplog.taxemail = string.Format("{0}@{1}", vm.Assign.taxemail1, vm.Assign.taxemail2);
}
#endregion
#region User
2020-11-06 18:04:55 +09:00
if (!string.IsNullOrEmpty(vm.User.userpno1) && !string.IsNullOrEmpty(vm.User.userpno2))
{
2021-06-04 18:01:04 +09:00
pplog.userpno = string.Format("{0}{1}", vm.User.userpno1, vm.User.userpno2);
2020-11-06 18:04:55 +09:00
}
2021-06-04 18:01:04 +09:00
pplog.mobile = string.Format("{0}-{1}-{2}", vm.User.mobile1, vm.User.mobile2, vm.User.mobile3);
pplog.email = string.Format("{0}@{1}", vm.User.email1, vm.User.email2);
pplog.upost = vm.User.post;
pplog.uaddress1 = vm.User.address1;
pplog.uaddress2 = vm.User.address2;
pplog.isassignuser = vm.User.isassignuser;
pplog.uduty = vm.User.uduty;
pplog.slevel = vm.User.slevel;
#endregion
2021-06-04 18:01:04 +09:00
if (pplog.asno != null)
{
2021-06-04 18:01:04 +09:00
Dao.Save("cm.assign.applyedu.up", pplog);
}
2021-06-04 18:01:04 +09:00
Dao.Save("cm.users.applyedu.up", pplog);
Dao.Insert("cm.pplog.applyedu.in", pplog);
if (pplog.pplno > 0)
2020-11-06 18:04:55 +09:00
{
2021-06-04 18:01:04 +09:00
return JsonOK(pplog.pplno);
2020-11-06 18:04:55 +09:00
}
return JsonOK(rtn);
}
[HttpPost]
public JsonResult GetAssign(int asno)
{
if (asno != 0)
{
2021-05-20 17:14:27 +09:00
var assign = Dao.Get<Assign>("users.assigns2", new System.Collections.Hashtable() { { "asno", asno }, { "excel1", ",a.post" }, { "orderby", "a.asname" } })
.Select( s => new { s.brno, s.ceoname, s.post, s.address1, s.address2, s.btype, s.bkind, s.eino, s.mname, s.mphone, s.taxemail, s.fgnobno })
.FirstOrDefault();
return JsonBack(assign);
}
else
{
return JsonOK(0);
}
}
2020-10-12 14:39:23 +09:00
}
2020-10-12 14:39:23 +09:00
}