Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                    if (Request.QueryString["ID"] != null || Request.QueryString["UserName"] != null)
                    {
                        // CampaignID = Convert.ToInt32(Request.QueryString["ID"].ToString());
                        UserName = Request.QueryString["UserName"].ToString();

                        ProfileBase objProfileBase = ProfileBase.Create(UserName, true);
                        string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                        string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                        string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                        string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();
                        connectionString =
                           string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                         dbServerName, dbName, dbUserID, dbPassword);

                        CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(Request.QueryString["ID"]));
                        CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, connectionString);
                         selectedList = objCampaignMaster.SelectCondition.Split(',');

                         divHTMLContent.InnerHtml = objCampaignMaster.HTMLContent;
                    }

            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void bindGrid()
        {
            if (ddlCampaignName.SelectedItem.Text != defaultListItem)
            {

                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(ddlCampaignName.SelectedItem.Value));
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);

                hdfCampaignID.Value = campMaster.CampaignId.ToString();
                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(hdfCampaignID.Value), ConnectionString);
                lblCampaignTitle.Text = campMaster.CampaignName.ToString();
                lblsentDateTime.Text = objCampaignjob[0].CompletionTime.ToString();

                Session["CampaignID"] = hdfCampaignID.Value;
                Session["CampaignName"] = lblCampaignTitle.Text;
                Session["SentDateTime"] = lblsentDateTime.Text;
                showCampaignComplaints(hdfCampaignID.Value, GridSortExpression, GridViewSortDirection, rgdComplaints.CurrentPageIndex, 9, out Count);

            }
            else
            {
                Session["CampaignID"] = null;
                hdfCampaignID.Value = "";
                ViewState["TempdtExportSummary"] = null;

            }
        }
        public void bindGrid()
        {
            if (ddlMailingNames.SelectedItem.Text != defaultListItem)
            {

                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(ddlMailingNames.SelectedItem.Value));
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);

                hdfMailingID.Value = campMaster.CampaignId.ToString();
                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(hdfMailingID.Value), ConnectionString);
                lblCampaignTitle.Text = campMaster.CampaignName.ToString();
                lblsentDateTime.Text = objCampaignjob[0].CompletionTime.ToString();
                Session["CampId"] = ddlCampaignsNames.SelectedItem.Value != defaultListItem ? ddlCampaignsNames.SelectedItem.Value : null;
                Session["MailingID"] = hdfMailingID.Value;
                Session["TitleName"] = lblCampaignTitle.Text;
                Session["SentDateTime"] = lblsentDateTime.Text;
                showCampaignSummary(hdfCampaignID.Value, hdfMailingID.Value);
                rgdClicksReport.Rebind();
            }
            else
            {
                Session["MailingID"] = null;
                hdfMailingID.Value = "";
                lblsentDateTime.Text = string.Empty;
                ViewState["TempdtExportSummary"] = null;
                if (Session["CampId"] != null)
                {
                    showCampaignSummary(Session["CampId"].ToString(), hdfMailingID.Value);
                    rgdClicksReport.Rebind();
                }
                else
                {
                    rgdClicksReport.DataSource = ViewState["TempdtExportSummary"];
                    rgdClicksReport.DataBind();
                }
                if (ddlCampaignsNames.SelectedItem.Text != defaultListItem)
                {
                    lblCampaignTitle.Text = ddlCampaignsNames.SelectedItem.Text;
                    Session["TitleName"] = lblCampaignTitle.Text;
                }
                else
                {
                    lblCampaignTitle.Text = string.Empty;
                    Session["TitleName"] = null;
                    Session["SentDateTime"] = null;
                }
            }
        }
        public void CustomTrackUrls(string MailingID)
        {
            CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(MailingID));
            CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
            if (objCampMaster != null)
            {
                CustomLabel objCustomLabel1 = new CustomLabel(ConnectionString);
                Int64 CampaignId = Convert.ToInt32(MailingID);
                Int64 TemplateId = Convert.ToInt64(objCampMaster.TemplateId);
                DataTable CusLabel = objCustomLabel1.getCustomLabel(TemplateId, CampaignId);
                htmlContent = objCampMaster.HTMLContent;
                string linkids = string.Empty;
                #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];
                        if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE") && (linkID != "NewLink") && (linkID != "ExLink") && (linkID != "DeclineLink"))
                        {
                            linkids = linkids + linkID + ",";
                        }
                    }
                }
                if(linkids.EndsWith(","))
                 linkids = linkids.Substring(0, linkids.Length - 1);
                if (linkids.Trim().Length > 0)
                {
                    con = new SqlConnection(ConnectionString);
                    SqlDataAdapter da = new SqlDataAdapter(" select * from LinkDetails where ID in (" + linkids + ")", con);
                    DataSet linkset = new DataSet();
                    da.Fill(linkset);
                    grdLinkDetails.DataSource = linkset;
                    grdLinkDetails.DataBind();
                }
                else
                    lblMsg.Text = "No Links Found";
                #endregion

            }
            else
                lblMsg.Text="Mailing with ID "+hdMailingID.Value+" not exist";
        }
        public void update()
        {
            try
            {
                contactBase.ContactId = Convert.ToInt64(contMasters[0].ContactId);
                //status = contactBase.AMMFormUpdate();

                status = contactBase.Wheelock_Widener_FormsUpdate();

                GetValuesOfCustomControls();
                //contactID = Convert.ToInt32(contMasters[0].ContactId);
                statusmessage.Append(string.Format("Contact has been updated successfully"));
                lbMsg.ForeColor = System.Drawing.Color.Green;
                lbMsg.Text = statusmessage.ToString();
                if (hddIntendedMajor.Value.ToString() == "--Select--")
                    hddIntendedMajor.Value = string.Empty;
                if (hddSports.Value.ToString() == "--Select--")
                    hddSports.Value = string.Empty;
                //Get the AssignCampaignId for Mailing
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(Request.QueryString["CampaignID"].ToString()));
                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, connectionString);
                string CampId= objCampMaster.AssignedCampaignID.ToString().Trim();

                string WheelockLink = ConfigurationManager.AppSettings["WheelockLink"].ToString();
                string RedirectUrl = ConfigurationManager.AppSettings["WheelockSubmitLink"].ToString();
                string parameters = "FirstName=" + txtFirstName.Text.ToString().Trim() + "&LastName=" + txtLastName.Text.ToString().Trim() + "&Address1=" + txtAddress1.Text.ToString().Trim() + "&IntendedMajor=" + hddIntendedMajor.Value.ToString().Trim() +
                    "&Sport=" + hddSports.Value.ToString().Trim() + "&Facebook=False&WNews=False&StudentBlogs=False&ScholarshipInfo=False&MajorInfo=False&StudentVideos=False&Email=" + txtEmailAddress.Text + "&InstName=Wheelock"
                    + "&UniqueIdentifier=" + txtFirstName.Text.ToString().Trim() + txtLastName.Text.ToString().Trim() + contactID.ToString().Trim()
                    + "&LetterCode=" + hdLetterCode.Value.ToString().Trim() + "&Rep=" + hdRep.Value.ToString().Trim() + "&EID=" + hdEID.Value.ToString().Trim() + "&PURL=" + purlValue.ToString().Trim();
                string qStrValues = "?ContactID=" + Request.QueryString["ContactID"].ToString() + "&CampaignID=" + Request.QueryString["CampaignID"].ToString() + "&CampID=" + CampId.ToString() + "&Username="******"Username"].ToString() + "&direct=no";
                string Rstr = RedirectUrl + parameters + "&URL=" + WheelockLink.ToString().Trim() + qStrValues;//CampaignID

                //Insert formsubmit details in FormSubmitClicks
                FormSubmitClick objFormSubmitClick = new FormSubmitClick(connectionString);
                objFormSubmitClick.ContactID =Convert.ToInt64( Request.QueryString["ContactID"].ToString());
                objFormSubmitClick.MailingID = Convert.ToInt64(Request.QueryString["CampaignID"].ToString());
                objFormSubmitClick.DirectMail = false;
                objFormSubmitClick.LinkID = 2;
                objFormSubmitClick.SubmitDate = DateTime.Now;
                objFormSubmitClick.Insert();

                Response.Redirect(Rstr);
            }
            catch (Exception ex)
            { throw ex; }
        }
        protected void lbtnOk_Click(object sender, EventArgs e)
        {
            if (hdMailingID.Value.Trim().Length > 0 && ConnectionString.Trim().Length > 0)
            {
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdMailingID.Value));
                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                CampaignJobs objCampaignjobs = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(hdMailingID.Value), ConnectionString);
                if (objCampaignjobs.Count > 0 && objCampaignjobs[0].ScheduledDatetime > DateTime.Now.AddMinutes(1))
                {

                    objCampaignjobs[0].ID = objCampaignjobs[0].ID;
                    objCampaignjobs[0].ScheduledDatetime = objCampaignjobs[0].ScheduledDatetime;
                    objCampaignjobs[0].Status = 1;
                    objCampaignjobs[0].SendType = "LATER";
                    objCampaignjobs[0].UpdateDeliveryTabCampJob();

                    MailApprovals objMailApproval = MailApproval.SelectByField("MailingID", hdMailingID.Value, ConnectionString);
                    if (objMailApproval.Count > 0)
                    {
                        objMailApproval[0].MailingID = Convert.ToInt64(hdMailingID.Value);
                        objMailApproval[0].ApprovalMail = objMailApproval[0].ApprovalMail;
                        objMailApproval[0].ReportMailTo = objMailApproval[0].ReportMailTo;
                        objMailApproval[0].ApprovalStatus = "Approved";
                        objMailApproval[0].ApprovedDate = DateTime.Now;
                        objMailApproval[0].IsApprovalSent = objMailApproval[0].IsApprovalSent;
                        objMailApproval[0].IsReportMailied = objMailApproval[0].IsReportMailied;
                        objMailApproval[0].ReportSentDate = objMailApproval[0].ReportSentDate;
                        objMailApproval[0].Update();
                    }

                    lblMessage.ForeColor = System.Drawing.Color.Green;
                    lblMessage.Text = "Thank you for the approval request. Email campaign will be scheduled as per described in Log report.";
                    tblConfirm.Style.Add("display", "none");
                    tblMessage.Style.Add("display", "block");

                }
                else
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                    lblMessage.Text = "Your approval request is rejected as Email campaign schedule date has already been passed away.";
                    tblConfirm.Style.Add("display", "none");
                    tblMessage.Style.Add("display", "block");
                }

            }
        }
Exemple #7
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; }
        }
        protected void btnSubscribe_Click(object sender, EventArgs e)
        {
            //get campaign details
            CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(Request.QueryString["CampaignID"]));
            CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, connectionString);
            DataTable contselect = ContactMaster.SelectEmailAddressInNonDeletedContacts(connectionString, txtSubscriberEmail.Text.ToString());

            if (contselect.Rows.Count == 0)
            {
                if (objCampaignMaster.SelectCondition != "")
                {
                    string[] selectedList = objCampaignMaster.SelectCondition.Split(',');
                    ContactMaster objContactMaster = new ContactMaster(connectionString);

                    string EmailAddress = txtSubscriberEmail.Text;

                    //create the recipient
                    foreach (string listid in selectedList)
                    {
                        Status = objContactMaster.InsertNewSubscriber(Convert.ToInt64(listid), EmailAddress);
                    }

                    if (Status != -1)
                        divSubscribe.InnerHtml = "<b>You have been successfully subscribed to list.</b> ";
                    else
                        divSubscribe.InnerHtml = "<b>Email Alredy subscribed to list.</b> ";
                }
                else
                    divSubscribe.InnerHtml = "<b>List you want subscribe that already removed.</b> ";
            }
            else
            {

                divSubscribe.InnerHtml = "<b>Already existed Email - {0} </b> " + txtSubscriberEmail.Text;
            }
        }
        public XmlDocument EditCampaign(string UserID, string Password, long campId, string CampName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignEditInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && campId != 0 && CampName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)//(Convert.ToDateTime(LaunchDateTime) > DateTime.Now))
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);

                CampaignMasterPrimaryKey CampPk = new CampaignMasterPrimaryKey(campId);
                CampaignMaster campMaster = CampaignMaster.SelectOne(CampPk, ConnectionString);
                if (campMaster.CampaignName == CampName)
                {
                    campMaster.TemplateId = TempId;
                    campMaster.FromName = FromName;
                    campMaster.ReplytoAddress = ReplyEmailAdd;
                    campMaster.SelectCondition = ListIds;
                    campMaster.Subject = Subject;
                    campMaster.ModifiedDate = DateTime.Now;
                    campMaster.HTMLContent = tempMaster.HTMLContent;
                }
                else
                {
                    campMaster.CampaignName = CampName;
                    campMaster.TemplateId = TempId;
                    campMaster.FromName = FromName;
                    campMaster.ReplytoAddress = ReplyEmailAdd;
                    campMaster.SelectCondition = ListIds;
                    campMaster.Subject = Subject;
                    campMaster.ModifiedDate = DateTime.Now;
                    campMaster.HTMLContent = tempMaster.HTMLContent;
                }
                campMaster.Update();
                CampaignJobs objCampaignjobs = CampaignJob.SelectByField("CampaignMasterID", campId, ConnectionString);
                if (objCampaignjobs.Count > 0)
                {
                    objCampaignjobs[0].ID = objCampaignjobs[0].ID;
                    objCampaignjobs[0].BounceCount = objCampaignjobs[0].BounceCount;
                    objCampaignjobs[0].ClickCount = objCampaignjobs[0].ClickCount;
                    objCampaignjobs[0].CreatedDatetime = objCampaignjobs[0].CreatedDatetime;
                    objCampaignjobs[0].OpenCount = objCampaignjobs[0].OpenCount;
                    objCampaignjobs[0].OptoutCount = objCampaignjobs[0].OptoutCount;
                    objCampaignjobs[0].DeliveredCount = objCampaignjobs[0].DeliveredCount;
                    objCampaignjobs[0].Status = 1;
                    objCampaignjobs[0].StatusMessage = objCampaignjobs[0].StatusMessage;
                    objCampaignjobs[0].CampaignMasterID = campId;// Convert.ToInt64(hiddenCampaignID.Value);
                    objCampaignjobs[0].ScheduledDatetime = LaunchDateTime.AddMinutes(2); //Convert.ToDateTime(scheduledTime);
                    objCampaignjobs[0].SendType = "IMMEDIATE";
                    objCampaignjobs[0].Update();
                    str.Append("<Message>Campaign Updated Succefully</Message>");
                }
            }
            else
            {
                str.Append("<Message>Enter Valid Inputs</Message>");
            }
            str.Append("</CampaignEditInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
        protected void lbtnGenerateReport_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem row in rgdCampaignCompare.MasterTableView.Items)
            {
                CheckBox objCheckBox = (CheckBox)row.FindControl("SgrdaddchkSelectRecs");
                Label MailingId = (Label)row.FindControl("lblSCampaignId");
                if (objCheckBox.Checked == true)
                {
                    selectedMailingids.Append(MailingId.Text + ",");
                }
            }
            if (selectedMailingids.ToString().EndsWith(","))
                selectedMailingids.Remove(selectedMailingids.Length - 1, 1);
            //First we get top20 Domains for all selected Mailings.
            DataTable top20Domains = ContactMaster.getTop20DomainsBasedOnMailingIds(ConnectionString, selectedMailingids.ToString());
            if (top20Domains.Rows.Count != 0)
            {
                #region Build DataTable
                DataTable dtDomain = new DataTable();
                DataColumn c1 = new DataColumn("MailingName");
                dtDomain.Columns.Add(c1);

                DataRow row1 = dtDomain.NewRow();
                row1[c1] = "MailingId ";
                dtDomain.Rows.Add(row1);

                DataRow row2 = dtDomain.NewRow();
                row2[c1] = "Targeted Count ";
                dtDomain.Rows.Add(row2);

                DataRow row5 = dtDomain.NewRow();
                row5[c1] = "Date Time Sent";
                dtDomain.Rows.Add(row5);

                DataRow row3 = dtDomain.NewRow();
                row3[c1] = "Domain";
                dtDomain.Rows.Add(row3);

                foreach (DataRow dr in top20Domains.Rows)
                {
                    DataRow row4 = dtDomain.NewRow();
                    row4[c1] = dr["Domain"].ToString();
                    dtDomain.Rows.Add(row4);
                }
                top20Domains.Columns.Remove("TargetEmailsCount");

                //Get Indidual Mailing Domains based on Top20 Domain Names.
                int colCount = 0;
                if (selectedMailingids.Length != 0)
                {
                    string[] mailingId = selectedMailingids.ToString().Split(',');
                    for (int j = 0; j < mailingId.Length;j++ )
                    {
                        CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId[j].ToString()));
                        CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);

                        CampaignJobs objCampaignJob = CampaignJobBase.SelectAllByForeignKeyFromCampaignMaster(pk, ConnectionString);

                        colCount++;
                        //DataColumn c = new DataColumn("Mailing" + colCount.ToString());
                        DataColumn c = new DataColumn(objCampMaster.CampaignName.ToString());
                        dtDomain.Columns.Add(c);
                        dtDomain.Rows[0][j+1] = mailingId[j].ToString();
                        dtDomain.Rows[2][j + 1] = objCampaignJob[0].CompletionTime.ToString();

                        DataTable mailingDomains = ContactMaster.getDomainsBasedOnMailingId(ConnectionString, Convert.ToInt32(mailingId[j].ToString()), top20Domains, out TargetCount);
                        mailingDomains.PrimaryKey = new DataColumn[] { mailingDomains.Columns["Domain"] };
                        dtDomain.Rows[1][colCount] = TargetCount.ToString();
                        for (int i = 4; i < dtDomain.Rows.Count; i++)
                        {
                            //String sExpression = "Domain == '" + dtDomain.Rows[i][0].ToString() + "'";
                            //DataRow[] drFound = mailingDomains.Select(sExpression);
                            DataRow foundRow = mailingDomains.Rows.Find(dtDomain.Rows[i][0].ToString());
                            if (foundRow != null)
                            {
                                dtDomain.Rows[i][colCount] = foundRow[3].ToString();
                            }
                            else
                                dtDomain.Rows[i][colCount] = "0%";
                        }
                    }
                }
                if (dtDomain.Rows.Count != 0)
                {
                    ViewState["dtDomain"] = dtDomain;
                    rtsCampaignComparsion.SelectedIndex = 1;
                    rmprtsCampaignComparsion.SelectedIndex = rtsCampaignComparsion.SelectedIndex;
                    rtsCampaignComparsion.Tabs[1].Enabled = true;
                    //rtsCampaignComparsion.Tabs[2].Enabled = true;

                    gvCampCampare.DataSource = dtDomain;
                    gvCampCampare.DataBind();
                }

                #endregion
            }
        }
        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; }
        }
Exemple #12
0
        public void campaigns_bindcontent(string Htmlcontent)
        {
            try
            {
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                Cpk = new CampaignMasterPrimaryKey(campaignID);
                campMaster = CampaignMaster.SelectOne(Cpk, ConnectionString);
                lblCampaignName.Text = campMaster.CampaignName;
                lblFromAddress.Text = campMaster.FromAddress;
                lblFromName.Text = campMaster.FromName;
                lblSubject.Text = campMaster.Subject;
                trackReads = campMaster.TrackReads.ToString();

                if (Request.QueryString["Ptype"] == "GridCampaign")
                {
                    campaignContent = campMaster.HTMLContent;
                }
                else
                {
                    campaignContent = Htmlcontent;
                }
                if (!campaignContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                {
                    campaignContent = campaignContent + "<br />If you no longer wish to receive these emails, simply click on the following link:<a href='[!RPLINK:GLOBALUNSUBSCRIBE!]'>Unsubscribe</a>";
                }

                chkShowCamStuff.Visible = true;

                #region handle standared links

                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('UnSubscribe links will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("amm"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:AMM!]", "javascript:onClick=alert('AMM version link Can not be activated in Preview Or Test mode.')");
                }
                if (campaignContent.ToLower().Contains("amm2"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:AMM2!]", "javascript:onClick=alert('AMM2 version link Can not be activated in Preview Or Test mode.')");
                }
                #endregion

                //Add click link to the content.
                #region this logic will add click link to the content

                if (campaignContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.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))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                if (campaignContent.ToLower().Contains(linkID))
                                {
                                    campaignContent = campaignContent.Replace(replaceToken, LinkURL);
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = campaignContent;
                ViewState["Content"] = campaignContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Campaign";
            }
        }
        public void campaigns_bindcontent()
        {
            try
            {
                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                ContactMasterPrimaryKey cpk = new ContactMasterPrimaryKey(contactID);
                ContactMaster contact = ContactMaster.SelectOne(cpk, connectionString);

                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(campaignID);
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, connectionString);
                string campaignContent = "";
                //if (campMaster.HTMLContent != "")
                campaignContent = campMaster.HTMLContent;
                //else
                //    campaignContent = campMaster.TextContent;

                if (Request.QueryString["ForwardedEmail"] != null)
                {
                    #region handle standard links

                    if (campaignContent.Contains("[!RPLINK:LISTUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");//"<A style=\"cursor:default;color:Gray\" href=\"#\">List UnSubscribe</A>");
                    }

                    if (campaignContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Global Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Global Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("If you no longer wish to receive these emails, simply click on the following link:"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("If you no longer wish to receive these emails, simply click on the following link:", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }

                    if (campaignContent.ToLower().Contains("forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm2"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM2!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.
                    Int64 CampaignId = Convert.ToInt64(Request.QueryString["CampaignID"]);
                    Int64 ContactId = Convert.ToInt64(Request.QueryString["ContactID"]);
                    string EmailAddress = Request.QueryString["ForwardedEmail"].ToString();

                    string sqlQry ="SELECT *  FROM [ForwardDetails] where [CampaignID]=" + CampaignId + " and [EmailAddress]='" + EmailAddress + "' and [ContactID]=" + ContactId + " ";
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username="******"listunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&ListUnSub=YES" + "&Username="******"globalunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&GlobalUnSub=YES" + "&Username="******"forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.

                    string sqlQry = " select * from ContactMaster where ContactId=" + Convert.ToInt32(Request.QueryString["ContactID"]);
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username=" + userName);
                                    }
                                    else
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, linkData.LinkURL);
                                    }
                                }
                            }

                        }

                    }

                    #endregion

                }

                contentdiv.InnerHtml = campaignContent;

            }
            catch (Exception ex)
            {
            }
        }
        protected void lbtnDownloadAll_Click(object sender, EventArgs e)
        {
            if (hdfCampaignID.Value.ToString() != string.Empty)
            {
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfCampaignID.Value));
                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);

                string UrlStr = "../Reports/AmazonComplaintsReport.aspx?CampId=" + hdfCampaignID.Value.ToString();
                string fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
            }
            else
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please select Campaign from dropdown ')", true);
        }
        public void campaigns_bindcontent(string Textcontent)
        {
            try
            {
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                if (Request.QueryString["Ptype"] == "GridCampaign")
                {
                    Cpk = new CampaignMasterPrimaryKey(campaignID);
                    campMaster = CampaignMaster.SelectOne(Cpk, ConnectionString);
                    textContent = campMaster.TextContent;
                }
                else
                {
                    textContent = Textcontent;
                }
                if (!textContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                {
                    textContent = textContent + "<br />If you no longer wish to receive these emails, simply click on the following link:<a href='[!RPLINK:GLOBALUNSUBSCRIBE!]'>Unsubscribe</a>";
                }
                if (textContent.ToLower().Contains("listunsubscribe"))
                {
                    textContent = textContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('UnSubscribe links will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("globalunsubscribe"))
                {
                    textContent = textContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("forwardtofriend"))
                {
                    textContent = textContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("mirrorweblink"))
                {
                    textContent = textContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }

                #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];
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                if (textContent.ToLower().Contains(linkID))
                                {
                                    textContent = textContent.Replace(replaceToken, LinkURL);
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = textContent;
                ViewState["Content"] = textContent;
                Session["Textcontent"] = null;
            }
            catch (Exception ex)
            {
                //throw;
            }
        }
Exemple #16
0
        public XmlDocument GetMailingStausByMailingID(string UserID, string Password, int MailingID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<MailingStatusInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            try
            {
                if (ConnectionString.Trim().Length != 0 && MailingID > 0)
                {
                    CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(MailingID);
                    CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);
                    if (objCampaignMaster != null)
                    {
                        CampaignJobPrimaryKey pk = new CampaignJobPrimaryKey(MailingID);
                        CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", MailingID, ConnectionString);
                        ListMasterPrimaryKey pkList;
                        ListMaster listMaster = new ListMaster(ConnectionString);
                        ListContactMaster objListContactMaster;
                        string ListNames = string.Empty;
                        string ListIds = string.Empty;
                        if (objCampaignMaster.SelectCondition.Trim().Length > 0)
                        {
                            if (objCampaignMaster.SelectCondition.Trim().Contains(","))
                            {
                                string[] Lists = objCampaignMaster.SelectCondition.Split(',');
                                foreach (string list in Lists)
                                {
                                    pkList = new ListMasterPrimaryKey(Convert.ToInt32(list));
                                    listMaster = ListMaster.SelectOne(pkList, ConnectionString);
                                    if (listMaster != null)
                                    {
                                        ListNames = ListNames + listMaster.ListName + ",";
                                        ListIds = ListIds + listMaster.ListMasterID.ToString() + ",";
                                    }
                                }
                                ListNames = ListNames.Substring(0, ListNames.Length - 1);
                                ListIds = ListIds.Substring(0, ListIds.Length - 1);

                            }
                            else
                            {
                                pkList = new ListMasterPrimaryKey(Convert.ToInt32(objCampaignMaster.SelectCondition));
                                listMaster = ListMaster.SelectOne(pkList, ConnectionString);
                                objListContactMaster = new ListContactMaster(ConnectionString);
                                ListNames = listMaster.ListName;
                                ListIds = listMaster.ListMasterID.ToString();
                            }
                            str.Append("<CurrentStatusForTheMailing>");
                            if (objCampaignMaster.SelectCondition.Length > 0)
                                str.Append("<ListCreated>Yes</ListCreated>");
                            else
                                str.Append("<ListCreated>Error</ListCreated>");
                            if (objCampaignjob[0] != null && objCampaignjob[0].ScheduledDatetime.ToString().Length > 0)
                                str.Append("<ScheduleDefined>Yes</ScheduleDefined>");
                            else
                                str.Append("<ScheduleDefined>No</ScheduleDefined>");
                            MailApprovals objMailApprovals = MailApproval.SelectByField("MailingID", MailingID, ConnectionString);
                            if (objMailApprovals.Count > 0)
                            {
                                if (objMailApprovals[0].ApprovalStatus == "Approved")
                                    str.Append("<CreativeIsApproved>Yes</CreativeIsApproved>");
                                else
                                    str.Append("<CreativeIsApproved>Waiting For Approval</CreativeIsApproved>");
                            }
                            if (objCampaignjob.Count > 0 && objCampaignjob[0].CompletionTime != null)
                            {
                                str.Append("<MailingIsInSendingProcess>No</MailingIsInSendingProcess>");
                                str.Append("<MailingIsComplete>Yes</MailingIsComplete>");
                            }
                            else
                            {
                                str.Append("<MailingIsInSendingProcess>Yes</MailingIsInSendingProcess>");
                                str.Append("<MailingIsComplete>No</MailingIsComplete>");
                            }
                            str.Append("</CurrentStatusForTheMailing>");
                            str.Append("<MailingSummary>");
                            str.Append("<Client>" + UserID + "</Client>");
                            str.Append("<MailingName>" + objCampaignMaster.CampaignName.ToString() + "</MailingName> ");
                            str.Append("<MailingID>" + objCampaignMaster.CampaignId.ToString() + "</MailingID> ");
                            str.Append("<FromName>" + objCampaignMaster.FromName + "</FromName> ");
                            str.Append("<FromMail>" + objCampaignMaster.FromAddress + "</FromMail> ");
                            str.Append("<Subject>" + objCampaignMaster.Subject + "</Subject> ");
                            str.Append("<ReplyToMail>" + objCampaignMaster.ReplytoAddress + "</ReplyToMail> ");

                            str.Append("<MailingListFileQuantity>" + objCampaignjob[0].TotalRecipients + "</MailingListFileQuantity > ");
                            if (objCampaignMaster.SuppressSelection != null && objCampaignMaster.SuppressSelection != "0" && objCampaignMaster.SuppressSelection != "")
                            {
                                ListContactMasters objListContacts = ListContactMaster.SelectByField("ListMasterID", objCampaignMaster.SuppressSelection, ConnectionString);
                                str.Append("<SuppressListFileQuantity>" + objListContacts.Count.ToString() + "</SuppressListFileQuantity > ");
                            }

                            if (objCampaignjob.Count > 0)
                                str.Append("<ScheduleDateTime>" + objCampaignjob[0].ScheduledDatetime + "</ScheduleDateTime> ");
                            str.Append("<MailingListName>" + ListNames + "</MailingListName> ");
                            str.Append("<MailingListID>" + ListIds + "</MailingListID> ");
                            str.Append("</MailingSummary>");

                        }
                        else
                            str.Append("<Message>List Not Found For The Mailing With ID: " + MailingID + "</Message>");

                    }
                    else
                        str.Append("<Message>Mailing with id: " + MailingID + " not exist</Message>");


                }
                else
                    str.Append("<Message>Invalid UserName/Password</Message>");

            }
            catch (Exception ex)
            {
                str.Append("<Error>" + ex.Message + "</Error>");
            }
            str.Append("</MailingStatusInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemple #17
0
        public XmlDocument GetMailingReportByMailingID(string UserID, string Password, int MailingID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<MailingReportInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && MailingID > 0)
            {
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(MailingID);
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);
                if (objCampaignMaster != null)
                {
                    CampaignJobPrimaryKey pk = new CampaignJobPrimaryKey(MailingID);
                    CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", MailingID, ConnectionString);
                    str.Append("<MailingID>" + objCampaignMaster.CampaignId.ToString() + "</MailingID> ");
                    str.Append("<MailingName>" + objCampaignMaster.CampaignName.ToString() + "</MailingName> ");
                    str.Append("<MailingCreatedDate>" + objCampaignMaster.CreatedDate + "</MailingCreatedDate> ");
                    str.Append("<ResultsAsOf>" + DateTime.Now.ToString() + "</ResultsAsOf> ");
                    str.Append("<Subject>" + objCampaignMaster.Subject.ToString() + "</Subject> ");
                    ListMasterPrimaryKey pkList = new ListMasterPrimaryKey(Convert.ToInt32(objCampaignMaster.SelectCondition));
                    ListMaster listMaster = ListMaster.SelectOne(pkList, ConnectionString);
                    str.Append("<ListName>" + listMaster.ListName + "</ListName> ");

                    ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                    DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, MailingID.ToString());
                    int ForwardCount = -1;
                    int Fcount = LinkDetailBase.RecipientsForwardCount(ConnectionString, MailingID, out ForwardCount);
                    long ActiveCount = Convert.ToInt64(dtcontacts.Rows.Count);
                    str.Append("<TotalRecipientsCount>" + ActiveCount.ToString() + "</TotalRecipientsCount> ");
                    str.Append("<ContactsTargetd>" + ActiveCount.ToString() + "</ContactsTargetd> ");

                    foreach (CampaignJob job in objCampaignjob)
                    {
                        str.Append("<ScheduledTime>" + job.ScheduledDatetime.ToString() + "</ScheduledTime> ");
                        str.Append("<CompletionTime>" + job.CompletionTime.ToString() + "</CompletionTime> ");

                        long SentCount = (string.IsNullOrEmpty(job.DeliveredCount.ToString()) == true) ? 0 : Convert.ToInt64(job.DeliveredCount.ToString());
                        str.Append("<SucessfulDeliverdCount>" + SentCount + "</SucessfulDeliverdCount> ");

                        long BCount = (string.IsNullOrEmpty(job.BounceCount.ToString()) == true) ? 0 : Convert.ToInt64(job.BounceCount.ToString());
                        str.Append("<BounceCount>" + BCount + "</BounceCount> ");

                        long OCount = (string.IsNullOrEmpty(job.OpenCount.ToString()) == true) ? 0 : Convert.ToInt64(job.OpenCount.ToString());
                        str.Append("<OpenCount>" + OCount + "</OpenCount> ");

                        long ClickCount = (string.IsNullOrEmpty(job.ClickCount.ToString()) == true) ? 0 : Convert.ToInt64(job.ClickCount.ToString());
                        str.Append("<ClickCount>" + ClickCount + "</ClickCount> ");

                        long UCount = (string.IsNullOrEmpty(job.UnSubscribeCount.ToString()) == true) ? 0 : Convert.ToInt64(job.UnSubscribeCount.ToString());
                        str.Append("<UnsubscribeCount>" + UCount + "</UnsubscribeCount> ");

                        long FCount = (string.IsNullOrEmpty(Fcount.ToString()) == true) ? 0 : Convert.ToInt64(Fcount.ToString());
                        str.Append("<ForwardCount>" + FCount + "</ForwardCount>");
                    }

                    str.Append("<SucessfulDeliverd>");
                    DataTable ListSuccessfulDelivered = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, MailingID);
                    if (ListSuccessfulDelivered != null)
                    {
                        for (int i = 0; i < ListSuccessfulDelivered.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + ListSuccessfulDelivered.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</SucessfulDeliverd>");

                    str.Append("<BounceContacts>");
                    int TotalBounceCount, SoftBounceCount, HardBounceCount = -1;
                    DataTable BounceRecipients = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, MailingID, out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                    if (BounceRecipients != null)
                    {
                        for (int i = 0; i < BounceRecipients.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + BounceRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</BounceContacts>");

                    str.Append("<OpenedContacts>");
                    DataTable emailsOpened = ContactMaster.EmailOpendByCampId(ConnectionString, MailingID);
                    if (emailsOpened != null)
                    {
                        for (int i = 0; i < emailsOpened.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + emailsOpened.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</OpenedContacts>");

                    str.Append("<ClickedContacts>");
                    DataTable emailsClicked = ContactMaster.EmailClickedRecByCampId(ConnectionString, MailingID);
                    if (emailsClicked != null)
                    {
                        for (int i = 0; i < emailsClicked.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + emailsClicked.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</ClickedContacts>");

                    str.Append("<UnsubscribedContacts>");
                    int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1;
                    DataTable ListUnsubScribeRecipients = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, MailingID, out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount);
                    if (ListUnsubScribeRecipients != null)
                    {
                        for (int i = 0; i < ListUnsubScribeRecipients.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + ListUnsubScribeRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</UnsubscribedContacts>");

                    str.Append("<ForwardedContacts>");
                    DataTable forwardRecipients = ContactMaster.SelectForwardRecipients(ConnectionString, MailingID);
                    if (forwardRecipients != null)
                    {
                        for (int i = 0; i < forwardRecipients.Rows.Count; i++)
                        {
                            str.Append("<EmailAddress>" + forwardRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                        }
                    }
                    str.Append("</ForwardedContacts>");

                    string ss = str.ToString();
                }
                else
                    str.Append("<Message>Mailing with id: " + MailingID + " not exist</Message>");
            }
            else
                str.Append("<Message>Invalid UserName/Password</Message>");


            str.Append("</MailingReportInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
        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;
            }
        }
 public XmlDocument DeleteCampaign(string UserID, string Password, long campId)
 {
     XmlDocument doc = new System.Xml.XmlDocument();
     StringBuilder str = new StringBuilder();
     str.Append("<CampaignDeleteInfo>");
     string ConnectionString = GetConnectionString(UserID, Password);
     if (ConnectionString.Trim().Length != 0 && campId != 0)
     {
         CampaignMasterPrimaryKey CampPk = new CampaignMasterPrimaryKey(campId);
         CampaignMaster campMaster = CampaignMaster.SelectOne(CampPk, ConnectionString);
         campMaster.Active = false;
         bool status = campMaster.Update();
         if (status == true)
         {
             str.Append("<Message>Campaign Deleted Successfully</Message>");
         }
     }
     else
     {
         str.Append("<Message>Enter Valid Inputs</Message>");
     }
     str.Append("</CampaignDeleteInfo>");
     doc.LoadXml(str.ToString());
     return doc;
 }
        public XmlDocument SingleCampaignReports(string UserID, string Password, int CampaignID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<ReportInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && CampaignID>0)
            {
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(CampaignID);
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);
                CampaignJobPrimaryKey pk=new CampaignJobPrimaryKey(CampaignID);
                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", CampaignID, ConnectionString);
                //CampaignJob job = CampaignJob.SelectOne(pk, ConnectionString);

                str.Append("<CampaignMasterID>" + objCampaignMaster.CampaignId.ToString() + "</CampaignMasterID> ");
                str.Append("<CampaignMasterName>" + objCampaignMaster.CampaignName.ToString() + "</CampaignMasterName> ");
                str.Append("<ResultsAsOf>" + DateTime.Now.ToString() + "</ResultsAsOf> ");
                str.Append("<Subject>" + objCampaignMaster.Subject.ToString() + "</Subject> ");

                ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, CampaignID.ToString());
                int ForwardCount = -1;
                int Fcount = LinkDetailBase.RecipientsForwardCount(ConnectionString, CampaignID, out ForwardCount);
                long ActiveCount = Convert.ToInt64(dtcontacts.Rows.Count);
                str.Append("<TotalRecipientsCount>" + ActiveCount.ToString() + "</TotalRecipientsCount> ");
                str.Append("<ContactsTargetd>" + ActiveCount.ToString() + "</ContactsTargetd> ");
                foreach (CampaignJob job in objCampaignjob)
                {
                    str.Append("<SucessfulDeliverdCount>" + job.DeliveredCount.ToString() + "</SucessfulDeliverdCount> ");
                    str.Append("<BounceCount>" + job.BounceCount.ToString() + "</BounceCount> ");
                    str.Append("<OpenCount>" + job.OpenCount.ToString() + "</OpenCount> ");
                    str.Append("<ClickCount>" + job.ClickCount.ToString() + "</ClickCount> ");
                    str.Append("<UnsubscribeCount>" + job.UnSubscribeCount.ToString() + "</UnsubscribeCount> ");
                    str.Append("<ForwardCount>" + Fcount .ToString()+ "</ForwardCount>");
                }

                str.Append("<SucessfulDeliverdCount>");
                DataTable ListSuccessfulDelivered = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, CampaignID);
                if (ListSuccessfulDelivered != null)
                {
                    for (int i = 0; i < ListSuccessfulDelivered.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + ListSuccessfulDelivered.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</SucessfulDeliverdCount>");

                str.Append("<BounceCount>");
                int TotalBounceCount, SoftBounceCount, HardBounceCount = -1;
                DataTable BounceRecipients = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, CampaignID, out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                if (BounceRecipients != null)
                {
                    for (int i = 0; i < BounceRecipients.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + BounceRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</BounceCount>");

                str.Append("<OpenCount>");
                DataTable emailsOpened = ContactMaster.EmailOpendByCampId(ConnectionString, CampaignID);
                if (emailsOpened != null)
                {
                    for (int i = 0; i < emailsOpened.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + emailsOpened.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</OpenCount>");

                str.Append("<ClickCount>");
                DataTable emailsClicked = ContactMaster.EmailClickedRecByCampId(ConnectionString, CampaignID);
                if (emailsClicked != null)
                {
                    for (int i = 0; i < emailsClicked.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + emailsClicked.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</ClickCount>");

                str.Append("<UnsubscribeCount>");
                int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1;
                DataTable ListUnsubScribeRecipients = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, CampaignID, out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount);
                if (ListUnsubScribeRecipients != null)
                {
                    for (int i = 0; i < ListUnsubScribeRecipients.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + ListUnsubScribeRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</UnsubscribeCount>");

                str.Append("<ForwardCount>");
                DataTable forwardRecipients = ContactMaster.SelectForwardRecipients(ConnectionString, CampaignID);
                if (forwardRecipients != null)
                {
                    for (int i = 0; i < forwardRecipients.Rows.Count; i++)
                    {
                        str.Append("<Row>" + i.ToString() + "</Row>");
                        str.Append("<EmailAddress>" + forwardRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> ");
                    }
                }
                str.Append("</ForwardCount>");

                string ss = str.ToString();
            }
            str.Append("</ReportInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
 protected void bindMailingNames()
 {
     try
     {
         CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
         DataTable dtCampaignname = objCampaignJob.getAllCampaignsWithStatus(ConnectionString, "CreatedDate", "DESC", 1);
         ddlMailingNames.DataSource = dtCampaignname;
         ddlMailingNames.DataTextField = CampaignMasterFields.CampaignName;
         ddlMailingNames.DataValueField = CampaignMasterFields.CampaignId;
         ddlMailingNames.DataBind();
         //add default list item as first item
         ddlMailingNames.Items.Insert(0, defaultListItem);
         if (Session["MailingID"] != null)
         {
             CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(Session["MailingID"]));
             objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
             if (ddlMailingNames.Items.FindByValue(objCampaignMaster.CampaignId.ToString()) != null)
             {
                 ddlMailingNames.Items.FindByValue(objCampaignMaster.CampaignId.ToString()).Selected = true;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void lbtnDownload_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable CStable = new DataTable();
                string UrlStr = string.Empty;
                string fullURL = string.Empty;
                if (rmpRecipientActivity.SelectedIndex == 0)  //Trends
                {
                    #region Trends Download on Pdf
                    DataTable dtExportTrends = new DataTable();
                    DataColumn s1 = new DataColumn("Recipients Activity Summary");
                    DataColumn s2 = new DataColumn(" ");
                    dtExportTrends.Columns.Add(s1);
                    dtExportTrends.Columns.Add(s2);

                    DataRow row1 = dtExportTrends.NewRow();               //Campaign Name
                    if (ddlMailingNames.SelectedItem.ToString() != defaultListItem)
                        row1[s1] = "Mailing Name:";
                    else
                        row1[s1] = "Campaign Name:";

                    if (ddlMailingNames.SelectedItem.ToString() != defaultListItem)
                        row1[s2] = lblCampaignTitle.Text;
                    else
                        row1[s2] = ddlCampaignsNames.SelectedItem.ToString();

                    dtExportTrends.Rows.Add(row1);

                    DataRow row2 = dtExportTrends.NewRow();                //ListNames.
                    row2[s1] = "List(s) Selected :";

                    if (Session["ListNames"] != null)
                    {
                        row2[s2] = Session["ListNames"].ToString();
                    }

                    dtExportTrends.Rows.Add(row2);
                    List<double> countValues = new List<double>();
                    List<string> countTypes = new List<string>();
                    countTypes.Add("Contacts Targeted");
                    countTypes.Add("Successful Delivered");
                    countTypes.Add("Bounced");
                    countTypes.Add("Opened");
                    countTypes.Add("Unopened");
                    countTypes.Add("Clicked");
                    countTypes.Add("Forwards");
                    countTypes.Add("Unsubscribed");

                    if (Session["allCounts"] != null)
                        countValues = (List<double>)Session["allCounts"];

                    if (countValues.Count > 0)
                    {

                        for (int i = 0; i < countValues.Count; i++)
                        {
                            if (i == 0)//Contacts Targeted
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                row[s2] = countValues[i].ToString();
                                dtExportTrends.Rows.Add(row);
                            }
                            else if (i == 1)//Successful Delivered
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                //row[s2] = countValues[i].ToString();
                                if (countValues[0].ToString() != "0")
                                    row[s2] = countValues[i].ToString() + "  (" + Decimal.Round(Convert.ToDecimal(countValues[i].ToString()) / Convert.ToDecimal(countValues[0].ToString()) * 100, 1) + "%)";
                                else
                                    row[s2] = countValues[i].ToString() + "(0%)";
                                dtExportTrends.Rows.Add(row);
                            }
                            else if (i == 2)//Bounced
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                if (countValues[0].ToString() != "0")
                                    row[s2] = countValues[i].ToString() + "  (" + Decimal.Round(Convert.ToDecimal(countValues[i].ToString()) / Convert.ToDecimal(countValues[0].ToString()) * 100, 1) + "%)";
                                else
                                    row[s2] = countValues[i].ToString() + "(0%)";
                                dtExportTrends.Rows.Add(row);
                            }
                            else if (i == 3)//Opened
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                row[s2] = countValues[i].ToString() + "  (" + Decimal.Round(Convert.ToDecimal(countValues[i].ToString()) / Convert.ToDecimal(countValues[1].ToString()) * 100, 1) + "%)";
                                dtExportTrends.Rows.Add(row);
                            }
                            else if (i == 4)//Unopened
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                row[s2] = countValues[i].ToString() + "  (" + Decimal.Round(Convert.ToDecimal(countValues[i].ToString()) / Convert.ToDecimal(countValues[1].ToString()) * 100, 1) + "%)";
                                dtExportTrends.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dtExportTrends.NewRow();
                                row[s1] = countTypes[i].ToString();
                                row[s2] = countValues[i].ToString();
                                dtExportTrends.Rows.Add(row);
                            }
                        }
                        if (dtExportTrends.Rows.Count == 0)
                        {
                            lblMsg.Text = "No Records Found";
                            lblMsg.ForeColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            expfilname = "ContactActivitySummary_" + lblCampaignTitle.Text;
                            expfilname = expfilname + " " + DateTime.Now.ToShortDateString();
                            ExportToPDF(dtExportTrends, expfilname);
                        }
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    #endregion
                }
                else if (rmpRecipientActivity.SelectedIndex == 1)  //Contacts Targeted
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdContactsTargeted.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?MailingId=" + hdfMailingID.Value.ToString() + "&ListIds=" + objCampMaster.SelectCondition.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                            {
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&ListIds=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;
                            }
                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 2)  //Successful Delivered
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdSuccessfulDelivered.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                            {
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;
                            }
                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";

                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 3)  //Bounced
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdBounced.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                            {
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;
                            }
                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 4)  //Opened
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdOpened.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 5)  //Unopened
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdUnopened.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 6)  //Clicked
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdClicked.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 7)  //Forwards
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdForwards.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else if (rmpRecipientActivity.SelectedIndex == 8)  //Unsubscribed
                {
                    if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value.ToString() != string.Empty)
                    {
                        if (rgdUnsubscribed.Items.Count > 0)
                        {
                            if (hdfMailingID.Value != string.Empty)
                            {
                                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                                CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                            }
                            else
                                UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                            fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                        }
                        else
                            ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('No records to Download');</script>");
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
                else
                {
                    if (hdfMailingID.Value.ToString() != string.Empty)
                    {
                        CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                        CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);

                        UrlStr = "../Reports/ContactActivityReports.aspx?CampId=" + hdfMailingID.Value.ToString() + "&ListIds=" + objCampMaster.SelectCondition.ToString() + "&Carpt=" + rtsRecipientActivity.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                        fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                    }
                    else
                        ClientScript.RegisterStartupScript(typeof(String), "ReportMessage", "<script lanaguage='javascript'>alert('Please select Campaign from dropdown');</script>");
                }
            }
            catch (Exception ex)
            {

            }
        }
        protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
        {
            try
            {

                #region Ex1
                //CrystalDecisions.Shared.ExportFormatType formateType = ExportFormatType.PortableDocFormat;
                //if (dpExport.SelectedValue == "PDF")
                //{
                //    formateType = ExportFormatType.PortableDocFormat;
                //}
                //else if (dpExport.SelectedValue == "Excel")
                //{
                //    formateType = ExportFormatType.Excel;
                //}
                //else if (dpExport.SelectedValue == "Word")
                //{
                //    formateType = ExportFormatType.WordForWindows;
                //}
                //else if (dpExport.SelectedValue == "RichText")
                //{
                //    formateType = ExportFormatType.RichText;
                //}
                //else if (dpExport.SelectedValue == "CrystalReport")
                //{
                //    formateType = ExportFormatType.CrystalReport;
                //}
                //if (ContactRptname == "Contacts Targeted")
                //{
                //    SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString());
                //    TargetedRpt.SetParameterValue("@ListID", Request.QueryString["ListIds"].ToString());
                //    TargetedRpt.SetParameterValue("@CampaignID", Request.QueryString["CampId"].ToString());
                //    TargetedRpt.ExportToHttpResponse(formateType, Response, true, "ContactsTargeted");
                //}
                //else if (ContactRptname == "Advanced")
                //{
                //    SetDatabase(AdvancedRpt, Request.QueryString["ListIds"].ToString());
                //    AdvancedRpt.SetParameterValue("@ListIds", Request.QueryString["ListIds"].ToString());
                //    AdvancedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    AdvancedRpt.ExportToHttpResponse(formateType, Response, true, "Advanced");
                //}
                //else if (ContactRptname == "Successful Delivered")
                //{
                //    SetDatabase(SuccessDRpt, string.Empty);
                //    SuccessDRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    SuccessDRpt.ExportToHttpResponse(formateType, Response, true, "SuccessfulDeliveredContacts");
                //}
                //else if (ContactRptname == "Clicked")
                //{
                //    SetDatabase(ClickedRpt, string.Empty);
                //    ClickedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    ClickedRpt.ExportToHttpResponse(formateType, Response, true, "ClickedContacts");
                //}

                //else if (ContactRptname == "Forwards")
                //{
                //    SetDatabase(ForwardRpt, string.Empty);
                //    ForwardRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    ForwardRpt.ExportToHttpResponse(formateType, Response, true, "ForwardContacts");
                //}
                //else if (ContactRptname == "Opened")
                //{
                //    SetDatabase(OpenMailRpt, string.Empty);
                //    OpenMailRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    OpenMailRpt.ExportToHttpResponse(formateType, Response, true, "OpenedContacts");
                //}
                //else if (ContactRptname == "Unopened")
                //{
                //    SetDatabase(UnopenRpt, string.Empty);
                //    UnopenRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    UnopenRpt.ExportToHttpResponse(formateType, Response, true, "UnopenedContacts");
                //}
                //else if (ContactRptname == "Unsubscribed")
                //{
                //    SetDatabase(UnsubRpt, string.Empty);
                //    UnsubRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    UnsubRpt.ExportToHttpResponse(formateType, Response, true, "UnsubscribedContacts");
                //}
                //else if (ContactRptname == "Bounced")
                //{
                //    SetDatabase(BouncedRpt, string.Empty);
                //    BouncedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString());
                //    BouncedRpt.ExportToHttpResponse(formateType, Response, true, "BounceContacts");
                //}
                #endregion

                #region Ex2
                //SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString());
                //if (dpExport.SelectedValue == "PDF")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/pdf";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".pdf");
                //    Response.End();
                //    //TargetedRpt.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, true, Page.Title);
                //}
                //else if (dpExport.SelectedValue == "Excel")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.Excel);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/vnd.xls";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".xls");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "Word")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.WordForWindows);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/vnd.doc";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".doc");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "RichText")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.RichText);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/rtf";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rtf");
                //    Response.End();
                //}
                //else if (dpExport.SelectedValue == "CrystalReport")
                //{
                //    oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.CrystalReport);
                //    Response.Clear();
                //    Response.Buffer = true;
                //    Response.ContentType = "application/rpt";
                //    Response.BinaryWrite(oStream.ToArray());
                //    Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rpt");
                //    Response.End();
                //}

                #endregion
                string CampName = string.Empty;
                string campId = HttpContext.Current.Request.QueryString["CampId"] != null ? HttpContext.Current.Request.QueryString["CampId"].ToString() : string.Empty;
                string mailingId = HttpContext.Current.Request.QueryString["MailingID"] != null ? HttpContext.Current.Request.QueryString["MailingID"].ToString() : string.Empty;
                //Get the MailingName Using MailingId
                if (mailingId != string.Empty)
                {
                    CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId));
                    CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                    CampName = objCampMaster.CampaignName.ToString().Trim();
                }
                else
                {
                    CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(campId));
                    Campaign Campaign = Campaign.SelectOne(pk, ConnectionString);
                    CampName = Campaign.CampaignsName;
                }
                string listIds = HttpContext.Current.Request.QueryString["ListIds"] != null ? HttpContext.Current.Request.QueryString["ListIds"].ToString() : string.Empty;
                //string CampName = HttpContext.Current.Request.QueryString["CampName"] != null ? HttpContext.Current.Request.QueryString["CampName"].ToString() : string.Empty;
                string TabName = string.Empty;
                DataTable table = new DataTable();
                int TotalBounceCount, SoftBounceCount, HardBounceCount = -1;
                int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1, TotalUnsubCount = -1;
                Export Export = new Export("Web");
                #region download using Dll
                if (ContactRptname == "Contacts Targeted")
                {
                    TabName = "ContactsTargeted";
                    ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                    if (listIds != string.Empty && mailingId != string.Empty)
                        table = objListContactMaster.getContactsWithCampaignID(listIds, mailingId);
                    else
                        table = objListContactMaster.getContactsWithAssignCampaignID(campId);
                }
                else if (ContactRptname == "Successful Delivered")
                {
                    TabName = "SuccessfulDelivered";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectSuccDeliveredByAssignCampIdwithDistinct(ConnectionString, Convert.ToInt32(campId));
                    else
                        table = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, Convert.ToInt32(mailingId));

                }
                else if (ContactRptname == "Bounced")
                {
                    TabName = "Bounced";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectRecipientsBounceRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                    else
                        table = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, Convert.ToInt32(mailingId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                }
                else if (ContactRptname == "Opened")
                {
                    TabName = "Opened"; int TotalOpenCounts = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.EmailOpendByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalOpenCounts);
                    else
                        table = ContactMaster.EmailOpendByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Unopened")
                {
                    TabName = "Unopened";
                    if (campId != string.Empty)
                        table = ContactMaster.EmailUnopendRecByAssignCampId(ConnectionString, campId);
                    else
                        table = ContactMaster.EmailUnopendByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Clicked")
                {
                    TabName = "Clicked"; int TotalClickCounts = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.EmailClickedRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalClickCounts);
                    else
                        table = ContactMaster.EmailClickedRecByCampId(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Forwards")
                {
                    TabName = "Forwards"; int TotalForwardCount = -1;
                    if (campId != string.Empty)
                        table = ContactMaster.SelectForwardRecipientsByAssignId(ConnectionString, Convert.ToInt32(campId), out TotalForwardCount);
                    else
                        table = ContactMaster.SelectForwardRecipients(ConnectionString, Convert.ToInt32(mailingId));
                }
                else if (ContactRptname == "Unsubscribed")
                {
                    TabName = "Unsubscribed";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectUnsubscribeRecipientsByAssignedCampId(ConnectionString, Convert.ToInt32(campId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount, out TotalUnsubCount);
                    else
                        table = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, Convert.ToInt32(mailingId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount);
                }
                else if (ContactRptname == "Advanced")
                {
                    TabName = "Advanced";
                    if (campId != string.Empty)
                        table = ContactMaster.SelectRecipientsDomainCountsByAssign(ConnectionString, Convert.ToInt32(campId), "TargetedDomain", string.Empty);
                    else
                        table = ContactMaster.SelectRecipientsDomainCounts(ConnectionString, listIds, Convert.ToInt32(mailingId), "TargetedDomain", string.Empty);
                    table.Columns["TargetedDomain"].ColumnName = "Domains";
                    table.Columns["Unsubs"].ColumnName = "Unsubscribe";
                }
                if (dpExport.SelectedValue.Equals("CSV"))
                    Export.ExportDetails(table, Export.ExportFormat.CSV, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".csv");
                else if (dpExport.SelectedValue.Equals("Excel"))
                    Export.ExportDetails(table, Export.ExportFormat.Excel, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".xls");
                else if (dpExport.SelectedValue.Equals("Text"))
                {
                    Export.ExportDetails(table, Export.ExportFormat.Text, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".txt");
                }
                else
                    ExportToPDF(table, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".pdf");
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void BindAllContactsTargeted(string CampaignID, string MailingId, string OrderBy, string dir, int pageIndex, int pageSize, out int Count)
        {
            string ListIds = string.Empty;
            if (hdfMailingID.Value != string.Empty)
            {
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);
                ListIds = objCampaignMaster.SelectCondition;
            }
            DataTable ContactsTargeted = null;
            if (txtSearch_Targeted.Text.ToString().Trim().Length == 0)
            {
                if (hdfMailingID.Value != string.Empty)
                    ContactsTargeted = ContactMaster.BindGetAllContactsTargetedList(ConnectionString, MailingId, ListIds, OrderBy, dir, pageIndex, pageSize, out Count);
                else
                    ContactsTargeted = ContactMaster.BindGetAllContactsTargetedListByAssignCampId(ConnectionString, CampaignID, OrderBy, dir, pageIndex, pageSize, out Count);
            }
            else
            {
                StringBuilder wherecondition = new StringBuilder();
                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("'", "''");
                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("%", "[%]");
                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("_", "[_]");
                if (txtSearch_Targeted.Text.Trim().ToString() != "")
                    wherecondition.Append("FirstName LIKE '%" + txtSearch_Targeted.Text.Trim() + "%' OR LastName LIKE '%" + txtSearch_Targeted.Text.Trim() + "%' OR EmailAddress LIKE '%" + txtSearch_Targeted.Text.Trim() + "%'");
                else
                    wherecondition.Append("1=1");
                if (hdfMailingID.Value != string.Empty)
                    ContactsTargeted = ContactMaster.BindAllContactsTargeted_Unsub_Search(wherecondition.ToString().Trim(), ConnectionString, MailingId, ListIds, OrderBy, dir, pageIndex, pageSize, out Count);
                else
                    ContactsTargeted = ContactMaster.BindAllContactsTargetedByAssignCamp_Unsub_Search(wherecondition.ToString().Trim(), ConnectionString, CampaignID, OrderBy, dir, pageIndex, pageSize, out Count);

                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("''", "'");
                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("[%]", "%");
                txtSearch_Targeted.Text = txtSearch_Targeted.Text.Trim().Replace("[_]", "_");

                lblTargetedMsg.Text = (ContactsTargeted.Rows.Count != 0) ? "Records Found " + Count.ToString() : "No records found!";
                lblTargetedMsg.ForeColor = (ContactsTargeted.Rows.Count == 0) ? System.Drawing.Color.Red : System.Drawing.Color.Green;
            }
            rgdContactsTargeted.VirtualItemCount = Count;
            rgdContactsTargeted.DataSource = ContactsTargeted;
            rgdContactsTargeted.CurrentPageIndex = pageIndex;
            rgdContactsTargeted.DataBind();
        }
Exemple #26
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());
        }
        protected void ddlMailingNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlMailingNames.SelectedItem.Text != defaultListItem)
            {
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(ddlMailingNames.SelectedItem.Value));
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);

                hdfMailingID.Value = campMaster.CampaignId.ToString();
                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(hdfMailingID.Value), ConnectionString);
                lblCampaignTitle.Text = campMaster.CampaignName.ToString();
                lblsentDateTime.Text = objCampaignjob[0].CompletionTime.ToString();
                Session["CampId"] = ddlCampaignsNames.SelectedItem.Value != defaultListItem ? ddlCampaignsNames.SelectedItem.Value : null;
                Session["MailingID"] = hdfMailingID.Value;
                Session["TitleName"] = lblCampaignTitle.Text;
                Session["SentDateTime"] = lblsentDateTime.Text;
            }
            else
            {
                Session["MailingID"] = null;
                hdfMailingID.Value = "";
                hdfCampaignID.Value = (Session["CampId"] != null) ? Session["CampId"].ToString() : string.Empty;
                lblsentDateTime.Text = string.Empty;
                if (ddlCampaignsNames.SelectedItem.Text != defaultListItem)
                {
                    lblCampaignTitle.Text = ddlCampaignsNames.SelectedItem.Text;
                    Session["TitleName"] = lblCampaignTitle.Text;
                }
                else
                {
                    lblTotalBounces.Text = "0";
                    lblSoftBounces.Text = "0";
                    lblHardBounces.Text = "0";
                    lblTotalClicks.Text = "0";
                    lbluniqueclicks.Text = "0";
                    lblNeverOptedintoList.Text = "0";
                    lblToofreequentCommunication.Text = "0";
                    lblNotinsertedinmaterial.Text = "0";
                    lblOther.Text = "0";
                    lblTotalopens.Text = "0";
                    lbluniqueopens.Text = "0";

                    lblCampaignTitle.Text = string.Empty;
                    Session["TitleName"] = null;
                    Session["SentDateTime"] = null;
                }
            }
            bindReport();
        }
 protected void ddlMailingNames_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlMailingNames.SelectedItem.Text != defaultListItem)
     {
         CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(ddlMailingNames.SelectedItem.Value));
         CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);
         hdfMailingID.Value = campMaster.CampaignId.ToString();
         CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(hdfMailingID.Value), ConnectionString);
         lblCampaignTitle.Text = campMaster.CampaignName.ToString();
         lblsentDateTime.Text = objCampaignjob[0].CompletionTime.ToString();
         Session["CampId"] = ddlCampaignsNames.SelectedItem.Value != defaultListItem ? ddlCampaignsNames.SelectedItem.Value : null;
         Session["MailingID"] = hdfMailingID.Value;
         Session["TitleName"] = lblCampaignTitle.Text;
         Session["SentDateTime"] = lblsentDateTime.Text;
     }
     else
     {
         Session["MailingID"] = null;
         hdfMailingID.Value = "";
         hdfCampaignID.Value = (Session["CampId"] != null) ? Session["CampId"].ToString() : string.Empty;
         lblsentDateTime.Text = string.Empty;
         if (ddlCampaignsNames.SelectedItem.Text != defaultListItem)
         {
             lblCampaignTitle.Text = ddlCampaignsNames.SelectedItem.Text;
             Session["TitleName"] = lblCampaignTitle.Text;
         }
     }
     bindReport(hdfCampaignID.Value, hdfMailingID.Value);
 }
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified 
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="CampaignMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class EmailOpenDetails</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			1/8/2010 12:24:52 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static EmailOpenDetails SelectAllByForeignKeyFromCampaignMaster(CampaignMasterPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            EmailOpenDetails obj = null;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }

            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_EmailOpenDetails_SelectAllByForeignKeyCampaignMaster", ref ExecutionState);
            obj = new EmailOpenDetails();
            obj = EmailOpenDetail.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper,ConnectionString);

            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
        protected void lbtnDownload_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable CStable = new DataTable();
                string UrlStr = string.Empty;
                string fullURL = string.Empty;
                if (hdfMailingID.Value.ToString() != string.Empty || hdfCampaignID.Value!=string.Empty)
                {
                    if (hdfMailingID.Value != string.Empty)
                    {
                        CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(hdfMailingID.Value));
                        CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString);
                        UrlStr = "../Reports/FormSubmittedReports.aspx?CampId=" + string.Empty + "&MailingId=" + hdfMailingID.Value.ToString() + "&Carpt=" + formSubmitted.SelectedTab.Text;// +"&CampName=" + objCampMaster.CampaignName.ToString();
                    }
                    else
                        UrlStr = "../Reports/FormSubmittedReports.aspx?CampId=" + hdfCampaignID.Value.ToString() + "&MailingId=" + string.Empty + "&Carpt=" + formSubmitted.SelectedTab.Text;// +"&CampName=" + ddlCampaignsNames.SelectedItem.Text;

                    fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=1000,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                    ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                }
                else
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please select Campaign from dropdown ')", true);

            }
            catch (Exception ex)
            {

            }
        }