public static string AddLog(string systemCode, BaseUserEntity userEntity, string ipAddress, string ipAddressName, string macAddress, string loginStatus)
        {
            if (!BaseSystemInfo.RecordLogOnLog)
            {
                return(string.Empty);
            }
            if (userEntity == null)
            {
                return(null);
            }

            string             result = string.Empty;
            BaseLoginLogEntity entity = new BaseLoginLogEntity();

            entity.SystemCode  = systemCode;
            entity.UserId      = userEntity.Id;
            entity.UserName    = userEntity.NickName;
            entity.RealName    = userEntity.RealName;
            entity.CompanyId   = userEntity.CompanyId;
            entity.CompanyName = userEntity.CompanyName;
            if (BaseSystemInfo.OnInternet && !string.IsNullOrEmpty(userEntity.CompanyId))
            {
                entity.CompanyCode = BaseOrganizeManager.GetCodeByCache(userEntity.CompanyId);
            }
            entity.IPAddress     = ipAddress;
            entity.IPAddressName = ipAddressName;
            entity.MACAddress    = macAddress;
            entity.LoginStatus   = loginStatus;
            entity.LogLevel      = LoginStatusToLogLevel(loginStatus);
            entity.CreateOn      = DateTime.Now;

            string tableName = GetSplitTableName(userEntity);

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.LoginLogDbType, BaseSystemInfo.LoginLogDbConnection))
            {
                BaseLoginLogManager loginLogManager = new BaseLoginLogManager(dbHelper, tableName);
                try
                {
                    // 2015-07-13 把登录日志无法正常写入的,进行日志记录
                    result = loginLogManager.Add(entity, false, false);
                }
                catch (System.Exception ex)
                {
                    FileUtil.WriteMessage("AddLogTask: 异常信息:" + ex.Message
                                          + System.Environment.NewLine + "错误源:" + ex.Source
                                          + System.Environment.NewLine + "堆栈信息:" + ex.StackTrace, System.Web.HttpContext.Current.Server.MapPath("~/Log/") + "Log" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                }
            }

            return(result);
        }
        private static void AddLogTaskByBaseUserInfo(object param)
        {
            var          tuple         = param as Tuple <string, BaseUserInfo, string, string, string, string>;
            string       systemCode    = tuple.Item1;
            BaseUserInfo userInfo      = tuple.Item2;
            string       ipAddress     = tuple.Item3;
            string       ipAddressName = tuple.Item4;
            string       macAddress    = tuple.Item5;
            string       loginStatus   = tuple.Item6;

            BaseLoginLogEntity entity = new BaseLoginLogEntity();

            entity.SystemCode    = systemCode;
            entity.UserId        = userInfo.Id;
            entity.UserName      = userInfo.NickName;
            entity.RealName      = userInfo.RealName;
            entity.CompanyId     = userInfo.CompanyId;
            entity.CompanyName   = userInfo.CompanyName;
            entity.CompanyCode   = userInfo.CompanyCode;
            entity.IPAddress     = ipAddress;
            entity.IPAddressName = ipAddressName;
            entity.MACAddress    = macAddress;
            entity.LoginStatus   = loginStatus;
            entity.LogLevel      = LoginStatusToLogLevel(loginStatus);
            entity.CreateOn      = DateTime.Now;

            string tableName = GetSplitTableName(userInfo);

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.LoginLogDbType, BaseSystemInfo.LoginLogDbConnection))
            {
                BaseLoginLogManager loginLogManager = new BaseLoginLogManager(dbHelper, tableName);
                try
                {
                    // 2015-07-13 把登录日志无法正常写入的,进行日志记录
                    loginLogManager.Add(entity, false, false);
                }
                catch (System.Exception ex)
                {
                    FileUtil.WriteMessage("AddLogTask: ipAddress:" + ipAddress + "macAddress:" + macAddress
                                          + System.Environment.NewLine + "异常信息:" + ex.Message
                                          + System.Environment.NewLine + "错误源:" + ex.Source
                                          + System.Environment.NewLine + "堆栈信息:" + ex.StackTrace, System.Web.HttpContext.Current.Server.MapPath("~/Log/") + "Log" + DateTime.Now.ToString(BaseSystemInfo.DateFormat) + ".txt");
                }
            }
        }