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.
 
 
 
 
 
 

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