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.
 
 
 
 
 
 

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