/// <summary> /// 获取公司部门信息 /// </summary> /// <param name="companyId">公司编号</param> /// <returns></returns> public static List <MCacheDeptInfo> GetDepts(string companyId) { string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComDept, companyId); var items = (List <MCacheDeptInfo>)EyouSoftCache.GetCache(cacheKey); if (items != null) { return(items); } IUserLogin dal = new DUserLogin(); items = dal.GetComDepts(companyId); if (items == null) { return(null); } foreach (var item in items) { CTEDeptChildrens(items, item.DeptId, item.Depts); item.FirstId = CTEDeptFirstId(items, item.DeptId); } EyouSoft.Cache.Facade.EyouSoftCache.Add(cacheKey, items); return(items); }
/*/// <summary> * /// 获取组织机构用户(同级及下级部门用户)信息集合 * /// </summary> * /// <param name="companyId">公司编号</param> * /// <param name="deptId">部门编号</param> * /// <returns></returns> * public static IList<string> GetDeptUsers(string companyId, int deptId) * { * if (string.IsNullOrEmpty(companyId) || deptId < 1) return null; * * IList<string> users = null; * string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComDept, companyId); * //IDictionary<部门编号,IList<用户编号>> 部门缓存以公司为单位 * IDictionary<int, IList<string>> items = (IDictionary<int, IList<string>>)EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheKey); * * if (items == null || items.Count < 1 || !items.ContainsKey(deptId)) * { * IUserLogin dal = new DUserLogin(); * users = dal.GetDeptUsers(deptId); * * items = items ?? new Dictionary<int, IList<string>>(); * * items.Add(deptId, users); * * EyouSoft.Cache.Facade.EyouSoftCache.Add(cacheKey, items); * } * else * { * users = items[deptId]; * } * * return users; * }*/ /// <summary> /// 获取系统默认二级栏目信息集合 /// </summary> /// <returns></returns> public static IList <EyouSoft.Model.SysStructure.MSysMenu2Info> GetSysMenu2s() { string cacheKey = EyouSoft.Cache.Tag.TagName.SysMenu2s; IList <MSysMenu2Info> items = (IList <MSysMenu2Info>)EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheKey); if (items == null) { IUserLogin dal = new DUserLogin(); items = dal.GetSysMenu2s(); EyouSoft.Cache.Facade.EyouSoftCache.Add(cacheKey, items); } return(items); }
/// <summary> /// 用户退出 /// </summary> public static void Logout(string companyId, string userId) { if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(companyId)) { string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComUser, companyId, userId); var info = (MUserInfo)EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheKey); if (info != null) { info.OnlineStatus = EyouSoft.Model.EnumType.ComStructure.UserOnlineStatus.Offline; info.OnlineSessionId = string.Empty; } IUserLogin dal = new DUserLogin(); dal.SetOnlineStatus(userId, EyouSoft.Model.EnumType.ComStructure.UserOnlineStatus.Offline, "00000000-0000-0000-0000-000000000000"); } }
/// <summary> /// 自动登录处理 /// </summary> /// <param name="sysId">系统编号</param> /// <param name="companyId">公司编号</param> /// <param name="userId">用户编号</param> /// <param name="username">用户账号</param> /// <param name="uInfo">登录用户信息</param> private static void AutoLogin(string sysId, string companyId, string userId, string username, out MUserInfo uInfo) { uInfo = null; IUserLogin dal = new DUserLogin(); MSysDomain domainInfo = GetDomain(); if (domainInfo == null || domainInfo.SysId != sysId || domainInfo.CompanyId != companyId) { uInfo = null; return; } uInfo = dal.Login(userId); if (uInfo == null) { return; } if (uInfo.Username != username) { uInfo = null; return; } if (uInfo.CompanyId != companyId) { uInfo = null; return; } if (uInfo.UserType == EyouSoft.Model.EnumType.ComStructure.UserType.供应商 && uInfo.SourceCompanyInfo == null) { uInfo = null; return; } if (uInfo.UserType == EyouSoft.Model.EnumType.ComStructure.UserType.组团社 && uInfo.TourCompanyInfo == null) { uInfo = null; return; } if (uInfo.Status != EyouSoft.Model.EnumType.ComStructure.UserStatus.正常) { uInfo = null; return; } uInfo.SysId = sysId; uInfo.LoginTime = uInfo.LastLoginTime.HasValue ? uInfo.LastLoginTime.Value : DateTime.Now; dal.LoginLogwr(uInfo, EyouSoft.Model.EnumType.ComStructure.UserLoginType.自动登录); SetUserCache(uInfo); }
/// <summary> /// 用户退出 /// </summary> public static void Logout() { string companyId = GetCookie(LoginCookieCompanyId); string userId = GetCookie(LoginCookieUserId); if (!IsKeFuLogin() && !string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(companyId)) { RemoveUserCache(companyId, userId); } RemoveCookies(); if (!IsKeFuLogin()) { IUserLogin dal = new DUserLogin(); dal.SetOnlineStatus(userId, EyouSoft.Model.EnumType.ComStructure.UserOnlineStatus.Offline, "00000000-0000-0000-0000-000000000000"); } }
/// <summary> /// 获取公司配置信息 /// </summary> /// <param name="companyId">公司编号</param> /// <returns></returns> public static MComSetting GetComSetting(string companyId) { if (string.IsNullOrEmpty(companyId)) { return(null); } string cacheName = string.Format(EyouSoft.Cache.Tag.TagName.ComSetting, companyId); MComSetting setting = (MComSetting)EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheName); if (setting == null) { IUserLogin dal = new DUserLogin(); setting = dal.GetComSetting(companyId); EyouSoft.Cache.Facade.EyouSoftCache.Add(cacheName, setting); } return(setting); }
/// <summary> /// 获取公司菜单信息集合 /// </summary> /// <param name="sysId">系统编号</param> /// <returns></returns> public static IList <MComMenu1Info> GetComMenus(string sysId) { if (string.IsNullOrEmpty(sysId)) { return(null); } string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComMenu, sysId); IList <MComMenu1Info> items = (IList <MComMenu1Info>)EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheKey); if (items == null) { IUserLogin dal = new DUserLogin(); items = dal.GetComMenus(sysId); EyouSoft.Cache.Facade.EyouSoftCache.Add(cacheKey, items); } return(items); }
/// <summary> /// 获取当前域名信息 /// </summary> /// <returns></returns> public static MSysDomain GetDomain() { string s = System.Web.HttpContext.Current.Request.Url.Host.ToLower(); /*//单域名缓存 * MSysDomain info = (MSysDomain)EyouSoftCache.GetCache(string.Format(EyouSoft.Cache.Tag.TagName.SysDomain, s)); * * if (info == null) * { * IUserLogin dal = new DUserLogin(); * info = dal.GetDomain(s); * * if (info != null) * { * EyouSoft.Cache.Facade.EyouSoftCache.Add(string.Format(EyouSoft.Cache.Tag.TagName.SysDomain, s), info, DateTime.Now.AddHours(2)); * } * } * * return info;*/ IDictionary <string, MSysDomain> domains = (IDictionary <string, MSysDomain>)EyouSoftCache.GetCache(EyouSoft.Cache.Tag.TagName.SysDomains); MSysDomain info = null; domains = domains ?? new Dictionary <string, MSysDomain>(); if (domains.ContainsKey(s)) { info = domains[s]; } else { IUserLogin dal = new DUserLogin(); info = dal.GetDomain(s); if (info != null) { domains.Add(s, info); EyouSoft.Cache.Facade.EyouSoftCache.Add(EyouSoft.Cache.Tag.TagName.SysDomains, domains); } } return(info); }
/// <summary> /// 用户登录,返回1登录成功 /// </summary> /// <param name="companyId">系统公司编号</param> /// <param name="username">用户名</param> /// <param name="pwdInfo">登录密码</param> /// <param name="uInfo">登录用户信息</param> /// <returns></returns> public static int Login(string companyId, string username, MPasswordInfo pwdInfo, out MUserInfo uInfo) { IUserLogin dal = new DUserLogin(); uInfo = null; if (string.IsNullOrEmpty(companyId)) { return(0); } if (string.IsNullOrEmpty(username)) { return(-1); } if (pwdInfo == null || string.IsNullOrEmpty(pwdInfo.NoEncryptPassword)) { return(-2); } MSysDomain domainInfo = GetDomain(); if (domainInfo == null) { return(-3); } uInfo = dal.Login(companyId, username, pwdInfo); //通过用户名及密码验证失败,判断登录密码是否为客服服务密码,如果是将绕过密码验证 //使用客服密码登录时登录日志做客服登录标识 EyouSoft.Model.EnumType.ComStructure.UserLoginType loginType = EyouSoft.Model.EnumType.ComStructure.UserLoginType.用户登录; if (uInfo == null) { if (System.Configuration.ConfigurationManager.AppSettings["KeFuPwd"] == pwdInfo.MD5Password) { uInfo = dal.Login(companyId, username); loginType = EyouSoft.Model.EnumType.ComStructure.UserLoginType.客服登录; } if (uInfo == null) { return(-4); } } if (uInfo.UserType == EyouSoft.Model.EnumType.ComStructure.UserType.供应商 && uInfo.SourceCompanyInfo == null) { uInfo = null; return(-5); } if (uInfo.UserType == EyouSoft.Model.EnumType.ComStructure.UserType.组团社 && uInfo.TourCompanyInfo == null) { uInfo = null; return(-6); } if (uInfo.Status != EyouSoft.Model.EnumType.ComStructure.UserStatus.正常) { uInfo = null; return(-7); } var setting = GetComSetting(companyId); if (IsLoginLimit(uInfo.UserType)) { switch (setting.UserLoginLimitType) { case EyouSoft.Model.EnumType.ComStructure.UserLoginLimitType.None: break; case EyouSoft.Model.EnumType.ComStructure.UserLoginLimitType.Earliest: if (loginType == EyouSoft.Model.EnumType.ComStructure.UserLoginType.用户登录 && uInfo.OnlineStatus == EyouSoft.Model.EnumType.ComStructure.UserOnlineStatus.Online) { uInfo = null; return(-8); } break; case EyouSoft.Model.EnumType.ComStructure.UserLoginLimitType.Latest: break; default: break; } } uInfo.SysId = domainInfo.SysId; uInfo.LoginTime = DateTime.Now; if (loginType == EyouSoft.Model.EnumType.ComStructure.UserLoginType.用户登录) { uInfo.OnlineStatus = EyouSoft.Model.EnumType.ComStructure.UserOnlineStatus.Online; uInfo.OnlineSessionId = Guid.NewGuid().ToString(); } dal.LoginLogwr(uInfo, loginType); SetUserCache(uInfo); SetCookies(uInfo); if (loginType == EyouSoft.Model.EnumType.ComStructure.UserLoginType.客服登录) { SetKeFuLoginCookies(); } return(1); }