You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

951 lines
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. if (userinfo.Description == "学生")
  496. {
  497. ViewBag.wsbsdt = 0;
  498. }
  499. else
  500. {
  501. ViewBag.wsbsdt = 1;
  502. }
  503. switch (learn_UItheme)
  504. {
  505. case "1":
  506. return View("AdminDefault"); // 经典版本
  507. case "2":
  508. return View("AdminAccordion"); // 风尚版
  509. case "3":
  510. return View("AdminWindos"); // 炫动版
  511. case "4":
  512. return View("AdminTop"); // 飞扬版
  513. case "5":
  514. return View("AdminNavigation"); // 导航版
  515. case "6":
  516. return View("AdminTheme5"); // 主题五
  517. default:
  518. return View("AdminDefault"); // 经典版本
  519. }
  520. }
  521. /// <summary>
  522. /// 获取登录人员信息
  523. /// <param name="keyValue">主键</param>
  524. /// <summary>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [AjaxOnly]
  528. public ActionResult GetOnlineUserInfo(string keyValue)
  529. {
  530. return Success(sys_UpdateRecordIBLL.GetOnlineUserInfo());
  531. }
  532. /// <summary>
  533. /// 学生首页
  534. /// </summary>
  535. /// <returns></returns>
  536. [HttpGet]
  537. public ActionResult HomeOfStudent()
  538. {
  539. var userInfo = LoginUserInfo.Get();
  540. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  541. if (StuInfoFreshEntity != null)
  542. {
  543. StuInfoFreshEntity.DeptName = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo)?.DeptName;
  544. StuInfoFreshEntity.MajorName = majorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
  545. //是否完善信息
  546. StuInfoFreshEntity.IsStudentEdit = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).Any();
  547. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  548. if (classInfoEntity != null)
  549. {
  550. StuInfoFreshEntity.ClassName = classInfoEntity.ClassName;
  551. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  552. var empInfoEntity = empInfoIbll.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  553. if (empInfoEntity != null)
  554. {
  555. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  556. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  557. }
  558. }
  559. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  560. }
  561. var now = DateTime.Now;
  562. ViewBag.Year = now.Year;
  563. var companyEntity = companyIbll.GetEntity(userInfo.companyId);
  564. if (companyEntity != null)
  565. {
  566. ViewBag.Company = companyEntity.F_FullName;
  567. }
  568. return View(StuInfoFreshEntity);
  569. }
  570. /// <summary>
  571. /// 使用引导
  572. /// </summary>
  573. /// <returns></returns>
  574. [HttpGet]
  575. public ActionResult Guide()
  576. {
  577. var userInfo = LoginUserInfo.Get();
  578. ViewBag.userId = userInfo.userId;
  579. ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  580. return View();
  581. }
  582. /// <summary>
  583. /// 桌面导航
  584. /// </summary>
  585. /// <returns></returns>
  586. [HttpGet]
  587. public ActionResult DesktopNavigation()
  588. {
  589. //var userInfo = LoginUserInfo.Get();
  590. //ViewBag.userId = userInfo.userId;
  591. //ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  592. return View("DesktopNavigation4");
  593. }
  594. /// <summary>
  595. /// 首页桌面
  596. /// </summary>
  597. /// <returns></returns>
  598. [HttpGet]
  599. public ActionResult AdminDesktop()
  600. {
  601. //学生登录后跳转到“学生首页”
  602. var userInfo = LoginUserInfo.Get();
  603. if (userInfo.Description == "学生" && userInfo.companyId == "207fa1a9-160c-4943-a89b-8fa4db0547ce") //西昌民族幼儿
  604. {
  605. if (stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userInfo.account) == null) //新生
  606. {
  607. return RedirectToAction("HomeOfStudent");
  608. }
  609. else
  610. {
  611. return Redirect("/UserCenter/Index");
  612. }
  613. }
  614. //return View("AdminDesktopTop");
  615. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  616. switch (learn_UItheme)
  617. {
  618. case "1":
  619. return View("AdminDesktop"); // 经典版本
  620. case "2":
  621. return View("AdminDesktopAccordion"); // 风尚版
  622. case "3":
  623. return View("AdminDesktopWindos"); // 炫动版
  624. case "4":
  625. return View("AdminDesktopTop"); // 飞扬版
  626. default:
  627. return View("AdminDesktop"); // 经典版本
  628. }
  629. }
  630. /// <summary>
  631. /// 首页模板
  632. /// </summary>
  633. /// <returns></returns>
  634. [HttpGet]
  635. public ActionResult AdminDesktopTemp()
  636. {
  637. return View();
  638. }
  639. #endregion
  640. private ICache cache = CacheFactory.CaChe();
  641. #region 清空缓存
  642. /// <summary>
  643. /// 清空缓存
  644. /// </summary>
  645. /// <returns></returns>
  646. [HttpPost]
  647. [AjaxOnly]
  648. public ActionResult ClearRedis()
  649. {
  650. for (int i = 0; i < 16; i++)
  651. {
  652. cache.RemoveAll(i);
  653. }
  654. return Success("清空成功");
  655. }
  656. #endregion
  657. #region 解绑微信
  658. /// <summary>
  659. /// 解绑微信
  660. /// </summary>
  661. /// <returns></returns>
  662. [HttpPost]
  663. [AjaxOnly]
  664. public ActionResult CancelWeiXinBind(string keyValue)
  665. {
  666. var userId = LoginUserInfo.Get().userId;
  667. if (!string.IsNullOrEmpty(keyValue))
  668. {
  669. userId = keyValue;
  670. }
  671. //更新openid
  672. userIBLL.UpdateWeixinOpenIdPC(userId, "");
  673. return Success("解绑成功");
  674. }
  675. #endregion
  676. /// <summary>
  677. /// 访问功能
  678. /// </summary>
  679. /// <param name="moduleId">功能Id</param>
  680. /// <param name="moduleName">功能模块</param>
  681. /// <param name="moduleUrl">访问路径</param>
  682. /// <returns></returns>
  683. [HttpPost]
  684. public ActionResult VisitModule(string moduleName, string moduleUrl)
  685. {
  686. UserInfo userInfo = LoginUserInfo.Get();
  687. LogEntity logEntity = new LogEntity();
  688. logEntity.F_CategoryId = 2;
  689. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  690. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  691. logEntity.F_OperateAccount = userInfo.account;
  692. logEntity.F_OperateUserId = userInfo.userId;
  693. logEntity.F_Module = moduleName;
  694. logEntity.F_ExecuteResult = 1;
  695. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  696. logEntity.F_Description = "PC端";
  697. logEntity.WriteLog();
  698. return Success("ok");
  699. }
  700. #region 系统数据初始化
  701. public ActionResult DataBaseInit()
  702. {
  703. return View();
  704. }
  705. [HttpPost]
  706. public ActionResult DoDataBaseInit()
  707. {
  708. databaseInitIBLL.InitDatabase();
  709. return Success("初始化成功");
  710. }
  711. #endregion
  712. #region 获取数据
  713. [HttpGet]
  714. public ActionResult GetYearAndSemesteResult()
  715. {
  716. var result = Common.GetSemesterAndYear();
  717. return Success(result);
  718. }
  719. [HttpGet]
  720. public ActionResult GetDgree(string moduleID)
  721. {
  722. var result = dgreeIBLL.GetDgreeEntityByModuleID(moduleID);
  723. return Success(result);
  724. }
  725. [HttpGet]
  726. public ActionResult GetCompanyDgree()
  727. {
  728. var result = companyIbll.GetAny();
  729. return Success(result);
  730. }
  731. [HttpGet]
  732. public ActionResult GetDepartment()
  733. {
  734. var result = departmentIBLL.GetAny();
  735. return Success(result);
  736. }
  737. [HttpGet]
  738. public ActionResult GetPost()
  739. {
  740. var result = postIBLL.GetAny();
  741. return Success(result);
  742. }
  743. [HttpGet]
  744. public ActionResult GetEmpInfo()
  745. {
  746. var result = empInfoIbll.GetAny();
  747. return Success(result);
  748. }
  749. [HttpGet]
  750. public ActionResult GetEmpAccount()
  751. {
  752. var result = userIBLL.GetAny();
  753. return Success(result);
  754. }
  755. [HttpGet]
  756. public ActionResult GetCdDept()
  757. {
  758. var result = cdDeptIBLL.GetAny();
  759. return Success(result);
  760. }
  761. [HttpGet]
  762. public ActionResult GetMajor()
  763. {
  764. var result = majorIBLL.GetAny();
  765. return Success(result);
  766. }
  767. [HttpGet]
  768. public ActionResult GetLesson()
  769. {
  770. var result = infoIBLL.GetAny();
  771. return Success(result);
  772. }
  773. [HttpGet]
  774. public ActionResult GetClassroomBuilding()
  775. {
  776. var result = classroomBuildingIBLL.GetAny();
  777. return Success(result);
  778. }
  779. [HttpGet]
  780. public ActionResult GetClassroomInfo()
  781. {
  782. var result = classroomInfoIBLL.GetAny();
  783. return Success(result);
  784. }
  785. [HttpGet]
  786. public ActionResult GetClassInfo()
  787. {
  788. var result = classInfoIBLL.GetAny();
  789. return Success(result);
  790. }
  791. [HttpGet]
  792. public ActionResult GetStudentInfo()
  793. {
  794. var result = stuInfoBasicIbll.GetAny();
  795. return Success(result);
  796. }
  797. [HttpGet]
  798. public ActionResult GetStuAccount()
  799. {
  800. var result = userIBLL.GetStuAny();
  801. return Success(result);
  802. }
  803. [HttpGet]
  804. public ActionResult GetArrangeLesson()
  805. {
  806. var result = arrangeLessonTermIBLL.GetAny();
  807. return Success(result);
  808. }
  809. [HttpGet]
  810. public ActionResult GetArrangeExam()
  811. {
  812. var result = arrangeExamTermIBLL.GetAny();
  813. return Success(result);
  814. }
  815. [HttpGet]
  816. public ActionResult GetStuScore()
  817. {
  818. var result = stuScoreIBLL.GetAny();
  819. return Success(result);
  820. }
  821. #endregion
  822. private string GetIP()
  823. {
  824. //string ip = string.Empty;
  825. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  826. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  827. //if (string.IsNullOrEmpty(ip))
  828. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  829. //return ip;
  830. string userIP = "未获取用户IP";
  831. try
  832. {
  833. if (System.Web.HttpContext.Current == null
  834. || System.Web.HttpContext.Current.Request == null
  835. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  836. {
  837. return "";
  838. }
  839. string CustomerIP = "";
  840. //CDN加速后取到的IP simone 090805
  841. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  842. if (!string.IsNullOrEmpty(CustomerIP))
  843. {
  844. return CustomerIP;
  845. }
  846. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  847. if (!String.IsNullOrEmpty(CustomerIP))
  848. {
  849. return CustomerIP;
  850. }
  851. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  852. {
  853. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  854. if (CustomerIP == null)
  855. {
  856. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  857. }
  858. }
  859. else
  860. {
  861. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  862. }
  863. if (string.Compare(CustomerIP, "unknown", true) == 0 || String.IsNullOrEmpty(CustomerIP))
  864. {
  865. return System.Web.HttpContext.Current.Request.UserHostAddress;
  866. }
  867. return CustomerIP;
  868. }
  869. catch { }
  870. return userIP;
  871. }
  872. }
  873. }