|  |  | 
 |  |  |                 CodeRuleAttribute? codeRuleAttribute = propertyInfo.GetCustomAttribute<CodeRuleAttribute>(); | 
 |  |  |                 if (codeRuleAttribute != null) | 
 |  |  |                 { | 
 |  |  |                     SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig | 
 |  |  |                     if (propertyInfo.GetValue(entityInfo.EntityValue) == null) | 
 |  |  |                     { | 
 |  |  |                         ConfigId = MainDb.CurrentDbConnId, | 
 |  |  |                         ConnectionString = DBContext.GetMainConnectionDb().Connection, | 
 |  |  |                         IsAutoCloseConnection = true, | 
 |  |  |                         DbType = MainDb.DbType, | 
 |  |  |                     }); | 
 |  |  |                     dynamic ruleConfig = sugarClient.Queryable(MainDb.CodeRuleConfig, "x").Where(nameof(CodeRuleAttribute.RuleCode), "=", codeRuleAttribute.RuleCode.ToString()).First(); | 
 |  |  |                     if (ruleConfig != null) | 
 |  |  |                     { | 
 |  |  |                         string code = CreateCodeByRule(ruleConfig, sugarClient); | 
 |  |  |                         propertyInfo.SetValue(entityInfo.EntityValue, code, null); | 
 |  |  |                         SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig | 
 |  |  |                         { | 
 |  |  |                             ConfigId = MainDb.CurrentDbConnId, | 
 |  |  |                             ConnectionString = DBContext.GetMainConnectionDb().Connection, | 
 |  |  |                             IsAutoCloseConnection = true, | 
 |  |  |                             DbType = MainDb.DbType, | 
 |  |  |                         }); | 
 |  |  |                         dynamic ruleConfig = sugarClient.Queryable(MainDb.CodeRuleConfig, "x").Where(nameof(CodeRuleAttribute.RuleCode), "=", codeRuleAttribute.RuleCode.ToString()).First(); | 
 |  |  |                         if (ruleConfig != null) | 
 |  |  |                         { | 
 |  |  |                             string code = CreateCodeByRule(ruleConfig, sugarClient); | 
 |  |  |                             propertyInfo.SetValue(entityInfo.EntityValue, code, null); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         int seq = sugarClient.Ado.GetScalar($"SELECT NEXT VALUE FOR {sequenceAttirbute.SequenceName}").ObjToInt(); | 
 |  |  |                         propertyInfo.SetValue(entityInfo.EntityValue, seq, null); | 
 |  |  |                     } | 
 |  |  |                    | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (entityInfo.EntityValue is BaseEntity baseEntity) | 
 |  |  |             { | 
 |  |  |                 // 鏂板鎿嶄綔 | 
 |  |  |                 if (entityInfo.OperationType == DataFilterType.InsertByObject) | 
 |  |  |                 if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(BaseEntity.CreateDate)) | 
 |  |  |                 { | 
 |  |  |                     if (entityInfo.PropertyName == nameof(BaseEntity.CreateDate)) | 
 |  |  |                     { | 
 |  |  |                         baseEntity.CreateDate = DateTime.Now; | 
 |  |  |                     } | 
 |  |  |                     baseEntity.CreateDate = DateTime.Now; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (entityInfo.OperationType == DataFilterType.UpdateByObject) | 
 |  |  |                 if (entityInfo.OperationType == DataFilterType.UpdateByObject && entityInfo.PropertyName == nameof(BaseEntity.ModifyDate)) | 
 |  |  |                 { | 
 |  |  |                     baseEntity.ModifyDate = DateTime.Now; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 //if (App.User?.UserId > 0) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         private static void UpdateConfigData(dynamic ruleConfig) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             if (entityInfo.EntityValue is IBaseHistoryEntity baseHistoryEntity) | 
 |  |  |             { | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             catch (Exception ex) | 
 |  |  |             { | 
 |  |  |  | 
 |  |  |                 if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(IBaseHistoryEntity.InsertTime)) | 
 |  |  |                 { | 
 |  |  |                     baseHistoryEntity.InsertTime = DateTime.Now; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 sugarClient.Updateable(keyValuePairs).AS(MainDb.CodeRuleConfig).WhereColumns(nameof(ruleConfig.Id)).ExecuteCommand(); | 
 |  |  |             } | 
 |  |  |             return code; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         private static string GetWholeSql(SugarParameter[] paramArr, string sql) | 
 |  |  |         { | 
 |  |  |             foreach (var param in paramArr) | 
 |  |  |             { | 
 |  |  |                 sql = sql.Replace(param.ParameterName, $@"'{param.Value.ObjToString()}'"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             return sql; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         private static string GetParas(SugarParameter[] pars) | 
 |  |  |         { | 
 |  |  |             string key = "銆怱QL鍙傛暟銆戯細"; | 
 |  |  |             foreach (var param in pars) | 
 |  |  |             { | 
 |  |  |                 key += $"{param.ParameterName}:{param.Value}\n"; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             return key; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |