您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

942 行
39 KiB

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