private void AddEventLog(string text) { if (IsShowEvents) { EventsLog.Add(text); } }
private void AddLogLine(string txt) { try { if (string.IsNullOrEmpty(txt)) { return; } if (EventsLog.Lines.Count() >= 13) { this.SuspendLayout(); var lines = new string[13]; for (int i = 1; i < EventsLog.Lines.Count(); i++) { lines[i - 1] = EventsLog.Lines[i]; } lines[EventsLog.Lines.Count() - 1] = txt; EventsLog.Clear(); EventsLog.Lines = lines; this.ResumeLayout(); } else { EventsLog.AppendText(txt + Environment.NewLine); } } catch { } }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Description,timeStamp")] EventsLog eventsLog) { if (id != eventsLog.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(eventsLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventsLogExists(eventsLog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(eventsLog)); }
public static void Save(EventsLog log) { using (var session = DocumentStoreHolder.Store.OpenSession()) { session.Store(log); session.SaveChanges(); } }
public void Initialize() { _queue = new BlockingQueue <WrappedEvent>(10); _eventsCache = new InMemorySimpleCache <WrappedEvent>(_queue); _apiClientMock = new Mock <IEventSdkApiClient>(); _eventLog = new EventsLog(_apiClientMock.Object, 1, 1, _eventsCache, 10); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { eventsDataGrid.DataContext = DisplayedLogEvents; eventContextTreeView.SelectedItemChanged += eventContextTreeView_SelectedItemChanged; DisplayedLogEvents.Filter = EventFilter; EventsLog.StartLogging(); EventsLog.AddListener(this); }
public void Initialize() { _queue = new BlockingQueue <WrappedEvent>(10); _eventsCache = new InMemorySimpleCache <WrappedEvent>(_queue); _apiClientMock = new Mock <IEventSdkApiClient>(); _telemetryRuntimeProducer = new Mock <ITelemetryRuntimeProducer>(); _eventLog = new EventsLog(_apiClientMock.Object, 1, 1, _eventsCache, _telemetryRuntimeProducer.Object, new TasksManager(wrapperAdapter), 10); }
public static void WriteMSG(string msg, DateTime time, int evttype) { using (var db = new LiteDatabase(@"myDataDb.db")) { var evtLogs = db.GetCollection <EventsLog>("EventsLog"); EventsLog evt = new EventsLog(msg, time, evttype); evtLogs.Insert(evt); Console.WriteLine(evt); } }
public void WriteLog(string evType, string desc) { var log = new EventsLog(); log.EventType = evType; log.EventDate = DateTime.Now; log.Description = desc; db.EventsLog.Add(log); }
private void StartStopButton_Click(object sender, RoutedEventArgs e) { if (EventsLog.Running) { EventsLog.Stop(); } else { EventsLog.StartLogging(); } }
public async Task <IActionResult> Create([Bind("Id,Description,timeStamp")] EventsLog eventsLog) { if (ModelState.IsValid) { eventsLog.Id = Guid.NewGuid(); _context.Add(eventsLog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(eventsLog)); }
public OperationsStatus InsertEventsLog(EventsLog eventLogObj) { OperationsStatus OperationsStatusObj = null; try { OperationsStatusObj = _masterRepository.InsertEventsLog(eventLogObj); } catch (Exception) { } return(OperationsStatusObj); }
public void Create(Event message) //calls the create method { EventLog.EventsLog eventlog = new EventsLog() { Name = message.UserName, DateTime = message.DateTime, ETA = message.ETA, EventType = message.EventType, Status = message.StatusFlag, isRemoteSession = false }; //abov ecreate s a new EventsLog with the sepcified fields EventLog.Status statusLog = new Status(message.UserName, message.UserName) { ETA = message.ETA, StatusFlag = message.StatusFlag }; //above upadates the status of an employee EventsLogHandler.Save(eventlog); //this saves the eventlog StatusHandler.Save(statusLog); //this saves the status }
/// <summary> /// This maps the default support for the event types. /// </summary> protected override void SupportLoadDefault() { SupportAdd(DataCollectionSupport.Boundary, (e) => EventsBoundary.Add(e)); SupportAdd(DataCollectionSupport.Dispatcher, (e) => EventsDispatcher.Add(e)); SupportAdd(DataCollectionSupport.EventSource, (e) => EventsEventSource.Add(e)); SupportAdd(DataCollectionSupport.Logger, (e) => EventsLog.Add(e)); SupportAdd(DataCollectionSupport.Statistics, (e) => EventsMicroservice.Add(e)); SupportAdd(DataCollectionSupport.Telemetry, (e) => EventsMetric.Add(e)); SupportAdd(DataCollectionSupport.Resource, (e) => EventsResource.Add(e)); SupportAdd(DataCollectionSupport.Custom, (e) => EventsCustom.Add(e)); SupportAdd(DataCollectionSupport.Security, (e) => EventsSecurity.Add(e)); }
private void ResetHandle() { //try //{ // Reset model m_model.Reset(); // Clear log EventsLog.Clear(); // Clear statistics Statistics.Clear(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK); //} }
private void LogTimer_Tick(object sender, EventArgs e) { // For event logging this method (a timer and PickEvent) is better than // the events callback used into the Server console demo. // Here we are using the internal Server message queue without // disturbing the client handshake. while (Server.PickEvent(ref Event)) { if (EventsLog.Lines.Count() > 256) { EventsLog.Clear(); } EventsLog.AppendText(Server.EventText(ref Event) + "\n"); // Example of how use the parameters inside the event struct. // Here we check if our DB were changed and, if yes, update the // related textbox. // if ((Event.EvtCode == S7Server.evcDataWrite) && // write event // (Event.EvtRetCode == 0) && // succesfully // (Event.EvtParam1 == S7Server.S7AreaDB)) // it's a DB if ((Event.EvtCode == S7Server.evcDataWrite) && // write event (Event.EvtRetCode == 0)) { switch (Event.EvtParam2) { case 1: HexDump(DB1_Box, DB1, DB1.Length); break; case 2: HexDump(DB2_Box, DB2, DB2.Length); break; case 3: HexDump(DB3_Box, DB3, DB3.Length); break; } } } }
public void Log_ShouldRecordDroppedEvent() { // Arrange. var eventToLog = new Event { key = "Key1", eventTypeId = "testEventType", trafficTypeName = "testTrafficType", timestamp = 7000 }; var wrappedEventsCache = new Mock <ISimpleProducerCache <WrappedEvent> >(); var eventLog = new EventsLog(_apiClientMock.Object, 1, 1, wrappedEventsCache.Object, _telemetryRuntimeProducer.Object, new TasksManager(wrapperAdapter), 10); wrappedEventsCache .Setup(mock => mock.AddItems(It.IsAny <List <WrappedEvent> >())) .Returns(1); // Act. eventLog.Log(new WrappedEvent { Event = eventToLog, Size = 1024 }); // Assert. _telemetryRuntimeProducer.Verify(mock => mock.RecordEventsStats(EventsEnum.EventsQueued, 0), Times.Once); _telemetryRuntimeProducer.Verify(mock => mock.RecordEventsStats(EventsEnum.EventsDropped, 1), Times.Once); }
private static void MainWindow_Closing(object sender, CancelEventArgs e) { EventsLog.Stop(); }
private void BuildEventLog(ConfigurationOptions config) { var eventsCache = new InMemorySimpleCache <WrappedEvent>(new BlockingQueue <WrappedEvent>(_config.EventLogSize)); _eventsLog = new EventsLog(_eventSdkApiClient, _config.EventsFirstPushWindow, _config.EventLogRefreshRate, eventsCache, _telemetryRuntimeProducer, _tasksManager); }
private void ClearBtn_Click(object sender, EventArgs e) { // Simply clears the Log RichTextBox EventsLog.Clear(); }
public static void StartLog() { Log = new EventsLog(); Log.Init(); }
//--------------------------------------------------------------------- public void WriteLogEntry(ManagementArea mgmtArea, Stand stand) { int damagedSites = 0; int cohortsDamaged = 0; int cohortsKilled = 0; int standPrescriptionNumber = 0; double biomassRemoved = 0.0; double biomassRemovedPerHa = 0.0; foreach (ActiveSite site in stand) { //set the prescription name for this site if (BaseHarvest.SiteVars.Prescription[site] != null) { standPrescriptionNumber = BaseHarvest.SiteVars.Prescription[site].Number; BaseHarvest.SiteVars.PrescriptionName[site] = BaseHarvest.SiteVars.Prescription[site].Name; BaseHarvest.SiteVars.TimeOfLastEvent[site] = modelCore.CurrentTime; } cohortsDamaged += SiteVars.CohortsPartiallyDamaged[site]; cohortsKilled += BaseHarvest.SiteVars.CohortsDamaged[site]; if (SiteVars.CohortsPartiallyDamaged[site] > 0 || BaseHarvest.SiteVars.CohortsDamaged[site] > 0) { damagedSites++; //Conversion from [g m-2] to [Mg] biomassRemoved += SiteVars.BiomassRemoved[site] / 100.0 * modelCore.CellArea; } } totalSites[standPrescriptionNumber] += stand.SiteCount; totalDamagedSites[standPrescriptionNumber] += damagedSites; totalCohortsDamaged[standPrescriptionNumber] += cohortsDamaged; totalCohortsKilled[standPrescriptionNumber] += cohortsKilled; //string for log file, contains species harvest count double[] species_count = new double[modelCore.Species.Count]; //if this is the right species match, add it's count to the csv string foreach (ISpecies species in modelCore.Species) { bool assigned = false; //loop through dictionary of species kill count foreach (KeyValuePair<string, int> kvp in stand.DamageTable) { if (species.Name == kvp.Key) { assigned = true; species_count[species.Index] += kvp.Value; } } if (!assigned) { //put a 0 there if it's not assigned (because none were found in the dictionary) species_count[species.Index] = 0.0; } totalSpeciesCohorts[standPrescriptionNumber, species.Index] += (double) species_count[species.Index]; } //now that the damage table for this stand has been recorded, clear it!! stand.ClearDamageTable(); //write to log file: biomassRemovedPerHa = biomassRemoved / (double)damagedSites / modelCore.CellArea; if (biomassRemoved <= 0.0) return; eventLog.Clear(); EventsLog el = new EventsLog(); el.Time = modelCore.CurrentTime; el.ManagementArea = mgmtArea.MapCode; el.Prescription = stand.PrescriptionName; el.StandMapCode = stand.MapCode; el.EventID = stand.EventId; el.StandAge = stand.Age; el.StandRank = stand.HarvestedRank; el.StandSiteCount = stand.SiteCount; el.HarvestedSites = damagedSites; el.MgBiomassRemoved = biomassRemoved; // Mg el.MgBioRemovedPerDamagedHa = biomassRemovedPerHa; // Mg/ha el.CohortsHarvestedPartial = cohortsDamaged; el.CohortsHarvestedComplete = cohortsKilled; el.CohortsHarvested_ = species_count; eventLog.AddObject(el); eventLog.WriteToFile(); }
public EventListener(EventsLog eventsLog) { this.eventsLog = eventsLog; }
private static void Clear() { EventsLog.ClearAll(); Refresh(); }