選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

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