YNICTE/FO/Controllers/CDMSController.cs

131 lines
5.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NP.Model;
using NP.Base;
namespace NP.FO.Controllers
{
public class CDMSController : FOOpenBaseController
{
public ActionResult PlayTaste(VMCRoom vm)
{
vm.pseq = 1;
vm.istaste = 1;
vm.status = 1;
if (vm.cmino < 1 && vm.ctno < 1)
{
vm.status = 0;
}
else if (vm.cmino > 0)
{
vm.CMInning = Dao.Get<CMInning>("cm.cminnings", new System.Collections.Hashtable() { { "cmino", vm.cmino } }).FirstOrDefault();
if (vm.CMInning == null || vm.CMInning.istaste != 1)
{
vm.status = 0;
}
else
{
vm.Pages = Dao.Get<CTPage>("cm.ctps", new System.Collections.Hashtable() { { "ctno", vm.CMInning.ctno } }).Where(w => w.pseq == 1).ToList();
if (Request.IsLocal)
{
foreach(var d in vm.Pages)
{
d.srcp = "/Files/test.mp4";
}
}
vm.Page = vm.Pages.Where(w => w.pseq == 1).First();
vm.lip = new LectInningPage() { };
}
}
else if (vm.ctno > 0)
{
//관리자에서 보려는 인증키확인
var ct = Dao.Get<Data>("common.authkey.check"+ vm.authtype, new System.Collections.Hashtable() { { "authkey", vm.authkey }, { "ctno", vm.ctno } }).FirstOrDefault();
if (ct != null)
{
vm.CMInning = new CMInning() { iseq = 1, ititle="미리보기", ismenu = ct.intval2, ctype = ct.intval3, ccode=ct.strval };
vm.Pages = Dao.Get<CTPage>("cm.ctps", new System.Collections.Hashtable() { { "ctno", vm.ctno } });
if (vm.cpno > 0)
{
vm.Page = vm.Pages.Where(w => w.cpno == vm.cpno).First();
vm.pseq = vm.Page.pseq;
}
else
{
vm.Page = vm.Pages.Where(w => w.pseq == 1).First();
}
vm.lip = new LectInningPage() { };
}
else
{
vm.status = 0;
}
}
return View("ViewTaste",vm);
}
public ActionResult Play(VMCRoom vm)
{
var sd = Request.Url.Host.Split('.')[0];
if (GetConfig("isdevtest") != "1" && Request.Url.Host != "222.122.63.91" && Request.Url.Host != "ynicte.nptc.kr" && Request.Url.Host != "phd.nptc.kr" && MainSubDomain.ToUpper() != sd.ToUpper())
{
ViewBag.SiteTitle = Dao.Get<Assign>("users.assignsite", new System.Collections.Hashtable() { { "subdomain", sd } }).First().asname;
}
vm.istaste = 0;
vm = vm ?? new VMCRoom() { };
if (SUserInfo.UserNo > 0 && vm.cmino > 0 && vm.lectno > 0)
{
//이어보기를 위해 페이지관리
//vm.pseq = vm.pseq < 1 ? 1 : vm.pseq;
vm.pseq = 0;
//학습로그생성
String ua = "";
try
{
ua = (Request.UserAgent ?? "").ToLower();
}
catch (Exception ex)
{
Logger.Error("ExamStart Get UserAgent Info Error" + ex.StackTrace);
}
vm.lip = new LectInningPage() { lectno = vm.lectno, cmino = vm.cmino, pseq = vm.pseq, userno = SUserInfo.UserNo,
isrelay = 1,
uno = SUserInfo.UserNo, uip = GetUserIP(), ispc = vm.ismobile==1?0:1, webkitinfo = ua.Length > 500 ? ua.Substring(0, 500) : ua };
Dao.Insert("cr.lectinningpage.in", vm.lip);
if (vm.lip.logno > 0)
{
vm.status = 1;
vm.Pages = Dao.Get<LectInningPage, CTPage>("cr.ctps", vm.lip);
vm.pseq = vm.Pages.First().lastpseq;
vm.Page = vm.Pages.Where(w => w.pseq == vm.pseq).First();
vm.CMInning = new CMInning() { isokmid = vm.Page.isokmid, ismenu = vm.Page.ismenu, iseq = vm.Page.iseq, ititle = vm.Page.ititle, ctype = vm.Page.ctype, ccode = vm.Page.ccode, isoversize = vm.Page.isoversize, mstime = vm.Page.mstime, metime = vm.Page.metime };
if (vm.CMInning.isokmid == 0 && vm.CMInning.metime > 0)
{
//if (Request.IsLocal || GetConfig("isdevtest")=="1")
//{
// vm.CMInning.mtime = 10;
//}
//else
//{
Random r = new Random();
vm.CMInning.mtime = r.Next(vm.CMInning.mstime * 60, vm.CMInning.metime * 60);
vm.CMInning.mtime = vm.CMInning.mtime < 10 ? 15 : vm.CMInning.mtime;
//}
}
}
}
//Response.AddHeader("X-Frame-Options", "ALLOW-FROM http://www.kocw.net");
//Response.Headers.Remove("X-Frame-Options");
//Response.AddHeader("X-Frame-Options", "AllowAll");
return View("ViewTaste", vm);
}
public ActionResult HTTPS(String url)
{
ViewBag.https = url;
return View();
}
}
}