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

938 lines
39 KiB

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