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