/// <summary> /// Handles the event that is generated when an operation completes. /// </summary> /// <param name="sender">The <see cref="T:System.Object" /> that generated the event.</param> /// <param name="xdbOperationEventArgs">A <see cref="T:Sitecore.XConnect.Operations.XdbOperationEventArgs" /> object that provides information about the event.</param> private void OnOperationCompleted(object sender, XdbOperationEventArgs xdbOperationEventArgs) { //Check if no exceptions occurred during executing the operation. if (xdbOperationEventArgs.Operation.Exception != null) { return; } //We need to track only the SetFacetOperation operation. Trying to cast to a necessary type. var operation = xdbOperationEventArgs.Operation as SetFacetOperation; //Checking if an operation execution status is "Succeeded" if (operation?.Status == XdbOperationStatus.Succeeded) { //Log.Information("Processing add interaction operation for interaction id = {0} and contact id = {1}", operation.Entity.Events[0].Id, operation.Entity.Contact.Id.Value); DataExportService.SendFacet(operation.Facet, operation.FacetReference.Entity.Id?.ToString()); } }
private void OnOperationAdded(object sender, XdbOperationEventArgs xdbOperationEventArgs) { Condition.Requires(xdbOperationEventArgs, "xdbOperationEventArgs").IsNotNull(); RightToBeForgottenOperation rightToBeForgottenOperation; if ((rightToBeForgottenOperation = (xdbOperationEventArgs.Operation as RightToBeForgottenOperation)) == null) { return; } if (rightToBeForgottenOperation.Status == XdbOperationStatus.Canceled) { logger.LogDebug($"[{PluginName}] Skipping operation as it has been cancelled"); } else { rightToBeForgottenOperation.DependencyAdded += OnDependencyAddedToRightToBeForgottenOperation; } }
/// <summary> /// Handles the event that is generated when an operation completes. /// </summary> /// <param name="sender">The <see cref="T:System.Object" /> that generated the event.</param> /// <param name="xdbOperationEventArgs">A <see cref="T:Sitecore.XConnect.Operations.XdbOperationEventArgs" /> object that provides information about the event.</param> private void OnOperationCompleted(object sender, XdbOperationEventArgs xdbOperationEventArgs) { //Check if no exceptions are occurred during executing the operation. If it is, it will not guarantee that contact was created. if (xdbOperationEventArgs.Operation.Exception != null) { return; } //We need to track only the AddContactOperation operation. Trying to cast to a necessary type. var operation = xdbOperationEventArgs.Operation as AddContactOperation; //Checking if it is the necessary operation and if an operation execution status is "Succeeded" if (operation?.Status == XdbOperationStatus.Succeeded && operation.Entity.Id.HasValue) { //Sending a message with an id of newly created contact. _messageBus.SendAsync(new CreateDynamicsContactMessage { ContactId = operation.Entity.Id.Value }); } }