Пример #1
0
        public void CampaignDelete_Successful()
        {
            // Arrange
            MailChimpManager   mc        = new MailChimpManager(TestGlobal.Test_APIKey);
            CampaignListResult campaigns = mc.GetCampaigns();
            //Act
            CampaignActionResult result = mc.DeleteCampaign(campaigns.Data[0].Id);

            // Assert
            Assert.IsTrue(result.Complete);
        }
Пример #2
0
        public void SendCampaignTest_Successful()
        {
            //  Arrange
            MailChimpManager mc         = new MailChimpManager(TestGlobal.Test_APIKey);
            List <string>    testEmails = new List <string>()
            {
                "*****@*****.**"
            };
            string campaignId = "yourcampaignidhere";

            //  Act
            CampaignActionResult details = mc.SendCampaignTest(campaignId, testEmails);

            //  Assert
            Assert.IsTrue(details.Complete);
        }
Пример #3
0
        /// <summary>
        /// After confirmation send campaign
        /// </summary>
        public void SendCampaign()
        {
            if (ValidateFields())
            {
                var confirmResult = MessageBox.Show("Do you want to send Campaign ?",
                                                    "Send Campaign",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    string         listId     = string.Empty;
                    string         campaignId = cmbCampaign.SelectedValue.ToString();
                    CampaignFilter options    = new CampaignFilter();
                    options.CampaignId = campaignId;
                    // Loading panel
                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        //Send Campaign
                        CampaignActionResult result = Manager.SendCampaign(campaignId);
                        if (result.Complete)
                        {
                            if (chkEnableSMS.Checked)
                            {
                                bool flag  = true;
                                int  count = 0;
                                while (flag)
                                {
                                    List <EmailParameter> emails = new List <EmailParameter>();
                                    SentToLimits          opt    = new SentToLimits();
                                    opt.Status = "sent";
                                    opt.Start  = count;
                                    opt.Limit  = 100;

                                    bool isCampaignSend = false;
                                    while (!isCampaignSend)
                                    {
                                        CampaignFilter filter = new CampaignFilter();
                                        filter.CampaignId = campaignId;
                                        //Get Sent Campaign
                                        CampaignListResult lists = Manager.GetCampaigns(filter);
                                        foreach (var l in lists.Data)
                                        {
                                            if (l.Status.Trim() == "sent")
                                            {
                                                isCampaignSend = true;
                                                SentToMembers results = Manager.GetReportSentTo(campaignId, opt);
                                                if (results.Data.Count == 0)
                                                {
                                                    flag = false;
                                                    break;
                                                }
                                                foreach (var i in results.Data)
                                                {
                                                    string message = txtMessage.Text.Trim();
                                                    string phone   = string.Empty;
                                                    foreach (var j in i.Member.MemberMergeInfo)
                                                    {
                                                        if (message.IndexOf(j.Key.Trim()) != -1)
                                                        {
                                                            message = message.Replace("*|" + j.Key.Trim() + "|*", j.Value != null ? j.Value.ToString() : "");
                                                        }
                                                        if (cmbFieldPhone.SelectedIndex > 0 && cmbFieldPhone.SelectedItem != null)
                                                        {
                                                            if (cmbFieldPhone.Text.Trim() == j.Key.ToString())
                                                            {
                                                                if (j.Value != null && !string.IsNullOrEmpty(j.Value.ToString()))
                                                                {
                                                                    phone = j.Value.ToString();
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (message.IndexOf("EMAIL") != -1)
                                                    {
                                                        message = message.Replace("*|EMAIL|*", i.Member.Email.ToString());
                                                    }
                                                    if (!string.IsNullOrEmpty(phone))
                                                    {
                                                        //Send SMS
                                                        string smsResult = SmsSender.SendSMS(phone.Trim(), NexmoFromNumber, NexmoAPI, NexmoSecretKey, HttpUtility.UrlEncode(message));
                                                    }
                                                }
                                                break;
                                            }
                                        }
                                    }

                                    count++;
                                }
                            }
                        }
                        MessageBox.Show("Campaign sent successfully");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
            }
        }