public virtual async Task Handle(OrderChangedEvent message) { var operationLogs = new List <OperationLog>(); foreach (var changedEntry in message.ChangedEntries) { operationLogs.AddRange(await GetChangedEntryOperationLogsAsync(changedEntry)); } if (!operationLogs.IsNullOrEmpty()) { _changeLogService.SaveChanges(operationLogs.ToArray()); } }
public void OnNext(QuoteRequestChangeEvent value) { var origQuote = value.OrigQuote; var modifiedQuote = value.ModifiedQuote; if (value.ChangeState == Platform.Core.Common.EntryState.Modified) { var operationLog = new OperationLog { ObjectId = value.ModifiedQuote.Id, ObjectType = typeof(QuoteRequest).Name, OperationType = value.ChangeState }; if (origQuote.Status != modifiedQuote.Status) { operationLog.Detail += String.Format("status changed from {0} -> {1} ", origQuote.Status ?? "undef", modifiedQuote.Status ?? "undef"); } if (origQuote.Comment != modifiedQuote.Comment) { operationLog.Detail += String.Format("comment changed "); } if (origQuote.IsLocked != modifiedQuote.IsLocked) { operationLog.Detail += modifiedQuote.IsLocked ? "lock " : "unlock "; } _changeLogService.SaveChanges(operationLog); } }
public void OnNext(SubscriptionChangeEvent value) { var original = value.OriginalSubscription; var modified = value.ModifiedSubscription; if (value.ChangeState == Platform.Core.Common.EntryState.Modified) { var operationLogs = new List <OperationLog>(); if (original.SubscriptionStatus != modified.SubscriptionStatus) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.StatusChanged, original.SubscriptionStatus, modified.SubscriptionStatus)); } if (original.Interval != modified.Interval) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.IntervalChanged, original.Interval, modified.Interval)); } if (original.IntervalCount != modified.IntervalCount) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.IntervalCountChanged, original.IntervalCount, modified.IntervalCount)); } if (original.TrialPeriodDays != modified.TrialPeriodDays) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.TrialPeriodChanged, original.TrialPeriodDays, modified.TrialPeriodDays)); } if (original.CurrentPeriodEnd != modified.CurrentPeriodEnd) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.NextBillingDateChanged, original.CurrentPeriodEnd, modified.CurrentPeriodEnd)); } if (original.Balance != modified.Balance) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.BalanceChanged, original.Balance, modified.Balance)); } if (modified.IsCancelled && original.IsCancelled != modified.IsCancelled) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.SubscriptionCanceled, modified.CancelledDate, modified.CancelReason ?? "")); } if (original.OuterId != modified.OuterId) { operationLogs.Add(GetLogRecord(modified.Id, SubscriptionResources.OuterIdChanged, original.OuterId, modified.OuterId)); } _changeLogService.SaveChanges(operationLogs.ToArray()); } }
protected virtual void SaveOperationLog(string objectId, string detail, EntryState entryState) { var operation = new OperationLog { ObjectId = objectId, ObjectType = typeof(ApplicationUserExtended).Name, OperationType = entryState, Detail = detail }; _changeLogService.SaveChanges(operation); }
public virtual Task Handle(MemberChangedEvent message) { //Log audit records only for contacts members var operationLogs = message.ChangedEntries.Where(x => x.EntryState == EntryState.Modified && x.OldEntry is Contact) .SelectMany(GetChangedEntryOperationLogs) .ToArray(); if (operationLogs.Any()) { _changeLogService.SaveChanges(operationLogs); } return(Task.CompletedTask); }
public Task Handle(LicenseChangedEvent message) { foreach (var changedEntry in message.ChangedEntries) { var original = changedEntry.OldEntry; var modified = changedEntry.NewEntry; if (changedEntry.EntryState == EntryState.Modified) { var operationLogs = new List <OperationLog>(); if (original.CustomerName != modified.CustomerName) { operationLogs.Add(GetLogRecord(modified.Id, "Customer name changed from '{0}' to '{1}'", original.CustomerName, modified.CustomerName)); } if (original.CustomerEmail != modified.CustomerEmail) { operationLogs.Add(GetLogRecord(modified.Id, "Customer email changed from '{0}' to '{1}'", original.CustomerEmail, modified.CustomerEmail)); } if (original.ExpirationDate != modified.ExpirationDate) { operationLogs.Add(GetLogRecord(modified.Id, "Expiration date changed from '{0}' to '{1}'", original.ExpirationDate, modified.ExpirationDate)); } if (original.Type != modified.Type) { operationLogs.Add(GetLogRecord(modified.Id, "License type changed from '{0}' to '{1}'", original.Type, modified.Type)); } if (original.ActivationCode != modified.ActivationCode) { operationLogs.Add(GetLogRecord(modified.Id, "Activation code changed from '{0}' to '{1}'", original.ActivationCode, modified.ActivationCode)); } _changeLogService.SaveChanges(operationLogs.ToArray()); } } return(Task.CompletedTask); }
public void OnNext(OrderChangeEvent value) { if (value.ChangeState == EntryState.Modified) { var operationLogs = new List <OperationLog>(); var originalOperations = value.OrigOrder.GetFlatObjectsListWithInterface <IOperation>().Distinct(); var modifiedOperations = value.ModifiedOrder.GetFlatObjectsListWithInterface <IOperation>().Distinct(); modifiedOperations.ToList().CompareTo(originalOperations.ToList(), EqualityComparer <IOperation> .Default, (state, modified, original) => operationLogs.AddRange(GetOperationLogs(state, original, modified))); _changeLogService.SaveChanges(operationLogs.ToArray()); } }
public virtual Task Handle(OrderChangedEvent message) { var operationLogs = new List <OperationLog>(); foreach (var changedEntry in message.ChangedEntries.Where(x => x.EntryState == EntryState.Modified)) { var originalOperations = changedEntry.OldEntry.GetFlatObjectsListWithInterface <IOperation>().Distinct(); var modifiedOperations = changedEntry.NewEntry.GetFlatObjectsListWithInterface <IOperation>().Distinct(); modifiedOperations.ToList().CompareTo(originalOperations.ToList(), EqualityComparer <IOperation> .Default, (state, modified, original) => operationLogs.AddRange(GetChangedEntryOperationLogsAsync(new GenericChangedEntry <IOperation>(modified, original, state)).GetAwaiter().GetResult())); } if (!operationLogs.IsNullOrEmpty()) { _changeLogService.SaveChanges(operationLogs.ToArray()); } return(Task.CompletedTask); }