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.
 
 
 
 
 
 

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