private void ProcessForWorkflow(Guid?actionGuid, Rock.Data.RockContext rockContext, SendGridEvent payload) { RockLogger.Log.Debug(RockLogDomains.Communications, "ProcessForWorkflow {@payload}", payload); string status = string.Empty; switch (payload.EventType) { case "unsubscribe": case "delivered": status = SendEmailWithEvents.SENT_STATUS; break; case "click": status = SendEmailWithEvents.CLICKED_STATUS; break; case "open": status = SendEmailWithEvents.OPENED_STATUS; break; case "failed": case "dropped": case "blocked": case "bounce": case "bounced": status = SendEmailWithEvents.FAILED_STATUS; string message = payload.ServerResponse.IsNotNullOrWhiteSpace() ? payload.ServerResponse : payload.EventTypeReason; Rock.Communication.Email.ProcessBounce( payload.Email, Rock.Communication.BounceType.HardBounce, message, RockDateTime.ConvertLocalDateTimeToRockDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(payload.Timestamp).ToLocalTime())); break; } if (actionGuid != null && !string.IsNullOrWhiteSpace(status)) { SendEmailWithEvents.UpdateEmailStatus(actionGuid.Value, status, payload.EventType, rockContext, true); } }
/// <summary> /// Processes for workflow. /// </summary> /// <param name="eventType">Type of the event.</param> /// <param name="actionGuid">The action unique identifier.</param> /// <param name="rockContext">The rock context.</param> private void ProcessForWorkflow(Guid?actionGuid, Rock.Data.RockContext rockContext) { string status = string.Empty; switch (mailgunRequestPayload.EventType) { case "complained": case "unsubscribed": case "delivered": status = SendEmailWithEvents.SENT_STATUS; break; case "clicked": status = SendEmailWithEvents.CLICKED_STATUS; break; case "opened": status = SendEmailWithEvents.OPENED_STATUS; break; case "failed": case "dropped": case "suppress-bounce": case "bounced": status = SendEmailWithEvents.FAILED_STATUS; string message = mailgunRequestPayload.Notification.IsNotNullOrWhiteSpace() ? mailgunRequestPayload.Notification : mailgunRequestPayload.Description; Rock.Communication.Email.ProcessBounce( mailgunRequestPayload.Recipient, Rock.Communication.BounceType.HardBounce, message, RockDateTime.ConvertLocalDateTimeToRockDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(mailgunRequestPayload.TimeStamp).ToLocalTime())); break; } if (actionGuid != null && !string.IsNullOrWhiteSpace(status)) { SendEmailWithEvents.UpdateEmailStatus(actionGuid.Value, status, mailgunRequestPayload.EventType, rockContext, true); } }
/// <summary> /// Processes for workflow. /// </summary> /// <param name="eventType">Type of the event.</param> /// <param name="actionGuid">The action unique identifier.</param> /// <param name="rockContext">The rock context.</param> private void ProcessForWorkflow(string eventType, Guid?actionGuid, Rock.Data.RockContext rockContext) { string status = string.Empty; switch (eventType) { case "complained": case "unsubscribed": case "delivered": status = SendEmailWithEvents.SENT_STATUS; break; case "clicked": status = SendEmailWithEvents.CLICKED_STATUS; break; case "opened": status = SendEmailWithEvents.OPENED_STATUS; break; case "dropped": case "suppress-bounce": case "bounced": status = SendEmailWithEvents.FAILED_STATUS; int secs = request.Form["timestamp"].AsInteger(); Rock.Communication.Email.ProcessBounce( request.Form["recipient"], Rock.Communication.BounceType.HardBounce, request.Form["notification"], RockDateTime.ConvertLocalDateTimeToRockDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(secs).ToLocalTime())); break; } if (actionGuid != null && !string.IsNullOrWhiteSpace(status)) { SendEmailWithEvents.UpdateEmailStatus(actionGuid.Value, status, eventType, rockContext, true); } }