コード例 #1
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            var message = formatter(state, exception);

            if (message.Contains("INSERT INTO") || message.Contains("UPDATE") || message.Contains("DELETE"))
            {
                // Get Parameters
                Dictionary <string, string> parameters = GetParameters(message);
                foreach (string commandString in message.Split(';'))
                {
                    // Get Query
                    int commandIndex = commandString.IndexOf("INSERT");
                    if (commandIndex == -1)
                    {
                        commandIndex = commandString.IndexOf("UPDATE");
                    }
                    if (commandIndex == -1)
                    {
                        commandIndex = commandString.IndexOf("DELETE");
                    }
                    if (commandIndex == -1)
                    {
                        continue;
                    }
                    string command = commandString.Substring(commandIndex);

                    if (command.Contains("SELECT @@ROWCOUNT;"))
                    {
                        command = command.Substring(0, command.IndexOf("SELECT @@ROWCOUNT;") - 2);
                    }

                    // Get Parameters for this commandString
                    Dictionary <string, string> tempParameters = new Dictionary <string, string>();
                    foreach (KeyValuePair <string, string> keyValue in parameters)
                    {
                        if (command.Contains(keyValue.Key))
                        {
                            tempParameters.Add(keyValue.Key, keyValue.Value);
                        }
                    }

                    LogEntry entry = new LogEntry()
                    {
                        Command = command.Replace("\\r\\n", ""), Parameters = tempParameters
                    };


                    if (!LoggedEntries.Contains(entry.ToString()))
                    {
                        LogEntries.Add(entry);
                        LoggedEntries.Add(entry.ToString());
                    }
                }
            }
        }
コード例 #2
0
 public void LoadFromFile()
 {
     using (var cmd = _db.CreateCommand())
     {
         cmd.CommandText = "SELECT path FROM folders";
         using (var dr = cmd.ExecuteReader())
         {
             LogEntries.Clear();
             while (dr.Read())
             {
                 LogEntries.Add(new LogEntry()
                 {
                     MainItem = dr.GetString(0)
                 });
             }
             FolderCount = (uint)LogEntries.Count;
             if (FolderCount > 0)
             {
                 RootFolder = LogEntries[0].MainItem;
             }
         }
         cmd.CommandText = "SELECT COUNT(name) FROM files";
         FileCount       = Convert.ToUInt32(cmd.ExecuteScalar());
         Status          = ComparatorStatus.Ready;
     }
 }
コード例 #3
0
        public override int SaveChanges()
        {
            try
            {
                var logs = GetLogEntries().ToList();

                logs.ForEach(l => LogEntries.Add(l.Item1));

                var ret = base.SaveChanges();

                //set added key values
                //if any adds, make sure to log gen'd key values
                if (logs.Where(l => l.Item2 == EntityState.Added).Count() > 0)
                {
                    foreach (var a in logs.Where(l => l.Item2 == EntityState.Added))
                    {
                        a.Item1.SetKeyValues(getKeyValues(a.Item3));
                    }

                    base.SaveChanges(); //save added key values
                }

                return(ret);
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
                return(-1);
            }
        }
コード例 #4
0
        async Task LoadEntries()
        {
            LogEntries.Clear();

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Washington Monument",
                Notes     = "Amazing!",
                Rating    = 3,
                Date      = new DateTime(2017, 2, 5),
                Latitude  = 38.8895,
                Longitude = -77.0352
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Statue of Liberty",
                Notes     = "Inspiring!",
                Rating    = 4,
                Date      = new DateTime(2017, 4, 13),
                Latitude  = 40.6892,
                Longitude = -74.0444
            });

            LogEntries.Add(new TripLogEntry
            {
                Title     = "Golden Gate Bridge",
                Notes     = "Foggy, but beautiful.",
                Rating    = 5,
                Date      = new DateTime(2017, 4, 26),
                Latitude  = 37.8268,
                Longitude = -122.4798
            });
        }
コード例 #5
0
 public void AddMessage(string name, string message)
 {
     LogEntries.Add(new LogEntry()
     {
         Name = name, Message = message
     });
 }
コード例 #6
0
ファイル: LogReader.cs プロジェクト: wilmerbz/tools
        public static LogEntries FilterLogEntries(string searchText)
        {
            var filteredLogItems = new LogEntries();

            if (LogEntriesCollection == null || LogEntriesCollection.Count == 0)
            {
                return(filteredLogItems);
            }


            if (string.IsNullOrEmpty(searchText))
            {
                return(LogEntriesCollection);
            }

            LogEntry logEntry = null;

            for (int i = 0; i < LogEntriesCollection.Count; i++)
            {
                logEntry = LogEntriesCollection[i];

                if (logEntry.FullContent.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    filteredLogItems.Add(logEntry);
                }
            }

            return(filteredLogItems);
        }
コード例 #7
0
        public LogPanelViewModel(IMessenger messenger)
        {
            Name = "Log";

            _messenger = messenger;
            _messenger.Register <LogEntryReceivedMessage>(this, ParseResult);
            _messenger.Register <SessionClosedMessage>(this, m => Clear());

            if (IsInDesignMode)
            {
                LogEntries.Add(new LogPanelItemViewModel
                {
                    DateTime  = DateTime.Now.AddMinutes(-4),
                    EntryType = LogItemType.Log,
                    Message   = "This is a log entry"
                });

                LogEntries.Add(new LogPanelItemViewModel
                {
                    DateTime  = DateTime.Now.AddMinutes(-2),
                    EntryType = LogItemType.Debug,
                    Message   = "This is a debug entry"
                });
            }
        }
コード例 #8
0
 public void Info(string text)
 {
     LogEntries.Add(new LogItem {
         DateTime = DateTime.Now.ToString("HH:mm:ss"), Message = text
     });
     LogItemAdded?.Invoke(null, null);
 }
コード例 #9
0
#pragma warning disable CS0114
        public void AddText(string text)
#pragma warning restore CS0114
        {
            Dispatcher.BeginInvoke((Action)(() => LogEntries.Add(new LogEntry()
            {
                Index = IndexTotal++, Message = text
            })));
        }
コード例 #10
0
 public void AddEntry(LogEntry en)
 {
     if (en.Index > IndexTotal)
     {
         Dispatcher.BeginInvoke((Action)(() => LogEntries.Add(en)));
         IndexTotal = en.Index;
     }
 }
コード例 #11
0
 /// <summary>
 /// Add random log entry to the ViewList evoked by a timer.
 /// </summary>
 private void AddRandomEntry()
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         LogEntries.Add(GetRandomEntry());
         LogList.ScrollIntoView(LogList.Items[LogList.Items.Count - 1]);
     }));
 }
コード例 #12
0
 private async void LogUpdated(HttpEventData data)
 {
     await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         LogEntries.Add(new EventData {
             Data = data
         });
     });
 }
コード例 #13
0
 public void SetStatus(int status)
 {
     LogEntries.Add(status);
     objStatus = status;
     if (OnStatusChanged != null)
     {
         OnStatusChanged(status);
     }
 }
コード例 #14
0
 private void QueueStarted(object sender, EventArgs eventArgs)
 {
     //throw new NotImplementedException();
     LogEntries.Add(new LogEntry
     {
         EntryTime = DateTime.Now,
         JobName   = "Queue",
         LogText   = "Queue Started"
     });
 }
コード例 #15
0
        public MainWindowViewModel()
        {
            _random  = new Random();
            _words   = _testData.Split(' ').ToList();
            _maxword = _words.Count - 1;

            Enumerable.Range(0, 200000).ToList().ForEach(x => LogEntries.Add(GetRandomEntry()));

            _timer = new Timer(x => AddRandomEntry(), null, 1000, 10);
        }
コード例 #16
0
 public void OnLog(DateTime stamp, string msg, LogLevel level)
 {
     System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                                                                          LogEntries.Add(new LogItem
     {
         Stamp = stamp,
         Msg   = msg,
         Level = level
     })), DispatcherPriority.Background);
 }
コード例 #17
0
        public string Log(string message)
        {
            LogEntries.Add(new LogEntry {
                DateTime = DateTime.Now, Message = message, Index = ++messageCounter
            });
#if DEBUG
            Console.WriteLine(message);
#endif
            return(message);
        }
コード例 #18
0
        private void AddLogEntry(string message)
        {
            var now = DateTime.Now;

            var formatted = $"{now.ToShortDateString()} {now.ToShortTimeString()} - {message}";

            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                LogEntries.Add(formatted);
            });
        }
コード例 #19
0
ファイル: FakeTelemetry.cs プロジェクト: uffebjorklund/try
 public void TrackEvent(string eventName,
                        IDictionary <string, string> properties,
                        IDictionary <string, double> measurements)
 {
     LogEntries.Add(
         new LogEntry
     {
         EventName   = eventName,
         Measurement = measurements,
         Properties  = properties
     });
 }
コード例 #20
0
 public void AddEntry(LoggingEvent logEvent)
 {
     if (this.Dispatcher != null && !this.Dispatcher.CheckAccess())
     {
         this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new AddLogHandler((_logEvent) => {
             AddEntry(_logEvent);
         }), logEvent);
         return;
     }
     AddFilteredEntry(logEvent);
     LogEntries.Add(logEvent);
 }
コード例 #21
0
        private async void RefreshData()
        {
            LogEntries.Clear();
            IList <LogbookEntry> entries = await _logbookService.GetEntriesWithoutTrackAsync(_aircraft);

            foreach (LogbookEntry logbookEntry in entries)
            {
                LogEntries.Add(logbookEntry);
            }

            CreateSummary();
        }
コード例 #22
0
 public void Log(string entry)
 {
     Dispatcher.Invoke(() =>
     {
         if (LogEntries.Count > maxlog)
         {
             LogEntries.RemoveAt(0);
         }
         LogEntries.Add(new LogItem(entry));
         log.ScrollIntoView(log.Items[log.Items.Count - 1]);
     });
 }
コード例 #23
0
ファイル: DataLoadLog.cs プロジェクト: vinneyk/RioValleyChili
 public List <string> this[T reason]
 {
     get
     {
         List <string> logEntries;
         if (!LogEntries.TryGetValue(reason, out logEntries))
         {
             logEntries = new List <string>();
             LogEntries.Add(reason, logEntries);
         }
         return(logEntries);
     }
 }
コード例 #24
0
        public void WriteTo(LogEntry logEntry)
        {
            logEntry.Id = logEntries.Count + 1;

            logEntries.Add(logEntry);

            string serializeXml = String.Empty;

            //serialize xml
            Serialization.Serialize <Logg.LogEntries>(logEntries, ref serializeXml);

            XDocument.Parse(serializeXml).Save(SerializeTo);
        }
コード例 #25
0
 private async Task LoadEntries()
 {
     await Task.Factory.StartNew(() =>
     {
         var items = DataService.Instance.GetItems();
         LogEntries.Clear();
         foreach (var item in items)
         {
             LogEntries.Add(item);
         }
         OnPropertyChanged("LogEntries");
     });
 }
コード例 #26
0
        protected void LogReceived(NLog.Common.AsyncLogEventInfo log)
        {
            var vm = new LogEventViewModel(log.LogEvent);

            Dispatcher.BeginInvoke(new Action(() =>
            {
                if (LogEntries.Count >= MaxNumLogs)
                {
                    LogEntries.RemoveAt(0);
                }

                LogEntries.Add(vm);
            }));
        }
コード例 #27
0
        private void LogEntries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                if (e.NewItems.Count <= 0)
                {
                    return;
                }

                foreach (var item in e.NewItems)
                {
                    LogEntries.Add(item as LogEntry);
                }
            });
        }
コード例 #28
0
        public void Append(LogEvent logEvent)
        {
            if (logEvent.EventCode > 30000 && logEvent.EventCode < 40000)
            {
                if (logEvent.EventCode != 30008 && logEvent.EventCode != 30010)
                {
                    return;
                }
            }

            LogEntries.Add(new LogEntry()
            {
                DateTime = DateTime.Now, Index = ++counter, Message = logEvent.Message, LogLevel = logEvent.Level
            });
        }
コード例 #29
0
        private async Task <long> FolderStoreInfoAsync(DirectoryInfo dir)
        {
            SQLiteCommand cmd = _db.CreateCommand();
            long          rowid;

            cmd.CommandText = "INSERT INTO folders (path) VALUES (@path)";
            cmd.Parameters.AddWithValue("@path", dir.FullName);
            await cmd.ExecuteNonQueryAsync();

            rowid = _db.LastInsertRowId;
            LogEntries.Add(new LogEntry()
            {
                MainItem = dir.FullName
            });
            FolderCount++;
            return(rowid);
        }
        private async void LogHttpEvent(HttpEventData data)
        {
            await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (data != null)
                {
                    LogEntries.Add(new EventData {
                        Data = data, IsRequest = true
                    });
                    LogEntries.Add(new EventData {
                        Data = data, IsRequest = false
                    });

                    NotifyLogWindow();
                }
            });
        }
コード例 #31
0
ファイル: Log.cs プロジェクト: onesimoh/Andamio
        /// <summary>
        /// Contextual log, important messages and traces.
        /// </summary>
        /// <returns>Log Entries</returns>
        public LogEntries Contextual()
        {
            int index = 0;
            LogEntries logEntries = new LogEntries();
            while (logEntries.Count < 200)
            {
                if (index >= Entries.Count) break;
                LogEntry logEntry = Entries[index++];

                switch (logEntry.EventType)
                {
                    case LogEventType.Information:
                    case LogEventType.Warning:
                        logEntries.Add(logEntry);
                        break;
                    case LogEventType.Error:
                    case LogEventType.Critical:
                        logEntries.AddRange(Entries.Skip(index - 10).Take(10).Where(match => !logEntries.Contains(match)));
                        logEntries.AddRange(Entries.Skip(index).Take(10));
                        index += 10;
                        break;
                    case LogEventType.Trace:
                    default:
                        continue;
                }
            }

            return logEntries;
        }