using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using NP.Model; namespace NP.BO.Controllers { public class cmController : BOBaseController { public ActionResult terms(NP.Model.VMCM vm) { vm.Terms = InitM(); var ht = SetHash(vm); if (vm.stringval == null && !IsPost()) { vm.stringval = DateTime.Now.Year.ToString(); } ht.Add("tyear", vm.stringval); vm.Terms = Dao.Get("cm.terms", ht); vm.pagetotalcount = GetCount(vm.Terms.FirstOrDefault()); return View(vm); } public ActionResult termreg(NP.Model.VMCM vm) { vm.Term = new Term() { }; if (vm.intval > 0) { vm.Term = Dao.Get("cm.terms", new System.Collections.Hashtable() { { "tmno", vm.intval } }).First(); } else { vm.Term.tyear = DateTime.Now.Year; } return View(vm); } public ActionResult cgs(VMCM vm) { vm.CGs = InitM(); var ht = SetHash(vm); ht.Add("cgnamecode", vm.searchtext); ht.Add("isdel", 0); vm.CGs = Dao.Get("cm.cgs", ht); vm.pagetotalcount = GetCount(vm.CGs.FirstOrDefault()); vm.CGs2 = Dao.Get("cm.cgs", new System.Collections.Hashtable() { {"isuse",1 },{"istop",1 },{"isdel",0 } }); ViewBag.Fixed = ";" + OnCode + ";" + OnCode1 + ";" + OnCode2 + ";" + OnCode3 + ";" + OffCode + ";" + OffCode1 + ";" + OffCode2 + ";" + OffCode3 + ";" + TestCode + ";" + TestCode1 + ";" + TestCode2 + ";"; return View(vm); } public ActionResult cmmasters(NP.Model.VMCM vm) { vm.viewidx = 1; vm.viewname = "cmmasterreg"; vm.listviewname = "cmmasters"; return cms(vm); } public ActionResult cms(VMCM vm) { vm.viewidxname = vm.viewidx == 1 ? "과정" : "강좌"; vm.viewname = vm.viewname ?? "cmreg"; vm.listviewname = vm.listviewname ?? "cms"; vm.CMs = InitM(); vm.CGs = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "isuse", 1 }, { "isdel", 0 } }); vm.ComCodes = GetComCodes("typeman,typeedu,typegrade,typejob,studyplace"); //vm.CGs2 = new List() { }; //if (!string.IsNullOrEmpty(vm.stringval)) //{ // vm.CGs2 = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "isuse", 1 }, { "pcgno", vm.stringval },{ "isdel", 0 } }); //} if (vm.viewidx == 0 && !IsPost() && string.IsNullOrEmpty(vm.stringval5)) { vm.stringval5 = DateTime.Now.Year.ToString(); } vm.Terms = Dao.Get("cm.terms", new System.Collections.Hashtable() { /*{ "tyear", DateTime.Now.Year }*/ }); var ht = SetHash(vm); ht.Add("pcgno", vm.stringval); ht.Add("tyear", vm.stringval5); ht.Add("tseq", vm.stringval6); ht.Add("cgno", vm.stringval2); ht.Add("cshape", vm.stringval3); ht.Add("typeman", vm.stringval4); ht.Add("typeedu", vm.stringval5); ht.Add("typegrade", vm.stringval6); ht.Add("typejob", vm.stringval7); ht.Add("studyplace", vm.stringval8); ht.Add("cname", vm.stringval9); ht.Add("ismaster", vm.viewidx); ht.Add("listcolumn", 1); vm.CMs = Dao.Get("cm.cms", ht); if (vm.viewidx == 0 && vm.CMs.Count() > 0) { //수강신청 수 카운팅 vm.Datas = Dao.Get("cm.count.cmlect", new System.Collections.Hashtable() { { "cmnos", string.Join(",", vm.CMs.Select(s => s.cmno)) },{ "ischanged",0} }); } vm.pagetotalcount = GetCount(vm.CMs.FirstOrDefault()); vm.addstringval = "x"; if (vm.CMs.Count() > 0) { vm.addstringval = string.Join(",", Dao.Get("cm.cm.checklect", string.Join(",", vm.CMs.Select(s => s.cmno))).Select(s=>s.cmno)); if (string.IsNullOrEmpty(vm.addstringval)) { vm.addstringval = "x"; } else { vm.addstringval = "," + vm.addstringval + ","; } } return View("cms", vm); } public ActionResult cmmasterreg(NP.Model.VMCM vm) { vm.CM = new CM() { isuse = 1, ismaster = 1 , isseq=1 }; return cmreg(vm); } public ActionResult cmreg(VMCM vm) { ViewBag.TestCode = TestCode; //ViewBag.TestCode3 = TestCode3; ViewBag.OffCode = OffCode; if (string.IsNullOrEmpty(vm.viewidxname)) { vm.viewidxname = vm.viewidx == 0 ? "강좌" : "과정"; } vm.viewname = vm.viewname??"cmreg"; vm.listviewname = vm.listviewname??"cms"; vm.Datas = new List() { }; vm.FileList = new List() { }; if (vm.intval > 0) { vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.intval }, { "allcolumn", 1 } }).First(); vm.CGs = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "includepcgno", vm.CM.pcgno }, { "includecgno", vm.CM.cgno } }); vm.Datas = Dao.Get("cm.cmdatas", vm.CM.cmno); if (vm.CM.fgnocm != null) { vm.FileList = GetFiles(vm.CM.fgnocm.Value); } } else { vm.CGs = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "istop", 1 }, { "isdel", 0 }, { "isuse", 1 } }); } vm.Assigns = Dao.Get("users.assigns", new System.Collections.Hashtable() { { "status", 1 }, { "ismain", 1 } }); vm.ComCodes = GetComCodes("cert,certgrade,job,typeman,typeedu,typegrade,typejob,studyplace"); vm.userauths = Dao.Get("sys.menu.auths",new System.Collections.Hashtable() { {"isadminprof", 1 } }); return View("cmreg", vm); } public ActionResult cmmasterreginning(NP.Model.VMCM vm) { return cmreginning(vm); } public ActionResult cmreginning(VMCM vm) { vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.intval } }).FirstOrDefault(); if (vm.CM == null) { return Redirect("/"); } vm.CMInnings = Dao.Get("cm.cminnings", new System.Collections.Hashtable() { { "cmno", vm.CM.cmno } }); vm.CMPRs = Dao.Get("cm.cmprs", new System.Collections.Hashtable() { { "cmno", vm.CM.cmno } }); vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster",1 },{ "cshapes", "0,2"},{ "orderby","a.cname"} }); ViewBag.fronturl = GetConfig("fronturl"); return View("cmreginning", vm); } public ActionResult cmmasterregest(NP.Model.VMCM vm) { return cmregest(vm); } public ActionResult cmregest(VMCM vm) { vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.intval } }).First(); vm.CMEV = Dao.Get("cm.cmev", new System.Collections.Hashtable() { { "cmno", vm.CM.cmno } }).FirstOrDefault() ?? new CMEV() { attend = 100, attendrfd = 100 }; vm.ESTs = Dao.Get("cm.est", vm.CM.cmno); return View("cmregest", vm); } public ActionResult cmregex(VMCM vm) { ModelState.Clear(); vm.CMEX = new CMEX() { cmno = vm.cmno ,isresultopen=1}; vm.CMEXLayers = new List() { }; vm.CMEXQs = new List() { }; vm.ComGroups = Dao.Get("sys.comcode.glist", new System.Collections.Hashtable() { { "orderby", "cgroupname" } }); vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); vm.examsavable = ""; if (vm.intval > 0) { vm.CMEX = Dao.Get("cm.cmexes", new System.Collections.Hashtable() { { "exno", vm.intval } }).First(); vm.CMEXQs = Dao.Get("cm.cmexqs", vm.CMEX.exno); vm.examsavable = base.ExamSaveValid(vm.CMEX.exno); if (vm.CMEX.eqtype == 1) { vm.CMEXLayers = Dao.Get("cm.cmexlayers", vm.CMEX.exno); } } ViewBag.fronturl = GetConfig("fronturl"); return View("cmregex", vm); } public ActionResult cmregsd(VMCM vm) { ModelState.Clear(); vm.CMSD = new CMSD() { cmno = vm.cmno, sdtype = -1 }; vm.examsavable = ""; if (vm.intval > 0) { vm.CMSD = Dao.Get("cm.cmsds", new System.Collections.Hashtable() { { "sdno", vm.intval } }).First(); vm.examsavable = base.SDSaveValid(vm.CMSD.sdno); if ((vm.CMSD.fgno ?? 0) > 0) { vm.FileList = GetFiles(vm.CMSD.fgno.Value); } } return View("cmregsd", vm); } public ActionResult cmregrs(VMCM vm) { ModelState.Clear(); vm.CMRS = new CMRS() { cmno = vm.cmno, rstype = -1 }; vm.examsavable = ""; if (vm.intval > 0) { vm.CMRS = Dao.Get("cm.cmrss", new System.Collections.Hashtable() { { "rsno", vm.intval } }).First(); vm.examsavable = base.RSSaveValid(vm.CMRS.rsno); if (String.IsNullOrEmpty(vm.examsavable)) { vm.RSCs = Dao.Get("cm.rscs", new System.Collections.Hashtable() { { "isuse", 1 } }); } } else { vm.RSCs = Dao.Get("cm.rscs", new System.Collections.Hashtable() { { "isuse", 1 } }); } return View("cmregrs", vm); } public ActionResult cmmasterregmenu(NP.Model.VMCM vm) { return cmregmenu(vm); } public ActionResult cmregmenu(VMCM vm) { vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.intval } }).First(); vm.CMMenus = Dao.Get("cm.cmmenus", vm.CM.cmno); vm.CMMenu = vm.CMMenus.First(); vm.BoardMasters = Dao.Get("board.bms", new System.Collections.Hashtable() { {"bmposition",1 }, { "isopen", 1 },{ "orderby", "a.cdt"} }); return View("cmregmenu", vm); } public ActionResult books(NP.Model.VMCM vm) { var ht = SetHash(vm); ht.Add("bknamelike", vm.stringval); vm.Books = Dao.Get("cm.books", ht); vm.pagetotalcount = GetCount(vm.Books.FirstOrDefault()); return View(vm); } public ActionResult bookreg(NP.Model.VMCM vm) { vm.Book = new Book() { isuse = 1 }; vm.FileList = new List() { }; if (vm.intval > 0) { vm.Book = Dao.Get("cm.books", new System.Collections.Hashtable() { { "bkno", vm.intval } }).First(); string fgnos = ""; if ((vm.Book.fgnothumb??0) > 0) { fgnos += "," + vm.Book.fgnothumb.ToString(); } if ((vm.Book.fgno?? 0) > 0) { fgnos += "," + vm.Book.fgno.ToString(); } if (fgnos != "") { fgnos = fgnos.Substring(1); if (fgnos.Contains(",")) { vm.FileList = GetFiles(fgnos); } else { vm.FileList = GetFiles(GetInt64(fgnos)); } } } return View(vm); } public ActionResult cc(NP.Model.VMCM vm) { ViewBag.savedata = vm.savedata ?? ""; ModelState.Clear(); vm.ComGroups = Dao.Get("mm.comcode.glist", new System.Collections.Hashtable() { { "rno", "cgroup" },{ "cgroups", "'ccdiff','cc1','cc2','cc3','cc4','cc5'" } }); vm.ComCode = new ComCode(); return View(vm); } public ActionResult cts(VMCM vm) { vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster", 1 }, { "orderby", "a.cname" },{ "cshapes","0,2" } }); vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); var ht = SetHash(vm); ht.Add("cmno", vm.stringval); ht.Add("ccdiff", vm.stringval2); ht.Add("cc1", vm.stringval3); ht.Add("cc2", vm.stringval4); ht.Add("cc3", vm.stringval5); ht.Add("cc4", vm.stringval6); ht.Add("cc5", vm.stringval7); ht.Add("ctname", vm.searchtext); ht.Add("isuse", vm.stringval8); vm.CTs = Dao.Get("cm.cts", ht); vm.addstringval = "x"; if (vm.CTs.Count() > 0) { vm.addstringval = string.Join(",", Dao.Get("cm.ct.check", string.Join(",", vm.CTs.Select(s => s.ctno))).Select(s => s.ctno)); if (string.IsNullOrEmpty(vm.addstringval)) { vm.addstringval = "x"; } else { vm.addstringval = "," + vm.addstringval +","; } } vm.pagetotalcount = GetCount(vm.CTs.FirstOrDefault()); ViewBag.Front = GetConfig("fronturl"); return View(vm); } public ActionResult ctr(VMCM vm) { ModelState.Clear(); vm.CT = new Model.CT() { ismenu = 1, isuse=1 ,ctype=3}; vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster", 1 }, { "orderby", "a.cname" }, { "cshapes","0,2" } }); vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); vm.FileList = new List() { }; vm.CTPs = new List() { }; vm.CTPs.Add(new CTPage() { }); vm.Datas = new List() { }; if (vm.intval > 0) { vm.CT = Dao.Get("cm.cts", new System.Collections.Hashtable() { { "ctno", vm.intval } }).First(); vm.CTPs = Dao.Get("cm.ctps", new System.Collections.Hashtable() { { "ctno", vm.CT.ctno } }); if (vm.CTPs.Count() < 1) { vm.CTPs.Add(new CTPage() { }); } String fgnos = vm.CT.fgno != null ? vm.CT.fgno.Value.ToString() : ""; fgnos += vm.CT.fgnotf != null ? (fgnos == "" ? vm.CT.fgnotf.Value.ToString() : ("," + vm.CT.fgnotf.Value.ToString())) : ""; fgnos += vm.CT.fgnothumb != null ? (fgnos == "" ? vm.CT.fgnothumb.Value.ToString() : ("," + vm.CT.fgnothumb.Value.ToString())) : ""; if (fgnos != "") { vm.FileList = GetFiles(fgnos); } if (vm.CT.ctno > 0 && vm.CT.ctype < 2) { //콘텐츠 목록 불러오기 var di = new System.IO.DirectoryInfo(Server.MapPath(vm.Files + "/Contents/" + vm.CT.ccode + "/")); GetDirectory(vm.Datas, di, 0, 0); System.IO.Directory.GetDirectories(Server.MapPath(vm.Files + "/Contents/" + vm.CT.ccode + "/")); } } ViewBag.Front = GetConfig("fronturl"); return View(vm); } private void GetDirectory(IList d, System.IO.DirectoryInfo di, int idx, int p) { foreach(var f in di.GetDirectories()) { d.Add(new Data() { intval = idx, intval2 = 0, strval = f.Name, intval3 = (d.Where(w => w.intval == idx).Count() == 0 ? 0 : d.Where(w=>w.intval == idx).Max(m=>m.intval3)) + 1, intval4 = p }); GetDirectory(d, f, idx + 1, d.Where(w => w.intval == idx).Max(m => m.intval3)); } foreach(var f in di.GetFiles()) { d.Add(new Data() { intval = idx, intval2 = 1, strval = f.Name, intval3 = (d.Where(w => w.intval == idx).Count() == 0 ? 0 : d.Where(w => w.intval == idx).Max(m => m.intval3)) + 1, intval4 = p }); } } public ActionResult qs(VMCM vm) { vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster", 1 }, { "orderby", "a.cname" } }); var ht = SetHash(vm); vm.searchtype = vm.searchtype ?? "qtextstring"; ht.Add("cmno", vm.stringval); ht.Add("ccdiff", vm.stringval2); ht.Add("cc1", vm.stringval3); ht.Add("cc2", vm.stringval4); ht.Add("cc3", vm.stringval5); ht.Add("cc4", vm.stringval6); ht.Add("cc5", vm.stringval7); ht.Add("isuse", vm.stringval8); ht.Add(vm.searchtype, vm.searchtext); ht.Add("orderby", "a.udt desc"); vm.Qs = Dao.Get("cm.questions", ht); vm.pagetotalcount = GetCount(vm.Qs.FirstOrDefault()); return View(vm); } public ActionResult qr(VMCM vm) { ModelState.Clear(); vm.Question = new Model.Question() { atype = 0, isuse = 1 }; vm.Question.QIs = new List() { }; vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster", 1 }, { "orderby", "a.cname" } }); vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); vm.FileList = new List() { }; if (vm.intval > 0) { vm.intval3 = base.ExamQuestionCount(vm.intval); vm.Question = Dao.Get("cm.questions", new System.Collections.Hashtable() { { "qno", vm.intval } }).First(); vm.Question.QIs = Dao.Get("cm.questionitems", new System.Collections.Hashtable() { { "qno", vm.Question.qno }, { "isdel", 0 } }); var fgnos = string.Join(",", vm.Question.QIs.Where(w=>w.fgno != null).Select(s => s.fgno)); if (!string.IsNullOrEmpty(fgnos)) { vm.FileList = GetFiles(fgnos); } } ViewBag.Front = GetConfig("fronturl"); return View(vm); } public ActionResult qp(VMCM vm) { vm.ComCodes = GetComCodes("ccdiff,cc1,cc2,cc3,cc4,cc5"); vm.CMs = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "ismaster", 1 }, { "orderby", "a.cname" } }); vm.ComGroups = Dao.Get("sys.comcode.glist", new System.Collections.Hashtable() { { "orderby", "cgroupname" } }); var ht = new System.Collections.Hashtable(); if (IsPost()) { ht.Add("cmno", vm.stringval); ht.Add("qdiff", vm.stringval2); ht.Add("cc1", vm.stringval3); ht.Add("cc2", vm.stringval4); ht.Add("cc3", vm.stringval5); ht.Add("cc4", vm.stringval6); ht.Add("cc5", vm.stringval7); ht.Add("isuse", 1); if ("RSC".Equals(vm.stringval13)) { ht.Add("atypes", "0,2"); } if (!string.IsNullOrEmpty(vm.stringval8)) { ht.Add("qcount", GetInt(vm.stringval8)); } if (!string.IsNullOrEmpty(vm.stringval9)) { ht.Add("ecount", GetInt(vm.stringval9)); } if (!string.IsNullOrEmpty(vm.stringval10)) { ht.Add("rrate", GetInt(vm.stringval10)); } vm.Qs = Dao.Get("cm.questions2", ht); } vm.Qs = vm.Qs ?? new List(); return View(vm); } public ActionResult rs(VMCM vm) { var ht = SetHash(vm); ht.Add("rstype", vm.stringval); ht.Add("rscname", vm.stringval2); ht.Add("orderby", "a.udt desc"); vm.RSCs = Dao.Get("cm.rscs", ht); vm.pagetotalcount = GetCount(vm.RSCs.FirstOrDefault()); return View(vm); } public ActionResult rr(VMCM vm) { ModelState.Clear(); vm.RSC = new RSC() { rstype = -1, isuse = 1 }; vm.RSCQs = new List() { }; vm.examsavable = ""; if (vm.intval > 0) { vm.RSC = Dao.Get("cm.rscs", new System.Collections.Hashtable() { { "rscno", vm.intval } }).First(); vm.RSCQs = Dao.Get("cm.rscqs", vm.RSC.rscno); vm.examsavable = base.RSCSaveValid(vm.RSC.rscno); } return View("rr", vm); } public ActionResult pcs(VMCM vm) { vm.CMs = InitM(); if (!IsPost() && string.IsNullOrEmpty(vm.stringval)) { vm.stringval = DateTime.Now.Year.ToString(); } vm.Terms = Dao.Get("cm.terms", new System.Collections.Hashtable() { }); var ht = SetHash(vm); ht.Add("tyear", vm.stringval); ht.Add("tseq", vm.stringval2); ht.Add("cname", vm.stringval3); ht.Add("ismaster", 2); vm.CMs = Dao.Get("cm.cms", ht); if (vm.CMs.Count() > 0) { //수강신청 수 카운팅 vm.CMs2 = Dao.Get("cm.pcms", new System.Collections.Hashtable() { { "pcnos", string.Join(",", vm.CMs.Select(s => s.cmno)) } }); } vm.pagetotalcount = GetCount(vm.CMs.FirstOrDefault()); return View(vm); } public ActionResult pcr(VMCM vm) { vm.CM = new CM() { ismaster = 2, tyear = DateTime.Now.Year }; vm.Terms = Dao.Get("cm.terms", new System.Collections.Hashtable() { }); if (vm.intval > 0) { vm.CM = Dao.Get("cm.cms", new System.Collections.Hashtable() { { "cmno", vm.intval } }).First(); vm.CMs = Dao.Get("cm.pcms", new System.Collections.Hashtable() { { "pcno", vm.CM.pcno } }); vm.CGs = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "includepcgno", vm.CM.pcgno }, { "includecgno", vm.CM.cgno } }); } else { vm.CMs = new List() { }; vm.CGs = Dao.Get("cm.cgs", new System.Collections.Hashtable() { { "istop", 1 }, { "isdel", 0 }, { "isuse", 1 } }); } return View(vm); } } }