private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dataGridViewFiles.Rows[e.RowIndex]; ILogData d = row.Tag as ILogData; int ri = e.ColumnIndex; string text = row.Cells[ri].Value + ""; if (ri == 1) { if (d.Comment.Equals(text)) { return; } d.Comment = text; return; } if (ri == 0) { if (d.Name.Equals(text)) { return; } ILogDirectory dir = d.Parent as ILogDirectory; List <string> l = dir.GetDirectoryNames(); string name = d.Name; l.Remove(name); if (l.Contains(text)) { MessageBox.Show(this, "Name already exist"); row.Cells[ri].Value = name; return; } d.Name = text; } }
void ShowIntervalTable(ILogDirectory dir, bool isFile) { Dictionary <string, ILogData> d = new Dictionary <string, ILogData>(); foreach (object o in current.Children) { if (o is ILogData) { ILogData ld = o as ILogData; d[ld.Name] = ld; } } List <string> lt = new List <string>(d.Keys); lt.Sort(); bool isRoot = IsRoot; dataGridViewIntervals.Rows.Clear(); foreach (string key in lt) { DataGridViewRow row = new DataGridViewRow(); ILogData data = d[key]; ILogInterval i = data as ILogInterval; row.Tag = d[key]; row.CreateCells(dataGridViewIntervals, new object[] { data.Name, data.Comment, i.Begin, i.End, data.FileName }); dataGridViewIntervals.Rows.Add(row); } toolStripLabelDrag.Visible = false; newToolStripButton.Visible = !isRoot; dataGridViewFiles.Visible = false; dataGridViewIntervals.Visible = true; }
private void createRecord(Storage.Database db, ILogData data) { using (MemoryStream ms = new MemoryStream(DataBuffer)) using (BinaryWriter bw = new BinaryWriter(ms)) { ms.Position = 0; ms.Position = 150; bw.Write(data.LogType.ID); //150 bw.Write(Utils.Conversion.DateTimeToLong(data.Date)); //154 bw.Write(Utils.Conversion.DateTimeToLong(data.DataFromDate)); //162 bw.Write(data.Encoded); //170 ms.Position = 180; bw.Write(data.GeocacheCode ?? ""); ms.Position = 220; bw.Write(data.Finder ?? ""); ms.Position = 320; bw.Write(data.FinderId ?? ""); ms.Position = 350; bw.Write(data.TBCode ?? ""); ms.Position = 380; bw.Write(data.Text ?? ""); RecordInfo = db.RequestLogRecord(data.ID, data.GeocacheCode ?? "", DataBuffer, ms.Position, 100); } }
void AddInterval(ILogData data) { TreeNode s = selected; if (s == null) { return; } ILogDirectory d = s.Tag as ILogDirectory; if ((d == null) | (data == null)) { return; } try { List <string> l = d.GetDirectoryNames(); for (int i = 1; ; i++) { string n = "New interval" + i; if (!l.Contains(n)) { ILogInterval ld = d.CreateIntrerval(data, n, "", 0, (uint)data.Length); ShowIntervalTable(d, false); return; } } } catch (Exception exception) { exception.ShowError(); } }
public AccountServiceTest() { _stubAccountRepository = MockRepository.GenerateStub <IAccountRepository>(); mockmail = MockRepository.GenerateMock <ISendEmail>(); logData = MockRepository.GenerateMock <ILogData>(); sut = new AccountService(mockmail, _stubAccountRepository, logData, new ChatContext()); }
//new record to be stored public Log(Storage.Database db, ILogData data) : base(null) { _id = data.ID; using (MemoryStream ms = new MemoryStream(_buffer)) using (BinaryWriter bw = new BinaryWriter(ms)) { ms.Position = 0; //todo: add string length checks!!! ms.Position = 150; bw.Write(data.LogType.ID); //150 bw.Write(data.Date.ToFileTime()); //154 bw.Write(data.DataFromDate.ToFileTime()); //162 bw.Write(data.Encoded); //170 ms.Position = 180; bw.Write(data.GeocacheCode??""); ms.Position = 220; bw.Write(data.Finder??""); ms.Position = 320; bw.Write(data.FinderId??""); ms.Position = 350; bw.Write(data.TBCode??""); ms.Position = 380; bw.Write(data.Text??""); RecordInfo = db.RequestLogRecord(data.ID, _buffer, ms.Position, 100); } db.LogCollection.Add(this); }
public void Log(IInputData input, ISource source, OutputData output) { var log = Module.GetLog(source, input, output); if (log != null) { ILogData data = log.PickLogData(input, source, output); log.Log(data); } if (Module.RecordLogs != null) { ISupportRecordLog recordLog = source as ISupportRecordLog; if (recordLog != null) { foreach (var item in Module.RecordLogs) { ILog logData = item.LogData.CreateObject(); var data = recordLog.GetRecordDatas(item.TableName); BaseGlobalVariable.Current.BeginInvoke( new Action <ILog, IEnumerable <ILogData> >(Log), logData, data); //logData.LogData(data); } } } }
/// <summary> /// Constructor /// </summary> /// <param name="item">Item</param> /// <param name="parent">Parent</param> public LogItemWrapper(LogDirectoryWrapper parent, ILogData item) { this.item = item; this.parent = parent; parent.items.Add(this); StaticExtensionEventLogDatabase.items[item.Id] = this; }
public void Write(ILogData data) { if (data == null) { throw new ArgumentNullException("data"); } if (!(data is FileLogData)) { throw new InvalidOperationException("Given data is not compatible with this logger"); } FileLogData fileLoggingData = (FileLogData)data; fileLoggingData.Timestamp = useUtcTimestamps ? DateTime.UtcNow : DateTime.Now; if (this.loggingThread != null) { // Asynchronous logging messageQueue.Enqueue(fileLoggingData); doLogging.Set(); } else { sw.WriteLine("{1}: {2}", DateTime.Now, data.Message); sw.Flush(); } }
private LogController() { _LogFormatProvider = new DefaultLogFormatProvider(); _FileLog = LogFactory.GetLogData(LogDataType.FILE); _InMemoryLog = LogFactory.GetLogData(LogDataType.IN_MEMORY); LoadLogData(); }
public void ReceivedLogData(object sendor, LogDataReceivedEventArgs args) { if (args == null || args.Log == null) { return; } System.Windows.Application.Current.Dispatcher.Invoke(() => { LogCollection.Add(args.Log); SelectedItem = LogCollection[LogCollection.Count - 1]; }); //_logDataArray.Add(args.Log); //_currentCount++; //if (_currentCount == MAX_COUNT) //{ // System.Windows.Application.Current.Dispatcher.Invoke((Action)delegate() // { // foreach (var log in _logDataArray) // { // LogCollection.Add(log); // } // SelectedItem = LogCollection[LogCollection.Count - 1]; // }); // _logDataArray = new ObservableCollection<ILogData>(); // _currentCount = 0; //} }
/// <summary> /// Constructor /// </summary> /// <param name="item">Item</param> /// <param name="parent">Parent</param> public LogIntervalWrapper(LogDirectoryWrapper parent, ILogInterval interval, ILogData data) : this(interval) { this.parent = parent; parent.items.Add(this); this.data = data; }
public void Write(ILogData data) { if (!(data is EventLoggingData eventLoggingData)) { throw new ArgumentException(nameof(data)); } if (EventLog.SourceExists(this.eventSource)) { EventLog.CreateEventSource(new EventSourceCreationData(this.eventSource, "Application")); } EventLogEntryType foo = EventLogEntryType.Information; if (data.Severity == NLog.LogLevel.Debug || data.Severity == NLog.LogLevel.Info || data.Severity == NLog.LogLevel.Trace) { foo = EventLogEntryType.Information; } else if (data.Severity == NLog.LogLevel.Warn) { foo = EventLogEntryType.Warning; } else if (data.Severity == NLog.LogLevel.Error || data.Severity == NLog.LogLevel.Fatal) { foo = EventLogEntryType.Error; } EventLog.WriteEntry(this.eventSource, eventLoggingData.Message, foo, eventLoggingData.EventId); }
private static void WriteTheLogEntry(ILogData logEntry) { ILog toLog4Net = LogManager.GetLogger(logEntry.Application.ApplicationName); var logContent = TranslateLogEntryToJson(logEntry); switch (logEntry.Level) { case LogLevels.Debug: toLog4Net.Debug(logContent); break; case LogLevels.Info: toLog4Net.Info(logContent); break; case LogLevels.Warning: toLog4Net.Warn(logContent); break; case LogLevels.Error: toLog4Net.Error(logContent); break; case LogLevels.Fatal: toLog4Net.Fatal(logContent); break; } }
public AccountService(ISendEmail SendEmail, IAccountRepository accountRepository, ILogData LogData, ChatContext ctx) { _sendEmail = SendEmail; _accountRepository = accountRepository; _chatContext = ctx; _logData = LogData; }
public AccountServiceTest() { _chatContext = new ChatContext(); _sendEmailStub = MockRepository.GenerateStub <ISendEmail>(); _logDataStub = MockRepository.GenerateStub <ILogData>(); _accountRepository = new AccountRepository(_chatContext); _sut = new AccountService(_sendEmailStub, _accountRepository, _logDataStub, new ChatContext()); }
private void dataGridViewIntervals_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dataGridViewIntervals.Rows[e.RowIndex]; ILogData d = row.Tag as ILogData; int ri = e.ColumnIndex; string text = row.Cells[ri].Value + ""; if (ri == 1) { if (d.Comment.Equals(text)) { return; } d.Comment = text; return; } if (ri == 0) { if (d.Name.Equals(text)) { return; } ILogDirectory dir = d.Parent as ILogDirectory; List <string> l = dir.GetDirectoryNames(); string name = d.Name; l.Remove(name); if (l.Contains(text)) { MessageBox.Show(this, "Name already exist"); row.Cells[ri].Value = name; return; } d.Name = text; return; } ILogInterval interval = d as ILogInterval; try { uint number = uint.Parse(text); if (number == 1) { number = 0; } if (ri == 2) { interval.Begin = number; } if (ri == 3) { interval.End = number; } } catch (Exception exception) { exception.ShowError(); } }
/// <summary> /// Creates a tree /// </summary> /// <param name="data">Database interface</param> /// <returns>roots of trees</returns> static ILogDirectory[] CreateTree(this IDatabaseInterface data) { Dictionary <object, IParentSet> dictionary = new Dictionary <object, IParentSet>(); IEnumerable <object> list = data.Elements; List <ILogDirectory> directories = new List <ILogDirectory>(); foreach (object o in list) { ILogItem item = data[o]; IParentSet ps = null; if (item is ILogInterval) { ps = new LogIntervalWrapper(item as ILogInterval); } else if (item is ILogData) { ps = new LogItemWrapper(item as ILogData); } else { ps = new LogDirectoryWrapper(item); } dictionary[o] = ps; } foreach (IParentSet ps in dictionary.Values) { ILogItem it = (ps as ILogItem); object o = it.ParentId; if (!o.Equals(it.Id)) { if (dictionary.ContainsKey(o)) { ps.Parent = dictionary[o] as ILogItem; } } if (it is ILogInterval) { ILogInterval interval = it as ILogInterval; ILogData d = dictionary[interval.DataId] as ILogData; (interval as LogIntervalWrapper).DataSet = d; } } List <ILogDirectory> l = new List <ILogDirectory>(); foreach (IParentSet ps in dictionary.Values) { if (ps is ILogDirectory) { ILogDirectory item = (ps as ILogDirectory); if (item.Parent == null) { l.Add(item); } } } return(l.ToArray()); }
public HomeController(ILogData logData, ITipsData tipsData, IArticlesData articlesData, ICompanyData companyData, IFeedData FeedData, IShingleData ShingleData) { _logData = logData; _tipsData = tipsData; _articlesData = articlesData; _companyData = companyData; _feedData = FeedData; _shingleData = ShingleData; }
private void OnDataReceived(ILogData logData) { if (LogDataReceivedEvent != null) { LogDataReceivedEventArgs args = new LogDataReceivedEventArgs(); args.Log = logData; LogDataReceivedEvent(this, args); } }
private void Log(LogLevel level, ILogData data) { if (this.Level < level || level == LogLevel.Verb) { return; } this.logMethod(level, data.ToString()); }
private static string TranslateLogEntryToJson(ILogData logEntry) { JsonSerializerSettings serializerSettings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }; serializerSettings.Converters.Add(new StringEnumConverter()); return(JsonConvert.SerializeObject(logEntry, serializerSettings)); }
public void Log(ILogData data) { if (data is LogData logData) { Log(logData); } else { // If we get an unknown implementation, we log the bare minimmum. _loggerBase.LogInformation("This log entry originated from an unknown ILogData implementation", data.TenantId); } }
public static void Copy(ILogData src, ILogData dest) { dest.ID = src.ID; dest.LogType = src.LogType; dest.GeocacheCode = src.GeocacheCode; dest.TBCode = src.TBCode; dest.Date = src.Date; dest.DataFromDate = src.DataFromDate; dest.FinderId = src.FinderId; dest.Finder = src.Finder; dest.Text = src.Text; dest.Encoded = src.Encoded; }
/// <summary> /// Creates data /// </summary> /// <param name="directory">Directory</param> /// <param name="data">Data</param> /// <param name="name"></param> /// <param name="fileName">File name</param> /// <param name="comment">Comment</param> /// <returns>The data</returns> public static ILogInterval CreateIntrerval(this ILogDirectory directory, ILogData data, string name, string comment, uint begin, uint end) { IDatabaseInterface d = StaticExtensionEventLogDatabase.data; if (directory.GetDirectoryNames().Contains(name)) { throw new Exception(name + " already exists"); } ILogInterval interval = d.CreateInterval(directory.Id, name, comment, data, begin, end); return(new LogIntervalWrapper(directory as LogDirectoryWrapper, interval, data)); }
private void Instance_LogQueued(ILogData queuedLogData) { try { //lock (this) //{ _logQueue.Enqueue(queuedLogData); //} } catch { //Console.WriteLine(""); } }
public void GivenNewAccount_WhenInsert_ThenSendEmailAndLog() { //ARRANGE mockmail = MockRepository.GenerateStrictMock <ISendEmail>(); ILogData mocklogData = MockRepository.GenerateStrictMock <ILogData>(); sut = new AccountService(mockmail, _stubAccountRepository, mocklogData, new ChatContext()); mockmail.Expect(x => x.Send("", "", "")).IgnoreArguments().Return(true); mocklogData.Expect(x => x.LogThis("")).IgnoreArguments(); //ACT sut.AddAccount(new Account(), ""); //ASSERT //mockmail.VerifyAllExpectations(); }
private void StartReceivedLogQueue() { while (!_receivedLogQueue.IsCompleted) { ILogData logData = _receivedLogQueue.Take(); if (logData != null) { if (this.LogDataReceivedEvent != null) { LogDataReceivedEventArgs args = new LogDataReceivedEventArgs(); args.Log = logData; this.LogDataReceivedEvent(this, args); Thread.Sleep(100); } } } }
private void OnLogDataReceived(object sendor, LogDataReceivedEventArgs args) { if (args == null || args.Log == null) { return; } ILogData logData = args.Log; //lock (_writerLock) //{ // try // { // if (this.m_isRecording && (this._writer != null)) // { // this.CheckLogDataSize(); // if (this.m_writeSourceBufferName) // { // this._writer.WriteLine(string.Format("[{0}] [{1}:] {2}", logData.LocalTimestamp.ToString("MM-dd HH:mm:ss.fff"), logData.SourceBuffer, logData.ToString(this.OutputFormat, this.TimestampMode))); // } // else // { // this._writer.WriteLine(string.Format("[{0}] {1}", logData.LocalTimestamp.ToString("MM-dd HH:mm:ss.fff"), logData.ToString(this.OutputFormat, this.TimestampMode))); // } // this.m_logIndex++; // this._writer.Flush(); // } // //if (this.LogDataReceivedEvent != null) // //{ // // this.LogDataReceivedEvent(this, args); // //} // } // catch (Exception) // { // if (_writer != null) // { // _writer.Close(); // _writer.Dispose(); // } // } //} _receivedLogQueue.Add(logData); }
void ShowContent(ILogDirectory dir) { if (dir == current) { return; } current = dir; bool isFile = IsFile; Dictionary <string, ILogData> d = new Dictionary <string, ILogData>(); foreach (object o in current.Children) { if (o is ILogData) { ILogData ld = o as ILogData; d[ld.Name] = ld; } } List <string> lt = new List <string>(d.Keys); lt.Sort(); bool isRoot = IsRoot; if (isFile) { dataGridViewFiles.Rows.Clear(); foreach (string key in lt) { DataGridViewRow row = new DataGridViewRow(); ILogData data = d[key]; row.Tag = d[key]; row.CreateCells(dataGridViewFiles, new object[] { data.Name, data.Comment, data.Length, data.FileName }); dataGridViewFiles.Rows.Add(row); } toolStripLabelDrag.Visible = !isRoot; newToolStripButton.Visible = false; dataGridViewFiles.Visible = true; dataGridViewIntervals.Visible = false; } else { ShowIntervalTable(dir, isFile); } }
private static void WriteTheLogEntry(ILogData logEntry) { var originColor = Console.ForegroundColor; JsonSerializerSettings serializerSettings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented }; serializerSettings.Converters.Add(new StringEnumConverter()); string contents = JsonConvert.SerializeObject(logEntry, serializerSettings); switch (logEntry.Level) { case LogLevels.Debug: Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(contents); break; case LogLevels.Info: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(contents); break; case LogLevels.Warning: Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(contents); break; case LogLevels.Error: Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(contents); break; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(contents); break; } Console.ForegroundColor = originColor; defaultFileLog.WriteToLog(contents); }
public LogData(XElement input, ILogData view) : this(view) { this.logForClassName = input.Attribute(Log.ATTRIBUTE_NAME_FOR).Value; this.logNumber = input.Attribute(Log.ATTRIBUTE_NAME_NUMBER).Value.ParseTo<int>(); Logger.AddToQueue("LogData", "Attempting to enter log information from xml.", 3); var exception = input.Element(Log.NODE_NAME_EXCEPTION); if (!exception.IsNull()) { this.exceptionType = CheckAndAssign(exception, Log.ATTRIBUTE_NAME_EXCEPTION_TYPE); this.exceptionMethodName = CheckAndAssign(exception, Log.ATTRIBUTE_NAME_METHOD); this.exceptionMessage = CheckAndAssign(exception, Log.ATTRIBUTE_NAME_MESSAGE); this.exceptionStack = CheckAndAssign(exception, Log.ATTRIBUTE_NAME_STACK); } var comment = input.Element(Log.NODE_NAME_COMMENT); if (!comment.IsNull()) { this.logComment = CheckAndAssign(comment, Log.ATTRIBUTE_NAME_COMMENT); } }
private LogData(ILogData view) { this.view = view; }
//new record to be stored public Log(Storage.Database db, ILogData data) : this(null) { createRecord(db, data); db.LogCollection.Add(this); }