Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

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