/// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="loginStatus">动作</param>
        public static void AddLog(BaseUserInfo userInfo, string loginStatus)
        {
            var systemCode    = userInfo.SystemCode;
            var ipAddress     = userInfo.IpAddress;
            var ipAddressName = IpUtil.GetInstance().FindName(userInfo.IpAddress);
            var macAddress    = userInfo.MacAddress;

            AddLog(systemCode, userInfo, ipAddress, ipAddressName, macAddress, loginStatus);
        }
        /// <summary>
        /// 用户退出
        /// </summary>
        /// <param name="openId">信令</param>
        /// <param name="systemCode">系统编码</param>
        /// <param name="ipAddress">IP地址</param>
        /// <param name="macAddress">MAC地址</param>
        /// <returns>影响行数</returns>
        public bool SignOut(string openId, string systemCode = "Base", string ipAddress = null, string macAddress = null)
        {
            var result = 0;

            // 应该进行一次日志记录
            // 从缓存读取、效率高
            if (!string.IsNullOrWhiteSpace(openId))
            {
                var userEntity = BaseUserManager.GetEntityByOpenIdByCache(openId);
                if (userEntity != null && userEntity.Id > 0)
                {
                    var ipAddressName = string.Empty;
                    if (!string.IsNullOrEmpty(ipAddress))
                    {
                        ipAddressName = IpUtil.GetInstance().FindName(ipAddress);
                    }

                    BaseLogonLogManager.AddLog(systemCode, userEntity, ipAddress, ipAddressName, macAddress, Status.SignOut.ToDescription(), 0, 1);

                    // 是否更新访问日期信息
                    if (!BaseSystemInfo.UpdateVisit)
                    {
                        return(result > 0);
                    }
                    // 最后一次登录时间
                    var sql = "UPDATE " + BaseUserLogonEntity.CurrentTableName + " SET " + BaseUserLogonEntity.FieldPreviousVisitTime + " = " + BaseUserLogonEntity.FieldLastVisitTime;
                    //Troy.Cui 2020-02-29用户退出时也强制OpenId重新生成,和登录时一样强制生成OpenId
                    sql += " , " + BaseUserLogonEntity.FieldOpenId + " = '" + Guid.NewGuid().ToString("N") + "'";
                    sql += ", " + BaseUserLogonEntity.FieldOpenIdTimeoutTime + " = " + DbHelper.GetDbNow();
                    sql += " , " + BaseUserLogonEntity.FieldUserOnline + " = 0 "
                           + " , " + BaseUserLogonEntity.FieldLastVisitTime + " = " + DbHelper.GetDbNow();
                    sql += "  WHERE " + BaseUserLogonEntity.FieldUserId + " = " + DbHelper.GetParameter(BaseUserEntity.FieldId);

                    var dbParameters = new List <IDbDataParameter>
                    {
                        DbHelper.MakeParameter(BaseUserEntity.FieldId, userEntity.Id)
                    };
                    result = ExecuteNonQuery(sql, dbParameters.ToArray());
                }
            }

            return(result > 0);
        }