選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

HomeController.cs 39 KiB

4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Net.Http;
  5. using Learun.Application.Base.SystemModule;
  6. using Learun.Cache.Base;
  7. using Learun.Cache.Factory;
  8. using Learun.Util;
  9. using Learun.Util.Operat;
  10. using System.Web.Mvc;
  11. using Learun.Application.Organization;
  12. using Learun.Application.TwoDevelopment.EducationalAdministration;
  13. using Quanjiang.DigitalScholl.WebLicense;
  14. using Learun.Application.TwoDevelopment.LogisticsManagement;
  15. using System.Linq;
  16. using Learun.Application.OA;
  17. using Learun.Application.TwoDevelopment.LR_Desktop;
  18. using Learun.Application.TwoDevelopment.Permission;
  19. using Learun.Application.WorkFlow;
  20. using Learun.Application.OA.Email.EmailSend;
  21. namespace Learun.Application.Web.Controllers
  22. {
  23. /// <summary>
  24. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  25. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  26. /// 创建人:陈彬彬
  27. /// 日 期:2017.03.09
  28. /// 描 述:主页控制器
  29. /// </summary>
  30. public class HomeController : MvcControllerBase
  31. {
  32. private EmpInfoIBLL empInfoIbll = new EmpInfoBLL();
  33. private CompanyIBLL companyIbll = new CompanyBLL();
  34. private QingJu_UserAccountIBLL qjAccountIbll = new QingJu_UserAccountBLL();
  35. private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL();
  36. private DatabaseInitIBLL databaseInitIBLL = new DatabaseInitBLL();
  37. private DepartmentIBLL departmentIBLL = new DepartmentBLL();
  38. private DgreeIBLL dgreeIBLL = new DgreeBLL();
  39. private PostIBLL postIBLL = new PostBLL();
  40. private UserIBLL userIBLL = new UserBLL();
  41. private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
  42. private CdMajorIBLL majorIBLL = new CdMajorBLL();
  43. private LessonInfoIBLL infoIBLL = new LessonInfoBLL();
  44. private ClassroomBuildingIBLL classroomBuildingIBLL = new ClassroomBuildingBLL();
  45. private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
  46. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  47. private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
  48. private ArrangeExamTermIBLL arrangeExamTermIBLL = new ArrangeExamTermBLL();
  49. private StuScoreIBLL stuScoreIBLL = new StuScoreBLL();
  50. private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL();
  51. private AccommodationIBLL accdormitoryIBLL = new AccommodationBLL();
  52. private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
  53. private NoticeIBLL newsIBLL = new NoticeBLL();
  54. private SYS_ReceiveMessageIBLL sYS_ReceiveMessageIBLL = new SYS_ReceiveMessageBLL();
  55. private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();
  56. private Sys_UpdateRecordIBLL sys_UpdateRecordIBLL = new Sys_UpdateRecordBLL();
  57. private Perm_FunctionIBLL perm_FunctionIBLL = new Perm_FunctionBLL();
  58. private ICache redisCache = CacheFactory.CaChe();
  59. private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL();
  60. private EmailSendIBLL emailSendIBLL = new EmailSendBLL();
  61. #region 视图功能
  62. public ActionResult FirstChangePwd()
  63. {
  64. return View();
  65. }
  66. public ActionResult ChangePwd()
  67. {
  68. return View();
  69. }
  70. #region 统一身份认证2.0
  71. public ActionResult SSOApplication()
  72. {
  73. var userinfo = LoginUserInfo.Get();
  74. ViewBag.FunctionList = perm_FunctionIBLL.GetListByUserId(userinfo.userId);
  75. return View();
  76. }
  77. /// <summary>
  78. /// 跳转网站
  79. /// </summary>
  80. /// <returns></returns>
  81. public ActionResult GoToApplication()
  82. {
  83. string redi = Request.QueryString["redi"];
  84. if (!string.IsNullOrEmpty(redi))
  85. {
  86. var userinfo = LoginUserInfo.Get();
  87. if (userinfo != null)
  88. {
  89. var perm_application = perm_FunctionIBLL.GetPerm_FunctionEntity(Request.QueryString["appid"]);
  90. if (perm_application != null)
  91. {
  92. //写入当前请求所登录的用户
  93. var code = Util.CommonHelper.RndNum(9);
  94. redisCache.Write(code, userinfo.account, TimeSpan.FromMinutes(10));
  95. var url = perm_application.FInterfaceUrl;
  96. if (url.Contains("?"))
  97. {
  98. url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
  99. }
  100. else
  101. {
  102. url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
  103. }
  104. return Redirect(url);
  105. }
  106. else
  107. return RedirectToAction("Index");
  108. }
  109. else
  110. {
  111. return RedirectToAction("Index");
  112. }
  113. }
  114. return View();
  115. }
  116. #endregion
  117. public ActionResult NeedToDoForm()
  118. {
  119. var userinfo = LoginUserInfo.Get();
  120. Pagination paginationobj = new Pagination() { rows = 5, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
  121. //未读邮件
  122. ViewBag.UnreadMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}").Count(m => m.READFLAG == 0);
  123. //办公事项
  124. paginationobj.sidx = "F_CreateDate";
  125. ViewBag.UnreadTask = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}").Count();
  126. //公告
  127. List<NewsEntity> outnewslist = new List<NewsEntity>();
  128. var newsList = newsIBLL.GetPageList(paginationobj, "");
  129. foreach (var newsitemEntity in newsList)
  130. {
  131. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  132. {
  133. if (!string.IsNullOrEmpty(userinfo.postIds))
  134. {
  135. if (userinfo.postIds.Contains(","))
  136. {
  137. foreach (var postid in userinfo.postIds.Split(','))
  138. {
  139. if (newsitemEntity.F_SendPostId.Contains(postid))
  140. {
  141. outnewslist.Add(newsitemEntity);
  142. break;
  143. }
  144. }
  145. }
  146. else
  147. {
  148. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  149. {
  150. outnewslist.Add(newsitemEntity);
  151. }
  152. }
  153. }
  154. }
  155. else
  156. {
  157. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  158. {
  159. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  160. {
  161. outnewslist.Add(newsitemEntity);
  162. }
  163. }
  164. else
  165. {
  166. outnewslist.Add(newsitemEntity);
  167. }
  168. }
  169. }
  170. var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId);
  171. ViewBag.UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId));
  172. paginationobj.sidx = "SendTime";
  173. //ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListByUserId(paginationobj, "{}", userinfo.userId).Where(a => a.STypeId == 1).Count();
  174. ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId);
  175. return View();
  176. }
  177. public ActionResult GoTo()
  178. {
  179. var loginUserInfo = LoginUserInfo.Get();
  180. string redi = Request.QueryString["redi"];
  181. if (!string.IsNullOrEmpty(redi))
  182. {
  183. string sysid = Request.QueryString["sysid"];
  184. if (!string.IsNullOrEmpty(sysid))
  185. {
  186. if (sysid == "kaoshi")
  187. {
  188. if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["kaoshisystemurl"]))
  189. {
  190. return Redirect(ConfigurationManager.AppSettings["kaoshisystemurl"] + "?u=" + DESEncrypt.Encrypt(loginUserInfo.account, ConfigurationManager.AppSettings["SSOPublicSecret"]));
  191. }
  192. else
  193. {
  194. return Fail("系统地址未配置");
  195. }
  196. }
  197. if (sysid == "paike")
  198. {
  199. if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["kaoshisystemurl"]))
  200. {
  201. return Redirect(ConfigurationManager.AppSettings["kaoshisystemurl"] + "?u=" + DESEncrypt.Encrypt(loginUserInfo.account, ConfigurationManager.AppSettings["SSOPublicSecret"]));
  202. }
  203. else
  204. {
  205. return Fail("系统地址未配置");
  206. }
  207. }
  208. return Fail("系统id未找到");
  209. }
  210. else
  211. {
  212. return Fail("系统id未设置");
  213. }
  214. }
  215. else
  216. {
  217. return View();
  218. }
  219. }
  220. public ActionResult GoQingJu()
  221. {
  222. string redi = Request.QueryString["redi"];
  223. if (!string.IsNullOrEmpty(redi))
  224. {
  225. HttpClient client = new HttpClient();
  226. try
  227. {
  228. var userinfo = LoginUserInfo.Get();
  229. string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  230. string qingJuurl = ConfigurationManager.AppSettings["QingJuurl"];
  231. string qingjuregisterurl = ConfigurationManager.AppSettings["QingJuRegisterurl"];
  232. string defpwd = ConfigurationManager.AppSettings["defaultpwd"];
  233. //读取默认密码配置中已启用的密码
  234. if (sys_DefaultPwdConfigIBLL.GetEnabledEntity() != null)
  235. {
  236. defpwd = sys_DefaultPwdConfigIBLL.GetEnabledEntity().Pwd;
  237. }
  238. var qjinfo = qjAccountIbll.GetQingJu_UserAccountEntityByAccount(userinfo.account);
  239. if (qjinfo == null || string.IsNullOrEmpty(qjinfo.UserAccount))
  240. {
  241. if (userinfo.Description == "教师")
  242. {
  243. var empinfo = empInfoIbll.GetEmpInfoEntityByEmpNo(userinfo.account);
  244. string jsoncontent = "{\"account\":\"" + userinfo.account + "\"," +
  245. "\"realname\":\"" + empinfo.EmpName + "\"," +
  246. "\"mobile\":\"" + empinfo.mobile + "\"," +
  247. "\"idcardno\":\"" + empinfo.IdentityCardNo + "\"," +
  248. "\"genderno\":\"" + (empinfo.GenderNo != null ? empinfo.GenderNo.Value.ToString() : "true") + "\"," +
  249. "\"school\":\"" + (companyIbll.GetEntity(empinfo.F_CompanyId) != null ? companyIbll.GetEntity(empinfo.F_CompanyId).F_FullName : "") + "\"," +
  250. "\"isteacher\":\"true\"" +
  251. "}";
  252. HttpContent httpContent = new StringContent(jsoncontent);
  253. httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
  254. string clientData = client.PostAsync(qingjuregisterurl, httpContent).Result.Content.ReadAsStringAsync().Result;
  255. var result = Convert.ToBoolean(clientData);
  256. if (result)
  257. {
  258. QingJu_UserAccountEntity qjentity = new QingJu_UserAccountEntity();
  259. qjentity.Create();
  260. qjentity.UserAccount = userinfo.account;
  261. qjentity.QUserName = userinfo.account;
  262. qjentity.QPass = DESEncrypt.Encrypt(defpwd, publickey);
  263. qjAccountIbll.SaveEntity(null, qjentity);
  264. return Redirect(qingJuurl + "?u=" + DESEncrypt.Encrypt(userinfo.account, publickey) + "&p=" + DESEncrypt.Encrypt(defpwd, publickey) + "&t=" + DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), publickey));
  265. }
  266. else
  267. {
  268. //注册失败
  269. return Redirect("/Home/QingJuRegister?e=1");
  270. }
  271. }
  272. else
  273. {
  274. var empinfo = stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userinfo.account);
  275. string jsoncontent = "{\"account\":\"" + userinfo.account + "\"," +
  276. "\"realname\":\"" + empinfo.StuName + "\"," +
  277. "\"mobile\":\"" + empinfo.mobile + "\"," +
  278. "\"idcardno\":\"" + empinfo.IdentityCardNo + "\"," +
  279. "\"genderno\":\"" + (empinfo.GenderNo != null ? empinfo.GenderNo.Value.ToString() : "true") + "\"," +
  280. "\"school\":\"" + (companyIbll.GetEntity(empinfo.F_SchoolId) != null ? companyIbll.GetEntity(empinfo.F_SchoolId).F_FullName : "") + "\"," +
  281. "\"isteacher\":\"false\"" +
  282. "}";
  283. HttpContent httpContent = new StringContent(jsoncontent);
  284. httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
  285. string clientData = client.PostAsync(qingjuregisterurl, httpContent).Result.Content.ReadAsStringAsync().Result;
  286. var result = Convert.ToBoolean(clientData);
  287. if (result)
  288. {
  289. QingJu_UserAccountEntity qjentity = new QingJu_UserAccountEntity();
  290. qjentity.Create();
  291. qjentity.UserAccount = userinfo.account;
  292. qjentity.QUserName = userinfo.account;
  293. qjentity.QPass = DESEncrypt.Encrypt(defpwd, publickey);
  294. qjAccountIbll.SaveEntity(null, qjentity);
  295. return Redirect(qingJuurl + "?u=" + DESEncrypt.Encrypt(userinfo.account, publickey) + "&p=" + DESEncrypt.Encrypt(defpwd, publickey) + "&t=" + DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), publickey));
  296. }
  297. else
  298. {
  299. //注册失败
  300. return Redirect("/Home/QingJuRegister");
  301. }
  302. }
  303. }
  304. else
  305. {
  306. qjinfo.QPass = DESEncrypt.Decrypt(qjinfo.QPass, publickey);
  307. return Redirect(qingJuurl + "?u=" + DESEncrypt.Encrypt(qjinfo.QUserName, publickey) + "&p=" + DESEncrypt.Encrypt(qjinfo.QPass, publickey) + "&t=" + DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), publickey));
  308. }
  309. }
  310. catch (Exception e)
  311. {
  312. throw ExceptionEx.ThrowBusinessException(e);
  313. }
  314. }
  315. else
  316. {
  317. return View();
  318. }
  319. }
  320. public ActionResult QingJuRegister(QingJu_UserAccountEntity up)
  321. {
  322. string e = Request.QueryString["e"];
  323. if (!string.IsNullOrEmpty(e))
  324. {
  325. if (e == "1")
  326. {
  327. ViewBag.EMessage = "默认帐号自动注册失败,原因:帐号重复,请更换帐号后注册。";
  328. }
  329. if (e == "2")
  330. {
  331. ViewBag.EMessage = "帐号重复,请更换";
  332. }
  333. }
  334. HttpClient client = new HttpClient();
  335. var userinfo = LoginUserInfo.Get();
  336. string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  337. string qingJuurl = ConfigurationManager.AppSettings["QingJuurl"];
  338. string qingjuregisterurl = ConfigurationManager.AppSettings["QingJuRegisterurl"];
  339. string defpwd = ConfigurationManager.AppSettings["defaultpwd"];
  340. //读取默认密码配置中已启用的密码
  341. if (sys_DefaultPwdConfigIBLL.GetEnabledEntity() != null)
  342. {
  343. defpwd = sys_DefaultPwdConfigIBLL.GetEnabledEntity().Pwd;
  344. }
  345. if (up != null && !string.IsNullOrEmpty(up.QUserName))
  346. {
  347. if (userinfo.Description == "教师")
  348. {
  349. var empinfo = empInfoIbll.GetEmpInfoEntityByEmpNo(userinfo.account);
  350. string jsoncontent = "{\"account\":\"" + up.QUserName + "\"," +
  351. "\"realname\":\"" + empinfo.EmpName + "\"," +
  352. "\"mobile\":\"" + empinfo.mobile + "\"," +
  353. "\"idcardno\":\"" + empinfo.IdentityCardNo + "\"," +
  354. "\"genderno\":\"" + (empinfo.GenderNo != null ? empinfo.GenderNo.Value.ToString() : "true") + "\"," +
  355. "\"school\":\"" + (companyIbll.GetEntity(empinfo.F_CompanyId) != null ? companyIbll.GetEntity(empinfo.F_CompanyId).F_FullName : "") + "\"," +
  356. "\"isteacher\":\"true\"" +
  357. "}";
  358. HttpContent httpContent = new StringContent(jsoncontent);
  359. httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
  360. string clientData = client.PostAsync(qingjuregisterurl, httpContent).Result.Content.ReadAsStringAsync().Result;
  361. var result = Convert.ToBoolean(clientData);
  362. if (result)
  363. {
  364. QingJu_UserAccountEntity qjentity = new QingJu_UserAccountEntity();
  365. qjentity.Create();
  366. qjentity.UserAccount = userinfo.account;
  367. qjentity.QUserName = up.QUserName;
  368. qjentity.QPass = DESEncrypt.Encrypt(defpwd, publickey);
  369. qjAccountIbll.SaveEntity(null, qjentity);
  370. return Redirect(qingJuurl + "?u=" + DESEncrypt.Encrypt(up.QUserName, publickey) + "&p=" + DESEncrypt.Encrypt(defpwd, publickey) + "&t=" + DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), publickey));
  371. }
  372. else
  373. {
  374. return Redirect("/Home/QingJuRegister?e=2");
  375. }
  376. }
  377. else
  378. {
  379. var empinfo = stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userinfo.account);
  380. string jsoncontent = "{\"account\":\"" + up.QUserName + "\"," +
  381. "\"realname\":\"" + empinfo.StuName + "\"," +
  382. "\"mobile\":\"" + empinfo.mobile + "\"," +
  383. "\"idcardno\":\"" + empinfo.IdentityCardNo + "\"," +
  384. "\"genderno\":\"" + (empinfo.GenderNo != null ? empinfo.GenderNo.Value.ToString() : "true") + "\"," +
  385. "\"school\":\"" + (companyIbll.GetEntity(empinfo.F_SchoolId) != null ? companyIbll.GetEntity(empinfo.F_SchoolId).F_FullName : "") + "\"," +
  386. "\"isteacher\":\"false\"" +
  387. "}";
  388. HttpContent httpContent = new StringContent(jsoncontent);
  389. httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
  390. string clientData = client.PostAsync(qingjuregisterurl, httpContent).Result.Content.ReadAsStringAsync().Result;
  391. var result = Convert.ToBoolean(clientData);
  392. if (result)
  393. {
  394. QingJu_UserAccountEntity qjentity = new QingJu_UserAccountEntity();
  395. qjentity.Create();
  396. qjentity.UserAccount = userinfo.account;
  397. qjentity.QUserName = up.QUserName;
  398. qjentity.QPass = DESEncrypt.Encrypt(defpwd, publickey);
  399. qjAccountIbll.SaveEntity(null, qjentity);
  400. return Redirect(qingJuurl + "?u=" + DESEncrypt.Encrypt(up.QUserName, publickey) + "&p=" + DESEncrypt.Encrypt(defpwd, publickey) + "&t=" + DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), publickey));
  401. }
  402. else
  403. {
  404. return Redirect("/Home/QingJuRegister?e=2");
  405. }
  406. }
  407. }
  408. else
  409. {
  410. return View();
  411. }
  412. }
  413. /// <summary>
  414. /// 初始化页面
  415. /// </summary>
  416. /// <returns></returns>
  417. [HttpGet]
  418. public ActionResult Index()
  419. {
  420. //判断当前ip是否是123服务器,如果是123服务器,跳过授权验证
  421. if (Net.GetLanIp() != "172.17.3.181")
  422. {
  423. //授权验证
  424. var lc = LicenseChecker.CheckLicense();
  425. if (!lc.Result)
  426. {
  427. return Content("<script>alert('" + lc.Message + "');location.href='/ShowRegister/Index';</script>");
  428. }
  429. }
  430. //return View("AdminTop");
  431. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  432. #region 待办
  433. var userinfo = LoginUserInfo.Get();
  434. Pagination paginationobj = new Pagination() { rows = 100, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
  435. //未读邮件
  436. ViewBag.UnreadMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}").Count(m => m.READFLAG == 0);
  437. //办公事项
  438. paginationobj.sidx = "F_CreateDate";
  439. ViewBag.UnreadTask = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}").Count();
  440. //公告
  441. List<NewsEntity> outnewslist = new List<NewsEntity>();
  442. var newsList = newsIBLL.GetPageList(paginationobj, "");
  443. foreach (var newsitemEntity in newsList)
  444. {
  445. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  446. {
  447. if (!string.IsNullOrEmpty(userinfo.postIds))
  448. {
  449. if (userinfo.postIds.Contains(","))
  450. {
  451. foreach (var postid in userinfo.postIds.Split(','))
  452. {
  453. if (newsitemEntity.F_SendPostId.Contains(postid))
  454. {
  455. outnewslist.Add(newsitemEntity);
  456. break;
  457. }
  458. }
  459. }
  460. else
  461. {
  462. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  463. {
  464. outnewslist.Add(newsitemEntity);
  465. }
  466. }
  467. }
  468. }
  469. else
  470. {
  471. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  472. {
  473. if (userinfo.departmentId != null && newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  474. {
  475. outnewslist.Add(newsitemEntity);
  476. }
  477. }
  478. else
  479. {
  480. outnewslist.Add(newsitemEntity);
  481. }
  482. }
  483. }
  484. var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId);
  485. ViewBag.UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId));
  486. paginationobj.sidx = "SendTime";
  487. ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId).Count();
  488. //普通教师请假-未归档数
  489. ViewBag.UnfileLeave = 0;
  490. //中层领导请假-未归档数
  491. ViewBag.UnfileLeaveZC = 0;
  492. ViewBag.UnreadNum = ViewBag.UnreadFile + ViewBag.UnreadNews + ViewBag.UnreadTask + ViewBag.UnreadMail + ViewBag.UnfileLeave + ViewBag.UnfileLeaveZC;
  493. #endregion
  494. //获取在线用户人数
  495. ViewBag.OnlineUserNum = 0;
  496. var onlineUserResult = sys_UpdateRecordIBLL.GetOnlineUserNum();
  497. if (onlineUserResult != null)
  498. {
  499. ViewBag.OnlineUserNum = onlineUserResult.OnlineUserNum;
  500. }
  501. //获取本机ip
  502. ViewBag.Ip = GetIP();
  503. ViewBag.ACIp = ConfigurationManager.AppSettings["ACIp"] ?? "";
  504. ViewBag.ACIp2 = ConfigurationManager.AppSettings["ACIp2"] ?? "";
  505. switch (learn_UItheme)
  506. {
  507. case "1":
  508. return View("AdminDefault"); // 经典版本
  509. case "2":
  510. return View("AdminAccordion"); // 风尚版
  511. case "3":
  512. return View("AdminWindos"); // 炫动版
  513. case "4":
  514. return View("AdminTop"); // 飞扬版
  515. case "5":
  516. return View("AdminNavigation"); // 导航版
  517. case "6":
  518. return View("AdminTheme5"); // 主题五
  519. default:
  520. return View("AdminDefault"); // 经典版本
  521. }
  522. }
  523. /// <summary>
  524. /// 获取登录人员信息
  525. /// <param name="keyValue">主键</param>
  526. /// <summary>
  527. /// <returns></returns>
  528. [HttpPost]
  529. [AjaxOnly]
  530. public ActionResult GetOnlineUserInfo(string keyValue)
  531. {
  532. return Success(sys_UpdateRecordIBLL.GetOnlineUserInfo());
  533. }
  534. /// <summary>
  535. /// 学生首页
  536. /// </summary>
  537. /// <returns></returns>
  538. [HttpGet]
  539. public ActionResult HomeOfStudent()
  540. {
  541. var userInfo = LoginUserInfo.Get();
  542. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  543. if (StuInfoFreshEntity != null)
  544. {
  545. StuInfoFreshEntity.DeptName = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo)?.DeptName;
  546. StuInfoFreshEntity.MajorName = majorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
  547. //是否完善信息
  548. StuInfoFreshEntity.IsStudentEdit = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).Any();
  549. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  550. if (classInfoEntity != null)
  551. {
  552. StuInfoFreshEntity.ClassName = classInfoEntity.ClassName;
  553. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  554. var empInfoEntity = empInfoIbll.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  555. if (empInfoEntity != null)
  556. {
  557. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  558. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  559. }
  560. }
  561. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  562. }
  563. var now = DateTime.Now;
  564. ViewBag.Year = now.Year;
  565. var companyEntity = companyIbll.GetEntity(userInfo.companyId);
  566. if (companyEntity != null)
  567. {
  568. ViewBag.Company = companyEntity.F_FullName;
  569. }
  570. return View(StuInfoFreshEntity);
  571. }
  572. /// <summary>
  573. /// 使用引导
  574. /// </summary>
  575. /// <returns></returns>
  576. [HttpGet]
  577. public ActionResult Guide()
  578. {
  579. var userInfo = LoginUserInfo.Get();
  580. ViewBag.userId = userInfo.userId;
  581. ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  582. return View();
  583. }
  584. /// <summary>
  585. /// 桌面导航
  586. /// </summary>
  587. /// <returns></returns>
  588. [HttpGet]
  589. public ActionResult DesktopNavigation()
  590. {
  591. //var userInfo = LoginUserInfo.Get();
  592. //ViewBag.userId = userInfo.userId;
  593. //ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  594. return View("DesktopNavigation4");
  595. }
  596. /// <summary>
  597. /// 首页桌面
  598. /// </summary>
  599. /// <returns></returns>
  600. [HttpGet]
  601. public ActionResult AdminDesktop()
  602. {
  603. //学生登录后跳转到“学生首页”
  604. var userInfo = LoginUserInfo.Get();
  605. if (userInfo.Description == "学生" && userInfo.companyId == "207fa1a9-160c-4943-a89b-8fa4db0547ce") //西昌民族幼儿
  606. {
  607. if (stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userInfo.account) == null) //新生
  608. {
  609. return RedirectToAction("HomeOfStudent");
  610. }
  611. else
  612. {
  613. return Redirect("/UserCenter/Index");
  614. }
  615. }
  616. //return View("AdminDesktopTop");
  617. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  618. switch (learn_UItheme)
  619. {
  620. case "1":
  621. return View("AdminDesktop"); // 经典版本
  622. case "2":
  623. return View("AdminDesktopAccordion"); // 风尚版
  624. case "3":
  625. return View("AdminDesktopWindos"); // 炫动版
  626. case "4":
  627. return View("AdminDesktopTop"); // 飞扬版
  628. default:
  629. return View("AdminDesktop"); // 经典版本
  630. }
  631. }
  632. /// <summary>
  633. /// 首页模板
  634. /// </summary>
  635. /// <returns></returns>
  636. [HttpGet]
  637. public ActionResult AdminDesktopTemp()
  638. {
  639. return View();
  640. }
  641. #endregion
  642. private ICache cache = CacheFactory.CaChe();
  643. #region 清空缓存
  644. /// <summary>
  645. /// 清空缓存
  646. /// </summary>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [AjaxOnly]
  650. public ActionResult ClearRedis()
  651. {
  652. for (int i = 0; i < 16; i++)
  653. {
  654. cache.RemoveAll(i);
  655. }
  656. return Success("清空成功");
  657. }
  658. #endregion
  659. #region 解绑微信
  660. /// <summary>
  661. /// 解绑微信
  662. /// </summary>
  663. /// <returns></returns>
  664. [HttpPost]
  665. [AjaxOnly]
  666. public ActionResult CancelWeiXinBind(string keyValue)
  667. {
  668. var userId = LoginUserInfo.Get().userId;
  669. if (!string.IsNullOrEmpty(keyValue))
  670. {
  671. userId = keyValue;
  672. }
  673. //更新openid
  674. userIBLL.UpdateWeixinOpenIdPC(userId, "");
  675. return Success("解绑成功");
  676. }
  677. #endregion
  678. /// <summary>
  679. /// 访问功能
  680. /// </summary>
  681. /// <param name="moduleId">功能Id</param>
  682. /// <param name="moduleName">功能模块</param>
  683. /// <param name="moduleUrl">访问路径</param>
  684. /// <returns></returns>
  685. [HttpPost]
  686. public ActionResult VisitModule(string moduleName, string moduleUrl)
  687. {
  688. UserInfo userInfo = LoginUserInfo.Get();
  689. LogEntity logEntity = new LogEntity();
  690. logEntity.F_CategoryId = 2;
  691. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  692. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  693. logEntity.F_OperateAccount = userInfo.account;
  694. logEntity.F_OperateUserId = userInfo.userId;
  695. logEntity.F_Module = moduleName;
  696. logEntity.F_ExecuteResult = 1;
  697. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  698. logEntity.F_Description = "PC端";
  699. logEntity.WriteLog();
  700. return Success("ok");
  701. }
  702. #region 系统数据初始化
  703. public ActionResult DataBaseInit()
  704. {
  705. return View();
  706. }
  707. [HttpPost]
  708. public ActionResult DoDataBaseInit()
  709. {
  710. databaseInitIBLL.InitDatabase();
  711. return Success("初始化成功");
  712. }
  713. #endregion
  714. #region 获取数据
  715. [HttpGet]
  716. public ActionResult GetYearAndSemesteResult()
  717. {
  718. var result = Common.GetSemesterAndYear();
  719. return Success(result);
  720. }
  721. [HttpGet]
  722. public ActionResult GetDgree(string moduleID)
  723. {
  724. var result = dgreeIBLL.GetDgreeEntityByModuleID(moduleID);
  725. return Success(result);
  726. }
  727. [HttpGet]
  728. public ActionResult GetCompanyDgree()
  729. {
  730. var result = companyIbll.GetAny();
  731. return Success(result);
  732. }
  733. [HttpGet]
  734. public ActionResult GetDepartment()
  735. {
  736. var result = departmentIBLL.GetAny();
  737. return Success(result);
  738. }
  739. [HttpGet]
  740. public ActionResult GetPost()
  741. {
  742. var result = postIBLL.GetAny();
  743. return Success(result);
  744. }
  745. [HttpGet]
  746. public ActionResult GetEmpInfo()
  747. {
  748. var result = empInfoIbll.GetAny();
  749. return Success(result);
  750. }
  751. [HttpGet]
  752. public ActionResult GetEmpAccount()
  753. {
  754. var result = userIBLL.GetAny();
  755. return Success(result);
  756. }
  757. [HttpGet]
  758. public ActionResult GetCdDept()
  759. {
  760. var result = cdDeptIBLL.GetAny();
  761. return Success(result);
  762. }
  763. [HttpGet]
  764. public ActionResult GetMajor()
  765. {
  766. var result = majorIBLL.GetAny();
  767. return Success(result);
  768. }
  769. [HttpGet]
  770. public ActionResult GetLesson()
  771. {
  772. var result = infoIBLL.GetAny();
  773. return Success(result);
  774. }
  775. [HttpGet]
  776. public ActionResult GetClassroomBuilding()
  777. {
  778. var result = classroomBuildingIBLL.GetAny();
  779. return Success(result);
  780. }
  781. [HttpGet]
  782. public ActionResult GetClassroomInfo()
  783. {
  784. var result = classroomInfoIBLL.GetAny();
  785. return Success(result);
  786. }
  787. [HttpGet]
  788. public ActionResult GetClassInfo()
  789. {
  790. var result = classInfoIBLL.GetAny();
  791. return Success(result);
  792. }
  793. [HttpGet]
  794. public ActionResult GetStudentInfo()
  795. {
  796. var result = stuInfoBasicIbll.GetAny();
  797. return Success(result);
  798. }
  799. [HttpGet]
  800. public ActionResult GetStuAccount()
  801. {
  802. var result = userIBLL.GetStuAny();
  803. return Success(result);
  804. }
  805. [HttpGet]
  806. public ActionResult GetArrangeLesson()
  807. {
  808. var result = arrangeLessonTermIBLL.GetAny();
  809. return Success(result);
  810. }
  811. [HttpGet]
  812. public ActionResult GetArrangeExam()
  813. {
  814. var result = arrangeExamTermIBLL.GetAny();
  815. return Success(result);
  816. }
  817. [HttpGet]
  818. public ActionResult GetStuScore()
  819. {
  820. var result = stuScoreIBLL.GetAny();
  821. return Success(result);
  822. }
  823. #endregion
  824. private string GetIP()
  825. {
  826. //string ip = string.Empty;
  827. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  828. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  829. //if (string.IsNullOrEmpty(ip))
  830. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  831. //return ip;
  832. string userIP = "未获取用户IP";
  833. try
  834. {
  835. if (System.Web.HttpContext.Current == null
  836. || System.Web.HttpContext.Current.Request == null
  837. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  838. {
  839. return "";
  840. }
  841. string CustomerIP = "";
  842. //CDN加速后取到的IP simone 090805
  843. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  844. if (!string.IsNullOrEmpty(CustomerIP))
  845. {
  846. return CustomerIP;
  847. }
  848. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  849. if (!String.IsNullOrEmpty(CustomerIP))
  850. {
  851. return CustomerIP;
  852. }
  853. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  854. {
  855. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  856. if (CustomerIP == null)
  857. {
  858. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  859. }
  860. }
  861. else
  862. {
  863. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  864. }
  865. if (string.Compare(CustomerIP, "unknown", true) == 0 || String.IsNullOrEmpty(CustomerIP))
  866. {
  867. return System.Web.HttpContext.Current.Request.UserHostAddress;
  868. }
  869. return CustomerIP;
  870. }
  871. catch { }
  872. return userIP;
  873. }
  874. }
  875. }