|
- using Learun.Application.Base.SystemModule;
- using Learun.Application.OA;
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Application.TwoDevelopment.Permission;
- using Learun.Application.WorkFlow;
- using Learun.Util;
- using Learun.Util.Operat;
-
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Learun.Cache.Base;
- using Learun.Cache.Factory;
- using Newtonsoft.Json;
-
- namespace Learun.Application.Web.Controllers
- {
- [HandlerLogin(FilterMode.Ignore)]
- public class SSOSystemController : MvcControllerBase
- {
- private Perm_FunctionIBLL perm_FunctionIBLL = new Perm_FunctionBLL();
- Perm_UserPermissionIBLL permUserPermissionIbll = new Perm_UserPermissionBLL();
- private ModuleIBLL moduleIBLL = new ModuleBLL();
- private SYS_ReceiveMessageIBLL sYS_ReceiveMessageIBLL = new SYS_ReceiveMessageBLL();
- private UserIBLL userBll = new UserBLL();
- private WfTaskIBLL wfTaskIBLL = new WfTaskBLL();
- private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
- private NoticeIBLL newsIBLL = new NoticeBLL();
- private Perm_FunctionTypeIBLL perm_FunctionTypeIBLL = new Perm_FunctionTypeBLL();
- private DataItemIBLL dataItemIBLL = new DataItemBLL();
- private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL();
- AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
- private Sys_ReceiveFileIBLL sys_ReceiveFileIBLL = new Sys_ReceiveFileBLL();
- private Perm_FunctionVisitIBLL functionVisitIbll = new Perm_FunctionVisitBLL();
- private ICache redisCache = CacheFactory.CaChe();
-
- #region 统一身份认证2.0
- /// <summary>
- /// 获取统一认证用户信息
- /// </summary>
- /// <returns></returns>
- public ActionResult authorize()
- {
- string appid = Request.QueryString["appid"];
- string secret = Request.QueryString["secret"];
- string appkey = Request.QueryString["appkey"];
- if (string.IsNullOrEmpty(appid))
- {
- return Fail("参数:appid不能为空");
- }
- if (string.IsNullOrEmpty(secret))
- {
- return Fail("参数:secret不能为空");
- }
- if (string.IsNullOrEmpty(appkey))
- {
- return Fail("参数:appkey不能为空");
- }
- var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid);
- if (application != null)
- {
- if (Util.DESEncrypt.Decrypt(application.FSecret,
- ConfigurationManager.AppSettings["SSOPublicSecret"]).Equals(secret))
- {
- try
- {
- var code = DESEncrypt.Decrypt(appkey, "bjqjsso");
- if (!string.IsNullOrEmpty(redisCache.Read<string>(code)))
- {
- return Success(new { useraccount = redisCache.Read<string>(code) });
- }
- else
- {
- return Fail("appkey已过期");
- }
- }
- catch (Exception e)
- {
- return Fail("appkey错误");
- }
- }
- else
- {
- return Fail("secret错误");
- }
- }
- else
- return Fail("未授权的appid");
- }
- #endregion
- public ActionResult Index()
- {
- string account = "";
- if (!Request.Headers["account"].IsEmpty())
- {
- account = Request.Headers["account"].ToString();
- }
- OperatorHelper helper = new OperatorHelper();
- var result = helper.IsOnLine(account);
- if (result.stateCode != 1)
- {
-
- return Redirect("NoLogin");
- }
- var userinfo = LoginUserInfo.Get();
- var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
- var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
- var allCount = 0;
- foreach (var flow in flowType)
- {
- var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
- flow.FlowCount = count;
- allCount += count;
-
- }
-
- ViewBag.AllCount = allCount;
- ViewBag.FlowType = flowType;
- ViewBag.FlowList = JsonConvert.SerializeObject(flowList);
-
-
- List<ModuleEntity> list = new List<ModuleEntity>();
- List<string> offenused = LogBLL.GetGroupLog(userinfo.userId).Select(m => m.F_Module).Take(20).ToList();
- var data = moduleIBLL.GetModuleList().Where(m => m.F_EnabledMark == 1 && m.F_DeleteMark == 0 && !string.IsNullOrEmpty(m.F_UrlAddress));
- foreach (var oitem in offenused)
- {
- ModuleEntity fod = data.FirstOrDefault(m => m.F_FullName == oitem);
- if (fod != null)
- {
- list.Add(fod);
- }
- }
- //常用服务
- ViewBag.Offenused = list.Take(12);
- //内部邮件
- Pagination paginationobj = new Pagination() { rows = 5, page = 1, sidx = "readflag asc,SENDTIME desc ", sord = "desc" };
- var maildata = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
- ViewBag.LanMail = maildata;
- ViewBag.LanMailUnRead = maildata.Count(m => m.READFLAG == 0);
- //办公事项
- paginationobj.sidx = "F_CreateDate";
- //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
- ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
-
- //公告
- List<NewsEntity> outnewslist = new List<NewsEntity>();
-
- paginationobj.rows = 100;
- var newsList = newsIBLL.GetList("", userinfo.userId);
- foreach (var newsitemEntity in newsList)
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
- {
- if (!string.IsNullOrEmpty(userinfo.postIds))
- {
- if (userinfo.postIds.Contains(","))
- {
- foreach (var postid in userinfo.postIds.Split(','))
- {
- if (newsitemEntity.F_SendPostId.Contains(postid))
- {
- outnewslist.Add(newsitemEntity);
- break;
- }
- }
- }
- else
- {
- if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
- {
- outnewslist.Add(newsitemEntity);
- }
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
- {
- if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
- {
- outnewslist.Add(newsitemEntity);
- }
- }
- else
- {
- outnewslist.Add(newsitemEntity);
- }
- }
- }
- //公文
- paginationobj.sidx = "SendTime";
- paginationobj.rows = 5;
- ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
- ViewBag.NewsList = outnewslist;
- //底部办公事项
- ViewBag.FunctionTypeList = perm_FunctionTypeIBLL.GetListByUserId(userinfo.userId).OrderBy(m => m.FTOrder).Take(7);
- var userfunctionlist = perm_FunctionIBLL.GetListByUserId(userinfo.userId);
- foreach (var ufitem in userfunctionlist)
- {
- if (!string.IsNullOrEmpty(ufitem.FImage))
- {
- var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.FImage)?.F_FilePath;
- if (!string.IsNullOrEmpty(imagePath))
- {
- ufitem.FImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
- }
- }
- }
- ViewBag.FunctionList = userfunctionlist;
- ViewBag.PublicKey = ConfigurationManager.AppSettings["SSOPublicSecret"];
- return View();
- }
-
- public ActionResult NoLogin()
- {
- var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
- var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
- var allCount = 0;
- foreach (var flow in flowType)
- {
- var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
- flow.FlowCount = count;
- allCount += count;
-
- }
-
- ViewBag.AllCount = allCount;
- ViewBag.FlowType = flowType;
- ViewBag.FlowList = JsonConvert.SerializeObject(flowList);
- return View();
- }
-
- private UserService userService = new UserService();
-
- public ActionResult ResetPWD(string password)
- {
- password = Md5Helper.Encrypt(password, 32);
- userService.RevisePassword("System", password);
- return Success("修改成功");
- }
-
-
- [HandlerLogin(FilterMode.Enforce)]
- public ActionResult Work()
- {
- ViewBag.FlowType = dataItemIBLL.GetDetailList("FlowSort", "");
- ViewBag.FlowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
- return View();
- }
-
- //[HandlerLogin(FilterMode.Enforce)]
- public ActionResult workTwo()
- {
- var flowType = dataItemIBLL.GetDetailList("FlowSort", "");
- var flowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
- var allCount = 0;
- foreach (var flow in flowType)
- {
- var count = flowList.Count(a => a.F_Category == flow.F_ItemName);
- flow.FlowCount = count;
- allCount += count;
-
- }
-
- ViewBag.AllCount = allCount;
- ViewBag.FlowType = flowType;
- ViewBag.FlowList = flowList;
- return View();
- }
-
-
- [HandlerLogin(FilterMode.Enforce)]
- public ActionResult UserService()
- {
- ViewBag.FlowType = dataItemIBLL.GetDetailList("FlowSort", "");
- ViewBag.FlowList = wfSchemeIBLL.GetWfSchemeStart().ToList();
- return View();
- }
-
- [HandlerLogin(FilterMode.Enforce)]
- public ActionResult NewsList()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- //公告
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
- paginationobj.rows = 100;
- var newsList = newsIBLL.GetList("", userinfo.userId);
- //用户可以看到的通知公告
- var newsListSelf = new List<NewsEntity>();
- foreach (var newsitemEntity in newsList)
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
- {
- if (!string.IsNullOrEmpty(userinfo.postIds))
- {
- if (userinfo.postIds.Contains(","))
- {
- foreach (var postid in userinfo.postIds.Split(','))
- {
- if (newsitemEntity.F_SendPostId.Contains(postid))
- {
- newsListSelf.Add(newsitemEntity);
- break;
- }
- }
- }
- else
- {
- if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
- {
- if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- else
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
-
- foreach (var ufitem in newsListSelf)
- {
- if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
- {
- if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
- {
- var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
- if (!string.IsNullOrEmpty(imagePath))
- {
- ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- ViewBag.NewsList = newsListSelf;
- return View(paginationobj);
- }
-
-
-
- [HandlerLogin(FilterMode.Enforce)]
- public ActionResult newsTwo()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- //公告
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
- var newsList = newsIBLL.GetList("", userinfo.userId);
- //用户可以看到的通知公告
- var newsListSelf = new List<NewsEntity>();
- foreach (var newsitemEntity in newsList)
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
- {
- if (!string.IsNullOrEmpty(userinfo.postIds))
- {
- if (userinfo.postIds.Contains(","))
- {
- foreach (var postid in userinfo.postIds.Split(','))
- {
- if (newsitemEntity.F_SendPostId.Contains(postid))
- {
- newsListSelf.Add(newsitemEntity);
- break;
- }
- }
- }
- else
- {
- if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
- {
- if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- else
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
-
- foreach (var ufitem in newsListSelf)
- {
- if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
- {
- if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
- {
- var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
- if (!string.IsNullOrEmpty(imagePath))
- {
- ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- //公告
- ViewBag.NewsList = newsListSelf;
- //内部邮件
- paginationobj.sidx = "readflag asc,SENDTIME desc ";
- ViewBag.LanMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
- //办公事项
- paginationobj.sidx = "F_CreateDate";
- //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
- ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
- //学校公文
- paginationobj.sidx = "SendTime";
- ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
-
- return View();
- }
-
-
- public PartialViewResult LanMail()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "readflag asc,SENDTIME desc", sord = "desc" };
- ViewBag.LanMail = sYS_ReceiveMessageIBLL.GetPageList(paginationobj, "{\"userId\":\"" + userinfo.userId + "\"}");
- return PartialView(paginationobj);
- }
-
- public PartialViewResult TaskList()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
- ViewBag.TaskList = nWFProcessIBLL.GetMyTaskPageList(userinfo, paginationobj, "{}");
- //ViewBag.TaskList = wfTaskIBLL.GetActiveList(userinfo, paginationobj, "{}");
- return PartialView(paginationobj);
- }
-
- public PartialViewResult ReceiveFileList()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "SendTime", sord = "desc" };
- ViewBag.ReceiveFileList = sys_ReceiveFileIBLL.GetPageList(paginationobj, "{\"ReceiverId\":\"" + userinfo.userId + "\"}");
- return PartialView(paginationobj);
- }
-
-
-
-
-
- public PartialViewResult NewList()
- {
- var userinfo = LoginUserInfo.Get();
- int page = 1;
- if (!string.IsNullOrEmpty(Request.QueryString["page"]))
- {
- page = Convert.ToInt32(Request.QueryString["page"]);
- }
- //公告
- Pagination paginationobj = new Pagination() { rows = 10, page = page, sidx = "F_CreateDate", sord = "desc" };
- var newsList = newsIBLL.GetList("", userinfo.userId);
- //用户可以看到的通知公告
- var newsListSelf = new List<NewsEntity>();
- foreach (var newsitemEntity in newsList)
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
- {
- if (!string.IsNullOrEmpty(userinfo.postIds))
- {
- if (userinfo.postIds.Contains(","))
- {
- foreach (var postid in userinfo.postIds.Split(','))
- {
- if (newsitemEntity.F_SendPostId.Contains(postid))
- {
- newsListSelf.Add(newsitemEntity);
- break;
- }
- }
- }
- else
- {
- if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
- {
- if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- else
- {
- newsListSelf.Add(newsitemEntity);
- }
- }
- }
-
- foreach (var ufitem in newsListSelf)
- {
- if (!string.IsNullOrEmpty(ufitem.F_NewsImage))
- {
- if (annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage) != null)
- {
- var imagePath = annexesFileIBLL.GetEntityByFolderId(ufitem.F_NewsImage).F_FilePath;
- if (!string.IsNullOrEmpty(imagePath))
- {
- ufitem.F_NewsImage = imagePath.Substring(imagePath.IndexOf("Resource") - 1);
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- else
- {
- ufitem.F_NewsImage = "/Resource/NewsDefault.jpg";
- }
- }
- //公告
- ViewBag.NewsList = newsListSelf;
- return PartialView(paginationobj);
- }
-
-
- [HandlerLogin(FilterMode.Enforce)]
- public ActionResult NewsDetail()
- {
- return View();
- }
-
- public ActionResult Check()
- {
- try
- {
- string redi = Request.QueryString["redi"];
- if (!string.IsNullOrEmpty(redi))
- {
- string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
- string uid = Request.QueryString["u"];
- string pwd = Request.QueryString["p"];
- string logintime = Request.QueryString["t"];
- string n = Request.QueryString["n"];
- string mail = Request.QueryString["mail"];
- string sendfile = Request.QueryString["sendfile"];
- string task = Request.QueryString["task"];
- string gotomain = Request.QueryString["gotomain"];
- string nk = Request.QueryString["nk"];
- string jx = Request.QueryString["jx"];
- string zl = Request.QueryString["zl"];
- if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(logintime))
- {
- decimal decodelogintime = Convert.ToDecimal(DESEncrypt.Decrypt(logintime, publickey));
- decimal datetimenow = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss"));
- if (datetimenow - 300 <= decodelogintime && datetimenow + 300 >= decodelogintime)
- {
- string username = DESEncrypt.Decrypt(uid, publickey);
- string password = DESEncrypt.Decrypt(pwd, publickey);
- UserEntity userEntity = userBll.CheckLogin(username, Md5Helper.Encrypt(password, 32));
-
- LogEntity logEntity = new LogEntity();
- logEntity.F_CategoryId = 1;
- logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
- logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
- logEntity.F_OperateAccount = username + "(" + userEntity.F_RealName + ")";
- logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : username;
- logEntity.F_Module = Config.GetValue("SoftName");
- logEntity.F_Description = "PC端";
- if (!userEntity.LoginOk)//登录失败
- {
- //写入日志
- logEntity.F_ExecuteResult = 0;
- logEntity.F_ExecuteResultJson = "sso登录失败:" + userEntity.LoginMsg;
- logEntity.WriteLog();
- return Fail(userEntity.LoginMsg);
- }
- else
- {
- OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
- //写入日志
- logEntity.F_ExecuteResult = 1;
- logEntity.F_ExecuteResultJson = "sso登录成功";
- logEntity.WriteLog();
- var DigitalschoolMisLoginurl = ConfigurationManager.AppSettings["DigitalschoolMisLoginurl"];
- var Returnurl = "http://" + Request.Url.Host + ":" + Request.Url.Port;
- if (!string.IsNullOrEmpty(n))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=6252983c-52f5-402c-991b-ad19a9cb1f94&keyValue=" + n));
- }
- else if (!string.IsNullOrEmpty(mail))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=252878d7-d807-497f-b01e-839bb1b869c6"));
- }
- else if (!string.IsNullOrEmpty(sendfile))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=19637c39-624d-4be6-b680-04250f8df71f"));
- }
- else if (!string.IsNullOrEmpty(task))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=56ce34c2-882e-47d1-b12d-5036e3b79fcf"));
- }
- else if (!string.IsNullOrEmpty(gotomain))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index"));
- }
- else if (!string.IsNullOrEmpty(nk))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=07ceccd0-cf74-42ec-9b7d-3b36af0be451"));
- }
- else if (!string.IsNullOrEmpty(jx))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=5f2e3e9b-b0da-421a-b370-671dcae4fc17"));
- }
- else if (!string.IsNullOrEmpty(zl))
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + HttpUtility.UrlEncode(Returnurl + "/Home/Index?autoopen=8dfd9f38-8cab-49ff-b4d1-8b899b1ecbca"));
- }
- else
- {
- return Redirect(DigitalschoolMisLoginurl + "?F_Account=" + username + "&returnurl=" + Returnurl + "/SSOSystem/Index");
- }
- }
- }
- else
- {
- return Fail("时间戳验证失败");
- }
- }
- else
- {
- return Fail("参数错误");
- }
- }
- else
- {
- return View();
- }
- }
- catch (Exception e)
- {
- return Fail("参数错误");
- }
- }
-
- public ActionResult FirstLogin(Perm_FunctionEntity up)
- {
- string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
- if (up != null && !string.IsNullOrEmpty(up.UPId))
- {
- perm_FunctionIBLL.SaveEntityByUPId(up.UPId, up);
- return Redirect("/SSOSystem/GoTo?sysid=" + DESEncrypt.Encrypt(up.FId, publickey) + "&openid=" + DESEncrypt.Encrypt(up.UserId, publickey));
- }
- string sysid = Request.QueryString["sysid"];
- string strsysid = DESEncrypt.Decrypt(sysid, publickey);
- string openid = Request.QueryString["openid"];
- string userid = DESEncrypt.Decrypt(openid, publickey);
- var uplist = permUserPermissionIbll.GetPerm_UserPermissionEntityByFIdAndUid(strsysid, userid);
- if (uplist == null)
- {
- return Fail("用户未授权。");
- }
- var perfun = perm_FunctionIBLL.GetPerm_FunctionEntityByUPId(uplist.UPId);
- return View(perfun);
- }
-
- public ActionResult GoTo()
- {
- try
- {
- string redi = Request.QueryString["redi"];
- if (!string.IsNullOrEmpty(redi))
- {
- string publickey = ConfigurationManager.AppSettings["SSOPublicSecret"];
- string sysid = Request.QueryString["sysid"];
- string strsysid = DESEncrypt.Decrypt(sysid, publickey);
- string openid = Request.QueryString["openid"];
- string userid = DESEncrypt.Decrypt(openid, publickey);
- var uplist = permUserPermissionIbll.GetPerm_UserPermissionEntityByFIdAndUid(strsysid, userid);
- Perm_FunctionVisitEntity functionVisitEntity = new Perm_FunctionVisitEntity();
- functionVisitEntity.Create();
- functionVisitEntity.Fid = strsysid;
- functionVisitEntity.PDate = DateTime.Now;
- functionVisitEntity.PUId = userid;
- var userinfo = userBll.GetEntityByUserId(userid);
- functionVisitEntity.PUName = userinfo.F_RealName;
- if (uplist == null)
- {
- functionVisitEntity.PIsLoginSuccess = false;
- functionVisitEntity.PContent = "用户未授权";
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- return Fail("用户未授权。");
- }
- var perfun = perm_FunctionIBLL.GetPerm_FunctionEntityByUPId(uplist.UPId);
- string secretkey = DESEncrypt.Decrypt(perfun.FSecret, publickey);
- if (perfun.FIsManagePage == true)
- {
- if (!string.IsNullOrEmpty(perfun.FInterfaceUrl))
- {
- if (!string.IsNullOrEmpty(perfun.UPUserName) && !string.IsNullOrEmpty(perfun.UPPass))
- {
- functionVisitEntity.PIsLoginSuccess = true;
- functionVisitEntity.PContent = "成功转到统一认证网站:" + perfun.FUrl;
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- 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));
- }
- else
- {
- functionVisitEntity.PIsLoginSuccess = false;
- functionVisitEntity.PContent = "用户未配置转到用户名密码配置页面";
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- //用户未配置转到用户名密码配置页面
- return Redirect("/SSOSystem/FirstLogin?sysid=" + sysid + "&openid=" + openid);
- }
- }
- else
- {
- functionVisitEntity.PIsLoginSuccess = false;
- functionVisitEntity.PContent = "未配置登录接口地址";
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- return Fail("未配置登录接口地址。");
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(perfun.FUrl))
- {
- functionVisitEntity.PIsLoginSuccess = true;
- functionVisitEntity.PContent = "成功转到统一认证网站:" + perfun.FUrl;
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- return Redirect(perfun.FUrl);
- }
- else
- {
- functionVisitEntity.PIsLoginSuccess = false;
- functionVisitEntity.PContent = "未配置地址";
- functionVisitIbll.SaveEntity(null, functionVisitEntity);
- return Fail("未配置地址。");
- }
- }
- }
- else
- {
- return View();
- }
- }
- catch (Exception e)
- {
- return Fail("参数错误。");
- }
- }
- /// <summary>
- /// 获取IP
- /// </summary>
- /// <returns></returns>
- private string GetIP()
- {
- string ip = string.Empty;
- if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
- ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
- if (string.IsNullOrEmpty(ip))
- ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
- return ip;
- }
-
- }
- }
|