Exemplo n.º 1
0
 public void Create()
 {
     using (var sut = new LogEntries(FileName))
     {
         sut.Count().Should().Be(ExpectedEntryCount);
         sut.ToList();
     }
 }
Exemplo n.º 2
0
        void Page_LoadComplete(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("----------Page load complete!");

            myUser = Account.SecurePage(this, Data.DeviceType, "admin");

            List <LogEntry> LogEntries;

            if (selectedLogId == default)
            {
                LogEntries = ParsnipData.Logging.Data.GetAllLogEntries().OrderByDescending(x => x.date).ToList();
            }
            else
            {
                Log temp = Log.Select((Log.Ids)selectedLogId);
                LogEntries = temp.GetLogEntries().OrderByDescending(x => x.date).ToList();
            }

            foreach (LogEntry myEntry in LogEntries)
            {
                TableRow MyRow = new TableRow();
                MyRow.Attributes.Add("style", "word-wrap:break-word");
                MyRow.Cells.Add(new TableCell()
                {
                    Text = myEntry.date.ToString(), CssClass = "date-cell"
                });
                MyRow.Cells.Add(new TableCell()
                {
                    Text = myEntry.Text
                });
                LogTable.Rows.Add(MyRow);
            }

            EntryCount.Text = string.Format("{0} entries found", LogEntries.Count());

            if (Request.QueryString["action"] != null)
            {
                string action = Request.QueryString["action"];
                if (Request.QueryString["success"] != null)
                {
                    string success = Request.QueryString["success"];

                    if (success == "true")
                    {
                        SuccessText.Text = string.Format("<strong>Success</strong> All logs were successfully {0}d on the database!", action);
                        Success.Attributes.CssStyle.Add("display", "block");
                    }
                }
            }

            UpdateLogList();
            SelectLog.SelectedValue = selectedLogId.ToString();

            System.Diagnostics.Debug.WriteLine("Page_LoadComplete complete!");
        }
Exemplo n.º 3
0
        //public enum LogSources
        //{
        //    S2IMPORT, //0 -> 2 *
        //    S2EXPORT, //1 -> 4 *
        //    PSIMPORT, //2 -> 5 *
        //    USER      //3 -> 0 *
        //}

        //public enum LogSeverity
        //{
        //    INFO,
        //    WARN,
        //    ERROR,
        //    DEBUG
        //}

        //public int CountLogEntriesWithStatus(LogSources source, LogSeverity sev, DateTime since)
        //{
        //    return (from l in LogEntries
        //            where ((l.Source == (int) source) &&
        //                   (l.EventDate >= since) &&
        //                   (l.Severity == (int) sev))
        //            select l).Count();
        //}

        public int CountLogEntriesWithStatus(ExternalSystem system, Severity sev, DateTime since)
        {
            var severity = (int)sev;

            if (system == null)
            {
                return(0);
            }

            return(LogEntries.Count(l => l.Source == system.Id &&
                                    l.EventDate >= since &&
                                    l.Severity == severity));
        }
Exemplo n.º 4
0
        internal static StatusData GetCurrentStatus()
        {
            var statudData = new StatusData
            {
                Operation = OperationInfo,
            };

            statudData.DuplicateCount = DuplicateManager.Count;

            lock (LogEntriesLock)
            {
                statudData.LogCount = LogEntries.Count();
                statudData.LogToken = logId;
            }

            return(statudData);
        }
Exemplo n.º 5
0
        public void Next()
        {
            if (LogEntries.Count() == 0)
            {
                return;
            }
            var startFrom = SelectedItem ?? LogEntries.FirstOrDefault();
            var next      = FindNextBookMark(startFrom, SelectedItem != null);

            if (next == null)
            {
                next = FindNextBookMark(LogEntries.FirstOrDefault(), false);
            }

            if (next != null)
            {
                SelectedItem = next;
            }
        }
Exemplo n.º 6
0
        public void Previous()
        {
            if (LogEntries.Count() == 0)
            {
                return;
            }
            var startFrom = SelectedItem ?? LogEntries.FirstOrDefault();
            var prev      = FindPreviousBookMark(startFrom, SelectedItem != null);

            if (prev == null)
            {
                prev = FindPreviousBookMark(LogEntries.LastOrDefault(), false);
            }

            if (prev != null)
            {
                SelectedItem = prev;
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("logs?id=0");
            }

            myUser = Account.SecurePage("logs", this, Data.DeviceType, "admin");

            selectedLogId = Convert.ToInt16(Request.QueryString["id"]);

            List <LogEntry> LogEntries;

            if (selectedLogId == default)
            {
                LogEntries = ParsnipData.Logging.Data.GetAllLogEntries().OrderByDescending(x => x.date).ToList();
            }
            else
            {
                Log temp = Log.Select((Log.Ids)selectedLogId);
                LogEntries = temp.GetLogEntries().OrderByDescending(x => x.date).ToList();
            }

            foreach (LogEntry myEntry in LogEntries)
            {
                TableRow MyRow = new TableRow();
                MyRow.Attributes.Add("style", "word-wrap:break-word");
                MyRow.Cells.Add(new TableCell()
                {
                    Text = myEntry.date.ToString(), CssClass = "date-cell"
                });
                MyRow.Cells.Add(new TableCell()
                {
                    Text = myEntry.text
                });
                LogTable.Rows.Add(MyRow);
            }

            EntryCount.Text = string.Format("{0} entries found", LogEntries.Count());
        }
Exemplo n.º 8
0
        // Methods

        public override string ToString()
        {
            return($"#{LogEntries.Count()} LogEntries for #{FileName}");
        }