Esempio n. 1
0
        /// <summary>
        /// 解除锁定用户
        /// </summary>
        /// <param name="userIds">用户编号</param>
        /// <returns>更新成功记录数</returns>
        public int Unlock(string[] userIds)
        {
            var result = 0;

            if (userIds != null)
            {
                var parameters = new List <KeyValuePair <string, object> >
                {
                    new KeyValuePair <string, object>(BaseUserLogonEntity.FieldLockStartTime, null),
                    new KeyValuePair <string, object>(BaseUserLogonEntity.FieldLockEndTime, null)
                };

                result = UpdateProperty(BaseUtil.FieldUserId, userIds, parameters);
                //操作日志
                var entity = new BaseLogEntity
                {
                    Parameters  = userIds.ToString(),
                    Description = "解除锁定用户:" + ((result >= 1) ? "成功" : "失败")
                };
                if (UserInfo != null)
                {
                    entity.UserId   = int.Parse(UserInfo.Id);
                    entity.RealName = UserInfo.RealName;
                }
                new BaseLogManager(UserInfo).Add(entity);
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 2016-02-14 吉日嘎拉 增加服务器调用耗时统计功能。
        /// </summary>
        /// <param name="serviceInfo">服务调用情况</param>
        public static void AddLog(ServiceInfo serviceInfo)
        {
            if (!BaseSystemInfo.RecordLog)
            {
                return;
            }

            var entity = new BaseLogEntity
            {
                StartTime    = serviceInfo.StartTime,
                TaskId       = serviceInfo.TaskId,
                ClientIp     = serviceInfo.UserInfo.IpAddress,
                ElapsedTicks = serviceInfo.ElapsedTicks,

                UserId    = serviceInfo.UserInfo.UserId,
                CompanyId = serviceInfo.UserInfo.CompanyId.ToInt(),
                UserName  = serviceInfo.UserInfo.RealName,
                WebUrl    = serviceInfo.CurrentMethod.Module.Name.Replace(".dll", "") + "." + serviceInfo.CurrentMethod.Name
            };

            // 远程添加模式
            //LogHttpUtil.AddLog(serviceInfo.UserInfo, entity);

            // 直接写入本地数据库的方法
            var logManager = new BaseLogManager(serviceInfo.UserInfo);

            logManager.Add(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// 2016-02-14 吉日嘎拉 增加服务器调用耗时统计功能。
        /// </summary>
        /// <param name="serviceInfo">服务调用情况</param>
        public static void AddLog(ServiceInfo serviceInfo)
        {
            if (!BaseSystemInfo.RecordLog)
            {
                return;
            }

            BaseLogEntity entity = new BaseLogEntity();

            entity.StartTime    = serviceInfo.StartTime;
            entity.TaskId       = serviceInfo.TaskId;
            entity.ClientIP     = serviceInfo.UserInfo.IPAddress;
            entity.ElapsedTicks = serviceInfo.ElapsedTicks;

            entity.UserId       = serviceInfo.UserInfo.Id;
            entity.CompanyId    = serviceInfo.UserInfo.CompanyId;
            entity.UserRealName = serviceInfo.UserInfo.RealName;
            entity.WebUrl       = serviceInfo.CurrentMethod.Module.Name.Replace(".dll", "") + "." + serviceInfo.CurrentMethod.Name;

            // 远程添加模式
            LogUtilities.AddLog(serviceInfo.UserInfo, entity);

            // 直接写入本地数据库的方法
            // BaseLogManager logManager = new BaseLogManager(serviceInfo.UserInfo);
            // logManager.Add(entity);
        }
 /// <summary>
 /// 添加, 这里可以人工干预,提高程序的性能
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式,表主键是否采用自增的策略</param>
 /// <param name="returnId">返回主键,不返回程序允许速度会快,主要是为了主细表批量插入数据优化用的</param>
 /// <returns>主键</returns>
 public string Add(BaseLogEntity entity, bool identity = true, bool returnId = true)
 {
     Identity  = identity;
     ReturnId  = returnId;
     entity.Id = AddEntity(entity).ToInt();
     return(entity.Id.ToString());
 }
Esempio n. 5
0
 /// <summary>
 /// 添加日志
 /// </summary>
 /// <param name="dbHelper">数据库连接</param>
 /// <param name="logEntity">日志对象</param>
 /// <returns>主键</returns>
 public void Add(IDbHelper dbHelper, BaseLogEntity logEntity)
 {
     DbHelper = dbHelper;
     // 这里是出错了,才调试
     // return 0;
     AddEntity(logEntity);
 }
 /// <summary>
 /// 添加或更新(主键是否为0)
 /// </summary>
 /// <param name="entity">实体</param>
 /// <param name="identity">自增量方式,表主键是否采用自增的策略</param>
 /// <param name="returnId">返回主键,不返回程序允许速度会快,主要是为了主细表批量插入数据优化用的</param>
 /// <returns>主键</returns>
 public string AddOrUpdate(BaseLogEntity entity, bool identity = true, bool returnId = true)
 {
     Identity = identity;
     ReturnId = returnId;
     if (entity.Id == 0)
     {
         entity.Id = AddEntity(entity).ToInt();
         return(entity.Id.ToString());
     }
     else
     {
         return(UpdateEntity(entity) > 0 ? entity.Id.ToString() : string.Empty);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 写入网页访问日志
        /// </summary>
        /// <param name="urlReferrer">导入网址</param>
        /// <param name="ad">广告商ID</param>
        /// <param name="webUrl">访问的网址</param>
        /// <param name="ipAddress">网络地址</param>
        /// <param name="userId">用户主键</param>
        /// <param name="userName">用户名</param>
        public void AddWebLog(string urlReferrer, string adId, string webUrl, string ipAddress, string userId, string userName)
        {
            BaseLogEntity logEntity = new BaseLogEntity();

            logEntity.ProcessId   = "WebLog";
            logEntity.UrlReferrer = urlReferrer;
            if (!string.IsNullOrEmpty(adId))
            {
                logEntity.MethodName = "AD";
                logEntity.Parameters = adId;
            }
            logEntity.WebUrl       = webUrl;
            logEntity.IPAddress    = ipAddress;
            logEntity.UserId       = userId;
            logEntity.UserRealName = userName;
            this.AddEntity(logEntity);
        }
Esempio n. 8
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="userRealName">用户姓名</param>
        /// <param name="processID">模块ID</param>
        /// <param name="processName">模块名称</param>
        /// <param name="methodName">对象ID</param>
        /// <param name="parameters">对象名称</param>
        /// <param name="ipAddress">IP地址</param>
        /// <param name="description">描述</param>
        /// <returns>主键</returns>
        public void Add(string userId, string realName, string processId, string processName, string methodId, string methodName, string parameters, string ipAddress, string description)
        {
            BaseLogEntity logEntity = new BaseLogEntity();

            logEntity.UserId       = userId;
            logEntity.UserRealName = realName;
            logEntity.ProcessId    = processId;
            logEntity.ProcessName  = processName;
            logEntity.MethodName   = methodName;
            logEntity.MethodId     = methodId;
            logEntity.Parameters   = parameters;
            logEntity.IPAddress    = ipAddress;
            logEntity.Description  = description;
            // 这里是出错了,才调试
            // return 0;
            this.AddEntity(logEntity);
        }
Esempio n. 9
0
        public static void AddLog(BaseUserInfo userInfo, BaseLogEntity entity)
        {
            // 2016-02-17 吉日嘎拉 是否允许记录日志的判断
            if (!BaseSystemInfo.RecordLogOnLog)
            {
                return;
            }

            // string url = BaseSystemInfo.UserCenterHost + "/UserCenterV42/LogService.ashx";
            string              url        = "http://139.196.91.4/UserCenterV42/LogService.ashx";
            WebClient           webClient  = new WebClient();
            NameValueCollection postValues = new NameValueCollection();

            postValues.Add("system", BaseSystemInfo.SoftFullName);
            postValues.Add("systemCode", BaseSystemInfo.SystemCode);
            postValues.Add("securityKey", BaseSystemInfo.SecurityKey);
            // 2015-11-25 吉日嘎拉,这里还是从缓存里获取就可以了,提高登录的效率。
            postValues.Add("function", "AddLog");
            if (userInfo != null)
            {
                postValues.Add("userInfo", userInfo.Serialize());
            }
            postValues.Add("service", entity.Service);
            postValues.Add("startTime", entity.StartTime.ToString(BaseSystemInfo.DateTimeFormat));
            postValues.Add("TaskId", entity.TaskId);
            postValues.Add("ClientIP", entity.ClientIP);
            postValues.Add("ElapsedTicks", entity.ElapsedTicks.ToString());
            postValues.Add("UserId", entity.UserId);
            postValues.Add("CompanyId", entity.CompanyId);
            postValues.Add("UserRealName", entity.UserRealName);
            postValues.Add("WebUrl", entity.WebUrl);
            // 向服务器发送POST数据、异步提交日志服务器
            Uri address = new Uri(url);

            webClient.UploadValuesAsync(address, postValues);

            /*
             * BaseResult result = null;
             * byte[] responseArray = webClient.UploadValues(url, postValues);
             * string response = Encoding.UTF8.GetString(responseArray);
             * if (!string.IsNullOrEmpty(response))
             * {
             *  result = JsonConvert.DeserializeObject<BaseResult>(response);
             * }
             */
        }
Esempio n. 10
0
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="entity">日志对象</param>
        /// <returns>主键</returns>
        public string AddObject(BaseLogEntity entity)
        {
            // 2013-10-06 JiRiGala 改进为添加到消息队列里,提高系统的性能
            // System.Messaging.MessageQueue messageQueue = new System.Messaging.MessageQueue(".\\Private$\\DotNetLog");
            // System.Messaging.StatusMessage message = new System.Messaging.StatusMessage();
            // message.Body = entity;
            // message.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(string) });
            // messageQueue.Send(message);

            if (!BaseSystemInfo.RecordLog)
            {
                return(string.Empty);
            }

            if (string.IsNullOrEmpty(entity.Id))
            {
                entity.Id = System.Guid.NewGuid().ToString("N");
            }

            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginInsert(this.CurrentTableName, this.Identity);
            sqlBuilder.SetValue(BaseLogEntity.FieldId, entity.Id);
            sqlBuilder.SetValue(BaseLogEntity.FieldTaskId, entity.TaskId);
            sqlBuilder.SetValue(BaseLogEntity.FieldService, entity.Service);
            sqlBuilder.SetValue(BaseLogEntity.FieldStartTime, entity.StartTime);
            sqlBuilder.SetValue(BaseLogEntity.FieldUserId, entity.UserId);
            sqlBuilder.SetValue(BaseLogEntity.FieldUserRealName, entity.UserRealName);
            sqlBuilder.SetValue(BaseLogEntity.FieldCompanyId, entity.CompanyId);
            sqlBuilder.SetValue(BaseLogEntity.FieldUrlReferrer, entity.UrlReferrer);
            sqlBuilder.SetValue(BaseLogEntity.FieldWebUrl, entity.WebUrl);
            sqlBuilder.SetValue(BaseLogEntity.FieldParameters, entity.Parameters);
            sqlBuilder.SetValue(BaseLogEntity.FieldClientIP, entity.ClientIP);
            sqlBuilder.SetValue(BaseLogEntity.FieldServerIP, entity.ServerIP);
            sqlBuilder.SetValue(BaseLogEntity.FieldElapsedTicks, entity.ElapsedTicks);
            sqlBuilder.SetValue(BaseLogEntity.FieldDescription, entity.Description);

            // sqlBuilder.SetDBNow(BaseLogEntity.FieldStartTime);
            sqlBuilder.EndInsert();

            return(entity.Id);
        }
Esempio n. 11
0
        public void Add(IDbHelper dbHelper, BaseUserInfo userInfo, string processName, string methodName, string processId, string methodId, string parameters)
        {
            // int returnValue = 0;
            DbHelper = dbHelper;
            UserInfo = userInfo;
            if (!BaseSystemInfo.RecordLog)
            {
                return;
            }
            BaseLogEntity logEntity = new BaseLogEntity();

            logEntity.UserId       = userInfo.Id;
            logEntity.UserRealName = userInfo.RealName;
            logEntity.ProcessId    = processId;
            logEntity.ProcessName  = processName;
            logEntity.MethodId     = methodId;
            logEntity.MethodName   = methodName;
            logEntity.Parameters   = parameters;
            logEntity.IPAddress    = userInfo.IPAddress;
            this.Add(dbHelper, logEntity);
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="sqlBuilder">Sql语句生成器</param>
 /// <param name="entity">实体</param>
 private void SetEntity(SqlBuilder sqlBuilder, BaseLogEntity entity)
 {
     SetEntityExtend(sqlBuilder, entity);
     sqlBuilder.SetValue(BaseLogEntity.FieldCompanyId, entity.CompanyId);
     sqlBuilder.SetValue(BaseLogEntity.FieldUserId, entity.UserId);
     sqlBuilder.SetValue(BaseLogEntity.FieldUserName, entity.UserName);
     sqlBuilder.SetValue(BaseLogEntity.FieldRealName, entity.RealName);
     sqlBuilder.SetValue(BaseLogEntity.FieldService, entity.Service);
     sqlBuilder.SetValue(BaseLogEntity.FieldTaskId, entity.TaskId);
     sqlBuilder.SetValue(BaseLogEntity.FieldParameters, entity.Parameters);
     sqlBuilder.SetValue(BaseLogEntity.FieldClientIp, entity.ClientIp);
     sqlBuilder.SetValue(BaseLogEntity.FieldServerIp, entity.ServerIp);
     sqlBuilder.SetValue(BaseLogEntity.FieldUrlReferrer, entity.UrlReferrer);
     sqlBuilder.SetValue(BaseLogEntity.FieldWebUrl, entity.WebUrl);
     sqlBuilder.SetValue(BaseLogEntity.FieldElapsedTicks, entity.ElapsedTicks);
     sqlBuilder.SetValue(BaseLogEntity.FieldStartTime, entity.StartTime);
     sqlBuilder.SetValue(BaseLogEntity.FieldDescription, entity.Description);
     sqlBuilder.SetValue(BaseLogEntity.FieldSortCode, entity.SortCode);
     sqlBuilder.SetValue(BaseLogEntity.FieldDeleted, entity.Deleted);
     sqlBuilder.SetValue(BaseLogEntity.FieldEnabled, entity.Enabled);
 }
Esempio n. 13
0
        /// <summary>
        /// 设置并发用户
        /// </summary>
        /// <param name="userIds">用户编号</param>
        /// <returns>更新成功记录数</returns>
        public int SetConcurrentUser(string[] userIds)
        {
            var result = 0;

            if (userIds != null)
            {
                result = UpdateProperty(BaseUtil.FieldUserId, userIds, new KeyValuePair <string, object>(BaseUserLogonEntity.FieldConcurrentUser, 1));
                //操作日志
                var entity = new BaseLogEntity
                {
                    Parameters  = userIds.ToString(),
                    Description = "设置并发用户:" + ((result >= 1) ? "成功" : "失败")
                };
                if (UserInfo != null)
                {
                    entity.UserId   = int.Parse(UserInfo.Id);
                    entity.RealName = UserInfo.RealName;
                }
                new BaseLogManager(UserInfo).Add(entity);
            }

            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// 撤销设置超级管理员
        /// </summary>
        /// <param name="userIds">用户编号</param>
        /// <returns>更新成功记录数</returns>
        public int UndoSetAdministrator(string[] userIds)
        {
            var result = 0;

            if (userIds != null)
            {
                result = UpdateProperty(BaseUtil.FieldId, userIds, new KeyValuePair <string, object>(BaseUserEntity.FieldIsAdministrator, 0));
                //操作日志
                var entity = new BaseLogEntity
                {
                    Parameters  = userIds.ToString(),
                    Description = "撤销设置超级管理员:" + ((result >= 1) ? "成功" : "失败")
                };
                if (UserInfo != null)
                {
                    entity.UserId   = int.Parse(UserInfo.Id);
                    entity.RealName = UserInfo.RealName;
                }
                new BaseLogManager(UserInfo).Add(entity);
            }

            return(result);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体</param>
        public int UpdateEntity(BaseLogEntity entity)
        {
            var sqlBuilder = new SqlBuilder(DbHelper);

            sqlBuilder.BeginUpdate(CurrentTableName);
            SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDbNow(BaseLogEntity.FieldUpdateTime);
            sqlBuilder.SetValue(BaseLogEntity.FieldUpdateIp, Utils.GetIp());
            sqlBuilder.SetWhere(PrimaryKey, entity.Id);
            //return sqlBuilder.EndUpdate();
            var result = sqlBuilder.EndUpdate();

            if (result > 0)
            {
                RemoveCache(entity.Id);
            }
            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="logEntity">日志对象</param>
        /// <returns>主键</returns>
        public int AddEntity(BaseLogEntity logEntity)
        {
            int returnValue = 0;
            // if (!BaseSystemInfo.RecordLog)
            // {
            //    return string.Empty;
            // }
            // 由于并发控制,没有能获得有效ID的错误处理,测试一下错误发生的数量。
            // if (Log.ID.Length == 0)
            // {
            //    return returnValue;
            // }
            // string sequence = BaseSequenceManager.Instance.GetSequence(DbHelper, BaseLogEntity.TableName);
            // string sequence = BaseSequenceManager.Instance.NewGuid();
            string     sequence   = string.Empty;
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            if (DbHelper.CurrentDbType == CurrentDbType.Access)
            // sqlBuilder.BeginInsert(this.CurrentTableName, "LogId", this.Identity);
            {
                // 写入日志 04-24
                dbHelper.Open(BaseSystemInfo.UserCenterDbConnection);
                // 用户已经不存在的需要整理干净,防止数据不完整。
                string sqlQuery = " INSERT INTO [BaseLog]([ProcessId],[ProcessName],[MethodId] " +
                                  " ,[MethodName],[Parameters],[UserId],[UserRealName],[IPAddress],[UrlReferrer],[WebUrl],[Description],[CreateOn],[ModifiedOn]) VALUES " +
                                  "( '" + logEntity.ProcessId + "','" + logEntity.ProcessName + "','" + logEntity.MethodId.ToString() + "','" + logEntity.MethodName + "','" +
                                  logEntity.Parameters + "','" + logEntity.UserId + "','" + logEntity.UserRealName + "','" + logEntity.IPAddress + "','" + logEntity.UrlReferrer + "','" +
                                  logEntity.WebUrl + " ','" + logEntity.Description + "'," + DbHelper.GetDBNow() + "," + DbHelper.GetDBNow() + ")";

                return(dbHelper.ExecuteNonQuery(sqlQuery));;
            }
            else
            {
                sqlBuilder.BeginInsert(this.CurrentTableName, this.Identity);
            }

            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseLogEntity.FieldId, logEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseLogEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseLogEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(logEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            logEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(BaseLogEntity.FieldId, logEntity.Id);
                    }
                }
            }
            if (String.IsNullOrEmpty(logEntity.UserId))
            {
                logEntity.UserId = logEntity.IPAddress;
            }
            sqlBuilder.SetValue(BaseLogEntity.FieldUserId, logEntity.UserId);
            sqlBuilder.SetValue(BaseLogEntity.FieldUserRealName, logEntity.UserRealName);
            sqlBuilder.SetValue(BaseLogEntity.FieldProcessId, logEntity.ProcessId);
            sqlBuilder.SetValue(BaseLogEntity.FieldProcessName, logEntity.ProcessName);
            sqlBuilder.SetValue(BaseLogEntity.FieldMethodId, logEntity.MethodId);
            sqlBuilder.SetValue(BaseLogEntity.FieldMethodName, logEntity.MethodName);
            sqlBuilder.SetValue(BaseLogEntity.FieldParameters, logEntity.Parameters);
            sqlBuilder.SetValue(BaseLogEntity.FieldUrlReferrer, logEntity.UrlReferrer);
            sqlBuilder.SetValue(BaseLogEntity.FieldWebUrl, logEntity.WebUrl);
            sqlBuilder.SetValue(BaseLogEntity.FieldIPAddress, logEntity.IPAddress);
            sqlBuilder.SetValue(BaseLogEntity.FieldDescription, logEntity.Description);
            //if (logEntity.CreateUserId.Length == 0)
            //{
            //    logEntity.CreateUserId = logEntity.IPAddress;
            //}
            //sqlBuilder.SetValue(BaseLogEntity.FieldCreateUserId, logEntity.CreateUserId);
            sqlBuilder.SetDBNow(BaseLogEntity.FieldCreateOn);
            // return sqlBuilder.EndInsert() > 0 ? sequence : string.Empty;
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer)
            {
                returnValue = sqlBuilder.EndInsert();
            }
            else
            {
                sqlBuilder.EndInsert();
                if (this.ReturnId)//如果需要反回值
                {
                    returnValue = int.Parse(logEntity.Id);
                }
                else
                {
                    returnValue = 0;
                }
            }
            return(returnValue);
        }
Esempio n. 17
0
 /// <summary>
 /// 添加日志
 /// </summary>
 /// <param name="dbHelper">数据库连接</param>
 /// <param name="entity">日志对象</param>
 /// <returns>主键</returns>
 public void Add(BaseLogEntity entity)
 {
     // 本地添加模式
     AddObject(entity);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BaseLogEntity entity)
 {
     return(UpdateEntity(entity));
 }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体</param>
        public string AddEntity(BaseLogEntity entity)
        {
            if (!BaseSystemInfo.RecordLog)
            {
                return("0");
            }

            var key = string.Empty;

            if (entity.SortCode == 0)
            {
                //var managerSequence = new BaseSequenceManager(DbHelper, Identity);
                //if (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2)
                //{
                //    key = managerSequence.Increment($"SC_{CurrentTableName}_SEQ");
                //}
                //else
                //{
                //    key = managerSequence.Increment(CurrentTableName);
                //}
                //entity.SortCode = key.ToInt();
            }
            var sqlBuilder = new SqlBuilder(DbHelper, Identity, ReturnId);

            sqlBuilder.BeginInsert(CurrentTableName, PrimaryKey);
            if (!Identity)
            {
                // 这里已经是指定了主键了,所以不需要返回主键了
                sqlBuilder.ReturnId = false;
                sqlBuilder.SetValue(PrimaryKey, entity.Id);
            }
            else
            {
                if (!ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(PrimaryKey, $"{CurrentTableName}_SEQ.NEXTVAL");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.Db2)
                    {
                        sqlBuilder.SetFormula(PrimaryKey, $"NEXT VALUE FOR {CurrentTableName}_SEQ");
                    }
                }
                else
                {
                    if (Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
                    {
                        var managerSequence = new BaseSequenceManager(DbHelper);
                        entity.Id = managerSequence.Increment($"{CurrentTableName}_SEQ").ToInt();
                        sqlBuilder.SetValue(PrimaryKey, entity.Id);
                    }
                }
            }
            SetEntity(sqlBuilder, entity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseLogEntity.FieldCreateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BaseLogEntity.FieldCreateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BaseLogEntity.FieldCreateBy, UserInfo.RealName);
            }
            else
            {
                sqlBuilder.SetValue(BaseLogEntity.FieldCreateBy, entity.CreateBy);
                sqlBuilder.SetValue(BaseLogEntity.FieldCreateUserName, entity.CreateUserName);
            }
            sqlBuilder.SetDbNow(BaseLogEntity.FieldCreateTime);
            sqlBuilder.SetValue(BaseLogEntity.FieldCreateIp, Utils.GetIp());
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateUserId, UserInfo.UserId);
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateUserName, UserInfo.UserName);
                sqlBuilder.SetValue(BaseLogEntity.FieldUpdateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDbNow(BaseLogEntity.FieldUpdateTime);
            sqlBuilder.SetValue(BaseLogEntity.FieldUpdateIp, Utils.GetIp());
            if (Identity && (DbHelper.CurrentDbType == CurrentDbType.SqlServer || DbHelper.CurrentDbType == CurrentDbType.Access))
            {
                key = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            if (Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.Db2))
            {
                key = entity.Id.ToString();
            }
            if (!string.IsNullOrWhiteSpace(key))
            {
                RemoveCache();
            }
            return(key);
        }
 // 这个是声明扩展方法
 partial void SetEntityExtend(SqlBuilder sqlBuilder, BaseLogEntity entity);