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.
 
 
 
 
 
 

949 line
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. 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. if (!lc.Result)
  422. {
  423. return Content("<script>alert('" + lc.Message + "');location.href='/ShowRegister/Index';</script>");
  424. }
  425. }
  426. //return View("AdminTop");
  427. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  428. #region 待办
  429. var userinfo = LoginUserInfo.Get();
  430. Pagination paginationobj = new Pagination() { rows = 100, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
  431. //未读邮件
  432. ViewBag.UnreadMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}").Count(m => m.READFLAG == 0);
  433. //办公事项
  434. paginationobj.sidx = "F_CreateDate";
  435. ViewBag.UnreadTask = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}").Count();
  436. //公告
  437. List<NewsEntity> outnewslist = new List<NewsEntity>();
  438. var newsList = newsIBLL.GetPageList(paginationobj, "");
  439. foreach (var newsitemEntity in newsList)
  440. {
  441. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  442. {
  443. if (!string.IsNullOrEmpty(userinfo.postIds))
  444. {
  445. if (userinfo.postIds.Contains(","))
  446. {
  447. foreach (var postid in userinfo.postIds.Split(','))
  448. {
  449. if (newsitemEntity.F_SendPostId.Contains(postid))
  450. {
  451. outnewslist.Add(newsitemEntity);
  452. break;
  453. }
  454. }
  455. }
  456. else
  457. {
  458. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  459. {
  460. outnewslist.Add(newsitemEntity);
  461. }
  462. }
  463. }
  464. }
  465. else
  466. {
  467. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  468. {
  469. if (userinfo.departmentId != null && newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  470. {
  471. outnewslist.Add(newsitemEntity);
  472. }
  473. }
  474. else
  475. {
  476. outnewslist.Add(newsitemEntity);
  477. }
  478. }
  479. }
  480. var readnewslist = newsIBLL.GetList("", userinfo.userId).Where(m => !string.IsNullOrEmpty(m.RNewsId)).Select(m => m.F_NewsId);
  481. ViewBag.UnreadNews = outnewslist.Count(m => !readnewslist.Contains(m.F_NewsId));
  482. paginationobj.sidx = "SendTime";
  483. ViewBag.UnreadFile = sys_ReceiveFileIBLL.GetPageListBySenderId(userinfo.userId).Count();
  484. //普通教师请假-未归档数
  485. ViewBag.UnfileLeave = 0;
  486. //中层领导请假-未归档数
  487. ViewBag.UnfileLeaveZC = 0;
  488. ViewBag.UnreadNum = ViewBag.UnreadFile + ViewBag.UnreadNews + ViewBag.UnreadTask + ViewBag.UnreadMail + ViewBag.UnfileLeave + ViewBag.UnfileLeaveZC;
  489. #endregion
  490. //获取在线用户人数
  491. ViewBag.OnlineUserNum = 0;
  492. var onlineUserResult = sys_UpdateRecordIBLL.GetOnlineUserNum();
  493. if (onlineUserResult != null)
  494. {
  495. ViewBag.OnlineUserNum = onlineUserResult.OnlineUserNum;
  496. }
  497. //获取本机ip
  498. ViewBag.Ip = GetIP();
  499. ViewBag.ACIp = ConfigurationManager.AppSettings["ACIp"] ?? "";
  500. ViewBag.ACIp2 = ConfigurationManager.AppSettings["ACIp2"] ?? "";
  501. switch (learn_UItheme)
  502. {
  503. case "1":
  504. return View("AdminDefault"); // 经典版本
  505. case "2":
  506. return View("AdminAccordion"); // 风尚版
  507. case "3":
  508. return View("AdminWindos"); // 炫动版
  509. case "4":
  510. return View("AdminTop"); // 飞扬版
  511. case "5":
  512. return View("AdminNavigation"); // 导航版
  513. case "6":
  514. return View("AdminTheme5"); // 主题五
  515. default:
  516. return View("AdminDefault"); // 经典版本
  517. }
  518. }
  519. /// <summary>
  520. /// 获取登录人员信息
  521. /// <param name="keyValue">主键</param>
  522. /// <summary>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [AjaxOnly]
  526. public ActionResult GetOnlineUserInfo(string keyValue)
  527. {
  528. return Success(sys_UpdateRecordIBLL.GetOnlineUserInfo());
  529. }
  530. /// <summary>
  531. /// 学生首页
  532. /// </summary>
  533. /// <returns></returns>
  534. [HttpGet]
  535. public ActionResult HomeOfStudent()
  536. {
  537. var userInfo = LoginUserInfo.Get();
  538. var StuInfoFreshEntity = stuInfoFreshIBLL.GetStuInfoFreshEntityByStuNo(userInfo.account);
  539. if (StuInfoFreshEntity != null)
  540. {
  541. StuInfoFreshEntity.DeptName = cdDeptIBLL.GetCdDeptEntityByNo(StuInfoFreshEntity.DeptNo)?.DeptName;
  542. StuInfoFreshEntity.MajorName = majorIBLL.GetCdMajorEntityByMajorNo(StuInfoFreshEntity.MajorNo)?.MajorName;
  543. //是否完善信息
  544. StuInfoFreshEntity.IsStudentEdit = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshEntity.ID).Any();
  545. var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshEntity.ClassNo);
  546. if (classInfoEntity != null)
  547. {
  548. StuInfoFreshEntity.ClassName = classInfoEntity.ClassName;
  549. StuInfoFreshEntity.ClassTutorNo = classInfoEntity.ClassTutorNo;
  550. var empInfoEntity = empInfoIbll.GetEmpInfoEntityByEmpNo(classInfoEntity.ClassTutorNo);
  551. if (empInfoEntity != null)
  552. {
  553. StuInfoFreshEntity.ClassTutorName = empInfoEntity.EmpName;
  554. StuInfoFreshEntity.ClassTutorMobile = empInfoEntity.mobile;
  555. }
  556. }
  557. StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID);
  558. }
  559. var now = DateTime.Now;
  560. ViewBag.Year = now.Year;
  561. var companyEntity = companyIbll.GetEntity(userInfo.companyId);
  562. if (companyEntity != null)
  563. {
  564. ViewBag.Company = companyEntity.F_FullName;
  565. }
  566. return View(StuInfoFreshEntity);
  567. }
  568. /// <summary>
  569. /// 使用引导
  570. /// </summary>
  571. /// <returns></returns>
  572. [HttpGet]
  573. public ActionResult Guide()
  574. {
  575. var userInfo = LoginUserInfo.Get();
  576. ViewBag.userId = userInfo.userId;
  577. ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  578. return View();
  579. }
  580. /// <summary>
  581. /// 桌面导航
  582. /// </summary>
  583. /// <returns></returns>
  584. [HttpGet]
  585. public ActionResult DesktopNavigation()
  586. {
  587. //var userInfo = LoginUserInfo.Get();
  588. //ViewBag.userId = userInfo.userId;
  589. //ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  590. return View("DesktopNavigation4");
  591. }
  592. /// <summary>
  593. /// 首页桌面
  594. /// </summary>
  595. /// <returns></returns>
  596. [HttpGet]
  597. public ActionResult AdminDesktop()
  598. {
  599. //学生登录后跳转到“学生首页”
  600. var userInfo = LoginUserInfo.Get();
  601. if (userInfo.Description == "学生" && userInfo.companyId == "207fa1a9-160c-4943-a89b-8fa4db0547ce") //西昌民族幼儿
  602. {
  603. if (stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(userInfo.account) == null) //新生
  604. {
  605. return RedirectToAction("HomeOfStudent");
  606. }
  607. else
  608. {
  609. return Redirect("/UserCenter/Index");
  610. }
  611. }
  612. //return View("AdminDesktopTop");
  613. string learn_UItheme = WebHelper.GetCookie("Learn_ADMS_V6.1_UItheme");
  614. switch (learn_UItheme)
  615. {
  616. case "1":
  617. return View("AdminDesktop"); // 经典版本
  618. case "2":
  619. return View("AdminDesktopAccordion"); // 风尚版
  620. case "3":
  621. return View("AdminDesktopWindos"); // 炫动版
  622. case "4":
  623. return View("AdminDesktopTop"); // 飞扬版
  624. default:
  625. return View("AdminDesktop"); // 经典版本
  626. }
  627. }
  628. /// <summary>
  629. /// 首页模板
  630. /// </summary>
  631. /// <returns></returns>
  632. [HttpGet]
  633. public ActionResult AdminDesktopTemp()
  634. {
  635. return View();
  636. }
  637. #endregion
  638. private ICache cache = CacheFactory.CaChe();
  639. #region 清空缓存
  640. /// <summary>
  641. /// 清空缓存
  642. /// </summary>
  643. /// <returns></returns>
  644. [HttpPost]
  645. [AjaxOnly]
  646. public ActionResult ClearRedis()
  647. {
  648. for (int i = 0; i < 16; i++)
  649. {
  650. cache.RemoveAll(i);
  651. }
  652. return Success("清空成功");
  653. }
  654. #endregion
  655. #region 解绑微信
  656. /// <summary>
  657. /// 解绑微信
  658. /// </summary>
  659. /// <returns></returns>
  660. [HttpPost]
  661. [AjaxOnly]
  662. public ActionResult CancelWeiXinBind(string keyValue)
  663. {
  664. var userId = LoginUserInfo.Get().userId;
  665. if (!string.IsNullOrEmpty(keyValue))
  666. {
  667. userId = keyValue;
  668. }
  669. //更新openid
  670. userIBLL.UpdateWeixinOpenIdPC(userId, "");
  671. return Success("解绑成功");
  672. }
  673. #endregion
  674. /// <summary>
  675. /// 访问功能
  676. /// </summary>
  677. /// <param name="moduleId">功能Id</param>
  678. /// <param name="moduleName">功能模块</param>
  679. /// <param name="moduleUrl">访问路径</param>
  680. /// <returns></returns>
  681. [HttpPost]
  682. public ActionResult VisitModule(string moduleName, string moduleUrl)
  683. {
  684. UserInfo userInfo = LoginUserInfo.Get();
  685. LogEntity logEntity = new LogEntity();
  686. logEntity.F_CategoryId = 2;
  687. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  688. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  689. logEntity.F_OperateAccount = userInfo.account;
  690. logEntity.F_OperateUserId = userInfo.userId;
  691. logEntity.F_Module = moduleName;
  692. logEntity.F_ExecuteResult = 1;
  693. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  694. logEntity.F_Description = "PC端";
  695. logEntity.WriteLog();
  696. return Success("ok");
  697. }
  698. #region 系统数据初始化
  699. public ActionResult DataBaseInit()
  700. {
  701. return View();
  702. }
  703. [HttpPost]
  704. public ActionResult DoDataBaseInit()
  705. {
  706. databaseInitIBLL.InitDatabase();
  707. return Success("初始化成功");
  708. }
  709. #endregion
  710. #region 获取数据
  711. [HttpGet]
  712. public ActionResult GetYearAndSemesteResult()
  713. {
  714. var result = Common.GetSemesterAndYear();
  715. return Success(result);
  716. }
  717. [HttpGet]
  718. public ActionResult GetDgree(string moduleID)
  719. {
  720. var result = dgreeIBLL.GetDgreeEntityByModuleID(moduleID);
  721. return Success(result);
  722. }
  723. [HttpGet]
  724. public ActionResult GetCompanyDgree()
  725. {
  726. var result = companyIbll.GetAny();
  727. return Success(result);
  728. }
  729. [HttpGet]
  730. public ActionResult GetDepartment()
  731. {
  732. var result = departmentIBLL.GetAny();
  733. return Success(result);
  734. }
  735. [HttpGet]
  736. public ActionResult GetPost()
  737. {
  738. var result = postIBLL.GetAny();
  739. return Success(result);
  740. }
  741. [HttpGet]
  742. public ActionResult GetEmpInfo()
  743. {
  744. var result = empInfoIbll.GetAny();
  745. return Success(result);
  746. }
  747. [HttpGet]
  748. public ActionResult GetEmpAccount()
  749. {
  750. var result = userIBLL.GetAny();
  751. return Success(result);
  752. }
  753. [HttpGet]
  754. public ActionResult GetCdDept()
  755. {
  756. var result = cdDeptIBLL.GetAny();
  757. return Success(result);
  758. }
  759. [HttpGet]
  760. public ActionResult GetMajor()
  761. {
  762. var result = majorIBLL.GetAny();
  763. return Success(result);
  764. }
  765. [HttpGet]
  766. public ActionResult GetLesson()
  767. {
  768. var result = infoIBLL.GetAny();
  769. return Success(result);
  770. }
  771. [HttpGet]
  772. public ActionResult GetClassroomBuilding()
  773. {
  774. var result = classroomBuildingIBLL.GetAny();
  775. return Success(result);
  776. }
  777. [HttpGet]
  778. public ActionResult GetClassroomInfo()
  779. {
  780. var result = classroomInfoIBLL.GetAny();
  781. return Success(result);
  782. }
  783. [HttpGet]
  784. public ActionResult GetClassInfo()
  785. {
  786. var result = classInfoIBLL.GetAny();
  787. return Success(result);
  788. }
  789. [HttpGet]
  790. public ActionResult GetStudentInfo()
  791. {
  792. var result = stuInfoBasicIbll.GetAny();
  793. return Success(result);
  794. }
  795. [HttpGet]
  796. public ActionResult GetStuAccount()
  797. {
  798. var result = userIBLL.GetStuAny();
  799. return Success(result);
  800. }
  801. [HttpGet]
  802. public ActionResult GetArrangeLesson()
  803. {
  804. var result = arrangeLessonTermIBLL.GetAny();
  805. return Success(result);
  806. }
  807. [HttpGet]
  808. public ActionResult GetArrangeExam()
  809. {
  810. var result = arrangeExamTermIBLL.GetAny();
  811. return Success(result);
  812. }
  813. [HttpGet]
  814. public ActionResult GetStuScore()
  815. {
  816. var result = stuScoreIBLL.GetAny();
  817. return Success(result);
  818. }
  819. #endregion
  820. private string GetIP()
  821. {
  822. //string ip = string.Empty;
  823. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  824. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  825. //if (string.IsNullOrEmpty(ip))
  826. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  827. //return ip;
  828. string userIP = "未获取用户IP";
  829. try
  830. {
  831. if (System.Web.HttpContext.Current == null
  832. || System.Web.HttpContext.Current.Request == null
  833. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  834. {
  835. return "";
  836. }
  837. string CustomerIP = "";
  838. //CDN加速后取到的IP simone 090805
  839. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  840. if (!string.IsNullOrEmpty(CustomerIP))
  841. {
  842. return CustomerIP;
  843. }
  844. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  845. if (!String.IsNullOrEmpty(CustomerIP))
  846. {
  847. return CustomerIP;
  848. }
  849. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  850. {
  851. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  852. if (CustomerIP == null)
  853. {
  854. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  855. }
  856. }
  857. else
  858. {
  859. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  860. }
  861. if (string.Compare(CustomerIP, "unknown", true) == 0 || String.IsNullOrEmpty(CustomerIP))
  862. {
  863. return System.Web.HttpContext.Current.Request.UserHostAddress;
  864. }
  865. return CustomerIP;
  866. }
  867. catch { }
  868. return userIP;
  869. }
  870. }
  871. }