public ErrorCode AddAuditTrail(Guid Oid, string ChangedBy, string Data, CategoryAudit category, ActionAudit action) { ErrorCode err = ErrorCode.ERROR_SUCCESS; if (IsReadyForLogging == false) { return(err); } try { RDSAuditTrail.AddAuditTrail(Oid, ChangedBy, Data, category, action); return(err); } catch (Exception e) { throw e; } }
internal static void AddAuditTrail(Guid Oid, string ChangedBy, string Data, CategoryAudit category, ActionAudit action) { try { AuditTrail h = new AuditTrail(); h.Oid = Oid; h.ChangedBy = ChangedBy; h.Data = Data; h.ChangedOn = DateTime.Now; h.CategoryAudit = category; h.ActionAudit = action; db.AuditTrails.Insert(h); } catch (Exception e) { throw e; } }
internal static void AddAuditTrail(Guid Oid, string ChangedBy, string Data, CategoryAudit category, ActionAudit action) { try { //Db db = new Db(); AuditTrail h = new AuditTrail(); h.Oid = Oid.ToString(); h.ChangedBy = ChangedBy; h.Data = Data; h.ChangedOn = DateTime.Now; h.CategoryAudit = category; h.ActionAudit = action; db.AuditTrails.Insert(h); //db.AuditTrails.Add(h); //db.SaveChanges(); //db.Dispose(); } catch (Exception e) { throw e; } }
/// <summary> /// Save AuditTrail to Mysql. /// </summary> /// <param name="master">The master.</param> /// <param name="oid">The oid.</param> /// <param name="name">The name.</param> /// <param name="category">The category.</param> /// <param name="IsNewObj">if set to <c>true</c> [is new object].</param> /// <param name="nameObjectDeleted">The name object deleted.</param> public static void ToHistory(this Master HistoryHelper, Guid Oid, string ObjToString, string ChangedBy, CategoryAudit Category, bool IsNewObject = false, string NameObjectDeleted = null) { if (IsNewObject) { if (HistoryHelper.DescriptionHistory() != "") { NASDMS.RDS.Services.AuditTrailServices.IAuditTrailService AuditTrailService = new NASDMS.RDS.Services.AuditTrailServices.AuditTrailService(); var temp = new Master(); temp.list = HistoryHelper.list.Where(o => o.action == NASDMS.Module.Common.Helper.Action.Created).ToList(); if (temp.DescriptionHistory() != "") { AuditTrailService.AddAuditTrail(Oid, ChangedBy, temp.DescriptionHistory(), Category, ActionAudit.Created); foreach (var item in temp.list) { HistoryHelper.list.Remove(item); } } } } else { if (NameObjectDeleted == null) { if (HistoryHelper.DescriptionHistory() != "") { NASDMS.RDS.Services.AuditTrailServices.IAuditTrailService AuditTrailService = new NASDMS.RDS.Services.AuditTrailServices.AuditTrailService(); var finds = HistoryHelper.list.Where(o => o.Oid == HistoryHelper.Oid).ToList(); var DescriptionTemp = ""; if (finds != null) { foreach (var listHistory in finds) { DescriptionTemp += listHistory.propertyName + ": " + listHistory.oldValue + " -> " + listHistory.newValue + Environment.NewLine; } } foreach (var item in finds) { HistoryHelper.list.Remove(item); } AuditTrailService.AddAuditTrail(Oid, ChangedBy, ObjToString + Environment.NewLine + DescriptionTemp, Category, ActionAudit.Updated); } } else { NASDMS.RDS.Services.AuditTrailServices.IAuditTrailService AuditTrailService = new NASDMS.RDS.Services.AuditTrailServices.AuditTrailService(); AuditTrailService.AddAuditTrail(Oid, ChangedBy, NameObjectDeleted, Category, ActionAudit.Deleted); } } return; }