Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

953 рядки
39 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Net.Http;
  5. using Learun.Application.Base.SystemModule;
  6. using Learun.Cache.Base;
  7. using Learun.Cache.Factory;
  8. using Learun.Util;
  9. using Learun.Util.Operat;
  10. using System.Web.Mvc;
  11. using Learun.Application.Organization;
  12. using Learun.Application.TwoDevelopment.EducationalAdministration;
  13. using Quanjiang.DigitalScholl.WebLicense;
  14. using Learun.Application.TwoDevelopment.LogisticsManagement;
  15. using System.Linq;
  16. using Learun.Application.OA;
  17. using Learun.Application.TwoDevelopment.LR_Desktop;
  18. using Learun.Application.TwoDevelopment.Permission;
  19. using Learun.Application.WorkFlow;
  20. namespace Learun.Application.Web.Controllers
  21. {
  22. /// <summary>
  23. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  24. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  25. /// 创建人:陈彬彬
  26. /// 日 期:2017.03.09
  27. /// 描 述:主页控制器
  28. /// </summary>
  29. public class HomeController : MvcControllerBase
  30. {
  31. private EmpInfoIBLL empInfoIbll = new EmpInfoBLL();
  32. private CompanyIBLL companyIbll = new CompanyBLL();
  33. private QingJu_UserAccountIBLL qjAccountIbll = new QingJu_UserAccountBLL();
  34. private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL();
  35. private DatabaseInitIBLL databaseInitIBLL = new DatabaseInitBLL();
  36. private DepartmentIBLL departmentIBLL = new DepartmentBLL();
  37. private DgreeIBLL dgreeIBLL = new DgreeBLL();
  38. private PostIBLL postIBLL = new PostBLL();
  39. private UserIBLL userIBLL = new UserBLL();
  40. private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
  41. private CdMajorIBLL majorIBLL = new CdMajorBLL();
  42. private LessonInfoIBLL infoIBLL = new LessonInfoBLL();
  43. private ClassroomBuildingIBLL classroomBuildingIBLL = new ClassroomBuildingBLL();
  44. private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
  45. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  46. private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();
  47. private ArrangeExamTermIBLL arrangeExamTermIBLL = new ArrangeExamTermBLL();
  48. private StuScoreIBLL stuScoreIBLL = new StuScoreBLL();
  49. private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL();
  50. private AccommodationIBLL accdormitoryIBLL = new AccommodationBLL();
  51. private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
  52. private NoticeIBLL newsIBLL = new NoticeBLL();
  53. private SYS_ReceiveMessageIBLL sYS_ReceiveMessageIBLL = new SYS_ReceiveMessageBLL();
  54. private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();
  55. private Sys_UpdateRecordIBLL sys_UpdateRecordIBLL = new Sys_UpdateRecordBLL();
  56. private Perm_FunctionIBLL perm_FunctionIBLL = new Perm_FunctionBLL();
  57. private ICache redisCache = CacheFactory.CaChe();
  58. private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL();
  59. #region 视图功能
  60. public ActionResult ChangePwd()
  61. {
  62. return View();
  63. }
  64. #region 统一身份认证2.0
  65. public ActionResult SSOApplication()
  66. {
  67. var userinfo = LoginUserInfo.Get();
  68. ViewBag.FunctionList = perm_FunctionIBLL.GetListByUserId(userinfo.userId).Where(m => m.FIsH5 == false);
  69. return View();
  70. }
  71. /// <summary>
  72. /// 跳转网站
  73. /// </summary>
  74. /// <returns></returns>
  75. public ActionResult GoToApplication()
  76. {
  77. string redi = Request.QueryString["redi"];
  78. if (!string.IsNullOrEmpty(redi))
  79. {
  80. var userinfo = LoginUserInfo.Get();
  81. if (userinfo != null)
  82. {
  83. var perm_application = perm_FunctionIBLL.GetPerm_FunctionEntity(Request.QueryString["appid"]);
  84. if (perm_application != null)
  85. {
  86. //写入当前请求所登录的用户
  87. var code = Util.CommonHelper.RndNum(9);
  88. redisCache.Write(code, userinfo.account, TimeSpan.FromMinutes(10));
  89. var url = perm_application.FInterfaceUrl;
  90. if (url.Contains("?"))
  91. {
  92. url += "&appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
  93. }
  94. else
  95. {
  96. url += "?appkey=" + DESEncrypt.Encrypt(code, "bjqjsso");
  97. }
  98. return Redirect(url);
  99. }
  100. else
  101. return RedirectToAction("Index");
  102. }
  103. else
  104. {
  105. return RedirectToAction("Index");
  106. }
  107. }
  108. return View();
  109. }
  110. #endregion
  111. public ActionResult NeedToDoForm()
  112. {
  113. var userinfo = LoginUserInfo.Get();
  114. Pagination paginationobj = new Pagination() { rows = 5, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
  115. //未读邮件
  116. ViewBag.UnreadMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}").Count(m => m.READFLAG == 0);
  117. //办公事项
  118. paginationobj.sidx = "F_CreateDate";
  119. ViewBag.UnreadTask = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}").Count();
  120. //公告
  121. List<NewsEntity> outnewslist = new List<NewsEntity>();
  122. var newsList = newsIBLL.GetPageList(paginationobj, "");
  123. foreach (var newsitemEntity in newsList)
  124. {
  125. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  126. {
  127. if (!string.IsNullOrEmpty(userinfo.postIds))
  128. {
  129. if (userinfo.postIds.Contains(","))
  130. {
  131. foreach (var postid in userinfo.postIds.Split(','))
  132. {
  133. if (newsitemEntity.F_SendPostId.Contains(postid))
  134. {
  135. outnewslist.Add(newsitemEntity);
  136. break;
  137. }
  138. }
  139. }
  140. else
  141. {
  142. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  143. {
  144. outnewslist.Add(newsitemEntity);
  145. }
  146. }
  147. }
  148. }
  149. else
  150. {
  151. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  152. {
  153. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  154. {
  155. outnewslist.Add(newsitemEntity);
  156. }
  157. }
  158. else
  159. {
  160. outnewslist.Add(newsitemEntity);
  161. }
  162. }
  163. }
  164. //var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId);
  165. var readnewslist = readbll.GetListOfSelf().Select(m => m.NewsId).ToList();
  166. ViewBag.UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId));
  167. paginationobj.sidx = "SendTime";
  168. //ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListByUserId(paginationobj, "{}", userinfo.userId).Where(a => a.STypeId == 1).Count();
  169. ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId);
  170. return View();
  171. }
  172. private static LR_OA_NewsReadBLL readbll = new LR_OA_NewsReadBLL();
  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='about:blank';</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.GetPageListBySenderId(userinfo.userId).Count();
  480. //普通教师请假-未归档数
  481. ViewBag.UnfileLeave = 0;
  482. //中层领导请假-未归档数
  483. ViewBag.UnfileLeaveZC = 0;
  484. ViewBag.UnreadNum = ViewBag.UnreadFile + ViewBag.UnreadNews + ViewBag.UnreadTask + ViewBag.UnreadMail + ViewBag.UnfileLeave + ViewBag.UnfileLeaveZC;
  485. #endregion
  486. //获取在线用户人数
  487. ViewBag.OnlineUserNum = 0;
  488. var onlineUserResult = sys_UpdateRecordIBLL.GetOnlineUserNum();
  489. if (onlineUserResult != null)
  490. {
  491. ViewBag.OnlineUserNum = onlineUserResult.OnlineUserNum;
  492. }
  493. //获取本机ip
  494. ViewBag.Ip = GetIP();
  495. ViewBag.ACIp = ConfigurationManager.AppSettings["ACIp"] ?? "";
  496. ViewBag.ACIp2 = ConfigurationManager.AppSettings["ACIp2"] ?? "";
  497. if (userinfo.Description == "学生")
  498. {
  499. ViewBag.wsbsdt = 0;
  500. }
  501. else
  502. {
  503. ViewBag.wsbsdt = 1;
  504. }
  505. switch (learn_UItheme)
  506. {
  507. case "1":
  508. return View("AdminDefault"); // 经典版本
  509. case "2":
  510. return View("AdminAccordion"); // 风尚版
  511. case "3":
  512. return View("AdminWindos"); // 炫动版
  513. case "4":
  514. return View("AdminTop"); // 飞扬版
  515. case "5":
  516. return View("AdminNavigation"); // 导航版
  517. case "6":
  518. return View("AdminTheme5"); // 主题五
  519. default:
  520. return View("AdminDefault"); // 经典版本
  521. }
  522. }
  523. /// <summary>
  524. /// 获取登录人员信息
  525. /// <param name="keyValue">主键</param>
  526. /// <summary>
  527. /// <returns></returns>
  528. [HttpPost]
  529. [AjaxOnly]
  530. public ActionResult GetOnlineUserInfo(string keyValue)
  531. {
  532. return Success(sys_UpdateRecordIBLL.GetOnlineUserInfo());
  533. }
  534. /// <summary>
  535. /// 学生首页
  536. /// </summary>
  537. /// <returns></returns>
  538. [HttpGet]
  539. public ActionResult HomeOfStudent()
  540. {
  541. var userInfo = LoginUserInfo.Get();
  542. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  543. if (StuInfoFreshEntity != null)
  544. {
  545. StuInfoFreshEntity.DeptName = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo)?.DeptName;
  546. StuInfoFreshEntity.MajorName = majorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
  547. //是否完善信息
  548. StuInfoFreshEntity.IsStudentEdit = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).Any();
  549. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  550. if (classInfoEntity != null)
  551. {
  552. StuInfoFreshEntity.ClassName = classInfoEntity.ClassName;
  553. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  554. var empInfoEntity = empInfoIbll.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  555. if (empInfoEntity != null)
  556. {
  557. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  558. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  559. }
  560. }
  561. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  562. }
  563. var now = DateTime.Now;
  564. ViewBag.Year = now.Year;
  565. var companyEntity = companyIbll.GetEntity(userInfo.companyId);
  566. if (companyEntity != null)
  567. {
  568. ViewBag.Company = companyEntity.F_FullName;
  569. }
  570. return View(StuInfoFreshEntity);
  571. }
  572. /// <summary>
  573. /// 使用引导
  574. /// </summary>
  575. /// <returns></returns>
  576. [HttpGet]
  577. public ActionResult Guide()
  578. {
  579. var userInfo = LoginUserInfo.Get();
  580. ViewBag.userId = userInfo.userId;
  581. ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  582. return View();
  583. }
  584. /// <summary>
  585. /// 桌面导航
  586. /// </summary>
  587. /// <returns></returns>
  588. [HttpGet]
  589. public ActionResult DesktopNavigation()
  590. {
  591. //var userInfo = LoginUserInfo.Get();
  592. //ViewBag.userId = userInfo.userId;
  593. //ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  594. return View("DesktopNavigation4");
  595. }
  596. /// <summary>
  597. /// 首页桌面
  598. /// </summary>
  599. /// <returns></returns>
  600. [HttpGet]
  601. public ActionResult AdminDesktop()
  602. {
  603. //学生登录后跳转到“学生首页”
  604. var userInfo = LoginUserInfo.Get();
  605. if (userInfo.Description == "学生" && userInfo.companyId == "207fa1a9-160c-4943-a89b-8fa4db0547ce") //西昌民族幼儿
  606. {
  607. if (stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userInfo.account) == null) //新生
  608. {
  609. return RedirectToAction("HomeOfStudent");
  610. }
  611. else
  612. {
  613. return Redirect("/UserCenter/Index");
  614. }
  615. }
  616. //return View("AdminDesktopTop");
  617. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  618. switch (learn_UItheme)
  619. {
  620. case "1":
  621. return View("AdminDesktop"); // 经典版本
  622. case "2":
  623. return View("AdminDesktopAccordion"); // 风尚版
  624. case "3":
  625. return View("AdminDesktopWindos"); // 炫动版
  626. case "4":
  627. return View("AdminDesktopTop"); // 飞扬版
  628. default:
  629. return View("AdminDesktop"); // 经典版本
  630. }
  631. }
  632. /// <summary>
  633. /// 首页模板
  634. /// </summary>
  635. /// <returns></returns>
  636. [HttpGet]
  637. public ActionResult AdminDesktopTemp()
  638. {
  639. return View();
  640. }
  641. #endregion
  642. private ICache cache = CacheFactory.CaChe();
  643. #region 清空缓存
  644. /// <summary>
  645. /// 清空缓存
  646. /// </summary>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [AjaxOnly]
  650. public ActionResult ClearRedis()
  651. {
  652. for (int i = 0; i < 16; i++)
  653. {
  654. cache.RemoveAll(i);
  655. }
  656. return Success("清空成功");
  657. }
  658. #endregion
  659. #region 解绑微信
  660. /// <summary>
  661. /// 解绑微信
  662. /// </summary>
  663. /// <returns></returns>
  664. [HttpPost]
  665. [AjaxOnly]
  666. public ActionResult CancelWeiXinBind(string keyValue)
  667. {
  668. var userId = LoginUserInfo.Get().userId;
  669. if (!string.IsNullOrEmpty(keyValue))
  670. {
  671. userId = keyValue;
  672. }
  673. //更新openid
  674. userIBLL.UpdateWeixinOpenIdPC(userId, "");
  675. userIBLL.UpdateWeixinOpenId(userId, "");
  676. return Success("解绑成功");
  677. }
  678. #endregion
  679. /// <summary>
  680. /// 访问功能
  681. /// </summary>
  682. /// <param name="moduleId">功能Id</param>
  683. /// <param name="moduleName">功能模块</param>
  684. /// <param name="moduleUrl">访问路径</param>
  685. /// <returns></returns>
  686. [HttpPost]
  687. public ActionResult VisitModule(string moduleName, string moduleUrl)
  688. {
  689. UserInfo userInfo = LoginUserInfo.Get();
  690. LogEntity logEntity = new LogEntity();
  691. logEntity.F_CategoryId = 2;
  692. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  693. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  694. logEntity.F_OperateAccount = userInfo.account;
  695. logEntity.F_OperateUserId = userInfo.userId;
  696. logEntity.F_Module = moduleName;
  697. logEntity.F_ExecuteResult = 1;
  698. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  699. logEntity.F_Description = "PC端";
  700. logEntity.WriteLog();
  701. return Success("ok");
  702. }
  703. #region 系统数据初始化
  704. public ActionResult DataBaseInit()
  705. {
  706. return View();
  707. }
  708. [HttpPost]
  709. public ActionResult DoDataBaseInit()
  710. {
  711. databaseInitIBLL.InitDatabase();
  712. return Success("初始化成功");
  713. }
  714. #endregion
  715. #region 获取数据
  716. [HttpGet]
  717. public ActionResult GetYearAndSemesteResult()
  718. {
  719. var result = Common.GetSemesterAndYear();
  720. return Success(result);
  721. }
  722. [HttpGet]
  723. public ActionResult GetDgree(string moduleID)
  724. {
  725. var result = dgreeIBLL.GetDgreeEntityByModuleID(moduleID);
  726. return Success(result);
  727. }
  728. [HttpGet]
  729. public ActionResult GetCompanyDgree()
  730. {
  731. var result = companyIbll.GetAny();
  732. return Success(result);
  733. }
  734. [HttpGet]
  735. public ActionResult GetDepartment()
  736. {
  737. var result = departmentIBLL.GetAny();
  738. return Success(result);
  739. }
  740. [HttpGet]
  741. public ActionResult GetPost()
  742. {
  743. var result = postIBLL.GetAny();
  744. return Success(result);
  745. }
  746. [HttpGet]
  747. public ActionResult GetEmpInfo()
  748. {
  749. var result = empInfoIbll.GetAny();
  750. return Success(result);
  751. }
  752. [HttpGet]
  753. public ActionResult GetEmpAccount()
  754. {
  755. var result = userIBLL.GetAny();
  756. return Success(result);
  757. }
  758. [HttpGet]
  759. public ActionResult GetCdDept()
  760. {
  761. var result = cdDeptIBLL.GetAny();
  762. return Success(result);
  763. }
  764. [HttpGet]
  765. public ActionResult GetMajor()
  766. {
  767. var result = majorIBLL.GetAny();
  768. return Success(result);
  769. }
  770. [HttpGet]
  771. public ActionResult GetLesson()
  772. {
  773. var result = infoIBLL.GetAny();
  774. return Success(result);
  775. }
  776. [HttpGet]
  777. public ActionResult GetClassroomBuilding()
  778. {
  779. var result = classroomBuildingIBLL.GetAny();
  780. return Success(result);
  781. }
  782. [HttpGet]
  783. public ActionResult GetClassroomInfo()
  784. {
  785. var result = classroomInfoIBLL.GetAny();
  786. return Success(result);
  787. }
  788. [HttpGet]
  789. public ActionResult GetClassInfo()
  790. {
  791. var result = classInfoIBLL.GetAny();
  792. return Success(result);
  793. }
  794. [HttpGet]
  795. public ActionResult GetStudentInfo()
  796. {
  797. var result = stuInfoBasicIbll.GetAny();
  798. return Success(result);
  799. }
  800. [HttpGet]
  801. public ActionResult GetStuAccount()
  802. {
  803. var result = userIBLL.GetStuAny();
  804. return Success(result);
  805. }
  806. [HttpGet]
  807. public ActionResult GetArrangeLesson()
  808. {
  809. var result = arrangeLessonTermIBLL.GetAny();
  810. return Success(result);
  811. }
  812. [HttpGet]
  813. public ActionResult GetArrangeExam()
  814. {
  815. var result = arrangeExamTermIBLL.GetAny();
  816. return Success(result);
  817. }
  818. [HttpGet]
  819. public ActionResult GetStuScore()
  820. {
  821. var result = stuScoreIBLL.GetAny();
  822. return Success(result);
  823. }
  824. #endregion
  825. private string GetIP()
  826. {
  827. //string ip = string.Empty;
  828. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  829. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  830. //if (string.IsNullOrEmpty(ip))
  831. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  832. //return ip;
  833. string userIP = "未获取用户IP";
  834. try
  835. {
  836. if (System.Web.HttpContext.Current == null
  837. || System.Web.HttpContext.Current.Request == null
  838. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  839. {
  840. return "";
  841. }
  842. string CustomerIP = "";
  843. //CDN加速后取到的IP simone 090805
  844. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  845. if (!string.IsNullOrEmpty(CustomerIP))
  846. {
  847. return CustomerIP;
  848. }
  849. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  850. if (!String.IsNullOrEmpty(CustomerIP))
  851. {
  852. return CustomerIP;
  853. }
  854. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  855. {
  856. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  857. if (CustomerIP == null)
  858. {
  859. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  860. }
  861. }
  862. else
  863. {
  864. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  865. }
  866. if (string.Compare(CustomerIP, "unknown", true) == 0 || String.IsNullOrEmpty(CustomerIP))
  867. {
  868. return System.Web.HttpContext.Current.Request.UserHostAddress;
  869. }
  870. return CustomerIP;
  871. }
  872. catch { }
  873. return userIP;
  874. }
  875. }
  876. }