private void updateDVh(IAudit model) { try { generateDVh(model); Type type = model.GetType(); string tableName = getTableName(type); AuditDvh dvh = findDV(tableName, model.id.ToString()); if (dvh == null) { dvh = new AuditDvh(tableName, model.id.ToString(), model.dv); db.DVHs.Add(dvh); } else { dvh.dv = model.dv; db.Entry(dvh).State = EntityState.Modified; } db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
public Audit( ActionEvent action, IAudit audit) { Action = action; Type = audit.GetType().ToString(); Description = audit.ToAudit(); var now = DateTime.Now; Date = now.Date; Time = now.TimeOfDay; }
public static IAudit AuditRecursive(this IAudit model, object userId, IAudit auditClass) { model.Audit(userId, auditClass); var propsWithAudit = model.GetType().GetProperties() .Where(_ => typeof(IAudit).IsAssignableFrom(_.PropertyType)); foreach (var item in propsWithAudit) { if (item.GetValue(model).IsNotNull()) { var propModel = item.GetValue(model) as IAudit; propModel.Audit(userId, auditClass); } } return(model); }
public bool validateDVh(IAudit model) { bool result = true; Type type = model.GetType(); string tableName = getTableName(type); model.dv = generateDVh(model); AuditDvh currentDv = findDV(tableName, model.id.ToString()); if (currentDv != null) { result = model.dv == currentDv.dv; } else { result = false; } return(result); }
private string generateDVh(IAudit model) { Type type = model.GetType(); var properties = type.GetProperties(); string dv = ""; foreach (var property in properties) { try { if (property.Name != "DV") { var value = type.GetProperty(property.Name).GetValue(model, null); dv += value; } } catch (Exception err) { } } model.dv = Cryptog.EncriptarMD5(dv); return(model.dv); }