Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

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