25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

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