public ObservableCollection <AuditTrail> LoadAuditTrail(AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500) { return(sender.Logs); }
public long Begin(AuditTrailViewModel sender, AuditTrail message) { WriteLine(sender, message); return(1); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public static ObservableCollection <AuditTrail> LoadAuditTrail(DBSQLViewModel dBSQLViewModel, AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500) { var AuditTrail = new List <AuditTrail>(); string Where = GetWhere(dBSQLViewModel.DBType, sender); string SQL = DB_SQL.SelectAll(dBSQLViewModel.DBType, "AuditTrail", Where, MaxRecords); if (dBSQLViewModel != null) { try { AuditTrail = DB_SQL.Query <AuditTrail>(dBSQLViewModel, SQL); if (AuditTrail == null) { AuditTrail = new List <AuditTrail>(); } ; } catch (Exception ex) { Debug.WriteLine(ex.Message); }; } ; return(new ObservableCollection <AuditTrail>(AuditTrail)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public static string GetWhere(DBType dbType, AuditTrailViewModel sender, bool ShowUser = true) { // String SQL = "SELECT TOP 500 AuditTrail.*, UserAccount.Login FROM AuditTrail LEFT OUTER JOIN UserAccount ON AuditTrail.FKUser = UserAccount.PK WHERE 1=1 ORDER BY AuditTrail.PK DESC"; String Where = ""; switch (dbType) { case DBType.MySQL: // Where = "LEFT OUTER JOIN UserAccount ON AuditTrail.FKUser = cast(UserAccount.PK as varchar(128)) WHERE 1=1 order by AuditTrail.PK desc"; Where = "WHERE 1=1 order by AuditTrail.PK desc"; break; default: // Where = "LEFT OUTER JOIN UserAccount ON AuditTrail.FKUser = cast(UserAccount.PK as varchar(128)) WHERE 1=1 order by AuditTrail.PK desc"; Where = "WHERE 1=1 order by AuditTrail.PK desc"; break; } ; if (!ShowUser) { Where = "WHERE 1=1 order by AuditTrail.PK desc"; } ; // - - - - Where = Where.Replace("1=1", string.Format("Level>={0} and 1=1", (int)(sender.Level))); if (!sender.Childs) { Where = Where.Replace("1=1", "(Parent is null or Parent=0) and 1=1"); } ; if (!sender.IsDebug) { Where = Where.Replace("1=1", "IsBusiness = '1' and 1=1"); } ; if (!string.IsNullOrEmpty(sender.TerminalID)) { Where = Where.Replace("1=1", string.Format("TerminalID = '{0}' and 1=1", sender.TerminalID)); } ; //if (!string.IsNullOrEmpty(sender.User) && sender.User != "0") //{ // Where = Where.Replace("1=1", string.Format("FKUser = '******' and 1=1", User)); //}; //if (!string.IsNullOrEmpty(sender.UserWhere) && sender.User != "0") //{ // UserWhere = UserWhere.Trim(); // if (UserWhere.StartsWith("AND ")) // { // Where = Where.Replace("1=1", $"{UserWhere.Substring(5)} and 1=1"); // } // else if (UserWhere.StartsWith("OR ")) // { // Where = Where.Replace("1=1", $"{UserWhere.Substring(4)} or 1=1"); // } // else if (UserWhere.StartsWith("(")) // { // if (!UserWhere.EndsWith(")")) // { // UserWhere = UserWhere + ")"; // }; // Where = Where.Replace("1=1", $"{UserWhere} and 1=1"); // } // else // { // Where = Where.Replace("1=1", $"{UserWhere} and 1=1"); // }; //}; //if (!string.IsNullOrEmpty(Event) && Event != "01/01/1900 00:00:00") //{ // Where = Where.Replace("1=1", string.Format(" and ItemType like '{0}%' ", Event.Left(16))); //}; return(Where); }
public long Begin(AuditTrailViewModel sender, AuditTrail message) { //AuditTrailWriterHelper.LogsAdd(sender, message); return(AuditTrailWriterHelper.BeginWriteDB(_dBSQLViewModel, sender, message)); }
public void End(AuditTrailViewModel sender, long parent, ErrorLevel errorLevel, string message, string dataOutType, string dataOut) { AuditTrailWriterHelper.EndWriteDB(_dBSQLViewModel, parent, errorLevel, message, dataOutType, dataOut); }
public ObservableCollection <AuditTrail> LoadAuditTrail(AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500) { return(AuditTrailWriterHelper.LoadAuditTrail(_dBSQLViewModel, sender, Filtered, MaxRecords)); }
public void WriteLine(AuditTrailViewModel sender, AuditTrail message) { //AuditTrailWriterHelper.LogsAdd(sender, message); AuditTrailWriterHelper.WriteLineDB(_dBSQLViewModel, sender, message); }
public void Clean(AuditTrailViewModel sender) { throw new NotImplementedException(); }
private string GetWhere(AuditTrailViewModel sender, bool ShowUser = true) { return(AuditTrailWriterHelper.GetWhere(_dBSQLViewModel.DBType, sender, ShowUser)); }
public void Clean(AuditTrailViewModel sender) { //AuditTrailWriterHelper.Clean(sender, outputFile); }
public void WriteLine(AuditTrailViewModel sender, AuditTrail message) { if (_FileType == FileTypes.FullJSON) { try { string json = ""; if (System.IO.File.Exists(outputFile)) { json = File.ReadAllText(outputFile); } ; List <AuditTrail> lines = null; if (string.IsNullOrEmpty(json)) { lines = new List <AuditTrail>(); } else { lines = JsonSerializer.Deserialize <List <AuditTrail> >(json); }; lines.Add(message); json = JsonSerializer.Serialize(lines, new JsonSerializerOptions { IgnoreNullValues = true }); File.WriteAllText(outputFile, json, System.Text.Encoding.ASCII); } catch (Exception ex) { Debug.WriteLine(ex.Message); #if DEBUG if (Debugger.IsAttached) { Debugger.Break(); } ; #endif }; } else { try { string Line = JsonSerializer.Serialize(message, new JsonSerializerOptions { IgnoreNullValues = true, }); if (System.IO.File.Exists(outputFile)) { File.AppendAllLines(outputFile, new[] { "," + Line }); } else { File.AppendAllLines(outputFile, new[] { "{" + Line }); }; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("AuditTrailViewModel: " + ex.Message); }; }; }
public void Clean(AuditTrailViewModel sender) { // nothing to do ... }
public void End(AuditTrailViewModel sender, long parent, ErrorLevel errorLevel, string message, string dataOutType, string dataOut) { return; }
public void WriteLine(AuditTrailViewModel sender, AuditTrail message) { System.Diagnostics.Debug.WriteLine(message.Message); }