コード例 #1
0
        private void CreateReminding(Entity entity, string lczStringName, string caption,
                                     params object[] parameters)
        {
            string description = string.Empty;

            if (parameters.Any())
            {
                description = string.Format(GetLczStringValue(lczStringName), parameters);
            }
            else
            {
                description = GetLczStringValue(lczStringName);
            }
            MandrillUtilities.CreateReminding(UserConnection, entity, description, caption);
        }
コード例 #2
0
        private Insert GetWebHookInsert(WebHookEvent webHookEvent)
        {
            var    insertWebHook = new Insert(UserConnection).Into("MandrillWebHookEvent");
            int    allClicks     = 0;
            int    allOpens      = 0;
            string email         = String.Empty;

            if (webHookEvent.Reject != null)
            {
                return(null);
            }
            int responseCode = 0;
            BulkEmailResponseCode eventResponseCode;

            try {
                eventResponseCode = webHookEvent.Event.GetBulkEmailResponseCode();
                responseCode      = (int)eventResponseCode;
            } catch (InvalidCastException e) {
                _log.ErrorFormat("[HandleWebHooks]: Error parsing response Code:", e);
                return(null);
            }

            Guid mandrillId = Guid.Empty;

            if (!Guid.TryParse(webHookEvent.Id, out mandrillId))
            {
                _log.ErrorFormat("[HandleWebHooks]: Error parsing message Id: {0}.", webHookEvent.Id);
                return(null);
            }
            insertWebHook.Set("MandrillId", Column.Parameter(mandrillId));
            insertWebHook.Set("TimeStamp", Column.Parameter((int)webHookEvent.TS));
            insertWebHook.Set("ResponseCode", Column.Parameter(responseCode));
            var webHookMessage = webHookEvent.Msg;

            if (webHookMessage != null)
            {
                var webHookClicks = webHookMessage.Clicks;
                var webHookOpens  = webHookMessage.Opens;
                if (webHookClicks != null)
                {
                    allClicks = webHookClicks.Count;
                }
                if (webHookOpens != null)
                {
                    allOpens = webHookOpens.Count;
                }
                email = webHookMessage.Email;
                if (!string.IsNullOrEmpty(email))
                {
                    insertWebHook.Set("Email", Column.Parameter(email));
                }
                var metadata = webHookMessage.Metadata;
                if (metadata != null)
                {
                    var bulkEmailMetadata = metadata.FirstOrDefault(key => key.Key == BulkEmailMetadataValue);
                    if (bulkEmailMetadata != null)
                    {
                        Guid bulkEmailId = Guid.Empty;
                        Guid.TryParse(bulkEmailMetadata.Value, out bulkEmailId);
                        insertWebHook.Set("Metadata", Column.Parameter(bulkEmailId));
                    }
                }
            }
            insertWebHook.Set("AllClicks", Column.Parameter(allClicks));
            insertWebHook.Set("AllOpens", Column.Parameter(allOpens));
            if (eventResponseCode == BulkEmailResponseCode.Opened)
            {
                insertWebHook.Set("Opens", Column.Const(1));
            }
            else if (eventResponseCode == BulkEmailResponseCode.Clicked)
            {
                string url           = UtmHelper.RemoveUtmFromUri(webHookEvent.Url);
                Guid   hyperlinkHash = MandrillUtilities.GetMD5HashGuid(url.ToLower());
                insertWebHook.Set("Clicks", Column.Const(1));
                insertWebHook.Set("HyperlinkHash", Column.Parameter(hyperlinkHash));
            }
            return(insertWebHook);
        }
コード例 #3
0
        private List <Mandrill.WebHookEvent> CompressedJsonToEmailTargetStatuses(MemoryStream compressedJson)
        {
            string json = MandrillUtilities.DecompressToString(compressedJson);

            return(Mandrill.JSON.Parse <List <Mandrill.WebHookEvent> >(json));
        }