示例#1
0
        /// <summary>
        /// This method get invoke contentder scheduler to fetch mail on schedule date and send mail.
        /// </summary>
        /// <param name="ScheduleOn"></param>
        /// <returns></returns>
        private async void SendMailFromContentder(DateTime ScheduleOn, string DomainName)
        {
            try
            {
                string        scheduleOn    = ScheduleOn.ToString("yyyy-MM-dd HH:mm:ss");
                FetchRest     fetchRest     = new FetchRest();
                SettingHelper settingHelper = new SettingHelper(_memoryCache);
                string        configurecode = settingHelper.GetCachedSettingValue(SettingKeys.Configurecode);

                ClientRequestInfo clientRequest = new ClientRequestInfo();
                clientRequest.Sender      = DomainName;
                clientRequest.RequestType = 1;
                clientRequest.ExecuteOn   = scheduleOn;
                string PostData           = JsonConvert.SerializeObject(clientRequest);
                string MassMailRequestURL = ContentderAPI.AutomatedTaskRequest;
                Uri    URI = new Uri(MassMailRequestURL);
                HttpResponseMessage responseMessage = await Task.Run(() => fetchRest.PostData(DomainName, configurecode, URI, PostData));

                if (responseMessage.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);

                    PostResponse postResponse = JsonConvert.DeserializeObject <PostResponse>(responseContent);
                    if (postResponse.Code == (int)ePostResponseCode.PackageLimitExceed)
                    {
                        MassMailProvider mailProvider = new MassMailProvider();
                        _ = mailProvider.UpdateStausOfMail(ScheduleOn, eEmailStatus.LimitExceeded);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#2
0
        public async Task <SendsEmail> GetMailAndUserToSendMail(string SecheduleDate)
        {
            try
            {
                MassMailProvider objProvider = new MassMailProvider();
                SendsEmail       objInfo     = await objProvider.GetMailAndUserToSendMail(DateTime.Parse(SecheduleDate));

                SettingHelper pagebase = new SettingHelper();
                if (objInfo.Mail != null)
                {
                    //objInfo.Mail.MessageBody = objInfo.Mail.MessageBody.Replace(MailToken.CurrnetHostURL, TokenController.GetCurrnetHostURL());
                    objInfo.Mail.MailFrom = await pagebase.GetSettingValueByIndividualKey(SettingKeys.AdminEmail);

                    objInfo.Mail.MessageBody = await this.ReplaceApplicationMailTokens(objInfo.Mail.MessageBody);

                    //objInfo.Mail.MessageBody = objInfo.Mail.MessageBody.Replace(MailToken.SiteLogo, TokenController.GetLogo());
                    objInfo.Mail.TokenKeys = MailToken.FirstName + "," +
                                             MailToken.LastName + "," +
                                             MailToken.UserName + "," +
                                             MailToken.Email + "," + MailToken.UnsubscribeLink;
                }
                return(objInfo);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// This method replace the tokens of application such as ecommerce and blog news and return real data mail body.
        /// </summary>
        /// <param name="MailBody"></param>
        /// <returns></returns>
        public async Task <string> ReplaceApplicationMailTokens(string MailBody)
        {
            MassMailProvider          providerObj = new MassMailProvider();
            IList <MethodInvokerInfo> lstMethods  = await providerObj.GetAllAppMethods();

            foreach (MethodInvokerInfo objMethod in lstMethods)
            {
                MailBody = this.InvokeDynamicMethod(objMethod, MailBody);
            }
            return(MailBody);
        }
示例#4
0
        public async void SendMailFromMandril(DateTime SecheduleDate, bool IsInstant)
        {
            MassMailHelper conMassMail = new MassMailHelper(_httpContextAccessor, _env, _memoryCache);
            SendsEmail     sendsEmail  = await conMassMail.GetMailAndUserToSendMail(SecheduleDate.ToString());

            MailSendInfo        mail         = sendsEmail.Mail;
            List <MailMergeVar> lstMergeVars = new List <MailMergeVar>();
            EmailMessage        message      = new EmailMessage();

            if (mail != null)
            {
                message.from_email = mail.MailFrom;
                message.from_name  = mail.MailFrom;
                message.subject    = mail.Subject;
                List <EmailAddress> toEmails = new List <EmailAddress>();
                message.html = this.ConvertAllMergeTagsToMandrillsTags(mail.MessageBody);
                foreach (UserInfo subcriber in sendsEmail.Subscribers)
                {
                    if (!string.IsNullOrEmpty(subcriber.EmailAddress))
                    {
                        toEmails.Add(new EmailAddress(subcriber.EmailAddress, subcriber.FullName, "to"));
                        lstMergeVars.Add(new MailMergeVar {
                            rcpt = subcriber.EmailAddress, vars = this.GetSubscriberMergeVars(subcriber.TokenValues, mail.TokenKeys)
                        });
                    }
                }
                message.to         = toEmails;
                message.merge_vars = lstMergeVars;
                FinalEmail finalEmail = new FinalEmail();
                finalEmail.async   = true;
                finalEmail.message = message;

                if (!IsInstant)
                {
                    finalEmail.send_at = SecheduleDate.ToString(MandrilConfiguration.DATE_TIME_FORMAT_STRING);
                }
                string ApiKey = await MailSettingController.GetSettingByKey(MailSettingKey.MandrilAPIKey);

                MandrilHelper      mandrilMailHelper = new MandrilHelper(ApiKey);
                List <EmailResult> emailResults      = await mandrilMailHelper.SendMessage(finalEmail);

                MassMailProvider massMailProvider = new MassMailProvider();
                if (emailResults != null)
                {
                    await massMailProvider.UpdateStausOfFailMail(mail.MassMailID, string.Empty);

                    foreach (EmailResult objResult in emailResults)
                    {
                        await massMailProvider.AddMailSubscriberStatus(mail.MassMailID, objResult.Email, (int)objResult.Status, 1, objResult.RejectReason);
                    }
                }
            }
        }
示例#5
0
        public async Task <DataSet> GetMassMailDetailForEdit(long massmailID)
        {
            MassMailProvider objProvider = new MassMailProvider();
            DataSet          ds          = await objProvider.GetMassMailDetailForEdit(massmailID);

            ds.Tables[0].TableName = "Mails";
            ds.Tables[1].TableName = "Interests";
            ds.Tables[2].TableName = "Genders";
            ds.Tables[3].TableName = "Users";
            ds.Tables[4].TableName = "RecipientGroup";
            ds.Tables[5].TableName = "AdvanceFilters";
            return(ds);
        }
示例#6
0
        public async Task <OperationStatus> AddUpdateMassMail(MassMailAddInfo objMassMail, string username, string HostURL)
        {
            MassMailProvider objProvider = new MassMailProvider();

            if (objMassMail.IsInstant)
            {
                DateTime CurrentDate = DateTime.UtcNow.ToLocalTime();
                objMassMail.ScheduledOn    = CurrentDate.ToString();
                objMassMail.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(CurrentDate).ToString();
            }
            OperationStatus status = await objProvider.AddUpdateMassMail(objMassMail, username);

            if ((int)status.Result > 0)
            {
                this.CallMailGateway(objMassMail.UTCScheduled, objMassMail.IsInstant, HostURL);
            }
            return(status);
        }
示例#7
0
        /// <summary>
        /// Send email to subscribe users with interest and gender filter. All system token will be replaced by real value. Replace your app token before call it.This Mail is saved in massmail table.
        /// </summary>
        /// <param name="Subject">Email Subject</param>
        /// <param name="Body">Email Body Get From Mail Template with replaced tokens</param>
        /// <param name="UserName">Current System User</param>
        /// <param name="AudienceInterests">Email target audience interest(Category). eg sports,technology etc</param>
        /// <param name="TargetGender">(eg 0,1,2) 0-Male 1-Female 2-Others</param>
        /// <param name="ToAllGender">Send to all user whose gender is either specified or not.</param>
        /// <param name="AppName">Caller App name (eg Blog,e-Commerce).</param>
        /// <returns></returns>
        public async Task <int> SendMailToSubscribeUser(string Subject, string Body, string UserName, string AudienceInterests, string TargetGender, bool ToAllGender, string AppName, string HostURL)
        {
            MassMailAddInfo  objMassMail = new MassMailAddInfo();
            MassMailProvider objProvider = new MassMailProvider();

            objMassMail.MessageTitle = Subject;
            objMassMail.Gender       = TargetGender;
            objMassMail.Interests    = AudienceInterests;
            objMassMail.Subject      = Subject;
            objMassMail.MessageBody  = Body;
            objMassMail.IsInstant    = true;
            objMassMail.ToAllGender  = ToAllGender;
            DateTime CurrentDate = DateTime.UtcNow.ToLocalTime();

            objMassMail.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(CurrentDate).ToString();
            objMassMail.ScheduledOn    = CurrentDate.ToString();
            int status = await objProvider.AddMailByApp(objMassMail, UserName, AppName);

            if (status > 0)
            {
                this.CallMailGateway(objMassMail.UTCScheduled, objMassMail.IsInstant, HostURL);
            }
            return(status);
        }
示例#8
0
        public async Task <IList <MassMailInfo> > GetMassMailList(int offset, int limit, int filterTypeID, string title, int status)
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.GetMassMailList(offset, limit, filterTypeID, title, status));
        }
示例#9
0
        public async Task <IList <MassMailFilterTypeInfo> > GetAllUsers(string username)
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.GetAllUsersForAutoComplete(username));
        }
示例#10
0
        public async Task <IList <MassMailFilterTypeInfo> > GetFilterValueList(int filterTypeID)
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.GetFilterValueList(filterTypeID));
        }
示例#11
0
        public async Task <IList <MassMailDeliverInfo> > GetMailReportByID(int MailID, int OffSet, int Limit, int Types)
        {
            MassMailProvider providerObj = new MassMailProvider();

            return(await providerObj.GetMailReportByID(MailID, OffSet, Limit, Types));
        }
示例#12
0
        public async Task <MassMailReportInfo> GetReportByID(int MailID)
        {
            MassMailProvider providerObj = new MassMailProvider();

            return(await providerObj.GetReportByID(MailID));
        }
示例#13
0
        public async Task <IList <MassMailInterestInfo> > GetInterest(string Keyword)
        {
            MassMailProvider providerObj = new MassMailProvider();

            return(await providerObj.GetInterest(Keyword));
        }
示例#14
0
        public async Task <int> UpdateStausOfFailMail(long MailID, List <RequestSubscriber> Subscribers)
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.UpdateStausOfFailMail(MailID, this.CreateUserXML(Subscribers)));
        }
示例#15
0
        public async Task <int> DeleteMassMail(string massMailID, string username)
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.DeleteMassMail(massMailID, username));
        }
示例#16
0
        public async Task <IList <MassMailTimeZoneInfo> > GetAllTimeZone()
        {
            MassMailProvider objProvider = new MassMailProvider();

            return(await objProvider.GetAllTimeZone());
        }