250 lines
12 KiB
C#
250 lines
12 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;
|
|
using QRCoder;
|
|
namespace NP.Base.Controllers
|
|
{
|
|
public partial class FCommonController : NP.Base.BaseController
|
|
{
|
|
|
|
|
|
|
|
[HttpPost]
|
|
public JsonResult GetAttend(Int64 lectno)
|
|
{
|
|
var rtn = new Hashtable() { };
|
|
var d = Dao.Get<LectInningPage>("lect.lectinningpages", new System.Collections.Hashtable() { { "lectno", lectno }, { "userno", SUserInfo.UserNo } });
|
|
rtn.Add("d", d);
|
|
var ds = new List<LectInningPage>() { };
|
|
foreach(var iseq in d.Select(s => s.iseq).Distinct())
|
|
{
|
|
ds.Add(d.Where(w => w.iseq == iseq).First());
|
|
ds.Last().ccount = d.Where(w => w.iseq == iseq).Count();
|
|
}
|
|
rtn.Add("h", ds);
|
|
return JsonBack(rtn);
|
|
}
|
|
[HttpPost]
|
|
public JsonResult PageLogs(String d1, String d2)
|
|
{
|
|
return JsonBack(Dao.Get<PageLog>("lect.pagelogs", new System.Collections.Hashtable() { { "from"+(string.IsNullOrEmpty(d1)?"x":""), d1 }, { "to" + (string.IsNullOrEmpty(d2) ? "x" : ""), d2 + " 23:59:59" }, { "userno", SUserInfo.UserNo }, { "logsite", 1 } }));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult CMRSGo(Int64 lectno, int rsno)
|
|
{
|
|
var rtn = new Hashtable() { };
|
|
rtn.Add("q", Dao.Get<RSCQ>("cr.mycmrsq", new System.Collections.Hashtable() { { "lectno", lectno }, { "userno", SUserInfo.UserNo }, { "rsno", rsno } }));
|
|
rtn.Add("qi", Dao.Get<RSCQ>("cr.mycmrsqi", new System.Collections.Hashtable() { { "lectno", lectno }, { "userno", SUserInfo.UserNo }, { "rsno", rsno } }));
|
|
return JsonBack(rtn);
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectRSSave(Int64 lectno, int rsno, String sd)
|
|
{
|
|
var d = new LectRS() { lectno = lectno, userno = SUserInfo.UserNo, rsno = rsno, uno = SUserInfo.UserNo, uip = GetUserIP(), Ds = new List<LectRS>() { } };
|
|
foreach(var s in sd.Split(';'))
|
|
{
|
|
d.Ds.Add(new LectRS() { rscqno = GetInt(s.Split(':')[0]), atext = s.Split(':')[1] == "0" ? s.Split(':')[2] : s.Split(':')[2].Replace("▤", ";").Replace("▥", ":") });
|
|
}
|
|
return JsonOK(Dao.Save("cr.lectrs.in", d));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult SaveExam(Int64 lectno, int estno, String savedata, int issubmit, String qnos, bool isbackup = false, int cblock = 0)
|
|
{
|
|
var Exam = Dao.Get<CMEX>("cr.userexam.detailforexamforsubmit", new System.Collections.Hashtable() { {"lectno",lectno }, { "exno", estno}, { "userno", SUserInfo.UserNo } }).FirstOrDefault();
|
|
String OverTime = null;
|
|
if (Exam == null)
|
|
{
|
|
issubmit = 0;
|
|
OverTime = "1";
|
|
}
|
|
if(Exam.estart == null)
|
|
{
|
|
return JsonOK(-44,true);
|
|
}
|
|
var qis = Dao.Get<QuestionItem>("cr.questionitem.listforcheck", qnos);
|
|
var ue = new LectEX() {lectno=lectno, userno = SUserInfo.UserNo, uno = SUserInfo.UserNo, uip = GetUserIP(), exno = Exam.exno, cblock = cblock };
|
|
ue.extype = Exam.extype;
|
|
//ue.sip = SIP;
|
|
ue.UED = new List<LectEXQ>() { };
|
|
foreach (String sss in savedata.Split(';'))
|
|
{
|
|
String[] ss = sss.Split(':');
|
|
if (ss[4] == "0")
|
|
{
|
|
ue.UED.Add(new LectEXQ()
|
|
{
|
|
eqno = GetInt(ss[1]),
|
|
atext = ss[2].Replace("|||PHDPHD|||", ";").Replace("|||PHD|||", ":"),
|
|
qinos = ss[3],
|
|
iscorrect = string.Join(",", qis.Where(w => w.qno == GetInt64(ss[0])).ToList().Select(s => s.qino)) == ss[2] ? 1 : 0
|
|
});
|
|
}
|
|
else if (ss[6] == "0")
|
|
{
|
|
ue.UED.Add(new LectEXQ()
|
|
{
|
|
eqno = GetInt(ss[1]),
|
|
atext = ss[2].Replace("|||PHDPHD|||", ";").Replace("|||PHD|||", ":"),
|
|
qinos = ss[3],
|
|
iscorrect = qis.Where(w => w.qno == GetInt64(ss[0])).Where(w => (w.qitext ?? "").Replace(ss[5] == "1" ? " " : "박건박건박효동", "") == (ss[2].Replace("$$$PHDPHD$$$", ";").Replace("$$$PHD$$$", ":") ?? "").Replace(ss[5] == "1" ? " " : "박건박건박효동", "")).Count() > 0 ? 1 : 0
|
|
});
|
|
}
|
|
else
|
|
{
|
|
ue.UED.Add(new LectEXQ()
|
|
{
|
|
eqno = GetInt(ss[1]),
|
|
atext = ss[2].Replace("|||PHDPHD|||", ";").Replace("|||PHD|||", ":"),
|
|
qinos = ss[3],
|
|
iscorrect = qis.Where(w => w.qno == GetInt64(ss[0])).Where(w => (w.qitext ?? "").Replace(ss[5] == "1" ? " " : "박건박건박효동", "").ToLower() == (ss[2].Replace("$$$PHDPHD$$$", ";").Replace("$$$PHD$$$", ":") ?? "").Replace(ss[5] == "1" ? " " : "박건박건박효동", "").ToLower()).Count() > 0 ? 1 : 0
|
|
});
|
|
}
|
|
}
|
|
ue.issubmit = issubmit;
|
|
ue.zstring20 = OverTime;
|
|
var rtn = Dao.Save("cr.examsubmit" + (isbackup ? "backup" : ""), ue);
|
|
return JsonOK("1".Equals(OverTime) ? 0 : rtn, true);
|
|
}
|
|
[ValidateInput(false)]
|
|
[HttpPost]
|
|
public JsonResult SubjectSave(LectSD d)
|
|
{
|
|
d.uno = SUserInfo.UserNo; d.uip = GetUserIP();
|
|
d.userno = SUserInfo.UserNo;
|
|
if (Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).Count() > 0)
|
|
{
|
|
d.fgno = SetFile(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), d.fgno ?? 0, "lectsd", "fgno", 1, "XX", false, true, d.cmno);
|
|
d.fgno = d.fgno == 0 ? (Int64?)null : d.fgno;
|
|
}
|
|
return JsonOK(Dao.Save("cr.lectsd.save", d));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectSDBoardSave(LectSDBoard d)
|
|
{
|
|
d.uno = SUserInfo.UserNo; d.uip = GetUserIP();
|
|
d.userno = SUserInfo.UserNo;
|
|
if (Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).Count() > 0)
|
|
{
|
|
d.fgno = SetFile(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), d.fgno ?? 0, "lectsdboard", "fgno");
|
|
d.fgno = d.fgno == 0 ? (Int64?)null : d.fgno;
|
|
}
|
|
if (d.bno > 0)
|
|
{
|
|
return JsonOK(Dao.Save("cr.lectsdboard.save", d));
|
|
}
|
|
Dao.Insert("cr.lectsdboard.in", d);
|
|
return JsonOK(d.bno);
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectSDBoardDel(Int64 bno)
|
|
{
|
|
return JsonOK(Dao.Save("cr.lectsdboard.del", new Hashtable() { {"userno", SUserInfo.UserNo },{"bno", bno },{"uno", SUserInfo.UserNo },{ "uip", GetUserIP()} }));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectSDBoardCMTSave(BoardCMT c)
|
|
{
|
|
c.uno = SUserInfo.UserNo; c.uip = GetUserIP();
|
|
if (c.bcno < 1)
|
|
{
|
|
Dao.Insert("cr.lectsdboardcmt.in", c);
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = c.bcno, msg = DateTime.Now.ToString("yyyy.MM.dd HH:mm") });
|
|
}
|
|
return JsonOK(Dao.Save("cr.lectsdboardcmt.up", c));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectSDBoardCMTDel(Int64 bcno)
|
|
{
|
|
return JsonOK(Dao.Save("cr.lectsdboardcmt.del", new Hashtable() { { "bcno", bcno }, { "cno", SUserInfo.UserNo }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult AttCertCheck(long lectno)
|
|
{
|
|
var data = Dao.Get<Data>("lect.attcert.check", new Hashtable() { { "lectno", lectno } }).FirstOrDefault();
|
|
if (data.intval2 == 1 || data.intval3 == 1)
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 1 });
|
|
}
|
|
else
|
|
{
|
|
if (data.intval == 1)
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 2 });
|
|
}
|
|
if (!string.IsNullOrEmpty(data.strval))
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 3, msg = data.strval });
|
|
}
|
|
else
|
|
{
|
|
return JsonBack(new JsonRtn() { code = -1 });
|
|
}
|
|
}
|
|
}
|
|
[HttpPost]
|
|
public JsonResult AttCertCheckForLectinning(long lectno, long cmino)
|
|
{
|
|
var data = Dao.Get<Data>("lect.lectinning.attcert.check", new Hashtable() { { "lectno", lectno }, { "cmino", cmino }, {"userno", SUserInfo.UserNo } }).FirstOrDefault();
|
|
if (data.intval2 == 1 || data.intval3 == 1)
|
|
{
|
|
//intval2 출석인증제외 회원, intval3 출석인증제외 강좌
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 1 });
|
|
}
|
|
else
|
|
{
|
|
//출석인증
|
|
if (data.intval == 1)
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 2 });
|
|
}
|
|
//핸드폰인증인데 핸드폰번호가 없는경우(에러)
|
|
if ( string.IsNullOrEmpty(data.strval) && data.strval2 == "2")
|
|
{
|
|
return JsonBack(new JsonRtn() { code = -1 });
|
|
}
|
|
else
|
|
{
|
|
//data.strval2 <- authplatform 1:IPIN, 2:Mobile
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = 3, msg = data.strval2 });
|
|
}
|
|
}
|
|
}
|
|
[HttpPost]
|
|
public JsonResult LectComplete(Int64 lectno)
|
|
{
|
|
var ispass = Dao.Get<Lect>("grade.ispass", new Hashtable() { { "lectno", lectno } } ).FirstOrDefault().ispass;
|
|
if (ispass == 1)
|
|
{
|
|
return JsonOK(Dao.Save("grade.lectcomplete2", new Hashtable() { { "lectno", lectno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }));
|
|
}
|
|
else
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1, msg = "수료조건이 충족되지 않았습니다. 수료조건을 충족한 이후 요청해주세요" });
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult ReExamForUser(int exno, Int64 lectno, int extype)
|
|
{
|
|
// #xodus extype 추가
|
|
//재응시로그추가로인해 업데이트건 3개일때부터 정상처리
|
|
return JsonOK(Dao.Save("lect.reexam", new System.Collections.Hashtable() { { "exno", exno }, { "lectno", lectno }, { "extype", extype }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } }) > 2 ? 1 : 0);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public JsonResult delfileOk(int sdno, Int64 lectno)
|
|
{
|
|
//재응시로그추가로인해 업데이트건 3개일때부터 정상처리
|
|
int result = Dao.Save("lect.lectsd.del", new System.Collections.Hashtable() { { "sdno", sdno }, { "lectno", lectno }, { "uno", SUserInfo.UserNo }, { "uip", GetUserIP() } });
|
|
return JsonOK(result);
|
|
}
|
|
}
|
|
|
|
} |