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.
 
 
 
 
 
 

1052 lines
44 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. public ActionResult CancelWeiXinBindForm()
  664. {
  665. return View();
  666. }
  667. /// <summary>
  668. /// 解绑微信
  669. /// </summary>
  670. /// <returns></returns>
  671. [HttpPost]
  672. [AjaxOnly]
  673. public ActionResult CancelWeiXinBind(string keyValue, string codeType, string verifycode)
  674. {
  675. //短信验证码校验
  676. if (string.IsNullOrEmpty(codeType))
  677. {
  678. return Fail("未指定短信类型。");
  679. }
  680. var userId = LoginUserInfo.Get().userId;
  681. var mobile = userIBLL.GetEntityByUserId(userId)?.F_Mobile;
  682. if (string.IsNullOrEmpty(mobile))
  683. {
  684. return Fail("手机号不能为空。");
  685. }
  686. var code = redisCache.Read<string>("sendcodeinpc_" + codeType + "_" + mobile, CacheId.sms);
  687. if (!string.IsNullOrEmpty(code) && code == verifycode)
  688. {
  689. //return Success("验证成功。");
  690. if (!string.IsNullOrEmpty(keyValue))
  691. {
  692. userId = keyValue;
  693. }
  694. //更新openid
  695. userIBLL.UpdateWeixinOpenIdPC(userId, "");
  696. return Success("解绑成功");
  697. }
  698. else
  699. {
  700. return Fail("验证失败,验证码错误或已失效。");
  701. }
  702. }
  703. /// <summary>
  704. /// 发送短信验证码
  705. /// </summary>
  706. /// <param name="codeType">发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;</param>
  707. /// <param name="phone">手机号</param>
  708. /// <returns></returns>
  709. [HttpPost]
  710. public ActionResult Sendcode(string codeType)
  711. {
  712. if (string.IsNullOrEmpty(codeType))
  713. {
  714. return Fail("未指定短信类型。");
  715. }
  716. UserEntity userEntity = null;
  717. userEntity = userIBLL.GetEntityByUserId(LoginUserInfo.Get().userId);
  718. if (userEntity == null)
  719. {
  720. return Fail("用户不存在!");
  721. }
  722. if (string.IsNullOrEmpty(userEntity.F_Mobile))
  723. {
  724. return Fail("用户手机号不存在!");
  725. }
  726. if (!CommonHelper.IsValidMobile(userEntity.F_Mobile))
  727. {
  728. return Fail("手机号格式不正确!");
  729. }
  730. //todo:待取消注释
  731. //string raRndNum = Learun.Util.CommonHelper.RndNum(6);
  732. string raRndNum = "123456";
  733. var listStr = new List<string>();
  734. var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
  735. listStr.Add(str1);
  736. //todo:待开发短信平台
  737. //var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
  738. //if (result.Result.code == "0")
  739. if (true)
  740. {
  741. redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms);
  742. //日志
  743. LogEntity logEntity = new LogEntity();
  744. logEntity.F_CategoryId = 3;
  745. logEntity.F_SourceObjectId = codeType;
  746. logEntity.F_OperateTypeId = "sms";
  747. logEntity.F_OperateType = "sms";
  748. logEntity.F_OperateAccount = "system";
  749. logEntity.F_ExecuteResult = 200;
  750. logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
  751. logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
  752. logEntity.WriteLog();
  753. return Success("短信发送成功:");// + result.Result.message);
  754. }
  755. else
  756. {
  757. LogEntity logEntity = new LogEntity();
  758. logEntity.F_CategoryId = 4;
  759. logEntity.F_SourceObjectId = codeType;
  760. logEntity.F_OperateTypeId = "sms";
  761. logEntity.F_OperateType = "sms";
  762. logEntity.F_OperateAccount = "system";
  763. logEntity.F_ExecuteResult = 400;
  764. //logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
  765. //logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
  766. //logEntity.WriteLog();
  767. //return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
  768. }
  769. }
  770. #endregion
  771. /// <summary>
  772. /// 访问功能
  773. /// </summary>
  774. /// <param name="moduleId">功能Id</param>
  775. /// <param name="moduleName">功能模块</param>
  776. /// <param name="moduleUrl">访问路径</param>
  777. /// <returns></returns>
  778. [HttpPost]
  779. public ActionResult VisitModule(string moduleName, string moduleUrl)
  780. {
  781. UserInfo userInfo = LoginUserInfo.Get();
  782. LogEntity logEntity = new LogEntity();
  783. logEntity.F_CategoryId = 2;
  784. logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
  785. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
  786. logEntity.F_OperateAccount = userInfo.account;
  787. logEntity.F_OperateUserId = userInfo.userId;
  788. logEntity.F_Module = moduleName;
  789. logEntity.F_ExecuteResult = 1;
  790. logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
  791. logEntity.F_Description = "PC端";
  792. logEntity.WriteLog();
  793. return Success("ok");
  794. }
  795. #region 系统数据初始化
  796. public ActionResult DataBaseInit()
  797. {
  798. return View();
  799. }
  800. [HttpPost]
  801. public ActionResult DoDataBaseInit()
  802. {
  803. databaseInitIBLL.InitDatabase();
  804. return Success("初始化成功");
  805. }
  806. #endregion
  807. #region 获取数据
  808. [HttpGet]
  809. public ActionResult GetYearAndSemesteResult()
  810. {
  811. var result = TwoDevelopment.EducationalAdministration.Common.GetSemesterAndYear();
  812. return Success(result);
  813. }
  814. [HttpGet]
  815. public ActionResult GetDgree(string moduleID)
  816. {
  817. var result = dgreeIBLL.GetDgreeEntityByModuleID(moduleID);
  818. return Success(result);
  819. }
  820. [HttpGet]
  821. public ActionResult GetCompanyDgree()
  822. {
  823. var result = companyIbll.GetAny();
  824. return Success(result);
  825. }
  826. [HttpGet]
  827. public ActionResult GetDepartment()
  828. {
  829. var result = departmentIBLL.GetAny();
  830. return Success(result);
  831. }
  832. [HttpGet]
  833. public ActionResult GetPost()
  834. {
  835. var result = postIBLL.GetAny();
  836. return Success(result);
  837. }
  838. [HttpGet]
  839. public ActionResult GetEmpInfo()
  840. {
  841. var result = empInfoIbll.GetAny();
  842. return Success(result);
  843. }
  844. [HttpGet]
  845. public ActionResult GetEmpAccount()
  846. {
  847. var result = userIBLL.GetAny();
  848. return Success(result);
  849. }
  850. [HttpGet]
  851. public ActionResult GetCdDept()
  852. {
  853. var result = cdDeptIBLL.GetAny();
  854. return Success(result);
  855. }
  856. [HttpGet]
  857. public ActionResult GetMajor()
  858. {
  859. var result = majorIBLL.GetAny();
  860. return Success(result);
  861. }
  862. [HttpGet]
  863. public ActionResult GetLesson()
  864. {
  865. var result = infoIBLL.GetAny();
  866. return Success(result);
  867. }
  868. [HttpGet]
  869. public ActionResult GetClassroomBuilding()
  870. {
  871. var result = classroomBuildingIBLL.GetAny();
  872. return Success(result);
  873. }
  874. [HttpGet]
  875. public ActionResult GetClassroomInfo()
  876. {
  877. var result = classroomInfoIBLL.GetAny();
  878. return Success(result);
  879. }
  880. [HttpGet]
  881. public ActionResult GetClassInfo()
  882. {
  883. var result = classInfoIBLL.GetAny();
  884. return Success(result);
  885. }
  886. [HttpGet]
  887. public ActionResult GetStudentInfo()
  888. {
  889. var result = stuInfoBasicIbll.GetAny();
  890. return Success(result);
  891. }
  892. [HttpGet]
  893. public ActionResult GetStuAccount()
  894. {
  895. var result = userIBLL.GetStuAny();
  896. return Success(result);
  897. }
  898. [HttpGet]
  899. public ActionResult GetArrangeLesson()
  900. {
  901. var result = arrangeLessonTermIBLL.GetAny();
  902. return Success(result);
  903. }
  904. [HttpGet]
  905. public ActionResult GetArrangeExam()
  906. {
  907. var result = arrangeExamTermIBLL.GetAny();
  908. return Success(result);
  909. }
  910. [HttpGet]
  911. public ActionResult GetStuScore()
  912. {
  913. var result = stuScoreIBLL.GetAny();
  914. return Success(result);
  915. }
  916. #endregion
  917. private string GetIP()
  918. {
  919. //string ip = string.Empty;
  920. //if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  921. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  922. //if (string.IsNullOrEmpty(ip))
  923. // ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  924. //return ip;
  925. string userIP = "未获取用户IP";
  926. try
  927. {
  928. if (System.Web.HttpContext.Current == null
  929. || System.Web.HttpContext.Current.Request == null
  930. || System.Web.HttpContext.Current.Request.ServerVariables == null)
  931. {
  932. return "";
  933. }
  934. string CustomerIP = "";
  935. //CDN加速后取到的IP simone 090805
  936. CustomerIP = System.Web.HttpContext.Current.Request.Headers["Cdn-Src-Ip"];
  937. if (!string.IsNullOrEmpty(CustomerIP))
  938. {
  939. return CustomerIP;
  940. }
  941. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  942. if (!String.IsNullOrEmpty(CustomerIP))
  943. {
  944. return CustomerIP;
  945. }
  946. if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
  947. {
  948. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  949. if (CustomerIP == null)
  950. {
  951. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  952. }
  953. }
  954. else
  955. {
  956. CustomerIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
  957. }
  958. if (string.Compare(CustomerIP, "unknown", true) == 0 || String.IsNullOrEmpty(CustomerIP))
  959. {
  960. return System.Web.HttpContext.Current.Request.UserHostAddress;
  961. }
  962. return CustomerIP;
  963. }
  964. catch { }
  965. return userIP;
  966. }
  967. }
  968. }