Ejemplo n.º 1
0
        /// <summary>
        /// To get the top 10 campaigns 
        /// </summary>
        public void getLastTopTenCampaignsSentData()
        {
            CampaignJobs campaignJobs = CampaignJob.SelectTop10SentCamps(ConnectionString);

            List<string> xValues = new List<string>();
            List<Int32> yValuesSentCount = new List<Int32>();
            List<Int32> yValuesOpenCount = new List<Int32>();

            foreach (CampaignJob job in campaignJobs)
            {
                //get names of campaigns.
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);

                int opencount = 0, sentcount = 0;

                //Calculate LastTopTenCampaignsSent
                //get sum of opencount of all jobs in this month.
                opencount = Convert.ToInt32(job.OpenCount);
                //get sum of sentcount of all jobs in this month.
                sentcount = Convert.ToInt32(job.DeliveredCount);
                //Calculate openrate for that particular month.

                // for restricting the campaignjobs whcich have the sent count as zero
                if (sentcount != 0)
                {
                    xValues.Add(objCampaignMaster.CampaignName);
                    yValuesSentCount.Add(Convert.ToInt32(sentcount));
                    yValuesOpenCount.Add(Convert.ToInt32(opencount));
                }
            }

            //Show chart.
            showChartLastTopTenCampaignsSent(xValues.ToArray(), yValuesSentCount.ToArray(), yValuesOpenCount.ToArray());
        }
Ejemplo n.º 2
0
 public void getCampaignCompareCounts()
 {
     DataTable CampareDt = (DataTable)ViewState["CampareDt"];
     List<string> xValues = new List<string>();
     List<decimal> yValuesFirstCamp = new List<decimal>();
     List<decimal> yValuesSecCamp = new List<decimal>();
     List<decimal> yValuesThirdCamp = new List<decimal>();
     for (int i = 0; i < CampareDt.Rows.Count; i++)
     {
         xValues.Add(CampareDt.Rows[i][0].ToString());
         yValuesFirstCamp.Add(Convert.ToDecimal(CampareDt.Rows[i][1].ToString().Split('(')[0]));
         yValuesSecCamp.Add(Convert.ToDecimal(CampareDt.Rows[i][2].ToString().Split('(')[0]));
         if (CampareDt.Columns.Count == 4)
             yValuesThirdCamp.Add(Convert.ToDecimal(CampareDt.Rows[i][3].ToString().Split('(')[0]));
     }
     showCampaignCampareChart(CampareDt, xValues.ToArray(), yValuesFirstCamp.ToArray(), yValuesSecCamp.ToArray(), yValuesThirdCamp.ToArray());
 }
Ejemplo n.º 3
0
        public void getTopTenCampaignsByOpenRateData()
        {
            try
            {
                CampaignJobs objCampaignJob = CampaignJob.SelectAll(ConnectionString);
                //get campaigns whose sent count is greater than 20.
                List<CampaignJob> campaignJobs = (List<CampaignJob>)objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.DeliveredCount > 20; });

                List<string> xValues = new List<string>();
                List<string> yValues = new List<string>();

                foreach (CampaignJob job in campaignJobs)
                {
                    //get names of campaigns.
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                    CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                    yValues.Add(objCampaignMaster.CampaignName);

                    //Calculate openrate of campaigns
                    //get sum of opencount of all jobs in this month.
                    int opencount = Convert.ToInt32(campaignJobs.Sum(delegate(CampaignJob campjob) { return campjob.OpenCount; }));
                    //get sum of sentcount of all jobs in this month.
                    int sentcount = Convert.ToInt32(campaignJobs.Sum(delegate(CampaignJob campjob) { return campjob.DeliveredCount; }));
                    //Calculate openrate for that particular month.
                    if (sentcount != 0)
                    {
                        xValues.Add(Convert.ToString(Convert.ToDecimal(opencount) / Convert.ToDecimal(sentcount) * 100));
                    }

                    showChartTopTenCampaignsByOpenRate(xValues.ToArray(), yValues.ToArray());

                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 4
0
        public void checklistupdate()
        {
            try
            {
                ListContactMasters listContMastersContacts = ListContactMaster.SelectByField("ContactId", contactID, ConnectionString);
                //Modified By Anwar Jan17 2012
                List<int> removelist = new List<int>();
                for (int j = 0; j < listContMastersContacts.Count; j++)
                {
                    if (!list.Contains(listContMastersContacts[j].ListMasterID.ToString()))
                        removelist.Add(Convert.ToInt32(listContMastersContacts[j].ListMasterID));
                }

                for (int k = 0; k < removelist.Count; k++)
                {
                    ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(removelist[k].ToString()), contactID, ConnectionString);
                    ListContactMaster listContMaster = new ListContactMaster(ConnectionString);
                    listContMaster.ListContactId = listContactMaster[0].ListContactId;
                    if (listContactMaster.Count > 0)
                    {
                        bool statusDelete = listContMaster.Delete();
                    }
                }

                for (int k = 0; k < list.Count; k++)
                {
                    ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(list[k].ToString()), contactID, ConnectionString);
                    ListContactMaster listContMaster = new ListContactMaster(ConnectionString);
                    listContMaster.ContactId = contactID;
                    listContMaster.ListMasterID = Convert.ToInt64(list[k].ToString());
                    listContMaster.CreatedDate = DateTime.Now;
                    listContMaster.IsActive = true;
                    if (listContactMaster.Count > 0)
                    {
                    }
                    else
                    {
                        bool statusInsert = listContMaster.InsertWithActiveStatus();
                    }
                }
                if (!chkIsActive1.Checked && lstBoxListNames.Items.Count > 0)
                {
                    bool Status = ListContactMaster.ChangeContactStatusByList(contactID, chkIsActive1.Checked, ConnectionString);
                }
                binddata(contactID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public void getRecipientStatusSnapshotData()
        {
            try
            {
                List<string> xValues = new List<string>();
                List<decimal> yValues = new List<decimal>();

                ContactMasters objContactMaster;// = ContactMaster.SelectAll(ConnectionString);
                if (ddlDays.SelectedIndex == 0)
                {
                    objContactMaster = ContactMaster.SelectAllByToday(ConnectionString);
                    lblFromDate.Text =  DateTime.Now.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex > 0 && ddlDays.SelectedIndex < 4)
                {
                    objContactMaster = ContactMaster.SelectAllByDays(Convert.ToInt32(ddlDays.SelectedValue), ConnectionString);
                    lblFromDate.Text =  DateTime.Now.AddDays(Convert.ToDouble(ddlDays.SelectedValue)).ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.Date.AddDays(-1).ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex == 4)
                {
                    objContactMaster = ContactMaster.SelectAllByWeek(ConnectionString, ref fdate, ref tdate);
                    lblFromDate.Text =  fdate.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + tdate.ToString("dd/MM/yyyy");

                }
                else
                {
                    objContactMaster = ContactMaster.SelectAllByMonths(DateTime.Now.AddMonths(Convert.ToInt32(ddlDays.SelectedValue)), DateTime.Now.AddMonths(-1), ConnectionString);

                    arDates = new ArrayList();
                    arDates = FirstAndLastdates(Convert.ToInt32(ddlDays.SelectedValue));
                    lblFromDate.Text =  Convert.ToDateTime(arDates[0]).ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + Convert.ToDateTime(arDates[1]).ToString("dd/MM/yyyy");

                }

                //get active contacts.
                IEnumerable<ContactMaster> activeContacts = (IEnumerable<ContactMaster>)objContactMaster.ToList().FindAll(delegate(ContactMaster contact) { return contact.IsActive == true; });
                xValues.Add("Active");
                yValues.Add(activeContacts.Count());
                //if (objContactMaster.Count() != 0)
                //yValues.Add(Convert.ToDecimal(activeContacts.Count()) / Convert.ToDecimal(objContactMaster.Count()) * 100);
                //else
                //    yValues.Add(0);

                //get inactive contacts.
                IEnumerable<ContactMaster> inactiveContacts = (IEnumerable<ContactMaster>)objContactMaster.ToList().FindAll(delegate(ContactMaster contact) { return contact.IsActive == false && (contact.IsDeleted == false || contact.IsDeleted == null); });
                xValues.Add("InActive");
                yValues.Add(inactiveContacts.Count());

                //get deleted contacts
                ContactDeleteds objContactsDeleted;// = ContactDeleted.SelectAll(ConnectionString);
                if (ddlDays.SelectedIndex == 0)
                {
                    objContactsDeleted = ContactDeleted.SelectAllByToday(ConnectionString);
                }
                else if (ddlDays.SelectedIndex>0 && ddlDays.SelectedIndex < 4)
                    objContactsDeleted = ContactDeleted.SelectAllByDays(Convert.ToInt32(ddlDays.SelectedValue), ConnectionString);
                else if (ddlDays.SelectedIndex == 4)
                    objContactsDeleted = ContactDeleted.SelectAllByWeek(ConnectionString, ref fdate, ref tdate);
                else
                    objContactsDeleted = ContactDeleted.SelectAllByMonths(DateTime.Now.AddMonths(Convert.ToInt32(ddlDays.SelectedValue)), DateTime.Now.AddMonths(-1), ConnectionString);
                xValues.Add("Deleted Contacts");
                yValues.Add(objContactsDeleted.Count());

                //get unverified contacts
                IEnumerable<ContactMaster> unverifiedContacts = (IEnumerable<ContactMaster>)objContactMaster.ToList().FindAll(delegate(ContactMaster contact) { return contact.IsVerified != true && contact.IsDeleted != true; });
                xValues.Add("UnVerified Contacts");
                yValues.Add(unverifiedContacts.Count());

                //get inactive and unverified contacts.
                IEnumerable<ContactMaster> inactiveandunverifiedContacts = (IEnumerable<ContactMaster>)objContactMaster.ToList().FindAll(delegate(ContactMaster contact) { return contact.IsActive == false && contact.IsVerified != true && contact.IsDeleted != true; });
                xValues.Add("InActive and UnVerified Contacts");
                yValues.Add(inactiveandunverifiedContacts.Count());

                //Show chart.
                showChartRecipientStatusSnapshot(xValues.ToArray(), yValues.ToArray());
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 6
0
        public void getTopTenCampaignsByOpenRateData()
        {
            try
            {
                CampaignJobs objCampaignJob;// = CampaignJob.SelectAll(ConnectionString);
                if (ddlDays.SelectedIndex == 0)
                {
                    objCampaignJob = CampaignJob.SelectAllByToday(ConnectionString);
                    lblFromDate.Text =DateTime.Now.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex > 0 && ddlDays.SelectedIndex < 4)
                {
                    objCampaignJob = CampaignJob.SelectAllByDays(Convert.ToInt32(ddlDays.SelectedValue), ConnectionString);

                    lblFromDate.Text =  DateTime.Now.AddDays(Convert.ToDouble(ddlDays.SelectedValue)).ToString("dd/MM/yyyy");
                    //lblToDate.Text = " - " + DateTime.Now.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.Date.AddDays(-1).ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex == 4)
                {
                    objCampaignJob = CampaignJob.SelectAllByWeek(ConnectionString, ref fdate, ref tdate);

                    lblFromDate.Text = fdate.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + tdate.ToString("dd/MM/yyyy");

                }

                else
                {
                    objCampaignJob = CampaignJob.SelectAllByMonths(DateTime.Now.AddMonths(Convert.ToInt32(ddlDays.SelectedValue)), DateTime.Now.AddMonths(-1), ConnectionString);

                    arDates = new ArrayList();
                    arDates = FirstAndLastdates(Convert.ToInt32(ddlDays.SelectedValue));
                    lblFromDate.Text =  Convert.ToDateTime(arDates[0]).ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + Convert.ToDateTime(arDates[1]).ToString("dd/MM/yyyy");
                }

                //get top 10 campaigns whose sent count is greater than 20 and in order by descending.
                IEnumerable<CampaignJob> campaignJobs = (IEnumerable<CampaignJob>)(objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.DeliveredCount > 0; }).OrderByDescending(delegate(CampaignJob job) { return job.DeliveredCount; })).Take(10);
                List<string> xValues = new List<string>();
                List<decimal> yValues = new List<decimal>();

                foreach (CampaignJob job in campaignJobs)
                {
                    //get names of campaigns.
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                    CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                    xValues.Add(objCampaignMaster.CampaignName);

                    //Calculate openrate of campaigns
                    //get sum of opencount of all jobs in this month.
                    int opencount = Convert.ToInt32(job.OpenCount);
                    //get sum of sentcount of all jobs in this month.
                    int sentcount = Convert.ToInt32(job.DeliveredCount);
                    //Calculate openrate for that particular month.
                    if (sentcount != 0)
                    {
                        yValues.Add(Convert.ToDecimal(opencount) / Convert.ToDecimal(sentcount) * 100);
                    }
                }

                //Show chart.
                showChartTopTenCampaignsByOpenRate(xValues.ToArray(), yValues.ToArray());
            }
            catch (Exception ex)
            { throw ex; }
        }
        //Vikas Kumar Bhatnagar
        public void getListHealthOverLast12MonthsDomainData()
        {
            try
            {
                IEnumerable<CampaignJob> campaignJobs;
                CampaignJobs objCampaignJob;// = CampaignJob.SelectAll(ConnectionString);
                if (ddlDays.SelectedIndex == 0)
                {
                    objCampaignJob = CampaignJob.SelectAllDomianByToday(ConnectionString);
                    lblFromDate.Text =DateTime.Now.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex == 3)
                {
                    objCampaignJob = CampaignJob.SelectAllDomianLast90Days(ConnectionString);
                    lblFromDate.Text =  DateTime.Now.AddDays(Convert.ToDouble(ddlDays.SelectedValue)).ToString("dd/MM/yyyy");
                    //lblToDate.Text = " - " + DateTime.Now.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + DateTime.Now.Date.AddDays(-1).ToString("dd/MM/yyyy");

                }
                else if (ddlDays.SelectedIndex == 4)
                {
                    objCampaignJob = CampaignJob.SelectAllDomianByWeek(ConnectionString, ref fdate, ref  tdate);

                    lblFromDate.Text = fdate.ToString("dd/MM/yyyy");
                    lblToDate.Text = " - " + tdate.ToString("dd/MM/yyyy");
                }

                else if (ddlDays.SelectedIndex == 1)
                {
                    objCampaignJob = CampaignJob.SelectAllDomianByWeek(ConnectionString, ref fdate, ref  tdate);
                }

                else if (ddlDays.SelectedIndex == 6)
                {
                    objCampaignJob = CampaignJob.SelectAllDomianLast90Days(ConnectionString);
                }

                else
                {
                    objCampaignJob = CampaignJob.SelectAllDomianByMonth(ConnectionString);

                    arDates = new ArrayList();
                    arDates = FirstAndLastdates(Convert.ToInt32(ddlDays.SelectedValue));
                    //lblFromDate.Text = "Current View : " + Convert.ToDateTime(arDates[0]).ToString("dd/MM/yyyy");
                    //lblToDate.Text = " - " + Convert.ToDateTime(arDates[1]).ToString("dd/MM/yyyy");

                }
                //CampaignJobs objCampaignJob = CampaignJob.SelectAllDomianLast12Months(ConnectionString);
                //calculate last 12 month names to show on X-axis
                List<string> xValues = new List<string>();
                List<decimal> yValues = new List<decimal>();
                foreach (CampaignJob job in objCampaignJob)
                {
                    //get names of campaigns.

                    //CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                    //CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                    xValues.Add(job.Domain);
                    yValues.Add(Convert.ToDecimal(job.Accepted));

                }

                //Show chart.
                showChartTopTenCampaignsByBounceRate2(xValues.ToArray(), yValues.ToArray());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public void getGraphByCampaignId()
        {
            try
            {
                lblSubtitle1.Text = ddlcampaigns.SelectedItem.Text + " Campaign Report";
                List<string> xValues = new List<string>();
                List<decimal> yValuesSentCount = new List<decimal>();
                List<decimal> yValuesOpenCount = new List<decimal>();

                List<decimal> yValuesOpenCountChart = new List<decimal>();
                List<decimal> yValuesClickCountChart = new List<decimal>();
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(ddlcampaigns.SelectedValue));
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);

                CampaignJobPrimaryKey Camppk = new CampaignJobPrimaryKey(Convert.ToInt64(ddlcampaigns.SelectedValue));
                //CampaignJob objCampaignJob = CampaignJob.SelectOne(Camppk, ConnectionString);
                CampaignJobs objCampaignJob = CampaignJob.SelectByField("CampaignMasterID", ddlcampaigns.SelectedValue.ToString(), ConnectionString);
                int opencount = 0; int sentcount = 0; int clickcount = 0;
                foreach (CampaignJob job in objCampaignJob)
                {
                    //Calculate LastTopTenCampaignsSent
                    //get sum of opencount of all jobs in this month.
                    opencount = (job.OpenCount != null) ? Convert.ToInt32(job.OpenCount.ToString()) : 0;
                    //opencount = Convert.ToInt32(job.OpenCount.ToString());
                    //get sum of sentcount of all jobs in this month.
                    sentcount = (job.DeliveredCount != null) ? Convert.ToInt32(job.OpenCount.ToString()) : 0;//Convert.ToInt32(job.DeliveredCount.ToString());
                    //get sum of sentcount of all jobs in this month.
                    clickcount = (job.ClickCount != null) ? Convert.ToInt32(job.OpenCount.ToString()) : 0;//Convert.ToInt32(job.ClickCount);
                }
                xValues.Add(objCampaignMaster.CampaignName);
                yValuesSentCount.Add(Convert.ToDecimal(sentcount));
                yValuesOpenCount.Add(Convert.ToDecimal(opencount));

                //this is to bind the open count chart
                if (sentcount > 0)
                {
                    yValuesOpenCountChart.Add(Convert.ToDecimal(opencount) / Convert.ToDecimal(sentcount) * 100);
                }
                else
                {
                    yValuesOpenCountChart.Add(0);
                }

                //Calculate click for that particular month.
                if (opencount != 0)
                {
                    yValuesClickCountChart.Add(Convert.ToDecimal(clickcount) / Convert.ToDecimal(opencount) * 100);
                }
                else
                {
                    yValuesClickCountChart.Add(0);
                }
                //Show chart for sent and open count
                showChartLastTopTenCampaignsSent(xValues.ToArray(), yValuesSentCount.ToArray(), yValuesOpenCount.ToArray());

                //Show chart for open count
                showChartTopTenCampaignsByOpenRate(xValues.ToArray(), yValuesOpenCountChart.ToArray());

                //Show chart for click count
                showChartTopTenCampaignsByClickRate(xValues.ToArray(), yValuesClickCountChart.ToArray());
            }
            catch (Exception ex)
            {

            }
        }
        public void getLastTopTenCampaignsSentData()
        {
            CampaignJobs objCampaignJob;

            try
            {
                 DataTable campaignjobreport = CampaignJob.GetTop5CampaignJobs(4, ConnectionString);
                 if (ddlDays.SelectedIndex == 0)
                 {
                     campaignjobreport = CampaignJob.GetCampaignNamesByDays(1, 1, ConnectionString);
                 }
                 else if (ddlDays.SelectedIndex == 1)
                 {
                     campaignjobreport = CampaignJob.GetCampaignNamesByDays(7, 0, ConnectionString);
                 }
                 else if (ddlDays.SelectedIndex == 2)
                 {
                     campaignjobreport = CampaignJob.GetCampaignNamesByDays(30, 0, ConnectionString);
                 }
                 else if (ddlDays.SelectedIndex == 3)
                 {
                     campaignjobreport = CampaignJob.GetCampaignNamesByDays(90, 0, ConnectionString);
                 }
                 ddlcampaigns.DataSource = campaignjobreport;
                 ddlcampaigns.DataTextField = "CampaignName";
                 ddlcampaigns.DataValueField = "Id";
                 ddlcampaigns.DataBind();

                 if (campaignjobreport.Rows.Count > 0)
                 {

                     if (ddlcampaigns.SelectedIndex != 5)
                     {
                         objCampaignJob = SingleCampaignReports();
                         lblSubtitle1.Text = ddlcampaigns.SelectedItem.Text + " Campaign Report";
                     }
                     else
                     {
                         objCampaignJob = AllCampaignReport();
                         lblSubtitle1.Text = "Last Top 10 Campaigns report";
                     }

                     //get top 10 campaigns whose sent count is greater than 20 and in order by descending.
                     //IEnumerable<CampaignJob> campaignJobs = (IEnumerable<CampaignJob>)(objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.DeliveredCount > 0; }).OrderByDescending(delegate(CampaignJob job) { return job.DeliveredCount; })).Take(10);
                     IEnumerable<CampaignJob> campaignJobs = (IEnumerable<CampaignJob>)(objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.Status == 4; }));

                     List<string> xValues = new List<string>();
                     List<decimal> yValuesSentCount = new List<decimal>();
                     List<decimal> yValuesOpenCount = new List<decimal>();

                     List<decimal> yValuesOpenCountChart = new List<decimal>();
                     List<decimal> yValuesClickCountChart = new List<decimal>();

                     if (campaignJobs != null)
                     {
                         foreach (CampaignJob job in campaignJobs)
                         {
                             //get names of campaigns.
                             CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                             CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                             xValues.Add(objCampaignMaster.CampaignName);

                             //Calculate LastTopTenCampaignsSent
                             //get sum of opencount of all jobs in this month.
                             int opencount = Convert.ToInt32(job.OpenCount);
                             //get sum of sentcount of all jobs in this month.
                             int sentcount = Convert.ToInt32(job.DeliveredCount);
                             //get sum of sentcount of all jobs in this month.
                             int clickcount = Convert.ToInt32(job.ClickCount);

                             yValuesSentCount.Add(Convert.ToDecimal(sentcount));
                             yValuesOpenCount.Add(Convert.ToDecimal(opencount));

                             //this is to bind the open count chart
                             if (sentcount > 0)
                             {

                                 yValuesOpenCountChart.Add(Convert.ToDecimal(opencount) / Convert.ToDecimal(sentcount) * 100);
                             }
                             else
                             {
                                 yValuesOpenCountChart.Add(0);
                             }

                             //Calculate click for that particular month.
                             if (opencount != 0)
                             {

                                 yValuesClickCountChart.Add(Convert.ToDecimal(clickcount) / Convert.ToDecimal(opencount) * 100);

                             }
                             else
                             {
                                 yValuesClickCountChart.Add(0);
                             }

                         }
                     }
                     //Show chart for sent and open count
                     showChartLastTopTenCampaignsSent(xValues.ToArray(), yValuesSentCount.ToArray(), yValuesOpenCount.ToArray());

                     //Show chart for open count
                     showChartTopTenCampaignsByOpenRate(xValues.ToArray(), yValuesOpenCountChart.ToArray());

                     //Show chart for click count
                     showChartTopTenCampaignsByClickRate(xValues.ToArray(), yValuesClickCountChart.ToArray());
                 }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        public List<LinkItem> LinkFinder(string file)
        {
            List<LinkItem> list = new List<LinkItem>();
            // 1.
            // Find all matches in file.
            MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                RegexOptions.Singleline);

            // 2.
            // Loop over each match.
            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;
                LinkItem i = new LinkItem();

                // 3.
                // Get href attribute.
                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                    RegexOptions.Singleline);
                if (m2.Success)
                {
                    i.Href = m2.Groups[1].Value;
                }

                // 4.
                // Remove inner tags from text.
                string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                    RegexOptions.Singleline);
                i.Text = t;
                if (i.Href != null && i.Text != null)
                {
                    if ((i.Href != "[!RPLINK:MIRRORWEBLINK!]") && (i.Href != "[!RPLINK:LISTUNSUBSCRIBE!]") && (i.Href != "[!RPLINK:FORWARDTOFRIEND!]") && (i.Href != "[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                    {
                        if (!(i.Href.Contains("mailto")) && !(i.Href.Contains("RPLINK")))
                        {
                            if (!(i.Href.Trim() == "#"))
                                list.Add(i);
                        }
                    }
                }
            }
            return list;
        }
Ejemplo n.º 11
0
        public void CustomTrackUrls()
        {
            if (hiddenCampaignID.Value == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please save the Mailing to avail this option.')", true);
            }
            else
            {
                bindTemplates();
                CustomLabel objCustomLabel1 = new CustomLabel(ConnectionString);
                Int64 CampaignId = Convert.ToInt32(hiddenCampaignID.Value);
                Int64 TemplateId = (ddlTemplate.SelectedItem.Value != defaultListItem) ? Convert.ToInt32(ddlTemplate.SelectedItem.Value) : 0;
                DataTable CusLabel = objCustomLabel1.getCustomLabel(TemplateId, CampaignId);
                string customLabelingDivContent = "<table widht=\"670px\"><tbody><th widht=\"200px\" Align=\"left\"><B>Label</B></th><th widht=\"470px\" Align=\"left\"><B>URL</B></th>";
                htmlContent = RadEditor1.Content;
                #region this logic will add click link to the content

                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (htmlContent.ToLower().Contains(linkID))
                                    {
                                        htmlContent = htmlContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion

                string textContent = textRadEditor.Content;

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (textContent.ToLower().Contains(linkID))
                                    {
                                        textContent = textContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }
                    }
                }
                #endregion

                if (textContent != string.Empty)
                {
                    textContent = textContent.Replace("&quot;", "\"");
                    textContent = textContent.Replace("&lt;", "<");
                    textContent = textContent.Replace("&gt;", ">");
                }
                if (htmlContent != string.Empty)
                    HTMLlist = LinkFinder(htmlContent);
                if (textContent != string.Empty)
                    Textlist = LinkFinder(textContent);

                if (Textlist.Count > 0)
                    HTMLlist = HTMLlist.Concat(Textlist).ToList();

                List<string> URLlist = new List<string>();
                for (int i = 0; i < HTMLlist.Count; i++)
                {
                    URLlist.Add(HTMLlist[i].Href);
                }
                URLlist = URLlist.Distinct().ToList();
                if (CusLabel.Rows.Count != URLlist.Distinct().ToList().Count && CusLabel.Rows.Count > 0)
                {

                    for (int i = 0; i < CusLabel.Rows.Count; i++)
                    {
                        for (int j = 0; j < URLlist.Count; j++)
                        {
                            if (URLlist[j] == CusLabel.Rows[i]["LinkURL"].ToString())
                                URLlist.RemoveAt(j);
                        }
                    }
                    if (URLlist.Count > 0)
                    {
                        for (int i = 0; i < URLlist.Count; i++)
                        {
                            string txtBoxId = "txt" + i;
                            string divId = "div" + i;
                            customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";
                        }
                    }
                }
                if (CusLabel.Rows.Count != 0)
                {
                    for (int loopcount = 0; loopcount < CusLabel.Rows.Count; loopcount++)
                    {
                        string txtBoxId = "txt" + loopcount;
                        string divId = "div" + loopcount;
                        string str = string.Empty;
                        string url = string.Empty;

                        str = CusLabel.Rows[loopcount]["CustomLabel"].ToString();
                        url = CusLabel.Rows[loopcount]["LinkURL"].ToString();
                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + str + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + url + "</div></td></tr>";
                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else if (URLlist.Count > 0)
                {
                    for (int i = 0; i < URLlist.Count; i++)
                    {
                        string txtBoxId = "txt" + i;
                        string divId = "div" + i;

                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";

                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else
                { customLabelingDivContent += "<tr><td> No Links Found</td></tr>"; }


            }
        }
Ejemplo n.º 12
0
        public void getTopTenCampaignsByClickRateData()
        {
            try
            {
                CampaignJobs objCampaignJob;// = CampaignJob.SelectAll(ConnectionString);

                //if (ddlDays.SelectedIndex == 0)
                //    objCampaignJob = CampaignJob.SelectAll(ConnectionString);
                if (ddlDays.SelectedIndex < 3)
                    objCampaignJob = CampaignJob.SelectAllByDays(Convert.ToInt32(ddlDays.SelectedValue), ConnectionString);
                else if (ddlDays.SelectedIndex == 3)
                    objCampaignJob = CampaignJob.SelectAllByWeek(ConnectionString, ref fdate, ref tdate);
                else
                    objCampaignJob = CampaignJob.SelectAllByMonths(DateTime.Now.AddMonths(Convert.ToInt32(ddlDays.SelectedValue)), DateTime.Now.AddMonths(-1), ConnectionString);
                //get top 10 campaigns whose sent count is greater than 20 and in order by descending.
                //IEnumerable<CampaignJob> campaignJobs = (IEnumerable<CampaignJob>)(objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.DeliveredCount > 20; }).OrderByDescending(delegate(CampaignJob job) { return job.DeliveredCount; })).Take(12);

                IEnumerable<CampaignJob> campaignJobs = (IEnumerable<CampaignJob>)(objCampaignJob.ToList().FindAll(delegate(CampaignJob job) { return job.Status == 4; }));

                List<string> xValues = new List<string>();
                List<decimal> yValues = new List<decimal>();

                foreach (CampaignJob job in campaignJobs)
                {
                    //get names of campaigns.
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(job.CampaignMasterID));
                    CampaignMaster objCampaignMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                    xValues.Add(objCampaignMaster.CampaignName);

                    //Calculate openrate of campaigns
                    //get sum of opencount of all jobs in this month.
                    int opencount = Convert.ToInt32(job.OpenCount);
                    //get sum of sentcount of all jobs in this month.
                    int clickcount = Convert.ToInt32(job.ClickCount);
                    //Calculate openrate for that particular month.
                    if (opencount != 0)
                    {

                        yValues.Add(Convert.ToDecimal(clickcount) / Convert.ToDecimal(opencount) * 100);

                    }
                    else
                    {
                        yValues.Add(0);
                    }
                }

                //Show chart.
                showChartTopTenCampaignsByClickRate(xValues.ToArray(), yValues.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 13
0
        private void createSegemnt(string SegmentType)
        {
            try
            {
                lblMainMsg.Text = string.Empty;
                ListMasterBase listMaster = new ListMasterBase(ConnectionString);
                SegmentMasterBase segmentMaster = new SegmentMasterBase(ConnectionString);
                ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                DataTable dtListContactMaster = new DataTable();
                dtListContactMaster.Columns.Add(new DataColumn("ListMasterID", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("ContactId", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("ModifiedDate", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("IsSegment", typeof(bool)));
                dtListContactMaster.Columns.Add(new DataColumn("IsActive", typeof(bool)));
                List<string> contactids = new List<string>();
                contactids = (List<string>)Session["ContactId"];
                if (hdfListId.Value != "")
                {
                    bool isDeleted = objListContactMaster.DeleteAllContactsFromList(Convert.ToInt64(hdfListId.Value));
                    if (isDeleted)
                    {
                        foreach (string contactID in contactids)
                        {
                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                            rowListContactMaster["ListMasterID"] = hdfListId.Value;
                            rowListContactMaster["ContactId"] = contactID;
                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["IsActive"] = true;
                            dtListContactMaster.Rows.Add(rowListContactMaster);
                        }
                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate","IsActive"  };
                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                        ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hdfListId.Value));
                        ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);
                        listMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                        listMaster.ListName = txtSegmentName.Text;
                        listMaster.ListDesc = txtDescription.Text;
                        listMaster.CreatedDate = listMasterNew.CreatedDate;
                        listMaster.ModifiedDate = System.DateTime.Now;
                        listMaster.IsSegment = true;
                        listMaster.Update();
                        segmentMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                        segmentMaster.SegmentName = txtSegmentName.Text;
                        segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length);
                        if (rbSegCamRecOnly.Checked)
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='QueryBuild(this);'");
                        else
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='ListQueryBuild(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperatorName\" onChange='getSearchKeys(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddllinkdate\"", "\"ddllinkdate\" onChange='linkDateRange(this);'");
                        segmentMaster.SegmentFilter = HtmlContent.Value;
                        segmentMaster.Type = SegmentType;
                        segmentMaster.Update();
                    }
                    Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=update");
                }
                else
                {
                    if (rgdContacts.MasterTableView.Items.Count > 0)
                    {
                        listMaster.ListName = txtSegmentName.Text;
                        listMaster.ListDesc = txtDescription.Text;
                        listMaster.CreatedDate = System.DateTime.Now;
                        listMaster.IsSegment = true;
                        listMaster.InsertWithDefaultValues(true);
                        Int64 listid = Convert.ToInt64(listMaster.ListMasterID);

                        segmentMaster.ListMasterID = listid;
                        segmentMaster.SegmentName = txtSegmentName.Text;
                        segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length);
                        if (rbSegCamRecOnly.Checked)
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='QueryBuild(this);'");
                        else
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='ListQueryBuild(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperatorName\" onChange='getSearchKeys(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddllinkdate\"", "\"ddllinkdate\" onChange='linkDateRange(this);'");
                        segmentMaster.SegmentFilter = HtmlContent.Value;
                        segmentMaster.Type = SegmentType;
                        segmentMaster.Insert();

                        foreach (string contactID in contactids)
                        {
                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                            rowListContactMaster["ListMasterID"] = listid;
                            rowListContactMaster["ContactId"] = contactID;
                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["IsActive"] = true;
                            dtListContactMaster.Rows.Add(rowListContactMaster);
                        }
                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                    }
                }
                Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=create");
            }
            catch (Exception ex)
            {
                lblMainMsg.Text = "Error: " + ex.Message;
                rtsAddSegment.SelectedIndex = 0;
                rtsAddSegment.MultiPage.SelectedIndex = 0;
            }
        }
Ejemplo n.º 14
0
        public void BindDropdowns(string[] tableFields, string[] TableTextFields)
        {
            try
            {
                for (int i = 0; i < GridFieldmap.Rows.Count; i++)
                {
                    DropDownList ddlContactMasterFields = (DropDownList)this.GridFieldmap.Rows[i].FindControl("ddlContactMasterFields");
                    ddlContactMasterFields.Items.Clear();
                    for (int j = 0; j < tableFields.Length; j++)
                    {
                        ddlContactMasterFields.Items.Add(new ListItem(TableTextFields[j].ToString(), tableFields[j].ToString()));
                    }
                    DataTable dt = ManageFieldsBase.SelectCustomFields(Connectionstring);
                    dt.AsEnumerable().ToList().ForEach(delegate(DataRow drRow) { ddlContactMasterFields.Items.Add(new ListItem(drRow["FieldName"].ToString(), drRow["ContactFieldName"].ToString())); });
                }
                updatePanelFieldmap.Update();
                if (chkHasColumnNames.Checked == true)
                {
                    #region standard columns for auto mapping

                    //Email Address, Email, E-mail, E mail, E-mail Address, E mail Address, Email Add, E-mail Add
                    List<string> emailColumns = new List<string>();
                    emailColumns.Add("Email Address");
                    emailColumns.Add("emailaddress");
                    emailColumns.Add("email");
                    emailColumns.Add("e-mail");
                    emailColumns.Add("email");
                    emailColumns.Add("e-mailaddress");
                    emailColumns.Add("emailaddress");
                    emailColumns.Add("emailadd");
                    emailColumns.Add("e-mailadd");
                    emailColumns.Add("emailaddress");

                    //First Name, FirstName, Fname, First
                    List<string> fnameColumns = new List<string>();
                    fnameColumns.Add("First Name");
                    fnameColumns.Add("firstname");
                    fnameColumns.Add("fname");
                    fnameColumns.Add("first");

                    //Last Name, LastName, Surname, Last, Lname
                    List<string> lnameColumns = new List<string>();
                    lnameColumns.Add("Last Name");
                    lnameColumns.Add("lastname");
                    lnameColumns.Add("surname");
                    lnameColumns.Add("last");
                    lnameColumns.Add("lname");

                    //Address1, Add1
                    List<string> addrs1Columns = new List<string>();
                    addrs1Columns.Add("Address1");
                    addrs1Columns.Add("address1");
                    addrs1Columns.Add("add1");

                    //Address2, Add2
                    List<string> addrs2Columns = new List<string>();
                    addrs2Columns.Add("Address2");
                    addrs2Columns.Add("address2");
                    addrs2Columns.Add("add2");

                    //City
                    List<string> cityColumns = new List<string>();
                    cityColumns.Add("City");
                    cityColumns.Add("city");

                    //Country
                    List<string> countryColumns = new List<string>();
                    countryColumns.Add("Country");
                    countryColumns.Add("country");

                    //Postal Code
                    List<string> zipColumns = new List<string>();
                    zipColumns.Add("Postal Code");
                    zipColumns.Add("postalcode");
                    zipColumns.Add("zip");
                    zipColumns.Add("postal");
                    zipColumns.Add("zipcode");

                    //State
                    List<string> stateColumns = new List<string>();
                    stateColumns.Add("State");
                    stateColumns.Add("state");
                    stateColumns.Add("province");

                    //Work Phone
                    List<string> wPhoneColumns = new List<string>();
                    wPhoneColumns.Add("Work Phone");
                    wPhoneColumns.Add("workphone");
                    wPhoneColumns.Add("phone");
                    wPhoneColumns.Add("phone#");

                    //Home Phone
                    List<string> hPhoneColumns = new List<string>();
                    hPhoneColumns.Add("Home Phone");
                    hPhoneColumns.Add("homephone");

                    //Mobile Phone
                    List<string> mPhoneColumns = new List<string>();
                    mPhoneColumns.Add("Mobile Phone");
                    mPhoneColumns.Add("mobilephone");
                    mPhoneColumns.Add("mobile");
                    mPhoneColumns.Add("mobile#");

                    //Fax
                    List<string> faxColumns = new List<string>();
                    faxColumns.Add("Fax");
                    faxColumns.Add("fax");

                    //Marital Status
                    List<string> mStatusColumns = new List<string>();
                    mStatusColumns.Add("Marital Status");
                    mStatusColumns.Add("maritalstatus");

                    //Gender
                    List<string> genderColumns = new List<string>();
                    genderColumns.Add("Gender");
                    genderColumns.Add("gender");

                    #endregion
                    for (int i = 0; i < GridFieldmap.Rows.Count; i++)
                    {
                        DropDownList ddlContactMasterFields = (DropDownList)this.GridFieldmap.Rows[i].FindControl("ddlContactMasterFields");
                        //lblHeaderField
                        Label lblFiled = (Label)this.GridFieldmap.Rows[i].FindControl("lblHeaderField");

                        for (int j = 0; j < tableFields.Length; j++)
                        {
                            if (emailColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(emailColumns[0]).Selected = true;
                            else if (fnameColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(fnameColumns[0]).Selected = true;
                            else if (lnameColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(lnameColumns[0]).Selected = true;
                            else if (addrs1Columns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(addrs1Columns[0]).Selected = true;
                            else if (addrs2Columns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(addrs2Columns[0]).Selected = true;
                            else if (cityColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(cityColumns[0]).Selected = true;
                            else if (stateColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(stateColumns[0]).Selected = true;
                            else if (countryColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(countryColumns[0]).Selected = true;
                            else if (zipColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(zipColumns[0]).Selected = true;
                            else if (wPhoneColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(wPhoneColumns[0]).Selected = true;
                            else if (hPhoneColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(hPhoneColumns[0]).Selected = true;
                            else if (mPhoneColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(mPhoneColumns[0]).Selected = true;
                            else if (faxColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(faxColumns[0]).Selected = true;
                            else if (genderColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(genderColumns[0]).Selected = true;
                            else if (mStatusColumns.Contains(lblFiled.Text.ToString().Replace(" ", "").ToLower()))
                                ddlContactMasterFields.Items.FindByText(mStatusColumns[0]).Selected = true;
                            else
                            {
                                ddlContactMasterFields.SelectedIndex = 0;
                                LinkButton lbtnRemove = (LinkButton)GridFieldmap.Rows[i].FindControl("lbtnRemoveMapping");
                                lbtnRemove.Enabled = false; lbtnRemove.Attributes.Add("style", "text-decoration:none;");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 15
0
        public void showCampaignSummary(string campaignID)
        {
            try
            {

                //get summary details of campaign
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(campaignID));
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);

                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(campaignID), ConnectionString);


                String htmlContent = objCampaignMaster.HTMLContent;

                #region this logic will add click link to the content

                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    if (linkData.LinkURL.ToLower().Contains("http://"))
                                        linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                    LinkURL = linkData.LinkURL;
                                    if (!hashtable.Contains(LinkURL))
                                        hashtable.Add(linkData.LinkURL, linkData.clickCount);
                                    if (htmlContent.ToLower().Contains(linkID))
                                    {
                                        htmlContent = htmlContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion

                string textContent = objCampaignMaster.TextContent;

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    if (linkData.LinkURL.ToLower().Contains("http://"))
                                        linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                    LinkURL = linkData.LinkURL;
                                    if (!hashtable.Contains(LinkURL))
                                        hashtable.Add(linkData.LinkURL, linkData.clickCount);
                                    if (textContent.ToLower().Contains(linkID))
                                    {
                                        textContent = textContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion
                if (textContent != string.Empty)
                {
                    textContent = textContent.Replace("&quot;", "\"");
                    textContent = textContent.Replace("&lt;", "<");
                    textContent = textContent.Replace("&gt;", ">");
                }
                if (htmlContent != string.Empty)
                    HTMLlist = LinkFinder(htmlContent);
                if (textContent != string.Empty)
                    Textlist = LinkFinder(textContent);

                if (Textlist.Count > 0)
                    HTMLlist = HTMLlist.Concat(Textlist).ToList();

                string[] finalArray = new string[HTMLlist.Count];

                for (int i = 0; i < HTMLlist.Count; i++)
                {
                    finalArray[i] = HTMLlist[i].Href;

                }
                finalArray = finalArray.Distinct().ToArray();


                if (objCampaignMaster.CampaignJobs[0].Status == 4)    //if (objCampaignMaster.CampaignJobs[0].Status == 1)
                {
                    string SelectCondition = objCampaignMaster.SelectCondition;
                    string[] ListIds = SelectCondition.Split(',');
                    //string selectedList=null;
                    StringBuilder selectedList = new StringBuilder();
                    StringBuilder selectedListExport = new StringBuilder();
                    foreach (var Id in ListIds)
                    {

                        ListMasters List = ListMaster.SelectByField("ListMasterId", Id, ConnectionString);
                        if (List.Count > 0)
                        {
                            selectedList.Append(List[0].ListName.ToString() + ", ");
                            selectedListExport.Append(List[0].ListName.ToString() + "; ");
                        }
                        else
                        {
                            lblMainMsg.Style.Add("color", "red");
                            lblMainMsg.Text = "The List has been moved or removed";

                        }

                    }
                    if (selectedList.Length > 0)
                    {
                        selectedList.Remove(selectedList.Length - 2, 1);
                    }
                    else
                    {
                        //lblMainMsg.Style.Add("color", "red");
                        //lblMainMsg.Text = "The List has been moved or removed";
                        selectedList.Append("The List has been moved or removed");
                    }

                    if (selectedListExport.Length > 0)
                    {
                        selectedListExport.Remove(selectedListExport.Length - 2, 1);
                    }
                    else
                    {
                        //lblMainMsg.Style.Add("color", "red");
                        //lblMainMsg.Text = "The List has been moved or removed";
                        selectedListExport.Append("The List has been moved or removed");
                    }

                    string campaignName = objCampaignMaster.CampaignName;
                    string subject = objCampaignMaster.Subject;
                    int openCount = 0, sentCount = 0, clickCount = 0, optoutCount = 0, bounceCount = 0;
                    if (objCampaignjob[0].DeliveredCount != 0 || objCampaignjob[0].BounceCount != 0)
                    {
                        //get counts
                        openCount = Convert.ToInt32(objCampaignjob[0].OpenCount);
                        sentCount = Convert.ToInt32(objCampaignjob[0].DeliveredCount);
                        clickCount = Convert.ToInt32(objCampaignjob[0].ClickCount);
                        optoutCount = Convert.ToInt32(objCampaignjob[0].OptoutCount);
                        bounceCount = Convert.ToInt32(objCampaignjob[0].BounceCount);
                    }
                    int totalrecipients = Convert.ToInt32(objCampaignjob[0].TotalRecipients);
                    decimal averageOpenCount = 0, averageClickCount = 0, averageOptOutCount = 0, averageSentCount = 0, averageBounceCount = 0;
                    //calculate averages
                    if (sentCount != 0)
                        averageOpenCount = Decimal.Round(Convert.ToDecimal(openCount) / Convert.ToDecimal(sentCount) * 100, 1);
                    else
                        averageOpenCount = 0;
                    //else
                    //     averageOpenCount =0;
                    if (openCount != 0)
                        averageClickCount = Decimal.Round(Convert.ToDecimal(clickCount) / Convert.ToDecimal(openCount) * 100, 1);
                    else
                        averageClickCount = 0;
                    //else
                    //     averageClickCount =0;
                    if (sentCount != 0)
                        averageOptOutCount = Decimal.Round(Convert.ToDecimal(optoutCount) / Convert.ToDecimal(sentCount) * 100, 1);
                    else
                        averageOptOutCount = 0;
                    //else
                    //     averageOptOutCount=0;
                    if (totalrecipients != 0)
                        averageSentCount = Decimal.Round(Convert.ToDecimal(sentCount) / Convert.ToDecimal(totalrecipients) * 100, 1);
                    else
                        averageSentCount = 0;
                    //else

                    if (bounceCount != 0)
                        averageBounceCount = Decimal.Round(Convert.ToDecimal(bounceCount) / Convert.ToDecimal(totalrecipients) * 100, 1);
                    else
                        averageBounceCount = 0;
                    //build html string for campaign summary.
                    StringBuilder objStringBuilder = new StringBuilder();
                    objStringBuilder.Append("<table width=\"100%\" border=\"0px\" cellspacing=\"0px\">");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td width=\"25%\"><b>Campaign Details Criteria</b></td><td width=\"25%\"></td><td width=\"25%\"><b>Recipient Criteria</b></td><td></td></tr>");
                    objStringBuilder.Append("<tr><td width=\"25%\">Campaign Name</td><td width=\"25%\">" + campaignName + "</td> <td width=\"25%\">List(s) Selected</td><td width=\"25%\">" + selectedList + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Results as Of</td><td>" + DateTime.Now + "</td><td >Recipients Found</td><td>" + (totalrecipients) + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Send Start Date</td><td>" + objCampaignjob[0].StartTime.ToString() + "</td><td>Subject</td><td>" + subject + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Send Completion Date</td><td>" + objCampaignjob[0].CompletionTime.ToString() + "</td><td></td><td></td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    //objStringBuilder.Append("<tr><td>");
                    //objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    //objStringBuilder.Append("<tr><td colspan=3><b>Recipient Criteria</b></td></tr>");
                    //objStringBuilder.Append("<tr><td width=\"25%\">List(s) Selected</td><td>" + selectedList + "</td><td></td></tr>");
                    //objStringBuilder.Append("<tr><td >Recipients Found</td><td>" + (totalrecipients) + "</td><td></td></tr>");
                    //objStringBuilder.Append("</table>");
                    //objStringBuilder.Append("</td></tr>");

                    //objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td width=\"25%\"><b>Send Details</b></td><td width=\"25%\"><b>Total</b></td><td><b>Average</b></td><td></td></tr>");
                    objStringBuilder.Append("<tr><td >Successful Sends</td><td width=\"25%\">" + sentCount + "</td><td>" + averageSentCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >Bounces</td><td width=\"25%\">" + bounceCount + "</td><td>" + averageBounceCount + "%</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td><b>Subscriber Interaction</b></td><td width=\"25%\"><b>Unique total</b></td><td><b>Average</b></td>");
                    objStringBuilder.Append("<tr><td width=\"25%\">Open</td><td width=\"25%\">" + openCount + "</td><td>" + averageOpenCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >Click</td><td width=\"25%\">" + clickCount + "</td><td>" + averageClickCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >OptOut</td><td width=\"25%\">" + optoutCount + "</td><td>" + averageOptOutCount + "%</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\">");
                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<tr><td width=\"40%\"><b>Custom URL Links</b></td><td style=\"padding-left:110px\" width=\"25%\"><b>Total Clicks</b></td><td ><b>Unique Clicks</b></td><td></td></tr>");
                    objStringBuilder.Append("</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("<tr><td><div style=\"overflow:scroll;height:200px\">");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");

                    if (finalArray.Length > 0)
                    {
                        for (int i = 0; i < finalArray.Length; i++)
                            //objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                            if (hashtable.ContainsKey(finalArray[i].ToString()))
                            {
                                if (hashtable[finalArray[i].ToString()] != null)
                                    objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">" + hashtable[finalArray[i].ToString()] + "</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                                else
                                    objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                            }
                            else
                                objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                    }
                    else
                        objStringBuilder.Append("<tr><td width=\"25%\" colspan=4> No links exist</td><td width=\"25%\"></td><td ></td><td></td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</div></td></tr>");
                    objStringBuilder.Append("</td></tr>");
                    objStringBuilder.Append("</table>");

                    //bind html string to the the td.

                    tdCampaignSummary.InnerHtml = objStringBuilder.ToString();

                    DataTable dtExportSummary = new DataTable();

                    DataColumn s1 = new DataColumn("Details");
                    DataColumn s2 = new DataColumn("Values");
                    DataColumn s3 = new DataColumn("AvgValues");

                    dtExportSummary.Columns.Add(s1);
                    dtExportSummary.Columns.Add(s2);
                    dtExportSummary.Columns.Add(s3);

                    DataRow row1 = dtExportSummary.NewRow();
                    row1[s1] = "campaignName";
                    row1[s2] = campaignName;
                    row1[s3] = "";
                    dtExportSummary.Rows.Add(row1);

                    DataRow row2 = dtExportSummary.NewRow();
                    row2[s1] = "Result as of";
                    row2[s2] = DateTime.Now;
                    row2[s3] = "";
                    dtExportSummary.Rows.Add(row2);

                    DataRow row3 = dtExportSummary.NewRow();
                    row3[s1] = "Send Start Date";
                    row3[s2] = objCampaignjob[0].StartTime.ToString();
                    row3[s3] = "";
                    dtExportSummary.Rows.Add(row3);

                    DataRow row4 = dtExportSummary.NewRow();
                    row4[s1] = "Send Completion Date";
                    row4[s2] = objCampaignjob[0].CompletionTime.ToString();
                    row4[s3] = "";
                    dtExportSummary.Rows.Add(row4);

                    DataRow row5 = dtExportSummary.NewRow();
                    row5[s1] = "List(s) Selected";
                    row5[s2] = selectedListExport;
                    row5[s3] = "";
                    dtExportSummary.Rows.Add(row5);

                    DataRow row6 = dtExportSummary.NewRow();
                    row6[s1] = "Recipients Found";
                    row6[s2] = totalrecipients;
                    row6[s3] = "";
                    dtExportSummary.Rows.Add(row6);

                    DataRow row7 = dtExportSummary.NewRow();
                    row7[s1] = "Successful Sends";
                    row7[s2] = sentCount;
                    row7[s3] = averageSentCount + "%";
                    dtExportSummary.Rows.Add(row7);

                    DataRow row8 = dtExportSummary.NewRow();
                    row8[s1] = "Bounces";
                    row8[s2] = bounceCount;
                    row8[s3] = averageBounceCount + "%";
                    dtExportSummary.Rows.Add(row8);

                    DataRow row9 = dtExportSummary.NewRow();
                    row9[s1] = "Open";
                    row9[s2] = openCount;
                    row9[s3] = averageOpenCount + "%";
                    dtExportSummary.Rows.Add(row9);

                    DataRow row10 = dtExportSummary.NewRow();
                    row10[s1] = "Click";
                    row10[s2] = clickCount;
                    row10[s3] = averageClickCount + "%";
                    dtExportSummary.Rows.Add(row10);

                    DataRow row11 = dtExportSummary.NewRow();
                    row11[s1] = "Opt Out";
                    row11[s2] = optoutCount;
                    row11[s3] = averageOptOutCount + "%";
                    dtExportSummary.Rows.Add(row11);

                    DataRow row12 = dtExportSummary.NewRow();
                    row11[s1] = "URL's";
                    row11[s2] = "ClickCount";
                    row11[s3] = "Unique Click Count";
                    dtExportSummary.Rows.Add(row12);

                    hashtablekeys = new ArrayList(hashtable.Keys);
                    hashtablevalues = new ArrayList(hashtable.Values);

                    for (int i = 0; i < hashtable.Count; i++)
                    {
                        DataRow row = dtExportSummary.NewRow();
                        row[s1] = hashtablekeys[i].ToString(); //hashtable.Keys.ToString();
                        if (hashtablevalues[i] != null)
                            row[s2] = hashtablevalues[i];//hashtable.Values.ToString();
                        else
                            row[s2] = 0;
                        row[s3] = 0;
                        dtExportSummary.Rows.Add(row);
                    }

                    ViewState["TempdtExportSummary"] = dtExportSummary;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }