public static void AuditDataValue(object sender, T1 data, IFreeSql orm, TableInfo table, Dictionary <string, bool> changedDict) { if (data == null || table == null) { return; } if (typeof(T1) == typeof(object) && new[] { table.Type, table.TypeLazy }.Contains(data.GetType()) == false) { throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。"); } if (orm.Aop.AuditValueHandler == null) { return; } foreach (var col in table.Columns.Values) { object val = col.GetValue(data); var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties.TryGetValue(col.CsName, out var tryprop) ? tryprop : null, val); orm.Aop.AuditValueHandler(sender, auditArgs); if (auditArgs.ValueIsChanged) { col.SetValue(data, val = auditArgs.Value); if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false) { changedDict.Add(col.Attribute.Name, true); } } if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false) { col.SetValue(data, val = ""); } } }
public ReaderableCommand(IDbConnection connection, string sql, Dictionary <string, object> sqlParameter, Aop aop) { _connection = connection; _sql = sql; _sqlParameter = sqlParameter; _aop = aop; }
public ChecklistController(Common.Data.IUnitOfWork unitOfWork, Aop.Api.Repositories.Aop.IAppRepository appRepository, Docs.Api.Repositories.DocRepository.IDocRepository docRepository, Aop.Api.WordTemplates.IDataGenerator dataGenerator) { this.unitOfWork = unitOfWork; this.appRepository = appRepository; this.docRepository = docRepository; this.dataGenerator = dataGenerator; }
public Dbclient(string connectionString, string provider) { _connection = DatabaseFactory.CreateConnection(connectionString, provider); Aop = new Aop() { OnError = (sql, paramter) => { logger.Error($"Sql: {sql}, \r\n paramter: {JsonConvert.SerializeObject(paramter)}"); //Console.WriteLine(sql); }, OnExecuting = (sql, paramter) => { //Console.WriteLine(sql); logger.InfoFormat("Sql: \r\n{0}", sql); }, }; }
static void Main(string[] args) { Aop.AddAdvice(new ConsoleAdvice()); int i = 12; string s = "hello"; Aop.Exec(() => Foo()); Aop.Exec(() => Foo2(3)); Aop.Exec(() => Foo2(i)); Aop.Exec(() => Foo3(3, "hi")); Aop.Exec(() => Foo3(i, s)); string r = Aop.Exec <string>(() => Foo4(i, s)); Console.WriteLine("返回值 : " + r); TestObj o = new TestObj(); Aop.Exec(() => o.Test()); Aop.Exec(() => o.Test2(3)); Aop.Exec(() => o.Test2(i)); Aop.Exec(() => o.Test3(3, "hi")); Aop.Exec(() => o.Test3(i, s)); r = Aop.Exec <string>(() => o.Test4(i, s)); Console.WriteLine("返回值 : " + r); Console.ReadLine(); }
public AppEmpController(Common.Data.IUnitOfWork unitOfWork, Aop.Api.Repositories.Aop.IAppRepository appRepository) { this.unitOfWork = unitOfWork; this.appRepository = appRepository; }