コード例 #1
0
 public ObservableCollection <AuditTrail> LoadAuditTrail(AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500)
 {
     return(sender.Logs);
 }
コード例 #2
0
 public long Begin(AuditTrailViewModel sender, AuditTrail message)
 {
     WriteLine(sender, message);
     return(1);
 }
コード例 #3
0
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        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));
        }
コード例 #4
0
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        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);
        }
コード例 #5
0
        public long Begin(AuditTrailViewModel sender, AuditTrail message)
        {
            //AuditTrailWriterHelper.LogsAdd(sender, message);

            return(AuditTrailWriterHelper.BeginWriteDB(_dBSQLViewModel, sender, message));
        }
コード例 #6
0
 public void End(AuditTrailViewModel sender, long parent, ErrorLevel errorLevel, string message, string dataOutType, string dataOut)
 {
     AuditTrailWriterHelper.EndWriteDB(_dBSQLViewModel, parent, errorLevel, message, dataOutType, dataOut);
 }
コード例 #7
0
 public ObservableCollection <AuditTrail> LoadAuditTrail(AuditTrailViewModel sender, bool Filtered = true, long MaxRecords = 500)
 {
     return(AuditTrailWriterHelper.LoadAuditTrail(_dBSQLViewModel, sender, Filtered, MaxRecords));
 }
コード例 #8
0
        public void WriteLine(AuditTrailViewModel sender, AuditTrail message)
        {
            //AuditTrailWriterHelper.LogsAdd(sender, message);

            AuditTrailWriterHelper.WriteLineDB(_dBSQLViewModel, sender, message);
        }
コード例 #9
0
 public void Clean(AuditTrailViewModel sender)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
 private string GetWhere(AuditTrailViewModel sender, bool ShowUser = true)
 {
     return(AuditTrailWriterHelper.GetWhere(_dBSQLViewModel.DBType, sender, ShowUser));
 }
コード例 #11
0
 public void Clean(AuditTrailViewModel sender)
 {
     //AuditTrailWriterHelper.Clean(sender, outputFile);
 }
コード例 #12
0
        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);
                };
            };
        }
コード例 #13
0
 public void Clean(AuditTrailViewModel sender)
 {
     // nothing to do ...
 }
コード例 #14
0
 public void End(AuditTrailViewModel sender, long parent, ErrorLevel errorLevel, string message, string dataOutType, string dataOut)
 {
     return;
 }
コード例 #15
0
 public void WriteLine(AuditTrailViewModel sender, AuditTrail message)
 {
     System.Diagnostics.Debug.WriteLine(message.Message);
 }