Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

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