/// <summary> /// 窗体打开前加载数据 /// </summary> /// <param name="sender">FrmSinglePaymentManage</param> /// <param name="e">事件参数</param> private void FrmSinglePaymentManage_OpenWindowBefore(object sender, EventArgs e) { myDictionary = new Dictionary <string, object>(); sysLoginRight = (InvokeController("this") as AbstractController).LoginUserInfo; statDTime.Bdate.Value = Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")); statDTime.Edate.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); InvokeController("GetStaff"); AccountRefresh(); ucAccountTab1.InitUC(); ucAccountTab1.InvokeController = InvokeController; }
/// <summary> /// 客户端传送户权限 /// </summary> /// <param name="loginRight"></param> public void BindLoginRight(SysLoginRight loginRight) { _loginRight = loginRight; if (loginRight != null) { oleDb.WorkId = loginRight.WorkId;//重新绑定workid,因为wcf服务的workid每次调用都是客户端传递过来的 } else { oleDb.WorkId = 0; } }
public void ChangeDept() { string deptid = FormData["selectDept"]; DataTable dt = sessionData["ListDepts"] as DataTable; SysLoginRight afm = LoginUserInfo; afm.DeptId = Convert.ToInt32(deptid); afm.DeptName = dt.Select("DeptId=" + deptid)[0]["Name"].ToString(); if (PutOutData.ContainsKey("RoleUser")) { PutOutData.Remove("RoleUser"); } PutOutData.Add("RoleUser", afm); JsonResult = RetSuccess(""); }
public override void OnActionExecuting(HttpActionContext actionContext) { if (WebApiFrame.WebApiGlobal.IsToken == true) { //登陆之外的请求验证token if (actionContext.Request.RequestUri.AbsolutePath.ToLower().IndexOf("/efwplusApi/coresys/login/userlogin".ToLower()) == -1) { string token = null; string[] qs = actionContext.Request.RequestUri.Query.ToLower().Split(new char[] { '?', '&' }); foreach (var s in qs) { string[] kv = s.Split(new char[] { '=' }); if (kv.Length == 2 && kv[0] == "token") { token = kv[1]; break; } } if (token == null) { throw new Exception("no token"); } AuthResult result = SsoHelper.ValidateToken(token); if (result.ErrorMsg != null) { throw new Exception(result.ErrorMsg); } SysLoginRight loginInfo = new SysLoginRight(); loginInfo.EmpId = result.User.EmpId; //loginInfo.UserId =; loginInfo.EmpName = result.User.UserName; loginInfo.DeptId = result.User.DeptId; loginInfo.DeptName = result.User.DeptName; loginInfo.WorkId = result.User.WorkId; loginInfo.WorkName = result.User.WorkName; loginInfo.IsAdmin = result.User.IsAdmin; loginInfo.token = Guid.Parse(result.token); actionContext.Request.Properties[Key] = loginInfo; } } }
public override void OnActionExecuting(HttpActionContext actionContext) { if (EFWCoreLib.WcfFrame.ServerController.WcfServerManage.IsDebug == false) { //登陆之外的请求验证token if (actionContext.Request.RequestUri.AbsolutePath.ToLower().IndexOf("/efwplusApi/coresys/login/userlogin".ToLower()) == -1) { string token = null; string[] qs = actionContext.Request.RequestUri.Query.ToLower().Split(new char[] { '?', '&' }); foreach (var s in qs) { string[] kv = s.Split(new char[] { '=' }); if (kv.Length == 2 && kv[0] == "token") { token = kv[1]; break; } } if (token == null) { throw new Exception("no token"); } AuthResult result = SsoHelper.ValidateToken(token); if (result.ErrorMsg != null) { throw new Exception(result.ErrorMsg); } SysLoginRight loginInfo = new SysLoginRight(); loginInfo.UserId = Convert.ToInt32(result.User.UserId); loginInfo.EmpName = result.User.UserName; actionContext.Request.Properties[Key] = loginInfo; } } }
//每次请求的身份验证,分布式情况下验证麻烦 private static bool IsAuth(string pname, string cname, string methodname, string token) { ModulePlugin mp; WcfControllerAttributeInfo cattr = AppPluginManage.GetPluginWcfControllerAttributeInfo(pname, cname, out mp); if (cattr == null) { throw new Exception("插件中没有此控制器名"); } WcfMethodAttributeInfo mattr = cattr.MethodList.Find(x => x.methodName == methodname); if (mattr == null) { throw new Exception("控制器中没有此方法名"); } if (mattr.IsAuthentication) { if (token == null) { throw new Exception("no token"); } AuthResult result = SsoHelper.ValidateToken(token); if (result.ErrorMsg != null) { throw new Exception(result.ErrorMsg); } SysLoginRight loginInfo = new SysLoginRight(); loginInfo.UserId = Convert.ToInt32(result.User.UserId); loginInfo.EmpName = result.User.UserName; //clientinfo.LoginRight = loginInfo; } return(true); }
/// <summary> /// 执行请求 /// </summary> /// <param name="request"></param> /// <param name="login"></param> /// <param name="userName"></param> /// <param name="accessKey"></param> /// <returns></returns> public static Response Execute(RestRequest request, SysLoginRight login = null, string userName = "******", string accessKey = "default") { var restClient = new RestClient(GetBaseUrl("ApiGateway")) { Authenticator = new HttpBasicAuthenticator(userName, accessKey) }; request.AddHeader("Content-Type", "application/json"); if (login != null) { request.AddHeader("SysLoginRight", System.Web.HttpUtility.UrlEncodeUnicode(JsonConvert.SerializeObject(login))); } var response = restClient.Execute <Response>(request); if (response.IsSuccessful == false) { string message = "StatusCode:" + response.StatusCode.ToString() + " \r\nStatusDescription:" + response.StatusDescription; var browserStackException = new ApplicationException(message, response.ErrorException); throw browserStackException; } return(response.Data); }
public void ChangePassWord() { try { string oldpassword = FormData["oldpasswd"]; string password = FormData["newpasswd"]; SysLoginRight slr = (SysLoginRight)sessionData["RoleUser"]; bool b = NewObject <User>().AlterPassWrod(LoginUserInfo.UserId, oldpassword, password); if (b == true) { JsonResult = RetSuccess("修改成功!"); } else { JsonResult = RetError("输入的原始密码有误!"); } } catch (Exception e) { JsonResult = RetError(e.Message); } }
public void UserLogin() { User user = NewObject <User>(); bool islogin = user.UserLogin(frmlogin.usercode, frmlogin.password); if (islogin) { BaseUser EbaseUser = user.GetUser(frmlogin.usercode); SysLoginRight right = new SysLoginRight(); right.UserId = EbaseUser.UserId; right.EmpId = EbaseUser.EmpId; right.WorkId = EbaseUser.WorkId; Dept dept = NewObject <Dept>(); BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId); if (EbaseDept != null) { right.DeptId = EbaseDept.DeptId; right.DeptName = EbaseDept.Name; } BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId); right.EmpName = EbaseEmp.Name; BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId); right.WorkName = EbaseWork.WorkName; if (EbaseWork.DelFlag == 0) { string regkey = EbaseWork.RegKey; DESEncryptor des = new DESEncryptor(); des.InputString = regkey; des.DesDecrypt(); string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' }); if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now) { AppGlobal.cache.Add("RoleUser", right); //调用单点登录 //Guid TokenKey; //EFWCoreLib.CoreFrame.SSO.SsoHelper.SignIn(right.UserId.ToString(), right.EmpName, out TokenKey); //AppGlobal.cache.Add("TokenKey", TokenKey); frmmain.UserName = right.EmpName; frmmain.DeptName = right.DeptName; frmmain.WorkName = right.WorkName; frmmain.modules = NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList(); frmmain.menus = NewObject <WinMainUIFrame.ObjectModel.RightManager.Menu>().GetMenuList(right.UserId); frmmain.depts = NewObject <Dept>().GetHaveDept(right.EmpId); frmmain.showSysMenu(); ShowWeclomeForm(); ((System.Windows.Forms.Form)frmmain).ShowIcon = true; ((System.Windows.Forms.Form)frmmain).Icon = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico"); ((System.Windows.Forms.Form)frmmain).Show(); AppGlobal.winfromMain.MainForm = (System.Windows.Forms.Form)frmmain; //InitMessageForm();//? //登录完成后执行扩展的插件方法 string val = AppPluginManage.getbaseinfoDataValue(_pluginName, "LoginCompleted"); if (val != null && val.Split('@').Length == 3) { string pluginName = val.Split('@')[0]; string controllerName = val.Split('@')[1]; string methodName = val.Split('@')[2]; InvokeController(pluginName, controllerName, methodName, right); } CustomConfigManager.xmlDoc = null; } else { throw new Exception("登录用户的当前机构注册码不正确!"); } } else { throw new Exception("登录用户的当前机构还未启用!"); } } else { throw new Exception("输入的用户名密码不正确!"); } }
public void Login() { try { string strUsertitle = FormData["txtUserName"]; string strPassWord = FormData["txtUserPWD"]; string strIP = FormData["txtUserIP"]; string strMac = FormData["txtMac"]; User user = NewObject <User>(); bool islogin = user.UserLogin(strUsertitle, strPassWord); if (islogin) { BaseUser EbaseUser = user.GetUser(strUsertitle); SysLoginRight right = new SysLoginRight(); right.UserId = EbaseUser.UserId; right.EmpId = EbaseUser.EmpId; right.WorkId = EbaseUser.WorkId; oleDb.WorkId = EbaseUser.WorkId; Dept dept = NewObject <Dept>(); BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId); if (EbaseDept != null) { right.DeptId = EbaseDept.DeptId; right.DeptName = EbaseDept.Name; } BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId); right.EmpName = EbaseEmp.Name; BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId); right.WorkName = EbaseWork.WorkName; if (EbaseWork.DelFlag == 0) { string regkey = EbaseWork.RegKey; DESEncryptor des = new DESEncryptor(); des.InputString = regkey; des.DesDecrypt(); string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' }); if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now) { if (PutOutData.ContainsKey("RoleUser")) { PutOutData.Remove("RoleUser"); } PutOutData.Add("RoleUser", right); if (PutOutData.ContainsKey("WorkId")) { PutOutData.Remove("WorkId"); } PutOutData.Add("WorkId", right.WorkId); DataTable ListModeules = ConvertExtend.ToDataTable(NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList()); List <BaseMenu> listM = NewObject <Menu>().GetMenuList(right.UserId); //给菜单url后面绑定MenuId参数 for (int i = 0; i < listM.Count; i++) { listM[i].UrlName = ConvertExtend.UrlAddParams(listM[i].UrlName, "MenuId", listM[i].MenuId.ToString()); } DataTable ListMenus = ConvertExtend.ToDataTable(listM); DataTable ListDepts = ConvertExtend.ToDataTable(NewObject <Dept>().GetHaveDept(right.EmpId)); DataTable ListGroups = ConvertExtend.ToDataTable(NewObject <Group>().GetGroupList(right.UserId)); if (PutOutData.ContainsKey("ListModeules")) { PutOutData.Remove("ListModeules"); } PutOutData.Add("ListModeules", ListModeules); if (PutOutData.ContainsKey("ListMenus")) { PutOutData.Remove("ListMenus"); } PutOutData.Add("ListMenus", ListMenus); if (PutOutData.ContainsKey("ListDepts")) { PutOutData.Remove("ListDepts"); } PutOutData.Add("ListDepts", ListDepts); if (PutOutData.ContainsKey("ListGroups")) { PutOutData.Remove("ListGroups"); } PutOutData.Add("ListGroups", ListGroups); JsonResult = RetSuccess(""); } else { //throw new Exception("登录用户的当前机构注册码不正确!"); JsonResult = RetError("登录用户的当前机构注册码不正确!"); } } else { //throw new Exception("登录用户的当前机构还未启用!"); JsonResult = RetError("登录用户的当前机构还未启用!"); } } else { //throw new Exception("输入的用户名密码不正确!"); JsonResult = RetError("输入的用户名密码不正确!"); } //JsonResult = RetSuccess(""); } catch (Exception err) { //ZhyContainer.CreateException().HandleException(err, "HISPolicy"); JsonResult = RetError("登录失败,请联系系统管理员!" + err.Message); } }
private void AddMessageHeader(IContextChannel channel, string cmd, bool iscompressjson, bool isencryptionjson, SerializeType serializetype, SysLoginRight loginright, Action callback) { using (var scope = new OperationContextScope(channel as IContextChannel)) { if (string.IsNullOrEmpty(cmd)) { cmd = ""; } HeaderParameter para = new HeaderParameter(); para.cmd = cmd; para.routerid = clientObj.RouterID; para.pluginname = clientObj.PluginName; //ReplyIdentify如果客户端创建连接为空,如果中间件连接上级中间件那就是本地中间件标识 para.replyidentify = WcfGlobal.Identify; para.token = clientObj.Token; para.iscompressjson = iscompressjson; para.isencryptionjson = isencryptionjson; para.serializetype = serializetype; para.LoginRight = loginright; HeaderOperater.AddMessageHeader(OperationContext.Current.OutgoingMessageHeaders, para); callback(); } }
/// <summary> /// 取得登录用户信息 /// </summary> /// <param name="loginUserInfo">登录用户对象</param> public void GetLoginUserInfo(SysLoginRight loginUserInfo) { this.loginUserInfo = loginUserInfo; }
public Object WcfServerExecuteMethod(string controllername, string methodname, object[] paramValue, ClientRequestData requestData, SysLoginRight loginRight) { EFWCoreLib.WcfFrame.ServerController.WcfServerController wscontroller = helper.CreateController(plugin.name, controllername) as EFWCoreLib.WcfFrame.ServerController.WcfServerController; wscontroller.requestData = requestData; wscontroller.responseData = new ServiceResponseData(requestData.Iscompressjson, requestData.Isencryptionjson, requestData.Serializetype); wscontroller.BindLoginRight(loginRight); MethodInfo methodinfo = helper.CreateMethodInfo(plugin.name, controllername, methodname, wscontroller); return(methodinfo.Invoke(wscontroller, paramValue)); }
public ServiceResponseData UserLogin() { string usercode = requestData.GetData <string>(0); string password = requestData.GetData <string>(1); User user = NewObject <User>(); bool islogin = user.UserLogin(usercode, password); if (islogin) { BaseUser EbaseUser = user.GetUser(usercode); SysLoginRight right = new SysLoginRight(); right.UserId = EbaseUser.UserId; right.EmpId = EbaseUser.EmpId; right.WorkId = EbaseUser.WorkId; Dept dept = NewObject <Dept>(); BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId); if (EbaseDept != null) { right.DeptId = EbaseDept.DeptId; right.DeptName = EbaseDept.Name; } BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId); right.EmpName = EbaseEmp.Name; BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId); right.WorkName = EbaseWork.WorkName; if (EbaseWork.DelFlag == 0) { string regkey = EbaseWork.RegKey; DESEncryptor des = new DESEncryptor(); des.InputString = regkey; des.DesDecrypt(); string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' }); if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now) { //ClientInfo.LoginRight = right;//缓存登录用户信息 //单点登录注册 Guid token = Guid.Empty; SsoHelper.SignIn(usercode, new UserInfo() { UserId = usercode, UserName = right.EmpName, DeptName = right.DeptName, WorkName = right.WorkName }, out token); responseData.AddData(right.EmpName); responseData.AddData(right.DeptName); responseData.AddData(right.WorkName); responseData.AddData(NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList()); responseData.AddData(NewObject <Menu>().GetMenuList(right.UserId)); responseData.AddData(NewObject <Dept>().GetHaveDept(right.EmpId)); responseData.AddData(right); return(responseData); } else { throw new Exception("登录用户的当前机构注册码不正确!"); } } else { throw new Exception("登录用户的当前机构还未启用!"); } } else { throw new Exception("输入的用户名密码不正确!"); } }
public void SetUserInfo(SysLoginRight user) { //_loginUserInfo = user; WinformGlobal.LoginUserInfo = user; }
//调试免登录 private void DebugLogin() { #region 进入调试模式 if (AppPluginManage.getbaseinfoDataValue(_pluginName, "isdebug") == "true") { //进入调试模式 DefaultView = frmmain as IBaseViewBusiness; SysLoginRight right = new SysLoginRight(); right.UserId = 1; right.EmpId = 1; right.WorkId = 1; right.DeptId = 1; right.DeptName = "调试科室"; right.EmpName = "调试用户"; right.WorkName = "调试机构"; AppGlobal.cache.Add("RoleUser", right); frmmain.UserName = right.EmpName; frmmain.DeptName = right.DeptName; frmmain.WorkName = right.WorkName; if (AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig") != null) { string filepath = AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig"); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(filepath); XmlNodeList nl = xmlDoc.DocumentElement.SelectNodes("modules/module"); List <BaseModule> mdlist = new List <BaseModule>(); foreach (XmlNode n in nl) { BaseModule bmd = new BaseModule(); bmd.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value); bmd.Name = n.Attributes["Name"].Value; mdlist.Add(bmd); } nl = xmlDoc.DocumentElement.SelectNodes("menus/menu"); List <BaseMenu> menulist = new List <BaseMenu>(); foreach (XmlNode n in nl) { BaseMenu bmenu = new BaseMenu(); bmenu.MenuId = Convert.ToInt32(n.Attributes["MenuId"].Value); bmenu.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value); bmenu.PMenuId = Convert.ToInt32(n.Attributes["PMenuId"].Value); bmenu.Name = n.Attributes["Name"].Value; bmenu.Image = n.Attributes["Image"].Value; bmenu.DllName = n.Attributes["DllName"].Value; bmenu.FunName = n.Attributes["FunName"].Value; menulist.Add(bmenu); } frmmain.modules = mdlist; frmmain.menus = menulist; //frmmain.depts = NewObject<Dept>().GetHaveDept(right.EmpId); } frmmain.showSysMenu(); ShowWeclomeForm(); ((System.Windows.Forms.Form)frmmain).ShowIcon = true; ((System.Windows.Forms.Form)frmmain).Icon = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico"); } #endregion }
public string UserLogin() { //UseDb("SQL20052"); //string strsql = @"select count(*) from appcenter"; //object o = oleDb.GetDataResult(strsql); //UseDb(); string usercode = ToArray(ParamJsonData)[0].ToString(); string password = ToArray(ParamJsonData)[1].ToString(); User user = NewObject <User>(); bool islogin = user.UserLogin(usercode, password); if (islogin) { BaseUser EbaseUser = user.GetUser(usercode); SysLoginRight right = new SysLoginRight(); right.UserId = EbaseUser.UserId; right.EmpId = EbaseUser.EmpId; right.WorkId = EbaseUser.WorkId; Dept dept = NewObject <Dept>(); BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId); if (EbaseDept != null) { right.DeptId = EbaseDept.DeptId; right.DeptName = EbaseDept.Name; } BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId); right.EmpName = EbaseEmp.Name; BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId); right.WorkName = EbaseWork.WorkName; if (EbaseWork.DelFlag == 0) { string regkey = EbaseWork.RegKey; DESEncryptor des = new DESEncryptor(); des.InputString = regkey; des.DesDecrypt(); string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' }); if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now) { ClientInfo.LoginRight = right;//缓存登录用户信息 Object[] retObjs = new Object[] { right.EmpName, right.DeptName, right.WorkName , NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList() , NewObject <Menu>().GetMenuList(right.UserId) , NewObject <Dept>().GetHaveDept(right.EmpId) , right }; return(ToJson(retObjs)); } else { throw new Exception("登录用户的当前机构注册码不正确!"); } } else { throw new Exception("登录用户的当前机构还未启用!"); } } else { throw new Exception("输入的用户名密码不正确!"); } }
public void BindLoginRight(SysLoginRight loginRight) { _loginRight = loginRight; }