public override bool Login() { string passwd = this.tePassword.Text; string system_code = this.lueSystem.EditValue.ToString(); string ret = ""; if (string.IsNullOrEmpty(passwd)) { ret = "请输入密码"; } else { ret = EmpInfo.Login(EnvInfo.BranchId, system_code, passwd); } if (ret.IsNullOrEmpty()) { var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("empId", EmpInfo.Id.ToString()) }; CustomException ce = null; BDictEmp empInfo = HttpDataHelper.GetWithInfo <BDictEmp>("BASE", "/sys/empinfo", out ce, parmList); List <string> roleList = HttpDataHelper.GetWithInfo <List <string> >("BASE", "/sys/role", out ce, parmList); List <CDictAction> actionList = HttpDataHelper.GetWithInfo <List <CDictAction> >("BASE", "/sys/action", out ce, parmList); EmpInfo.SetEmpInfo(empInfo, roleList, actionList); return(true); } else { MessageHelper.ShowError(ret); return(false); } }
/// <summary> /// 判别是否有功能点权限 /// </summary> /// <param name="container_code">容器代码</param> /// <param name="code">代码</param> /// <param name="name">名称</param> /// <param name="describe">描述信息</param> /// <returns>是否有权限</returns> public static bool GetFunctionPointAuthority(string container_code, string code, string name, string describe) { if (String.IsNullOrEmpty(code)) { return(false); } // 判别是否有功能点记录,返回记录数(>0有权) var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("fpCode", container_code + "-" + code), new KeyValuePair <string, string>("empId", EmpInfo.Id.ToString()), new KeyValuePair <string, string>("roles", EmpInfo.Roles) }; CustomException ce = null; CDictFunctionPoint fp = HttpDataHelper.GetWithInfo <CDictFunctionPoint>("BASE", "/setup/funcpoint", out ce, parmList); return(fp != null && fp.Code.Length > 0); }
/// <summary> /// 判别人员是否有职责性质 /// </summary> /// <param name="kind">职责性质</param> /// <returns></returns> //public static bool HasKind(int kind) //{ // if (KindList != null) // { // return KindList.Contains(kind); // } // return false; //} #endregion #region 功能方法 /// <summary> /// 通过代码获取员工ID及可用系统信息 /// </summary> /// <param name="code">员工代码</param> /// <returns>返回错误信息,空为成功</returns> public static string QueryEmpByCode(string code) { //EmpInfo.CanUseSystemList = new List<BDicSystem>(); if (code.IsNullOrEmpty()) { EmpInfo.Id = 0; EmpInfo.Code = string.Empty; return("工号不可为空!"); } // 依据员工代码获取员工ID,再获取可使用的子系统 var parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("empCode", code) }; CustomException ce = null; int emp_id = HttpDataHelper.GetWithInfo <int>("BASE", "/sys/empid", out ce, parmList); if (emp_id < 0) { return("不存在工号为" + code + "的人员!"); } parmList = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("empId", emp_id.ToString()) }; List <BDictSystem> ls = HttpDataHelper.GetWithInfo <List <BDictSystem> >("BASE", "/sys/system", out ce, parmList); if (ls == null || ls.Count == 0) { return("工号" + code + "的人员没有可用的子系统!"); } EmpInfo.CanUseSystemList = ls; EmpInfo.Code = code; EmpInfo.Id = emp_id; return(string.Empty); }
/// <summary> /// 通过配置文件设置机构信息 /// </summary> private static void SetBranchInfo() { // 获取机构ID,默认为1. string sid = ConfigurationManager.AppSettings.Get("BranchId"); if (!sid.IsNullOrEmpty() && sid.IsInt()) { EnvInfo.BranchId = int.Parse(sid); } else { EnvInfo.BranchId = 1; } string key = ConfigurationManager.AppSettings.Get("UserSerial").Reversal(); // 获取用户名称 string rets = ConfigurationManager.AppSettings.Get("UserName"); if (!string.IsNullOrEmpty(rets)) { rets = DataCryptoHelper.Decrypting(rets, "Wonder.His" + key); EnvInfo.UserName = rets; } else { throw new Exception("配置文件中用户名称有误!"); } //try //{ // 系统时间与数据库时间同步 DateTime d = DateTime.Now; //int timezone = int.Parse(DateTime.Now.ToString("%z").Substring(1)); CustomException ex = null; String systime = HttpDataHelper.GetStringWithInfo("BASE", "/sys/date", out ex); if (ex != null) { throw ex; } char[] spp = new char[] { '-', ':', ' ', '+' }; string[] tp = systime.Split(spp, StringSplitOptions.RemoveEmptyEntries); int[] itp = new int[7]; for (int i = 0; i < 7; i++) { itp[i] = int.Parse(tp[i]); } DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(itp[0], itp[1], itp[2], itp[3], itp[4], itp[5])); long delta = GetTimeStamp(startTime) - GetTimeStamp(d) - itp[6] * 36000; //时区处理 if (Math.Abs(delta) < 60000) { SYSTEMTIME st = new SYSTEMTIME(); st.FromDateTime(DateTime.Now.AddMilliseconds(delta)); bool syn = Win32API.SetLocalTime(ref st); if (!syn) { EnvInfo.ServerTimeDelta = delta; } } // 通过BranchId 查询 名称及代码 List <KeyValuePair <string, string> > parms = new List <KeyValuePair <string, string> >(); parms.Add(new KeyValuePair <string, string>("branchId", EnvInfo.BranchId.ToString())); CustomException ce = null; CDictBranch branch = HttpDataHelper.GetWithInfo <CDictBranch>("BASE", "/sys/branch", out ce, parms); EnvInfo.BranchCode = branch.Code; // "101"; EnvInfo.BranchName = branch.Name; // EnvInfo.UserName; #region MONGODB 测试 //ErrorLogInfo eli = new ErrorLogInfo(); //eli.BranchId = EnvInfo.BranchId; //eli.EmpId = EmpInfo.Id; //eli.ComputerIp = EnvInfo.ComputerIp; //eli.Info = "Try"; //eli.Message = "Demo message"; //String json = StringHelper.SerializeObject<ErrorLogInfo>(eli); //HttpDataHelper.HttpPostWithInfo"BASE", "/mongo/errorlog/save", json); #endregion //} //catch (Exception ex) //{ // MessageHelper.ShowError(ex.Message); //} }