Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

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