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.
 
 
 
 
 
 

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