///// <summary> ///// 获取登录用户信息 ///// </summary> ///// <param name="customerId"></param> ///// <param name="token"></param> ///// <returns></returns> //public static LoggingSessionInfo GetLjLoggingSession(string userId, string customerId) //{ // if (userId == null || userId.Trim().Length == 0) userId = "1"; // LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); // //loggingSessionInfo = new CLoggingSessionService().GetLoggingSessionInfo(customerId, "7d4cda48970b4ed0aa697d8c2c2e4af3"); // loggingSessionInfo.CurrentUser = new BS.Entity.User.UserInfo(); // loggingSessionInfo.CurrentUser.User_Id = userId; // loggingSessionInfo.CurrentUser.customer_id = customerId; // loggingSessionInfo.UserID = loggingSessionInfo.CurrentUser.User_Id; // loggingSessionInfo.ClientID = customerId; // loggingSessionInfo.Conn = ConfigurationManager.AppSettings["Conn_lj"].Trim(); // loggingSessionInfo.CurrentLoggingManager = new LoggingManager(); // loggingSessionInfo.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn; // loggingSessionInfo.CurrentLoggingManager.User_Id = userId; // loggingSessionInfo.CurrentLoggingManager.Customer_Id = customerId; // loggingSessionInfo.CurrentLoggingManager.Customer_Name = ""; // loggingSessionInfo.CurrentLoggingManager.User_Name = ""; // return loggingSessionInfo; //} //public static LoggingSessionInfo GetLjLoggingSession() //{ // return GetLjLoggingSession("", ""); //} //public static LoggingSessionInfo GetLjLoggingSession(string userId) //{ // return GetLjLoggingSession(userId, ""); //} /// <summary> /// 获取BS用户登录信息 /// </summary> /// <param name="customerId"></param> /// <param name="userId"></param> /// <returns></returns> public static LoggingSessionInfo GetBSLoggingSession(string customerId, string userId) { if (userId == null || userId == string.Empty) { userId = "1"; } string conn = ""; string name = ""; CC_Connection connection = new RedisConnectionBLL().GetConnection(customerId);//从redis里获取商户数据库链接 RedisXML _RedisXML = new RedisXML(); //如果从缓存里获取不到信息,就从数据库读取,并种到缓存里 if (connection == null || string.IsNullOrEmpty(connection.ConnectionStr) || string.IsNullOrEmpty(connection.Customer_Name)) { //记录redis读取不成功,从数据库里读取数据的情况 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 2); conn = GetCustomerConn(customerId); name = GetCustomerName(customerId); string code = GetCustomerCode(customerId); new RedisConnectionBLL().SetConnection(customerId, conn, name, code); } else { //记录redis读取日志 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 1); conn = connection.ConnectionStr; name = connection.Customer_Name; } LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); //loggingSessionInfo = new CLoggingSessionService().GetLoggingSessionInfo(customerId, "7d4cda48970b4ed0aa697d8c2c2e4af3"); loggingSessionInfo.CurrentUser = new BS.Entity.User.UserInfo(); loggingSessionInfo.CurrentUser.User_Id = userId; loggingSessionInfo.CurrentUser.customer_id = customerId; loggingSessionInfo.UserID = loggingSessionInfo.CurrentUser.User_Id; loggingSessionInfo.ClientID = customerId; loggingSessionInfo.Conn = conn; loggingSessionInfo.CurrentLoggingManager = new LoggingManager(); loggingSessionInfo.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn; loggingSessionInfo.CurrentLoggingManager.User_Id = userId; loggingSessionInfo.CurrentLoggingManager.Customer_Id = customerId; loggingSessionInfo.CurrentLoggingManager.Customer_Name = name; loggingSessionInfo.CurrentLoggingManager.User_Name = ""; loggingSessionInfo.ClientName = name; return(loggingSessionInfo); }
/// <summary> /// 获取BS用户登录信息 /// </summary> /// <param name="customerId"></param> /// <param name="userId"></param> /// <returns></returns> public static LoggingSessionInfo GetBSLoggingSession(string customerId, string userId) { if (userId == null || userId == string.Empty) { userId = "system"; } string conn = ""; string name = ""; CC_Connection connection = new RedisConnectionBLL().GetConnection(customerId);//从redis里获取商户数据库链接 RedisXML _RedisXML = new RedisXML(); //如果从缓存里获取不到信息,就从数据库读取,并种到缓存里 if (connection == null || string.IsNullOrEmpty(connection.ConnectionStr) || string.IsNullOrEmpty(connection.Customer_Name)) { //记录redis读取不成功,从数据库里读取数据的情况 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 2); conn = GetCustomerConn(customerId); name = GetCustomerName(customerId); string code = GetCustomerCode(customerId); new RedisConnectionBLL().SetConnection(customerId, conn, name, code); } else { //记录redis读取日志 _RedisXML.RedisReadDBCount("Connection", "商户数据库链接", 1); conn = connection.ConnectionStr; name = connection.Customer_Name; } LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo(); //loggingSessionInfo = new CLoggingSessionService().GetLoggingSessionInfo(customerId, "7d4cda48970b4ed0aa697d8c2c2e4af3"); loggingSessionInfo.CurrentUser = new BS.Entity.User.UserInfo(); loggingSessionInfo.CurrentUser.User_Id = userId; loggingSessionInfo.CurrentUser.customer_id = customerId; loggingSessionInfo.UserID = loggingSessionInfo.CurrentUser.User_Id; loggingSessionInfo.ClientID = customerId; loggingSessionInfo.Conn = conn; loggingSessionInfo.CurrentLoggingManager = new LoggingManager(); loggingSessionInfo.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn; loggingSessionInfo.CurrentLoggingManager.User_Id = userId; loggingSessionInfo.CurrentLoggingManager.Customer_Id = customerId; loggingSessionInfo.CurrentLoggingManager.Customer_Name = name; loggingSessionInfo.CurrentLoggingManager.User_Name = ""; if (!string.IsNullOrEmpty(conn)) { //用户角色信息 cUserService userService = new cUserService(loggingSessionInfo); string applicationId = "649F8B8BDA9840D6A18130A5FF4CB9C8";//[T_Def_App] app IList <UserRoleInfo> userRoleList = userService.GetUserRoles(loggingSessionInfo.UserID, applicationId); if (userRoleList != null && userRoleList.Count > 0) { loggingSessionInfo.CurrentUserRole = new UserRoleInfo(); loggingSessionInfo.CurrentUserRole.UserId = loggingSessionInfo.UserID; //loggingSessionInfo.CurrentUserRole.UserName = login_user.User_Name; loggingSessionInfo.CurrentUserRole.RoleId = userRoleList[0].RoleId; loggingSessionInfo.CurrentUserRole.RoleCode = userRoleList[0].RoleCode; loggingSessionInfo.CurrentUserRole.RoleName = userRoleList[0].RoleName; loggingSessionInfo.CurrentUserRole.UnitId = userService.GetDefaultUnitByUserIdAndRoleId( loggingSessionInfo.CurrentUserRole.UserId, loggingSessionInfo.CurrentUserRole.RoleId); } loggingSessionInfo.ClientName = name; } return(loggingSessionInfo); }