/// <summary> /// Called when the <see cref="Session"/> <see cref="CloudSpatialAnchorSession.SessionUpdated">SessionUpdated</see> event is fired. /// </summary> /// <param name="sender"> /// The <see cref="Session"/>. /// </param> /// <param name="args"> /// The event data. /// </param> protected virtual void OnSessionUpdated(object sender, SessionUpdatedEventArgs args) { // Update the cached session status sessionStatus = args.Status; // Raise the event SessionUpdated?.Invoke(this, args); }
public void UpdateName(Guid sessionId, string newSessionName) { var session = Get(sessionId); var oldName = session.Name; session.Name = newSessionName; SessionUpdated?.Invoke(this, new GameSessionUpdateEventArgs(oldName, newSessionName)); }
/// <summary>Raises the <see cref="E:SessionUpdated" /> event.</summary> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void OnSessionUpdated(EventArgs e) { if (SessionUpdated != null) { Task.Factory.StartNew(() => { SessionUpdated?.Invoke(this, e); }); } }
public void Apply(SessionUpdated domainEvent) { Date = domainEvent.Date; ClientId = domainEvent.ClientId; ClientFullName = domainEvent.ClientFullName; Feedback = domainEvent.Feedback; GoalOrExpectations = domainEvent.GoalOrExpectations; AreasOfDiscomfort = domainEvent.AreasOfDiscomfort; ContraIndications = domainEvent.ContraIndications; ContributingFactorsToCondition = domainEvent.ContributingFactorsToCondition; Hypothesis = domainEvent.Hypothesis; PreMassagePalpation = domainEvent.PreMassagePalpation; SessionPlan = domainEvent.PreMassagePalpation; TreatmentNotes = domainEvent.TreatmentNotes; AddHistory(domainEvent, "Session Updated"); }
/// <summary> /// Consolida los datos de la sesión /// </summary> private async Task UpdateSessionDataAsync(WebSession.Session session, SessionEventArgs e, bool isNew) { var webRequest = e.WebSession.Request; var webResponse = e.WebSession.Response; // Código de estado, protocolo, proceso... session.StatusCode = webResponse?.StatusCode ?? 0; session.Uri = webRequest.RequestUri; session.ProcessId = e.WebSession.ProcessId.Value; // Tamaño del cuerpo session.BodySize = -1; if (!session.IsTunnelConnect && webResponse != null) { if (webResponse.ContentLength != -1) { session.BodySize = webResponse.ContentLength; } else if (webResponse.IsBodyRead && webResponse.Body != null) { session.BodySize = webResponse.Body.Length; } } // Obtiene los detalles de la solicitud y la respuesta session.Request = ReadRequestData(webRequest); session.Response = ReadResponseData(webResponse); // Trata la sesión nueva o modificada await Dispatcher.InvokeAsync(() => { if (isNew) { // Añade la sesión al diccionario _sessions.Add(e.WebSession, session); // Lanza el evento SessionAdded?.Invoke(this, new NewSessionEventArgs(session)); } else { // Lanza el evento SessionUpdated?.Invoke(this, new UpdateSessionEventArgs(session)); // Elimina la sesión del diccionario _sessions.Remove(e.WebSession); } }); }
public void Handle(SessionUpdated @event) { using (var context = new ProjectionContext(ConnectionString.Get())) { var entity = context.Sessions.Find(@event.AggregateId); if (entity == null) { throw new EntityNotFoundException(@event.AggregateId, "Session"); } entity.TrainingId = @event.TrainingId; entity.SessionId = @event.AggregateId; entity.SessionStart = @event.SessionStart; entity.Duration = @event.Duration; entity.TrainerId = @event.TrainerId; entity.LocationId = @event.LocationId; entity.Seats = @event.Seats; context.SaveChanges(); } }