public LoggedEvent GetLoggedEvent(int loggedEventId) { LoggedEvent loggedEvent = null; try { using (var db = new Entities()) { if (loggedEventId > 0) { var tmpLoggedEvent = db.LoggedEvents.SingleOrDefault(i => i.LoggedEventID == loggedEventId); if (tmpLoggedEvent != null) { loggedEvent = tmpLoggedEvent; } } } } catch (Exception ex) { Logger.ErrorFormat("GetLoggedEvent - error [{0}] - - \r\n {1} \r\n\r\n", ex.Message, ex.StackTrace); } return(loggedEvent); }
private AuthenticationEvent Map(LoggedEvent loggedEvent) { var authenticationEvent = new AuthenticationEvent(); var whatHappened = (EventAction)Enum.Parse(typeof(EventAction), loggedEvent.Action); switch (whatHappened) { case EventAction.UserRegistered: authenticationEvent = JsonConvert.DeserializeObject <UserRegisteredEvent>(loggedEvent.Data); break; case EventAction.EmailUniqueValidationFailed: authenticationEvent = JsonConvert.DeserializeObject <EmailUniqueValidationFailedEvent>(loggedEvent.Data); break; case EventAction.EmailVerified: authenticationEvent = JsonConvert.DeserializeObject <EmailVerifiedEvent>(loggedEvent.Data); break; case EventAction.EmailChangeRequested: authenticationEvent = JsonConvert.DeserializeObject <EmailChangeRequestedEvent>(loggedEvent.Data); break; } return(authenticationEvent); }
public override int WriteEvent(LoggedEvent e) { XmlDocument doc = new XmlDocument(); XmlNode xEvent = doc.AppendChild(doc.CreateElement("event")); xEvent.AppendChild(doc.CreateElement("level")).InnerText = e.Level.ToString(); xEvent.AppendChild(doc.CreateElement("group")).InnerText = e.Group; xEvent.AppendChild(doc.CreateElement("type")).InnerText = e.Type; xEvent.AppendChild(doc.CreateElement("details")).InnerText = e.Details; xEvent.AppendChild(doc.CreateElement("clientip")).InnerText = e.ClientIp; xEvent.AppendChild(doc.CreateElement("hostip")).InnerText = e.HostIp; XmlNode xApplication = xEvent.AppendChild(doc.CreateElement("application")); xApplication.AppendChild(doc.CreateElement("id")).InnerText = e.ApplicationId.ToString(); xApplication.AppendChild(doc.CreateElement("name")).InnerText = e.ApplicationName; xApplication.AppendChild(doc.CreateElement("type")).InnerText = e.ApplicationType.ToString(); XmlNode xLoggingUser = xEvent.AppendChild(doc.CreateElement("logginguser")); xLoggingUser.AppendChild(doc.CreateElement("id")).InnerText = e.LoggingUserId; xLoggingUser.AppendChild(doc.CreateElement("type")).InnerText = e.LoggingUserType; XmlNode xAffectedUser = xEvent.AppendChild(doc.CreateElement("affecteduser")); xAffectedUser.AppendChild(doc.CreateElement("id")).InnerText = e.AffectedUserId; xAffectedUser.AppendChild(doc.CreateElement("type")).InnerText = e.AffectedUserType; EventLog.WriteEntry(xEvent.OuterXml, EventLogEntryType.Information); //EventLog does not synchronously return IDs for new events, so return 1 //This module is intended to log to a centralized logging source, not the local event log //This module is provided for exabple purposes only return(1); }
public void It_can_parse_the_input_parameter_correctly(string input, long occuredAt, string callId, string eventTypeId) { var result = new LoggedEvent(input); result.OccuredAt.Should().Be(occuredAt); result.CallId.Should().Be(callId); result.EventTypeIdentifier.Should().Be(eventTypeId); }
/// <summary> /// Method called on new log entry, entry is stored in session /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void OnEntryWritten(object source, EntryWrittenEventArgs e) { EventLogEntry entry = e.Entry; var loggedEvent = new LoggedEvent(entry); //TraceWriteLn("Captured event: " + entry.EventID); EventLogEntries.Add(loggedEvent); }
public AuthenticationEventViewModel Map(LoggedEvent authEvent) { return(new AuthenticationEventViewModel() { EventAction = authEvent.Action, TimeStamp = authEvent.TimeStamp, UserInfo = authEvent.Data }); }
public void Save <T>(T theEvent) where T : Event { var loggedEvent = new LoggedEvent() { Action = theEvent.Name, Cargo = JsonSerializer.Serialize(theEvent) }; _eventRepository.Store(loggedEvent); }
public void ApiV1EventPostWithHttpInfo() { configuration = GetClientConfig(); LoggedEvent loggedEvent = new LoggedEvent(dt, "Portal", 1, 7, 1, "anonymous", "Test Event", new Guid("52c5dd34-1b5f-460b-8904-6f0f2897f6a1"), "int.example", 1L); eventApitest = new EventApi(configuration); ApiResponse <object> response = eventApitest.ApiV1EventPostWithHttpInfo(loggedEvent); Assert.Equal(200, response.StatusCode); }
public void Save <T>(T theEvent) where T : Event { var loggedEvent = new LoggedEvent() { Action = theEvent.Name, Cargo = new JavaScriptSerializer().Serialize(theEvent) }; EventRepository.Store(loggedEvent); }
public void OnBotEvent(LoggedEvent userLogged) { this.datacontext.UI.PlayerStatus = "Playing"; this.datacontext.UI.PlayerName = userLogged.Profile.PlayerData.Username; this.datacontext.RaisePropertyChanged("UI"); this.Dispatcher.Invoke(() => { lblAccount.Content = $"{this.datacontext.UI.PlayerStatus} as : {this.datacontext.UI.PlayerName}"; }); }
public void OnBotEvent(LoggedEvent userLogged) { datacontext.UI.PlayerStatus = "Playing"; datacontext.UI.PlayerName = userLogged.Profile.PlayerData.Username; datacontext.RaisePropertyChanged("UI"); Dispatcher.Invoke(() => { popSwithAccount.IsOpen = false; lblAccount.Content = $"{datacontext.UI.PlayerStatus} as : {datacontext.UI.PlayerName}"; }); }
private void TestUserInfoAssertion(int number, string guid, string message, UserInfoState state) { LoggedEvent evt = _logger.Events[number]; Assert.AreEqual(ExecutionLoggerEventType.UserInfo, evt.Type); Assert.IsInstanceOf(typeof(UserInfoData), evt.Data); UserInfoData data = (UserInfoData)evt.Data; Assert.AreEqual(guid, data.Guid); Assert.AreEqual(message, data.Message); Assert.AreEqual(state, data.State); }
public void LogEvent(string eventName, GameObject linkedObject) { LoggedEvent lge = new LoggedEvent(); lge.m_eventName = eventName; lge.m_linkedObject = linkedObject; lge.m_time = AudioSettings.dspTime - m_startTime; m_loggedEvents.Add(lge); if (m_loggedEvents.Count > m_maxEvents) { m_loggedEvents.RemoveAt(0); } }
public void Store(AuthenticationEvent authenticationEvent) { authenticationEvent.TimeStamp = DateTime.Now; var loggedEvent = new LoggedEvent() { Action = authenticationEvent.EventAction, AggregateId = authenticationEvent.UserId, Data = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationEvent), TimeStamp = authenticationEvent.TimeStamp }; _eventDb.Save(loggedEvent); }
public static LoggedEvent LogStartEvent(IObjectRepository objectRepository, string eventName, string eventDetails) { var newLoggedEvent = new LoggedEvent { DateStarted = DateTime.Now, Name = eventName }; if (!string.IsNullOrEmpty(eventDetails)) { newLoggedEvent.Details = eventDetails; } newLoggedEvent = objectRepository.SaveLoggedEvent(newLoggedEvent); return(newLoggedEvent); }
public LoggedEvent SaveLoggedEvent(LoggedEvent loggedEvent) { LoggedEvent savedEvent = null; try { using (var db = new Entities()) { if (loggedEvent.LoggedEventID > 0) { var tmpLoggedEvent = db.LoggedEvents.SingleOrDefault(i => i.LoggedEventID == loggedEvent.LoggedEventID); if (tmpLoggedEvent != null) { tmpLoggedEvent.DateEnded = loggedEvent.DateEnded; tmpLoggedEvent.DateStarted = loggedEvent.DateStarted; tmpLoggedEvent.Name = loggedEvent.Name; tmpLoggedEvent.Details = loggedEvent.Details; savedEvent = tmpLoggedEvent; } } else { db.LoggedEvents.Add(loggedEvent); savedEvent = loggedEvent; } db.SaveChanges(); } } catch (Exception ex) { Logger.ErrorFormat("SaveLoggedEvent - error [{0}] - - \r\n {1} \r\n\r\n", ex.Message, ex.StackTrace); } return(savedEvent); }
/// <summary> /// Run query for logged event based on criteria in EventInfo /// </summary> /// <param name="eventInfo"></param> /// <returns></returns> private LoggedEvent RunQuery(EventInfo eventInfo) { LoggedEvent loggedEvent = null; IEnumerable <LoggedEvent> results = null; if (eventInfo.EventId >= 0) // kind of silly, but... { // select with minimun info results = EventLogEntries.Where(e => e.Observed == false && e.LogEntry.EventID == eventInfo.EventId && e.LogEntry.EntryType == eventInfo.EventType); // Event source populated? if (!string.IsNullOrWhiteSpace(eventInfo.EventSource)) { results = results.Where(e => e.LogEntry.Source == eventInfo.EventSource); } // EventMEssage populated? if (!string.IsNullOrWhiteSpace(eventInfo.EventMessage)) { results = results.Where(e => e.LogEntry.Message.Contains(eventInfo.EventMessage)); } loggedEvent = results.DefaultIfEmpty(null).FirstOrDefault(); } else { TraceWriteLn("Event lacks basic criteria for query (min: EventId >= 0)"); // set as never found loggedEvent = null; } return(loggedEvent); }
public void Store(LoggedEvent eventToLog) { eventToLog.TimeStamp = DateTime.Now; _db.LoggedEvents.Add(eventToLog); _db.SaveChanges(); }
/// <summary> /// Store information about an event. /// </summary> /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request"> (optional)</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiV1EventPostAsyncWithHttpInfo(LoggedEvent request = null) { var localVarPath = "/api/v1/event"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new Dictionary <String, String>(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json", "text/json", "application/json-patch+json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (request != null && request.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter } else { localVarPostBody = request; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiV1EventPost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null)); }
/// <summary> /// Store information about an event. /// </summary> /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request"> (optional)</param> /// <returns></returns> public void ApiV1EventPost(LoggedEvent request = null) { ApiV1EventPostWithHttpInfo(request); }
/// <summary> /// Store information about an event. /// </summary> /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request"> (optional)</param> /// <returns>Task of void</returns> public async System.Threading.Tasks.Task ApiV1EventPostAsync(LoggedEvent request = null) { await ApiV1EventPostAsyncWithHttpInfo(request); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='request'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task ApiV1EventPostAsync(this IColecticaRepositoryRESTAPI operations, LoggedEvent request = default(LoggedEvent), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.ApiV1EventPostWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
public void Store(LoggedEvent eventToLog) { eventToLog.TimeStamp = DateTime.Now; _merloEventStoreContext.LoggedEvents.Add(eventToLog); _merloEventStoreContext.SaveChanges(); }
public void Log(LoggedEvent eventType, params (string property, string value)[] data) =>
/// <inheritdoc/> public void Log(LoggedEvent eventType, params (string, string)[] data) => Log($"{eventType}", data);
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='request'> /// </param> public static void ApiV1EventPost(this IColecticaRepositoryRESTAPI operations, LoggedEvent request = default(LoggedEvent)) { operations.ApiV1EventPostAsync(request).GetAwaiter().GetResult(); }