Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

844 Zeilen
37 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.OA;
  3. using Learun.Application.Organization;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using Learun.Application.TwoDevelopment.Permission;
  6. using Learun.Application.WorkFlow;
  7. using Learun.Util;
  8. using Learun.Util.Operat;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Configuration;
  12. using System.Linq;
  13. using System.Web;
  14. using System.Web.Mvc;
  15. using Learun.Cache.Base;
  16. using Learun.Cache.Factory;
  17. using Newtonsoft.Json;
  18. namespace Learun.Application.Web.Controllers
  19. {
  20. [HandlerLogin(FilterMode.Ignore)]
  21. public class SSOSystemController : MvcControllerBase
  22. {
  23. private Perm_FunctionIBLL perm_FunctionIBLL = new Perm_FunctionBLL();
  24. Perm_UserPermissionIBLL permUserPermissionIbll = new Perm_UserPermissionBLL();
  25. private ModuleIBLL moduleIBLL = new ModuleBLL();
  26. private SYS_ReceiveMessageIBLL sYS_ReceiveMessageIBLL = new SYS_ReceiveMessageBLL();
  27. private UserIBLL userBll = new UserBLL();
  28. private WfTaskIBLL wfTaskIBLL = new WfTaskBLL();
  29. private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
  30. private NoticeIBLL newsIBLL = new NoticeBLL();
  31. private Perm_FunctionTypeIBLL perm_FunctionTypeIBLL = new Perm_FunctionTypeBLL();
  32. private DataItemIBLL dataItemIBLL = new DataItemBLL();
  33. private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL();
  34. AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  35. private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();
  36. private Perm_FunctionVisitIBLL functionVisitIbll = new Perm_FunctionVisitBLL();
  37. private ICache redisCache = CacheFactory.CaChe();
  38. #region 统一身份认证2.0
  39. /// <summary>
  40. /// 获取统一认证用户信息
  41. /// </summary>
  42. /// <returns></returns>
  43. public ActionResult authorize()
  44. {
  45. string appid = Request.QueryString["appid"];
  46. string secret = Request.QueryString["secret"];
  47. string appkey = Request.QueryString["appkey"];
  48. if (string.IsNullOrEmpty(appid))
  49. {
  50. return Fail("参数:appid不能为空");
  51. }
  52. if (string.IsNullOrEmpty(secret))
  53. {
  54. return Fail("参数:secret不能为空");
  55. }
  56. if (string.IsNullOrEmpty(appkey))
  57. {
  58. return Fail("参数:appkey不能为空");
  59. }
  60. var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid);
  61. if (application != null)
  62. {
  63. if (Util.DESEncrypt.Decrypt(application.FSecret,
  64. ConfigurationManager.AppSettings["SSOPublicSecret"]).Equals(secret))
  65. {
  66. try
  67. {
  68. var code = DESEncrypt.Decrypt(appkey, "bjqjsso");
  69. if (!string.IsNullOrEmpty(redisCache.Read<string>(code)))
  70. {
  71. return Success(new { useraccount = redisCache.Read<string>(code) });
  72. }
  73. else
  74. {
  75. return Fail("appkey已过期");
  76. }
  77. }
  78. catch (Exception e)
  79. {
  80. return Fail("appkey错误");
  81. }
  82. }
  83. else
  84. {
  85. return Fail("secret错误");
  86. }
  87. }
  88. else
  89. return Fail("未授权的appid");
  90. }
  91. #endregion
  92. public ActionResult Index()
  93. {
  94. string account = "";
  95. if (!Request.Headers["account"].IsEmpty())
  96. {
  97. account = Request.Headers["account"].ToString();
  98. }
  99. OperatorHelper helper = new OperatorHelper();
  100. var result = helper.IsOnLine(account);
  101. if (result.stateCode != 1)
  102. {
  103. return Redirect("NoLogin");
  104. }
  105. var userinfo = LoginUserInfo.Get();
  106. var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
  107. var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
  108. var allCount = 0;
  109. foreach (var flow in flowType)
  110. {
  111. var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
  112. flow.FlowCount = count;
  113. allCount += count;
  114. }
  115. ViewBag.AllCount = allCount;
  116. ViewBag.FlowType = flowType;
  117. ViewBag.FlowList = JsonConvert.SerializeObject(flowList);
  118. List<ModuleEntity> list = new List<ModuleEntity>();
  119. List<string> offenused = LogBLL.GetGroupLog(userinfo.userId).Select(m => m.F_Module).Take(20).ToList();
  120. var data = moduleIBLL.GetModuleList().Where(m => m.F_EnabledMark == 1 && m.F_DeleteMark == 0 && !string.IsNullOrEmpty(m.F_UrlAddress));
  121. foreach (var oitem in offenused)
  122. {
  123. ModuleEntity fod = data.FirstOrDefault(m => m.F_FullName == oitem);
  124. if (fod != null)
  125. {
  126. list.Add(fod);
  127. }
  128. }
  129. //常用服务
  130. ViewBag.Offenused = list.Take(12);
  131. //内部邮件
  132. Pagination paginationobj = new Pagination() { rows = 5, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
  133. var maildata = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
  134. ViewBag.LanMail = maildata;
  135. ViewBag.LanMailUnRead = maildata.Count(m => m.READFLAG == 0);
  136. //办公事项
  137. paginationobj.sidx = "F_CreateDate";
  138. //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
  139. ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
  140. //公告
  141. List<NewsEntity> outnewslist = new List<NewsEntity>();
  142. paginationobj.rows = 100;
  143. var newsList = newsIBLL.GetList("", userinfo.userId);
  144. foreach (var newsitemEntity in newsList)
  145. {
  146. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  147. {
  148. if (!string.IsNullOrEmpty(userinfo.postIds))
  149. {
  150. if (userinfo.postIds.Contains(","))
  151. {
  152. foreach (var postid in userinfo.postIds.Split(','))
  153. {
  154. if (newsitemEntity.F_SendPostId.Contains(postid))
  155. {
  156. outnewslist.Add(newsitemEntity);
  157. break;
  158. }
  159. }
  160. }
  161. else
  162. {
  163. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  164. {
  165. outnewslist.Add(newsitemEntity);
  166. }
  167. }
  168. }
  169. }
  170. else
  171. {
  172. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  173. {
  174. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  175. {
  176. outnewslist.Add(newsitemEntity);
  177. }
  178. }
  179. else
  180. {
  181. outnewslist.Add(newsitemEntity);
  182. }
  183. }
  184. }
  185. //公文
  186. paginationobj.sidx = "SendTime";
  187. paginationobj.rows = 5;
  188. ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
  189. ViewBag.NewsList = outnewslist;
  190. //底部办公事项
  191. ViewBag.FunctionTypeList = perm_FunctionTypeIBLL.GetListByUserId(userinfo.userId).OrderBy(m => m.FTOrder).Take(7);
  192. var userfunctionlist = perm_FunctionIBLL.GetListByUserId(userinfo.userId);
  193. foreach (var ufitem in userfunctionlist)
  194. {
  195. if (!string.IsNullOrEmpty(ufitem.FImage))
  196. {
  197. var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.FImage)?.F_FilePath;
  198. if (!string.IsNullOrEmpty(imagePath))
  199. {
  200. ufitem.FImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
  201. }
  202. }
  203. }
  204. ViewBag.FunctionList = userfunctionlist;
  205. ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  206. return View();
  207. }
  208. public ActionResult NoLogin()
  209. {
  210. var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
  211. var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
  212. var allCount = 0;
  213. foreach (var flow in flowType)
  214. {
  215. var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
  216. flow.FlowCount = count;
  217. allCount += count;
  218. }
  219. ViewBag.AllCount = allCount;
  220. ViewBag.FlowType = flowType;
  221. ViewBag.FlowList = JsonConvert.SerializeObject(flowList);
  222. return View();
  223. }
  224. private UserService userService = new UserService();
  225. public ActionResult ResetPWD(string password)
  226. {
  227. password = Md5Helper.Encrypt(password, 32);
  228. userService.RevisePassword("System", password);
  229. return Success("修改成功");
  230. }
  231. [HandlerLogin(FilterMode.Enforce)]
  232. public ActionResult Work()
  233. {
  234. ViewBag.FlowType = dataItemIBLL.GetDetailList("FlowSort", "");
  235. ViewBag.FlowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
  236. return View();
  237. }
  238. //[HandlerLogin(FilterMode.Enforce)]
  239. public ActionResult workTwo()
  240. {
  241. var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
  242. var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
  243. var allCount = 0;
  244. foreach (var flow in flowType)
  245. {
  246. var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
  247. flow.FlowCount = count;
  248. allCount += count;
  249. }
  250. ViewBag.AllCount = allCount;
  251. ViewBag.FlowType = flowType;
  252. ViewBag.FlowList = flowList;
  253. return View();
  254. }
  255. [HandlerLogin(FilterMode.Enforce)]
  256. public ActionResult UserService()
  257. {
  258. ViewBag.FlowType = dataItemIBLL.GetDetailList("FlowSort", "");
  259. ViewBag.FlowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
  260. return View();
  261. }
  262. [HandlerLogin(FilterMode.Enforce)]
  263. public ActionResult NewsList()
  264. {
  265. var userinfo = LoginUserInfo.Get();
  266. int page = 1;
  267. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  268. {
  269. page = Convert.ToInt32(Request.QueryString["page"]);
  270. }
  271. //公告
  272. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
  273. paginationobj.rows = 100;
  274. var newsList = newsIBLL.GetList("", userinfo.userId);
  275. //用户可以看到的通知公告
  276. var newsListSelf = new List<NewsEntity>();
  277. foreach (var newsitemEntity in newsList)
  278. {
  279. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  280. {
  281. if (!string.IsNullOrEmpty(userinfo.postIds))
  282. {
  283. if (userinfo.postIds.Contains(","))
  284. {
  285. foreach (var postid in userinfo.postIds.Split(','))
  286. {
  287. if (newsitemEntity.F_SendPostId.Contains(postid))
  288. {
  289. newsListSelf.Add(newsitemEntity);
  290. break;
  291. }
  292. }
  293. }
  294. else
  295. {
  296. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  297. {
  298. newsListSelf.Add(newsitemEntity);
  299. }
  300. }
  301. }
  302. }
  303. else
  304. {
  305. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  306. {
  307. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  308. {
  309. newsListSelf.Add(newsitemEntity);
  310. }
  311. }
  312. else
  313. {
  314. newsListSelf.Add(newsitemEntity);
  315. }
  316. }
  317. }
  318. foreach (var ufitem in newsListSelf)
  319. {
  320. if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
  321. {
  322. if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
  323. {
  324. var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
  325. if (!string.IsNullOrEmpty(imagePath))
  326. {
  327. ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
  328. }
  329. else
  330. {
  331. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  332. }
  333. }
  334. else
  335. {
  336. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  337. }
  338. }
  339. else
  340. {
  341. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  342. }
  343. }
  344. ViewBag.NewsList = newsListSelf;
  345. return View(paginationobj);
  346. }
  347. [HandlerLogin(FilterMode.Enforce)]
  348. public ActionResult newsTwo()
  349. {
  350. var userinfo = LoginUserInfo.Get();
  351. int page = 1;
  352. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  353. {
  354. page = Convert.ToInt32(Request.QueryString["page"]);
  355. }
  356. //公告
  357. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
  358. var newsList = newsIBLL.GetList("", userinfo.userId);
  359. //用户可以看到的通知公告
  360. var newsListSelf = new List<NewsEntity>();
  361. foreach (var newsitemEntity in newsList)
  362. {
  363. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  364. {
  365. if (!string.IsNullOrEmpty(userinfo.postIds))
  366. {
  367. if (userinfo.postIds.Contains(","))
  368. {
  369. foreach (var postid in userinfo.postIds.Split(','))
  370. {
  371. if (newsitemEntity.F_SendPostId.Contains(postid))
  372. {
  373. newsListSelf.Add(newsitemEntity);
  374. break;
  375. }
  376. }
  377. }
  378. else
  379. {
  380. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  381. {
  382. newsListSelf.Add(newsitemEntity);
  383. }
  384. }
  385. }
  386. }
  387. else
  388. {
  389. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  390. {
  391. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  392. {
  393. newsListSelf.Add(newsitemEntity);
  394. }
  395. }
  396. else
  397. {
  398. newsListSelf.Add(newsitemEntity);
  399. }
  400. }
  401. }
  402. foreach (var ufitem in newsListSelf)
  403. {
  404. if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
  405. {
  406. if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
  407. {
  408. var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
  409. if (!string.IsNullOrEmpty(imagePath))
  410. {
  411. ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
  412. }
  413. else
  414. {
  415. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  416. }
  417. }
  418. else
  419. {
  420. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  421. }
  422. }
  423. else
  424. {
  425. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  426. }
  427. }
  428. //公告
  429. ViewBag.NewsList = newsListSelf;
  430. //内部邮件
  431. paginationobj.sidx = "readflag asc,SENDTIME desc ";
  432. ViewBag.LanMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
  433. //办公事项
  434. paginationobj.sidx = "F_CreateDate";
  435. //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
  436. ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
  437. //学校公文
  438. paginationobj.sidx = "SendTime";
  439. ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
  440. return View();
  441. }
  442. public PartialViewResult LanMail()
  443. {
  444. var userinfo = LoginUserInfo.Get();
  445. int page = 1;
  446. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  447. {
  448. page = Convert.ToInt32(Request.QueryString["page"]);
  449. }
  450. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "readflag asc,SENDTIME desc", sord = "desc" };
  451. ViewBag.LanMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
  452. return PartialView(paginationobj);
  453. }
  454. public PartialViewResult TaskList()
  455. {
  456. var userinfo = LoginUserInfo.Get();
  457. int page = 1;
  458. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  459. {
  460. page = Convert.ToInt32(Request.QueryString["page"]);
  461. }
  462. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
  463. ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
  464. //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
  465. return PartialView(paginationobj);
  466. }
  467. public PartialViewResult ReceiveFileList()
  468. {
  469. var userinfo = LoginUserInfo.Get();
  470. int page = 1;
  471. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  472. {
  473. page = Convert.ToInt32(Request.QueryString["page"]);
  474. }
  475. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "SendTime", sord = "desc" };
  476. ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
  477. return PartialView(paginationobj);
  478. }
  479. public PartialViewResult NewList()
  480. {
  481. var userinfo = LoginUserInfo.Get();
  482. int page = 1;
  483. if (!string.IsNullOrEmpty(Request.QueryString["page"]))
  484. {
  485. page = Convert.ToInt32(Request.QueryString["page"]);
  486. }
  487. //公告
  488. Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
  489. var newsList = newsIBLL.GetList("", userinfo.userId);
  490. //用户可以看到的通知公告
  491. var newsListSelf = new List<NewsEntity>();
  492. foreach (var newsitemEntity in newsList)
  493. {
  494. if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  495. {
  496. if (!string.IsNullOrEmpty(userinfo.postIds))
  497. {
  498. if (userinfo.postIds.Contains(","))
  499. {
  500. foreach (var postid in userinfo.postIds.Split(','))
  501. {
  502. if (newsitemEntity.F_SendPostId.Contains(postid))
  503. {
  504. newsListSelf.Add(newsitemEntity);
  505. break;
  506. }
  507. }
  508. }
  509. else
  510. {
  511. if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  512. {
  513. newsListSelf.Add(newsitemEntity);
  514. }
  515. }
  516. }
  517. }
  518. else
  519. {
  520. if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  521. {
  522. if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  523. {
  524. newsListSelf.Add(newsitemEntity);
  525. }
  526. }
  527. else
  528. {
  529. newsListSelf.Add(newsitemEntity);
  530. }
  531. }
  532. }
  533. foreach (var ufitem in newsListSelf)
  534. {
  535. if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
  536. {
  537. if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
  538. {
  539. var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
  540. if (!string.IsNullOrEmpty(imagePath))
  541. {
  542. ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
  543. }
  544. else
  545. {
  546. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  547. }
  548. }
  549. else
  550. {
  551. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  552. }
  553. }
  554. else
  555. {
  556. ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
  557. }
  558. }
  559. //公告
  560. ViewBag.NewsList = newsListSelf;
  561. return PartialView(paginationobj);
  562. }
  563. [HandlerLogin(FilterMode.Enforce)]
  564. public ActionResult NewsDetail()
  565. {
  566. return View();
  567. }
  568. public ActionResult Check()
  569. {
  570. try
  571. {
  572. string redi = Request.QueryString["redi"];
  573. if (!string.IsNullOrEmpty(redi))
  574. {
  575. string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  576. string uid = Request.QueryString["u"];
  577. string pwd = Request.QueryString["p"];
  578. string logintime = Request.QueryString["t"];
  579. string n = Request.QueryString["n"];
  580. string mail = Request.QueryString["mail"];
  581. string sendfile = Request.QueryString["sendfile"];
  582. string task = Request.QueryString["task"];
  583. string gotomain = Request.QueryString["gotomain"];
  584. string nk = Request.QueryString["nk"];
  585. string jx = Request.QueryString["jx"];
  586. string zl = Request.QueryString["zl"];
  587. if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(logintime))
  588. {
  589. decimal decodelogintime = Convert.ToDecimal(DESEncrypt.Decrypt(logintime, publickey));
  590. decimal datetimenow = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss"));
  591. if (datetimenow - 300 <= decodelogintime && datetimenow + 300 >= decodelogintime)
  592. {
  593. string username = DESEncrypt.Decrypt(uid, publickey);
  594. string password = DESEncrypt.Decrypt(pwd, publickey);
  595. UserEntity userEntity = userBll.CheckLogin(username, Md5Helper.Encrypt(password, 32));
  596. LogEntity logEntity = new LogEntity();
  597. logEntity.F_CategoryId = 1;
  598. logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
  599. logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
  600. logEntity.F_OperateAccount = username + "(" + userEntity.F_RealName + ")";
  601. logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : username;
  602. logEntity.F_Module = Config.GetValue("SoftName");
  603. logEntity.F_Description = "PC端";
  604. if (!userEntity.LoginOk)//登录失败
  605. {
  606. //写入日志
  607. logEntity.F_ExecuteResult = 0;
  608. logEntity.F_ExecuteResultJson = "sso登录失败:" + userEntity.LoginMsg;
  609. logEntity.WriteLog();
  610. return Fail(userEntity.LoginMsg);
  611. }
  612. else
  613. {
  614. OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
  615. //写入日志
  616. logEntity.F_ExecuteResult = 1;
  617. logEntity.F_ExecuteResultJson = "sso登录成功";
  618. logEntity.WriteLog();
  619. var DigitalschoolMisLoginurl = ConfigurationManager.AppSettings["DigitalschoolMisLoginurl"];
  620. var Returnurl = "http://" + Request.Url.Host + ":" + Request.Url.Port;
  621. if (!string.IsNullOrEmpty(n))
  622. {
  623. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=6252983c-52f5-402c-991b-ad19a9cb1f94&keyValue=" + n));
  624. }
  625. else if (!string.IsNullOrEmpty(mail))
  626. {
  627. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=252878d7-d807-497f-b01e-839bb1b869c6"));
  628. }
  629. else if (!string.IsNullOrEmpty(sendfile))
  630. {
  631. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=19637c39-624d-4be6-b680-04250f8df71f"));
  632. }
  633. else if (!string.IsNullOrEmpty(task))
  634. {
  635. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=56ce34c2-882e-47d1-b12d-5036e3b79fcf"));
  636. }
  637. else if (!string.IsNullOrEmpty(gotomain))
  638. {
  639. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index"));
  640. }
  641. else if (!string.IsNullOrEmpty(nk))
  642. {
  643. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=07ceccd0-cf74-42ec-9b7d-3b36af0be451"));
  644. }
  645. else if (!string.IsNullOrEmpty(jx))
  646. {
  647. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=5f2e3e9b-b0da-421a-b370-671dcae4fc17"));
  648. }
  649. else if (!string.IsNullOrEmpty(zl))
  650. {
  651. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=8dfd9f38-8cab-49ff-b4d1-8b899b1ecbca"));
  652. }
  653. else
  654. {
  655. return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + Returnurl + "/SSOSystem/Index");
  656. }
  657. }
  658. }
  659. else
  660. {
  661. return Fail("时间戳验证失败");
  662. }
  663. }
  664. else
  665. {
  666. return Fail("参数错误");
  667. }
  668. }
  669. else
  670. {
  671. return View();
  672. }
  673. }
  674. catch (Exception e)
  675. {
  676. return Fail("参数错误");
  677. }
  678. }
  679. public ActionResult FirstLogin(Perm_FunctionEntity up)
  680. {
  681. string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  682. if (up != null && !string.IsNullOrEmpty(up.UPId))
  683. {
  684. perm_FunctionIBLL.SaveEntityByUPId(up.UPId, up);
  685. return Redirect("/SSOSystem/GoTo?sysid=" + DESEncrypt.Encrypt(up.FId, publickey) + "&openid=" + DESEncrypt.Encrypt(up.UserId, publickey));
  686. }
  687. string sysid = Request.QueryString["sysid"];
  688. string strsysid = DESEncrypt.Decrypt(sysid, publickey);
  689. string openid = Request.QueryString["openid"];
  690. string userid = DESEncrypt.Decrypt(openid, publickey);
  691. var uplist = permUserPermissionIbll.GetPerm_UserPermissionEntityByFIdAndUid(strsysid, userid);
  692. if (uplist == null)
  693. {
  694. return Fail("用户未授权。");
  695. }
  696. var perfun = perm_FunctionIBLL.GetPerm_FunctionEntityByUPId(uplist.UPId);
  697. return View(perfun);
  698. }
  699. public ActionResult GoTo()
  700. {
  701. try
  702. {
  703. string redi = Request.QueryString["redi"];
  704. if (!string.IsNullOrEmpty(redi))
  705. {
  706. string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
  707. string sysid = Request.QueryString["sysid"];
  708. string strsysid = DESEncrypt.Decrypt(sysid, publickey);
  709. string openid = Request.QueryString["openid"];
  710. string userid = DESEncrypt.Decrypt(openid, publickey);
  711. var uplist = permUserPermissionIbll.GetPerm_UserPermissionEntityByFIdAndUid(strsysid, userid);
  712. Perm_FunctionVisitEntity functionVisitEntity = new Perm_FunctionVisitEntity();
  713. functionVisitEntity.Create();
  714. functionVisitEntity.Fid = strsysid;
  715. functionVisitEntity.PDate = DateTime.Now;
  716. functionVisitEntity.PUId = userid;
  717. var userinfo = userBll.GetEntityByUserId(userid);
  718. functionVisitEntity.PUName = userinfo.F_RealName;
  719. if (uplist == null)
  720. {
  721. functionVisitEntity.PIsLoginSuccess = false;
  722. functionVisitEntity.PContent = "用户未授权";
  723. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  724. return Fail("用户未授权。");
  725. }
  726. var perfun = perm_FunctionIBLL.GetPerm_FunctionEntityByUPId(uplist.UPId);
  727. string secretkey = DESEncrypt.Decrypt(perfun.FSecret, publickey);
  728. if (perfun.FIsManagePage == true)
  729. {
  730. if (!string.IsNullOrEmpty(perfun.FInterfaceUrl))
  731. {
  732. if (!string.IsNullOrEmpty(perfun.UPUserName) && !string.IsNullOrEmpty(perfun.UPPass))
  733. {
  734. functionVisitEntity.PIsLoginSuccess = true;
  735. functionVisitEntity.PContent = "成功转到统一认证网站:" + perfun.FUrl;
  736. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  737. return Redirect(perfun.FInterfaceUrl + "?u=" + DESEncrypt.Encrypt(DESEncrypt.Encrypt(perfun.UPUserName, secretkey), publickey) + "&p=" + DESEncrypt.Encrypt(DESEncrypt.Encrypt(perfun.UPPass, secretkey), publickey) + "&t=" + DESEncrypt.Encrypt(DESEncrypt.Encrypt(DateTime.Now.ToString("yyyyMMddHHmmss"), secretkey), publickey) + "&ip=" + DESEncrypt.Encrypt(DESEncrypt.Encrypt(GetIP(), secretkey), publickey));
  738. }
  739. else
  740. {
  741. functionVisitEntity.PIsLoginSuccess = false;
  742. functionVisitEntity.PContent = "用户未配置转到用户名密码配置页面";
  743. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  744. //用户未配置转到用户名密码配置页面
  745. return Redirect("/SSOSystem/FirstLogin?sysid=" + sysid + "&openid=" + openid);
  746. }
  747. }
  748. else
  749. {
  750. functionVisitEntity.PIsLoginSuccess = false;
  751. functionVisitEntity.PContent = "未配置登录接口地址";
  752. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  753. return Fail("未配置登录接口地址。");
  754. }
  755. }
  756. else
  757. {
  758. if (!string.IsNullOrEmpty(perfun.FUrl))
  759. {
  760. functionVisitEntity.PIsLoginSuccess = true;
  761. functionVisitEntity.PContent = "成功转到统一认证网站:" + perfun.FUrl;
  762. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  763. return Redirect(perfun.FUrl);
  764. }
  765. else
  766. {
  767. functionVisitEntity.PIsLoginSuccess = false;
  768. functionVisitEntity.PContent = "未配置地址";
  769. functionVisitIbll.SaveEntity(null, functionVisitEntity);
  770. return Fail("未配置地址。");
  771. }
  772. }
  773. }
  774. else
  775. {
  776. return View();
  777. }
  778. }
  779. catch (Exception e)
  780. {
  781. return Fail("参数错误。");
  782. }
  783. }
  784. /// <summary>
  785. /// 获取IP
  786. /// </summary>
  787. /// <returns></returns>
  788. private string GetIP()
  789. {
  790. string ip = string.Empty;
  791. if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
  792. ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
  793. if (string.IsNullOrEmpty(ip))
  794. ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
  795. return ip;
  796. }
  797. }
  798. }