public void bindPopup(int listMasterID)
        {
            try
            {
                if (listMasterID > 0)
                {
                    ListMasterPrimaryKey pk = new ListMasterPrimaryKey(listMasterID);
                    ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
                    txtEditListName.Text = listMaster.ListName;
                    txtEditListDescription.Text = listMaster.ListDesc;
                    txtEditListCreationowner.Text = listMaster.ListCowner;
                }
                else
                {
                    txtEditListName.Text = "";
                    txtEditListDescription.Text = "";
                    txtEditListCreationowner.Text = "";
                }
            }
            catch
            {

            }
        }
Exemple #2
0
        public XmlDocument GetAllMailings(string UserID, string Password)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0)
            {
                CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                DataTable campaignDt = new DataTable();
                campaignDt = objCampaignJob.getAllCampaigns(ConnectionString, "CreatedDate", "asc");
                if (campaignDt != null)
                {
                    for (int i = 0; i < campaignDt.Rows.Count; i++)
                    {
                        str.Append("<Campaign Row=\"" + i.ToString() + "\"> ");
                        str.Append("<CampaignId>" + campaignDt.Rows[i]["CampaignId"].ToString() + "</CampaignId> ");
                        str.Append("<CampaignName>" + Server.HtmlEncode(campaignDt.Rows[i]["CampaignName"].ToString()) + "</CampaignName>");
                        str.Append("<CampaignStatus>" + campaignDt.Rows[i]["Status"].ToString() + "</CampaignStatus>");
                        str.Append("<CampaignCreatedDatetime>" + campaignDt.Rows[i]["CreatedDatetime"].ToString() + "</CampaignCreatedDatetime>");
                        str.Append("<CampaignScheduledDatetime>" + campaignDt.Rows[i]["ScheduledDatetime"].ToString() + "</CampaignScheduledDatetime>");
                        str.Append("<CampaignDeliveredCount>" + campaignDt.Rows[i]["DeliveredCount"].ToString() + "</CampaignDeliveredCount>");
                        str.Append("<CampaignBounceCount>" + campaignDt.Rows[i]["BounceCount"].ToString() + "</CampaignBounceCount>");

                        if (!string.IsNullOrEmpty(campaignDt.Rows[i]["SelectCondition"].ToString()))
                        {
                            string[] arrList = campaignDt.Rows[i]["SelectCondition"].ToString().Split(',');
                            foreach (string arr in arrList)
                            {
                                ListMasterPrimaryKey listpk = new ListMasterPrimaryKey(Convert.ToInt64(arr));
                                ListMaster listMaster = ListMaster.SelectOne(listpk, ConnectionString);
                                if (listMaster != null)
                                {
                                    str.Append("<ListId>" + listMaster.ListMasterID.ToString() + "</ListId>");
                                    str.Append("<ListName>" + Server.HtmlDecode(listMaster.ListName.ToString() + "</ListName>"));
                                }
                            }
                        }

                        str.Append("<Errormessage></Errormessage>");
                        str.Append("</Campaign>");
                        string ss = str.ToString();
                    }
                }
                else
                {
                    str.Append("<Message> Please Enter Valid Inputs</Message>");
                }
            }
            str.Append("</CampaignInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemple #3
0
        public XmlDocument GetMailingDetailsByMailingName(string UserID, string Password, string CampaignName)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);

            DataTable campMaster = CampaignMasterBase.SelectByName("CampaignName", CampaignName.Trim(), ConnectionString);
            if (campMaster.Rows.Count > 0)
            {

                str.Append("<CampaignName>" + campMaster.Rows[0]["CampaignName"].ToString() + "</CampaignName> ");
                str.Append("<CampaignSubject>" + campMaster.Rows[0]["Subject"].ToString() + "</CampaignSubject>");
                str.Append("<FromName>" + campMaster.Rows[0]["FromName"].ToString() + "</FromName>");
                str.Append("<FromAddress>" + campMaster.Rows[0]["FromAddress"].ToString() + "</FromAddress>");
                if (string.IsNullOrEmpty(campMaster.Rows[0]["ReplaytoName"].ToString()))
                {
                    str.Append("<ReplyName>" + string.Empty + "</ReplyName>");
                }
                else
                {
                    str.Append("<ReplyName>" + campMaster.Rows[0]["ReplaytoName"].ToString() + "</ReplyName>");
                }
                if (string.IsNullOrEmpty(campMaster.Rows[0]["ReplytoAddress"].ToString()))
                {
                    str.Append("<ReplyAddress>" + string.Empty + "</ReplyAddress>");
                }
                else
                {
                    str.Append("<ReplyAddress>" + campMaster.Rows[0]["ReplytoAddress"].ToString() + "</ReplyAddress>");
                }
                if (!string.IsNullOrEmpty(campMaster.Rows[0]["SelectCondition"].ToString()))
                {
                    string[] arrList = campMaster.Rows[0]["SelectCondition"].ToString().Split(',');
                    foreach (string arr in arrList)
                    {
                        ListMasterPrimaryKey listpk = new ListMasterPrimaryKey(Convert.ToInt64(arr));
                        ListMaster listMaster = ListMaster.SelectOne(listpk, ConnectionString);
                        if (listMaster != null)
                        {
                            ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);

                            DataTable dtContacts = objListContactMaster.getShowListRecipients(Convert.ToInt64(listMaster.ListMasterID), "firstname", "asc");
                            str.Append("<ListId>" + listMaster.ListMasterID.ToString() + "</ListId>");
                            str.Append("<ListName>" + Server.HtmlDecode(listMaster.ListName.ToString() + dtContacts.Rows.Count + "</ListName>"));
                            //lstBoxListNames.Items.Add(new ListItem(Server.HtmlDecode(listMaster.ListName.ToString()) + " (" + dtContacts.Rows.Count + ")", listMaster.ListMasterID.ToString(), true));
                        }
                    }
                }
            }
            else
                str.Append("<Message>Campaign with name" + CampaignName + " not exist</Message>");
            str.Append("</CampaignInfo>");
            doc.LoadXml(str.ToString());
            return doc;

        }
Exemple #4
0
        public XmlDocument GetListByListID(string UserID, string Password, int ListID)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<ListInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && ListID > 0)
            {
                ListMasterPrimaryKey pk = new ListMasterPrimaryKey(ListID);
                ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);

                str.Append("<ListName>" + Server.HtmlEncode(listMaster.ListName.ToString()) + "</ListName>");

                if (string.IsNullOrEmpty(listMaster.ListCowner))
                    str.Append("<ListOwner>" + string.Empty + "</ListOwner>");
                else
                    str.Append("<ListOwner>" + Server.HtmlEncode(listMaster.ListCowner.ToString()) + "</ListOwner>");
                if (string.IsNullOrEmpty(listMaster.ListCowner))
                    str.Append("<ListDescription>" + string.Empty + "</ListDescription>");
                else
                    str.Append("<ListDescription>" + Server.HtmlEncode(listMaster.ListDesc.ToString()) + "</ListDescription>");
                str.Append("<ListCreatedDate>" + Server.HtmlEncode(listMaster.CreatedDate.ToString()) + "</ListCreatedDate>");
            }
            str.Append("</ListInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemple #5
0
        /// <summary>
        /// This method is used to bind the edit popup while editing the list
        /// </summary>
        /// <param name="listMasterID"></param>
        public void bindPopup(int listMasterID)
        {
            try
            {
                if (listMasterID > 0)
                {
                    txtEditListName.Text = "";
                    txtEditListDescription.Text = "";
                    txtEditListCreationowner.Text = "";
                    chkESuppress.Checked = false;
                    chkESeedList.Checked = false;
                    ListMasterPrimaryKey pk = new ListMasterPrimaryKey(listMasterID);
                    ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
                    txtEditListName.Text = listMaster.ListName;
                    txtEditListDescription.Text = listMaster.ListDesc;
                    txtEditListCreationowner.Text = listMaster.ListCowner;
                    if (listMaster.IsSeedList != null && (bool)listMaster.IsSeedList)
                        chkESeedList.Checked = true;
                    else
                    {
                        DataTable memberCount = ListMasterBase.SelectListNamesWithContactCount(hiddenEditID.Value, ConnectionString);
                        int ListMemberCount = Convert.ToInt32(memberCount.Rows[0]["members"].ToString());
                        chkESeedList.Enabled = (ListMemberCount < 16) ? true : false;
                    }
                    if (listMaster.Active != null && (bool)listMaster.Active == false)
                        chkESuppress.Checked = true;
                }
                else
                {
                    txtEditListName.Text = "";
                    txtEditListDescription.Text = "";
                    txtEditListCreationowner.Text = "";
                    chkESuppress.Checked = false;
                    chkESeedList.Checked = false;
                }
            }
            catch
            {

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ConnectionString = Session["Connectionstring"].ToString();
            Master.ParentModulelbl.Text = "List Details";

            lbtnsearch.Attributes.Add("onClick", "return validateSearchBox('" + txtsearchrecipient.ClientID + "');");
            lbSearchRecipient.Attributes.Add("onClick", "return validateSearchBox('" + txtSearch.ClientID + "');");

            if (Request.QueryString["id"] != null)
            {
                hiddenEditID.Value = Request.QueryString["id"].ToString();
            }
            if (!IsPostBack)
            {
                if (hiddenEditID.Value != "0")
                {
                    ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hiddenEditID.Value));
                    ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
                    if (listMaster != null)
                    {
                        if (listMaster.ListName.Contains("&quot;"))
                            listMaster.ListName = Server.HtmlEncode(listMaster.ListName);
                        lblListName.Text = listMaster.ListName.ToString();
                    }
                    bindRecipients("sort");
                    bindHistorySection();
                    Session["SelectedContacts"] = null;
                }
            }
            else
                managePaging();
        }
        /// <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="ListMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class ListMaster</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/6/2009 11:39:08 AM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static ListMaster SelectOneWithListContactMasterUsingListMasterID(ListMasterPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            ListMaster 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_ListMaster_SelectOneWithListContactMasterUsingListMasterID", ref ExecutionState);
            if (dr.Read())
            {
                obj= new ListMaster(ConnectionString);
                PopulateObjectFromReader(obj,dr);

                dr.NextResult();

                //Get the child records.
                obj.ListContactMasters=ListContactMaster.PopulateObjectsFromReader(dr,ConnectionString);
            }
            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
Exemple #8
0
 /// <summary>
 ///  multiple list (Mass Desc Update) - yes Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lbtnEditMultipleYes_Click(object sender, EventArgs e)
 {
     //Edit Functionality
     if (grdList.Rows.Count > 0)
     {
         //Get contact Selection
         rememberContactSelection("grdaddchkSelectContact", "lblListMasterID", grdList, "grdaddselectall");
         if (Session["SelectedContacts"] != null)
         {
             StringBuilder strbEditContacts = new StringBuilder();
             //adding selected contatIds to stringbuilder
             for (int i = 0; i < contactsSelected.Count; i++)
             {
                 strbEditContacts.Append(contactsSelected[i] + ", ");
                 ListMaster ListMaster = new ListMaster(ConnectionString);
                 ListMaster.ListMasterID = Convert.ToInt64(contactsSelected[i]);
                 ListMaster.ListDesc = txtEditMultiListDescription.Text;
                 ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(contactsSelected[i]));
                 ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);
                 ListMaster.CreatedDate = listMasterNew.CreatedDate;
                 ListMaster.ModifiedDate = System.DateTime.Now;
                 if (ListMaster.SelectedEditUpdate() == true)
                 {
                     hiddenEditID.Value = null;
                 }
             }
             strbEditContacts.Remove(strbEditContacts.Length - 2, 1);
             Session["SelectedContacts"] = null;
             hdrchkselected.Clear();
             if (txtListNameSearch.Text != "")
             {
                 SearchCriteria(grdList.PageIndex, "");
             }
             else
             {
                 bindGrid("", "ASC", "ListName");
             }
             lblMainMsg.Text = "Successfully Edit List(s) with ids: " + strbEditContacts.ToString();
             hdnMeditselect.Value = "false";
             udpnlListGridview.Update();
         }
     }
 }
        public void getMailingRpt(DataRow dr, int RptSenthr)
        {
            Logger.logdata(logforemailbuilder, "************** in getMailingRpt(..) method **************");
            Logger.logdata(logforemailbuilder,
                           string.Format("getMailingRpt(..) has been started at {0}", DateTime.Now.ToString()));

            string message = string.Empty;

            int MailingId = Convert.ToInt32(dr["MailingID"].ToString());
            Logger.logdata(logforemailbuilder, string.Format("Mailing Id:{0}", MailingId.ToString()));

            //string[] rptMailIds= dr["ReportMailTo"].ToString().Split(',');

            string rptMailTo = dr["ReportMailTo"].ToString();

            CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(MailingId);
            CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, clientConnectionString);
            CampaignJobPrimaryKey pk = new CampaignJobPrimaryKey(MailingId);
            CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", MailingId, clientConnectionString);
            string MailinName = objCampaignMaster.CampaignName.ToString();
            Logger.logdata(logforemailbuilder, string.Format("MailingName:{0}", MailinName.ToString()));

            string Subject = objCampaignMaster.Subject.ToString();
            string sentTime = objCampaignjob[0].ScheduledDatetime.ToString();
            string completionTime = objCampaignjob[0].CompletionTime.ToString();

            string DeliveredCount = objCampaignjob[0].DeliveredCount.ToString();
            string BounceCount = objCampaignjob[0].BounceCount.ToString();
            string OpenCount = objCampaignjob[0].OpenCount.ToString();
            string ClickCount = objCampaignjob[0].ClickCount.ToString();
            string UnsubscribeCount = objCampaignjob[0].UnSubscribeCount.ToString();

            ListMasterPrimaryKey pkList = new ListMasterPrimaryKey(Convert.ToInt32(objCampaignMaster.SelectCondition));
            ListMaster listMaster = ListMaster.SelectOne(pkList, connectionString);
            string listName = listMaster.ListName;

            ListContactMaster objListContactMaster = new ListContactMaster(clientConnectionString);
            DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, MailingId.ToString());
            string TargetedCount = dtcontacts.Rows.Count.ToString();

            int ForwardCount = -1;
            int Fcount = LinkDetailBase.RecipientsForwardCount(clientConnectionString, MailingId, out ForwardCount);
            string forwardCount = Fcount.ToString();

            #region MailBody
            StringBuilder mailContent = new StringBuilder();
            mailContent.Append("<table width=\"600px\">");
            mailContent.Append("<tr><td style=\"font-weight: bold\">Mailing Report Summary</td></tr>");
            mailContent.Append("<tr><td width=\"250px\">Mailing Name:</td><td>" + MailinName + "</td></tr>");
            mailContent.Append("<tr><td>Subject Line:</td><td>" + Subject + "</td></tr>");
            mailContent.Append("<tr><td>Send Start Date:</td><td>" + sentTime + "</td></tr>");
            mailContent.Append("<tr><td>Send Completion Date :</td><td>" + completionTime + "</td></tr>");
            mailContent.Append("<tr><td>List Name:</td><td>" + listName + "</td></tr>");
            mailContent.Append("<tr><td style=\"height:20px\"></td><td></td></tr>");
            mailContent.Append("<tr><td style=\"font-weight:bold\">Overall Stats</td></tr>");
            mailContent.Append("<tr><td>Contacts Targeted</td><td>" + TargetedCount + "</td></tr>");
            mailContent.Append("<tr><td>Successful Delivered</td> <td>" + DeliveredCount + "</td></tr>");
            mailContent.Append("<tr><td>BounceCount</td> <td>" + BounceCount + "</td></tr>");
            mailContent.Append("<tr><td>OpenCount</td> <td>" + OpenCount + "</td></tr>");
            mailContent.Append("<tr><td>ClickCount</td> <td>" + ClickCount + "</td></tr>");
            mailContent.Append("<tr><td>UnsubscribeCount</td><td>" + UnsubscribeCount + "</td></tr>");
            mailContent.Append("<tr><td>ForwardCount</td><td>" + forwardCount + "</td></tr>");
            mailContent.Append("</table>");

            Logger.logdata(logforemailbuilder, string.Format("MailingBody :{0}", mailContent.ToString()));
            #endregion

            try
            {

                #region Build Mail Body DataTable

                DataTable mailRptDt = new DataTable();
                DataColumn s1 = new DataColumn("Mailing Report Summary");
                DataColumn s2 = new DataColumn(" ");
                mailRptDt.Columns.Add(s1);
                mailRptDt.Columns.Add(s2);

                DataRow row1 = mailRptDt.NewRow();
                row1[s1] = "Mailing Name:";
                row1[s2] = MailinName;
                mailRptDt.Rows.Add(row1);

                DataRow row2 = mailRptDt.NewRow();
                row2[s1] = "Subject Line:";
                row2[s2] = Subject;
                mailRptDt.Rows.Add(row2);

                DataRow row3 = mailRptDt.NewRow();
                row3[s1] = "Send Start Date:";
                row3[s2] = sentTime;
                mailRptDt.Rows.Add(row3);

                DataRow row4 = mailRptDt.NewRow();
                row4[s1] = "Send Completion Date :";
                row4[s2] = completionTime;
                mailRptDt.Rows.Add(row4);

                DataRow row5 = mailRptDt.NewRow();
                row5[s1] = "List Name:";
                row5[s2] = listName;
                mailRptDt.Rows.Add(row5);

                DataRow row6 = mailRptDt.NewRow();
                row6[s1] = "";
                row6[s2] = "";
                mailRptDt.Rows.Add(row6);

                DataRow row7 = mailRptDt.NewRow();
                row7[s1] = "Overall Stats";
                row7[s2] = "";
                mailRptDt.Rows.Add(row7);

                DataRow row8 = mailRptDt.NewRow();
                row8[s1] = "Contacts Targeted:";
                row8[s2] = TargetedCount;
                mailRptDt.Rows.Add(row8);

                DataRow row9 = mailRptDt.NewRow();
                row9[s1] = "Successful Delivered:";
                row9[s2] = DeliveredCount;
                mailRptDt.Rows.Add(row9);

                DataRow row10 = mailRptDt.NewRow();
                row10[s1] = "Bounce Count:";
                row10[s2] = BounceCount;
                mailRptDt.Rows.Add(row10);

                DataRow row11 = mailRptDt.NewRow();
                row11[s1] = "Open Count:";
                row11[s2] = OpenCount;
                mailRptDt.Rows.Add(row11);

                DataRow row12 = mailRptDt.NewRow();
                row12[s1] = "Click Count:";
                row12[s2] = ClickCount;
                mailRptDt.Rows.Add(row12);

                DataRow row13 = mailRptDt.NewRow();
                row13[s1] = "Unsubscribe Count:";
                row13[s2] = UnsubscribeCount;
                mailRptDt.Rows.Add(row13);

                DataRow row14 = mailRptDt.NewRow();
                row14[s1] = "Forward Count:";
                row14[s2] = forwardCount;
                mailRptDt.Rows.Add(row14);
                #endregion

                string dat = DateTime.Now.ToString("ddMMMyyyyhhmmssTT");
                string pPath = ConfigurationSettings.AppSettings["AttachFilePath"].ToString();
                string apiFromMail = ConfigurationSettings.AppSettings["ApiFromMail"].ToString();
                DirectoryInfo dirInfo = new DirectoryInfo(pPath);
                if (!dirInfo.Exists)
                    dirInfo.Create();
                pPath = Path.Combine(pPath, "MailingReport" + dat + ".csv");
                Logger.logdata(logforemailbuilder, string.Format("Attachment Path: {0}", pPath.ToString()));
                CreateCSVFile(mailRptDt, pPath);

                Logger.logdata(logforemailbuilder, string.Format("sendEmail(..) has been started at {0}", DateTime.Now.ToString()));

                bool status = sendEmail(apiFromMail, rptMailTo.ToString().Trim(), string.Empty, "Report", false, mailContent.ToString(), pPath, out message);
                if (status)
                {
                    Logger.logdata(logforemailbuilder, "Report Mail Sent Successfully to:'" + rptMailTo + "'");
                    #region Update Hours status in MailApproval Table

                    MailApproval objMailApproval = new MailApproval(clientConnectionString);
                    bool updateStatus = objMailApproval.UpdateHoursStatus(MailingId, RptSenthr);
                    if (updateStatus)
                        Logger.logdata(logforemailbuilder, string.Format("{0} Hours Status Updated Successfully at {1}", RptSenthr.ToString(), DateTime.Now.ToString()));
                    else
                        Logger.logdata(logforemailbuilder, string.Format("{0} Hours Status Updated Failed at {1}", RptSenthr.ToString(), DateTime.Now.ToString()));
                    #endregion
                }
                else
                {
                    Logger.logdata(logforemailbuilder, "Report Mail Sending Failed");
                }
                Logger.logdata(logforemailbuilder, string.Format("sendEmail(..) method has been ended at {0}", DateTime.Now.ToString()));
            }
            catch (Exception ex)
            {
            }
            Logger.logdata(logforemailbuilder, string.Format("getMailingRpt(..) method has been ended at {0}", DateTime.Now.ToString()));
            Logger.logdata(logforemailbuilder, "************** Exit getMailingRpt(..) method **************");
        }
Exemple #10
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="ListMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/6/2009 11:39:08 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(ListMasterPrimaryKey pk,string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // 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);

            oDatabaseHelper.ExecuteScalar("sp_ListMaster_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
        private void updateSegmentDetails()
        {
            ListMasterBase listMaster = new ListMasterBase(ConnectionString);
                SegmentMasterBase segmentMaster = new SegmentMasterBase(ConnectionString);
                ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hdfListId.Value));//hiddenEditID.Value));
                ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);

                listMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                listMaster.ListName = txtSegmentName.Text;
                listMaster.ListDesc = txtDescription.Text;
                listMaster.ModifiedDate = System.DateTime.Now;
                listMaster.CreatedDate = listMasterNew.CreatedDate;
                listMaster.IsSegment = true;
                listMaster.Update();

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

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

                        foreach (string contactID in contactids)
                        {
                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                            rowListContactMaster["ListMasterID"] = listid;
                            rowListContactMaster["ContactId"] = contactID;
                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["IsActive"] = true;
                            dtListContactMaster.Rows.Add(rowListContactMaster);
                        }
                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                    }
                }
                Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=create");
            }
            catch (Exception ex)
            {
                lblMainMsg.Text = "Error: " + ex.Message;
                rtsAddSegment.SelectedIndex = 0;
                rtsAddSegment.MultiPage.SelectedIndex = 0;
            }
        }
        //this method is used to insert the recipients of a single ImportJob into ListContactMaster and ContactMaster table
        public void ProcessSingleImportRecipients(DataRow dr)
        {
            bool isFirstRowHeader = false;
            bool isSendNotificationEmail = false;
            char[] delimiterChar = null;
            DataTable dtFileData = null;
            string[] strFileData = null;
            StreamReader sr = null;
            int JobID = 0;
            try
            {
                Logger.logdata(logforimportrecipients, "************** in ProcessSingleImportRecipients(..) method **************");
                Logger.logdata(logforimportrecipients, string.Format("ProcessSingleImportRecipients(..) has been started at {0}", DateTime.Now.ToString()));

                Logger.logdata(logforimportrecipients, string.Format("Import process satarted for job with ID: {0} at {1}", dr["ID"].ToString(), DateTime.Now.ToString()));
                //Get the filename of imported file.
                string filename = dr["GuidFilename"].ToString();
                ImportJobID = dr["ID"].ToString();
                DateTime importStartTime = DateTime.Now;
                if (File.Exists(Path.Combine(importFilePath, filename)))
                {
                    //update import job status
                    ImportJobPrimaryKey objImportJobPrimaryKey = new ImportJobPrimaryKey(Convert.ToInt64(ImportJobID));
                    ImportJob objImportJob = ImportJob.SelectOne(objImportJobPrimaryKey, connectionString);
                    objImportJob.Status = Common.ImportStatus.InProcess.ToString();
                    objImportJob.Update();
                    //Insert Import History
                    ReplyPositiveBL.ImportHistory objImportHistory = new ReplyPositiveBL.ImportHistory(connectionString);
                    objImportHistory.ImportJobID = Convert.ToInt64(ImportJobID);
                    objImportHistory.Staus = "Processing";
                    objImportHistory.StatusMessage = "File import is in processing.";
                    //objImportHistory.UpdatedCount = updatedCount;
                    //objImportHistory.InsertedCount = insertedCount;
                    objImportHistory.StartTime = importStartTime;
                    //objImportHistory.EndTime = DateTime.Now;
                    objImportHistory.InsertandReturnID(ref JobID);

                    isSendNotificationEmail = Convert.ToBoolean(dr["Notification"].ToString());
                    isFirstRowHeader = Convert.ToBoolean(dr["IsFileHasHeader"].ToString());
                    delimiterChar = getSeparatorChar(dr["FileType"].ToString());
                    Logger.logdata(logforimportrecipients, string.Format("import filepath: {0}", Path.Combine(importFilePath, filename)));
                    //Read the import file  content.
                    FileStream Stream = new FileStream(Path.Combine(importFilePath, filename), FileMode.Open, FileAccess.Read);
                    Logger.logdata(logforimportrecipients, string.Format("stream length: {0}", Stream.Length));
                    //convert file stream to datatable.
                    if (dr["FileType"].ToString().Equals("Excel(.xls, .xlsx)"))
                    {
                        if (filename.EndsWith(".xls"))
                            dtFileData = getDataTableOfExcel(Stream, filename, false);
                        else
                        {
                            string path = Path.Combine(importFilePath, filename);
                            System.Data.DataTable Contacts = new System.Data.DataTable();

                            ReadXlsx.Application xlApp;
                            ReadXlsx.Workbook xlWorkBook;
                            ReadXlsx.Worksheet xlWorkSheet;

                            xlApp = new ReadXlsx.ApplicationClass();
                            xlWorkBook = xlApp.Workbooks.Open(path, 0, true, 5, "", "", true, ReadXlsx.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                            xlWorkSheet = (ReadXlsx.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                            int r;
                            int c;
                            int intRows;
                            int intCols;
                            ReadXlsx.Range excelCell = xlWorkSheet.UsedRange;
                            Object[,] values = (Object[,])excelCell.Value2;
                            intRows = values.GetLength(0);
                            if (intRows != 0)
                            {
                                intCols = values.GetLength(1);
                                if (intCols != 0)
                                {
                                    for (c = 1; c <= intCols; c++)
                                    {
                                        Contacts.Columns.Add(new DataColumn("Column" + c));
                                    }
                                    for (r = 1; r <= intRows; r++)
                                    {
                                        DataRow tblRow = Contacts.NewRow();
                                        for (c = 0; c < Contacts.Columns.Count; c++)
                                        {
                                            tblRow[c] = (values[r, (c + 1)] == null) ? string.Empty : values[r, (c + 1)];

                                        }
                                        Contacts.Rows.Add(tblRow);
                                    }
                                }
                            }
                            dtFileData = Contacts;
                            xlWorkSheet = null;
                            xlWorkBook.Close(Missing.Value, Missing.Value, Missing.Value);
                            xlWorkBook = null;
                            xlApp.Quit();
                            xlApp = null;
                        }
                    }
                    else
                    {
                        sr = new StreamReader(Stream);
                        strFileData = sr.ReadToEnd().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        dtFileData = convertFileToDatatable(strFileData, isFirstRowHeader, delimiterChar);
                    }

                    //remove header from datatable if first row is header.
                    if (isFirstRowHeader)
                    {
                        dtFileData.Rows.RemoveAt(0);
                    }

                    //get fieldmap

                    sqlQry = "select * from Fieldmap where ImportJobID =" + ImportJobID;
                    ds = getDataset(sqlQry);
                    DataTable dtFieldMap = ds.Tables[0];

                    //The following code is for removing Unmapped columns while importing a file to List
                    if (dtFileData.Columns.Count != dtFieldMap.Rows.Count)
                    {
                        string[] ActualColumns = (from dc in dtFileData.Columns.Cast<DataColumn>() select dc.ColumnName).ToArray();
                        string[] MappedColumns = dtFieldMap.AsEnumerable().Select(row => row.Field<string>("SourceField")).ToArray();
                        string[] UnMappedColumns = ActualColumns.Except(MappedColumns).ToArray();
                        foreach (string clm in UnMappedColumns)
                        {
                            if (dtFileData.Columns.Contains(clm))
                                dtFileData.Columns.Remove(clm);
                        }
                    }
                    //Bulk insert the import file content in to temp table.
                    //insertImportingContactsInToTemp(dtFileData, dtFieldMap, ImportJobID);

                    //Logger.logdata(logforimportrecipients, string.Format("imported file records are bulk inserted to temp table: {0}", dtFileData.Rows.Count));

                    // process file data
                    if (dtFileData.Rows.Count > 0)
                    {
                        Logger.logdata(logforimportrecipients, string.Format("total number of records found in imported file: {0}", dtFileData.Rows.Count));
                        string emailAddressColumn = dtFieldMap.Select("DestinationField='EmailAddress'")[0]["SourceField"].ToString();

                        var v = from item in dtFieldMap.AsEnumerable() where item["DestinationField"].ToString() == "IsActive" select item;
                        foreach (var obj in v)
                        {
                            IsActiveField = dtFieldMap.Select("DestinationField='IsActive'")[0]["SourceField"].ToString();
                        }

                        DataTable dtValidEmailData = checkInValidEmailAddresses(dtFileData, emailAddressColumn, IsActiveField);
                        //to select distinct rows
                        //dtValidEmailData = dtValidEmailData.DefaultView.ToTable(true, Columns);
                        dtValidEmailData = RemoveDuplicateRows(dtValidEmailData, emailAddressColumn, dtFieldMap);
                        Logger.logdata(logforimportrecipients, string.Format("valid recipients count in selected file: {0}", dtValidEmailData.Rows.Count));
                        int totalRecipientsFound = dtFileData.Rows.Count;
                        int validRecipientsFound = dtValidEmailData.Rows.Count;
                        int inValidRecipientsFound = totalRecipientsFound - validRecipientsFound;
                        int insertedCount = 0;
                        int updatedCount = 0;
                        if (dtValidEmailData.Rows.Count == 0)
                        {
                            //throw new Exception("Please select proper file to import.");
                        }
                        //upsert into contactmaster and listcontactmaster based on importlimit.
                        var AllRecords = from item in dtValidEmailData.AsEnumerable() select item;
                        Logger.logdata(logforimportrecipients, string.Format("all records count in selected file: {0}", AllRecords.Count()));
                        int nextRecords = 0;
                        int importLimit = Convert.ToInt32(ConfigurationManager.AppSettings["ImportRecipientsLimit"].ToString());
                        Logger.logdata(logforimportrecipients, string.Format("Import limit: {0}", importLimit));
                        while (true)
                        {
                            Logger.logdata(logforimportrecipients, string.Format("looping records: {0}", nextRecords));
                            var top1000 = AllRecords.Skip(nextRecords).Take(importLimit);
                            if (top1000.Count() == 0)
                            {
                                break;
                            }
                            else
                            {
                                DataTable dtContacts = dtValidEmailData.Clone();
                                top1000.CopyToDataTable(dtContacts, LoadOption.PreserveChanges);
                                DataTable dtListContactMasterResult = ImportRecordsToContactMaster(dtContacts, dtFieldMap, dr);
                                insertedCount += Convert.ToInt32(dtListContactMasterResult.Compute("Count(Status)", "Status='INSERT' and ListMasterID=" + Convert.ToInt64(dr["ListID"].ToString())));
                                updatedCount += Convert.ToInt32(dtListContactMasterResult.Compute("Count(Status)", "Status='UPDATE' and ListMasterID=" + Convert.ToInt64(dr["ListID"].ToString())));
                                nextRecords = nextRecords + importLimit;
                            }
                        }
                        Logger.logdata(logforimportrecipients, string.Format("total number of records inserted: {0}", insertedCount));
                        Logger.logdata(logforimportrecipients, string.Format("total number of records found updated: {0}", updatedCount));

                        //build html string to send notification email.
                        //get listname of listid``````````````
                        ListMasterPrimaryKey objListMasterPrimaryKey = new ListMasterPrimaryKey(Convert.ToInt64(dr["ListID"]));
                        ListMaster objListmaster = ListMaster.SelectOne(objListMasterPrimaryKey, connectionString);

                        StringBuilder objStringBuilder = new StringBuilder();
                        objStringBuilder.Append("<table width=100%>");
                        objStringBuilder.Append("<tr><td>" + string.Format("Imported file: <b>{0}</b>.", dr["Filename"].ToString()) + "</td></tr>");
                        objStringBuilder.Append("<tr><td>" + string.Format("Total number of recipients found: <b>{0}</b>.", totalRecipientsFound) + "</td></tr>");
                        objStringBuilder.Append("<tr><td>" + string.Format("Number of valid recipients found: <b>{0}</b>.", validRecipientsFound) + "</td></tr>");
                        objStringBuilder.Append("<tr><td>" + string.Format("Number of InValid recipients found: <b>{0}</b>.", inValidRecipientsFound) + "</td></tr>");
                        objStringBuilder.Append("<br>");
                        objStringBuilder.Append("<br>");
                        objStringBuilder.Append("<tr><td><b>ListName</b></td><td><b>Inserted</b></td><td><b>Updated</b></td>");
                        objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");
                        objStringBuilder.Append("<tr><td>" + objListmaster.ListName + "</td><td>" + insertedCount + "</td><td>" + updatedCount + "</td></tr>");

                        //update import job status
                        //ImportJobPrimaryKey
                        objImportJobPrimaryKey = new ImportJobPrimaryKey(Convert.ToInt64(ImportJobID));
                        //ImportJob
                        objImportJob = ImportJob.SelectOne(objImportJobPrimaryKey, connectionString);
                        objImportJob.Status = Common.ImportStatus.Success.ToString();
                        objImportJob.Update();

                        //Insert Import History
                        //ReplyPositiveBL.ImportHistory
                        objImportHistory = new ReplyPositiveBL.ImportHistory(connectionString);
                        objImportHistory.ImportJobID = Convert.ToInt64(ImportJobID);
                        objImportHistory.Staus = "SUCCESS";
                        objImportHistory.StatusMessage = "File import process completed successfully.";
                        objImportHistory.UpdatedCount = updatedCount;
                        objImportHistory.InsertedCount = insertedCount;
                        objImportHistory.InvalidCount = inValidRecipientsFound;
                        objImportHistory.StartTime = importStartTime;
                        objImportHistory.ID = JobID;
                        objImportHistory.EndTime = DateTime.Now;

                        objImportHistory.Update();

                        //send notification email.
                        if (isSendNotificationEmail)
                            sendNotificationMail(objStringBuilder.ToString(), dr["NotificationEmailIDs"].ToString(), filename);
                    }
                }
                Logger.logdata(logforimportrecipients, string.Format("Import process ended for job with ID: {0} at {1}", dr["ID"].ToString(), DateTime.Now.ToString()));
                Logger.logdata(logforimportrecipients, string.Format("ProcessSingleImportRecipients(..) method has been ended at {0}", DateTime.Now.ToString()));
                Logger.logdata(logforimportrecipients, "************** Exit ProcessSingleImportRecipients(..) method **************");
            }
            catch (Exception ex)
            {
                //update import job status
                ImportJobPrimaryKey objImportJobPrimaryKey = new ImportJobPrimaryKey(Convert.ToInt64(ImportJobID));
                ImportJob objImportJob = ImportJob.SelectOne(objImportJobPrimaryKey, connectionString);
                objImportJob.Status = Common.ImportStatus.Error.ToString();
                objImportJob.Update();
                throw ex;
            }
        }
Exemple #14
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;
        }
        protected void SingleMailingCounts(string campaignID, string mailingId)
        {
            if (ddlMailingNames.SelectedItem.Text != defaultMailingItem)
                lblCampaignTitle.Text = ddlMailingNames.SelectedItem.Text.ToString();
            else if (ddlCampaignsNames.SelectedItem.Text != defaultCampItem)
                lblCampaignTitle.Text = ddlCampaignsNames.SelectedItem.Text.ToString();
            else
            {
                lblCampaignTitle.Text = string.Empty;
            }
            Session["TitleName"] = lblCampaignTitle.Text;

            string selectedList = string.Empty;
            if (mailingId != string.Empty || campaignID != string.Empty)
            {
                long ActiveCount = 0;
                lblContactsTargeted.Text = "0";
                lblSuccessfulDeliveries.Text = "0";
                lblUnsubscribe.Text = "0";
                lblTotalOpens.Text = "0";
                lblUniqueopens.Text = "0";
                lblBounces.Text = "0";
                lblTotalClicks.Text = "0";
                lblUniqueClicks.Text = "0";
                lblForwrds.Text = "0";
                List<string> listsSelected = new List<string>();
                List<string> xValues = new List<string>();
                List<double> yValues = new List<double>();

                string startMailingId = string.Empty;
                string endingMailingId = string.Empty;
                if (ddlCampaignsNames.SelectedItem.Text != defaultCampItem || ddlMailingNames.SelectedItem.Text!=defaultMailingItem)
                {
                    if (ddlMailingNames.SelectedItem.Text == defaultMailingItem)
                    {
                        //Get the Latest Sent Mailing.
                        startMailingId = ddlMailingNames.Items[1].Value.ToString();
                        CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(startMailingId));
                        objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);

                        objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(startMailingId), ConnectionString);
                        lblSendCompletionDate.Text = objCampaignjob[0].CompletionTime.ToString();

                        //Get the First Sent Mailing.
                        endingMailingId = ddlMailingNames.Items[ddlMailingNames.Items.Count - 1].Value.ToString();
                        if (ddlCampaignsNames.SelectedItem.Text != defaultCampItem)
                        {
                            objEndCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(endingMailingId), ConnectionString);
                            lblSendStartDate.Text = objEndCampaignjob[0].StartTime.ToString();
                        }
                        else
                        {
                            lblSendStartDate.Text = objCampaignjob[0].StartTime.ToString();
                        }
                    }
                    else
                    {
                        CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId));
                        objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);

                        objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(mailingId), ConnectionString);
                        lblSendStartDate.Text = objCampaignjob[0].StartTime.ToString();
                        lblSendCompletionDate.Text = objCampaignjob[0].CompletionTime.ToString();
                    }
                }
                if (mailingId.Length != 0)
                {

                    if (objCampaignMaster.Subject.Length > 30)
                        lblSubject.Text = objCampaignMaster.Subject.Substring(0, 30) + "..";
                    else
                        lblSubject.Text = objCampaignMaster.Subject.ToString();
                    lblSubject.ToolTip = objCampaignMaster.Subject.ToString();
                    lblsentDateTime.Text = "Sent: " + objCampaignjob[0].CompletionTime.ToString();
                    Session["SentDateTime"] = lblsentDateTime.Text;

                    string SelectCondition = objCampaignMaster.SelectCondition;
                    string[] ListIds = SelectCondition.Split(',');

                    StringBuilder selectedListExport = new StringBuilder();

                    //Commented by Swaroop no need to touch the db iam take the count form indivitual tables code written bellow
                    ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                    DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, mailingId.ToString());
                    Session["ContactsTargeted"] = dtcontacts;
                    foreach (var Id in ListIds)
                    {
                        if (Id != "")
                        {
                            ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(Id));
                            ListMaster list = ListMaster.SelectOne(pk, ConnectionString);
                            if (list != null)
                            {
                                bool IsListRemoved = true;
                                if (list.IsDeleted == null || list.IsDeleted == false)
                                    IsListRemoved = false;

                                if (!IsListRemoved)
                                    selectedList += list.ListName.ToString() + ",";
                                else
                                {
                                    selectedList += list.ListName.ToString() + "(List has been removed),";
                                }

                                listsSelected.Add(list.ListName);
                            }
                        }
                    }
                    if (selectedList != "")
                        selectedList = selectedList.TrimEnd(',');
                    if (selectedList.Length > 0)
                    {
                        lblSelectedList.Style.Add("color", "#717171");
                        selectedList.Remove(selectedList.Length - 2, 1);
                        lblSelectedList.Text = selectedList.ToString();
                        Session["ListNames"] = selectedList.ToString();
                    }
                    else
                    {
                        selectedList = "The List has been moved or removed";
                        Session["ListNames"] = selectedList.ToString();
                        lblSelectedList.Text = string.Empty;
                        lblSelectedList.Style.Add("color", "red");
                        lblSelectedList.Text = "The List has been moved or removed";
                    }
                    if (selectedList.Length >= 30)
                    {
                        lblSelectedList.Text = selectedList.Substring(0, 30) + "...";
                        lblSelectedList.ToolTip = selectedList;
                    }
                }
                lblResultsAsOf.Text = DateTime.Now.ToString();
                //Bellow mailingId become to empty bcz. when iam selecting only Campaign not Mailing at that time only we want to disply latest sent Mailing Info of particular Campaign.
                if (hdfMailingID.Value == string.Empty)
                    mailingId = string.Empty;

                #region Swaroop
                //Get the values form Individual Tables Link EmailOpenDatils Developed By Swaroop etc...

                DataTable ListSuccessfulDelivered, emailsOpened, emailsClicked, BounceRecipients, forwardRecipients, ListUnsubScribeRecipients = null;

                if (mailingId != string.Empty)
                {
                    ListSuccessfulDelivered = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, Convert.ToInt32(mailingId));
                    sentcount = ListSuccessfulDelivered.Rows.Count;
                }
                else
                {
                    ListSuccessfulDelivered = ContactMaster.SelectSuccessfulDeliveredByAssignCampId(ConnectionString, Convert.ToInt32(campaignID));
                    sentcount = ListSuccessfulDelivered.Rows.Count;
                }

                if (mailingId != string.Empty)
                {
                    emailsOpened = ContactMaster.EmailOpendRecByCampId_PageWise(ConnectionString, mailingId, "ContactId", "desc", 0, 10, out Count, out TotalOpenCounts, out UniqueOpenCounts);
                    opencount = UniqueOpenCounts;
                }
                else
                {
                    emailsOpened = ContactMaster.EmailOpendRecByAssignCampId_PageWise(ConnectionString, campaignID, "ContactId", "desc", 0, 10, out Count, out TotalOpenCounts, out UniqueOpenCounts);
                    opencount = UniqueOpenCounts;
                }
                if (mailingId != string.Empty)
                {
                    emailsClicked = ContactMaster.EmailClickedRecByCampId_PageWise(ConnectionString, mailingId, "ContactId", "desc", 0, 10, out Count, out TotalClickCounts, out UniqueClickCounts);
                }
                else
                {
                    emailsClicked = ContactMaster.EmailClickedRecByAssignCampId_PageWise(ConnectionString, campaignID, "ContactId", "desc", 0, 10, out Count, out TotalClickCounts, out UniqueClickCounts);
                }
                if (mailingId != string.Empty)
                {
                    BounceRecipients = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, Convert.ToInt32(mailingId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                    bouncecount = BounceRecipients.Rows.Count;
                }
                else
                {
                    BounceRecipients = ContactMaster.SelectRecipientsBounceRecByAssignCampId(ConnectionString, Convert.ToInt32(campaignID), out TotalBounceCount, out SoftBounceCount, out HardBounceCount);
                    bouncecount = TotalBounceCount;
                }

                unopencount = sentcount - opencount;
                if (mailingId != string.Empty)
                {
                    forwardRecipients = ContactMaster.SelectForwardRecipients(ConnectionString, Convert.ToInt32(mailingId));
                    Fcount = forwardRecipients.Rows.Count;
                }
                else
                {
                    forwardRecipients = ContactMaster.SelectForwardRecipientsByAssignId(ConnectionString, Convert.ToInt32(campaignID), out TotalForwardCount);
                    Fcount = TotalForwardCount;
                }
                if (mailingId != string.Empty)
                {
                    ListUnsubScribeRecipients = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, Convert.ToInt32(mailingId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount);
                    UnSubscribeCount = ListUnsubScribeRecipients.Rows.Count;
                }
                else
                {
                    ListUnsubScribeRecipients = ContactMaster.SelectUnsubscribeRecipientsByAssignedCampId(ConnectionString, Convert.ToInt32(campaignID), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount, out TotalUnsubCount);
                    UnSubscribeCount = TotalUnsubCount;
                }

                yValues.Clear();
                if (sentcount != 0)
                {
                    yValues.Add(Convert.ToDouble(opencount));
                    yValues.Add(Convert.ToDouble(bouncecount));
                    yValues.Add(Convert.ToDouble(unopencount));
                }

                #endregion

                lblRecipients.Text = (sentcount + bouncecount).ToString();
                ActiveCount = sentcount + bouncecount;
                double TotalCount = sentcount + bouncecount;
                double plotY = 0;
                ShowCampaignCountChart.Series["Series1"].Points.Clear();
                if (yValues.Count != 0)
                {
                    for (int pointIndex = 0; pointIndex < yValues.Count; pointIndex++)
                    {
                        plotY = yValues[pointIndex];
                        ShowCampaignCountChart.Series["Series1"].Points.AddY(plotY);
                        ShowCampaignCountChart.Series["Series1"].Points[pointIndex].LabelForeColor = System.Drawing.Color.White;
                    }

                    ShowCampaignCountChart.Series["Series1"].Points[0].LegendText = "Open" + " " + ((Convert.ToDouble(yValues[0].ToString()) / TotalCount) * 100).ToString("###########0.00") + "%" + " (" + yValues[0].ToString() + ")";
                    ShowCampaignCountChart.Series["Series1"].Points[1].LegendText = "Bounce" + " " + ((Convert.ToDouble(yValues[1].ToString()) / TotalCount) * 100).ToString("###########0.00") + "%" + " (" + yValues[1].ToString() + ")";
                    ShowCampaignCountChart.Series["Series1"].Points[2].LegendText = "Unopen" + " " + ((Convert.ToDouble(yValues[2].ToString()) / TotalCount) * 100).ToString("###########0.00") + "%" + " (" + yValues[2].ToString() + ")";

                    //Display tooltip for the chart
                    ShowCampaignCountChart.Series["Series1"].Points[0].ToolTip = "Open Count:" + yValues[0].ToString() + " (" + Math.Round((double.Parse(yValues[0].ToString()) * 100 / TotalCount)).ToString() + "%" + ")";
                    ShowCampaignCountChart.Series["Series1"].Points[1].ToolTip = "Bounce Count:" + yValues[1].ToString() + " (" + Math.Round((double.Parse(yValues[1].ToString()) * 100 / TotalCount)).ToString() + "%" + ")";
                    ShowCampaignCountChart.Series["Series1"].Points[2].ToolTip = "Unopen Count:" + yValues[2].ToString() + " (" + Math.Round((double.Parse(yValues[2].ToString()) * 100 / TotalCount)).ToString() + "%" + ")";
                    //Applying colors
                    ShowCampaignCountChart.Series["Series1"].Points[0].Color = System.Drawing.Color.Green;
                    ShowCampaignCountChart.Series["Series1"].Points[1].Color = System.Drawing.Color.Red;
                    ShowCampaignCountChart.Series["Series1"].Points[2].Color = System.Drawing.Color.DarkBlue;

                    //show Chart
                    ShowCampaignCountChart.Series["Series1"].ChartType = SeriesChartType.Pie;
                    ShowCampaignCountChart.Series["Series1"]["PieStartAngle"] = "30";

                    //get sum of sentcount for selected campaign .
                    double sendcount = Convert.ToDouble(sentcount);
                    double targetcount = sendcount + yValues[1];
                    //showing value in table
                    lblContactsTargeted.Text = lblContactsTargeted.Text != null ? ActiveCount.ToString() : "0";
                    lblSuccessfulDeliveries.Text = sendcount.ToString() != "" ? sendcount + "(" + Math.Round((sendcount) * 100 / ActiveCount).ToString() + "%" + ")" : "0";
                    lblBounces.Text = yValues[1].ToString() != null ? yValues[1].ToString() + "(" + Math.Round((double.Parse(yValues[1].ToString()) * 100 / ActiveCount)).ToString() + "%" + ")" : "0";

                    lblUnsubscribe.Text = UnSubscribeCount.ToString();
                    lblForwrds.Text = Fcount.ToString() != null ? Fcount.ToString() : "0";

                    lblTotalOpens.Text = TotalOpenCounts.ToString();
                    lblUniqueopens.Text = UniqueOpenCounts.ToString() != null ? UniqueOpenCounts.ToString() + "(" + Math.Round((double.Parse(UniqueOpenCounts.ToString()) * 100 / sendcount)).ToString() + "%" + ")" : "0";

                    lblUniqueClicks.Text = UniqueClickCounts.ToString();
                    lblTotalClicks.Text = TotalClickCounts.ToString();
                }
                else
                    Session["allCounts"] = null;
                # region DataExportToExcel
                string str = selectedList.ToString(); //.Replace(",", ";");
                DataTable dtExportSummary = new DataTable();
                DataColumn s1;
                if (ddlMailingNames.SelectedItem.ToString() != defaultMailingItem)
                    s1 = new DataColumn("Dashboard: Mailing Report Summary");
                else
                    s1 = new DataColumn("Dashboard: Campaign Report Summary");

                DataColumn s2 = new DataColumn("  ");
                DataColumn s3 = new DataColumn(" ");
                dtExportSummary.Columns.Add(s1);
                dtExportSummary.Columns.Add(s2);
                dtExportSummary.Columns.Add(s3);

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

                if (ddlMailingNames.SelectedItem.ToString() != defaultMailingItem)
                    row1[s2] = ddlMailingNames.SelectedItem.ToString();
                else
                    row1[s2] = ddlCampaignsNames.SelectedItem.ToString();
                row1[s3] = "";
                dtExportSummary.Rows.Add(row1);

                DataRow row2 = dtExportSummary.NewRow();
                row2[s1] = "Subject Line:";
                row2[s2] = lblSubject.ToolTip.ToString();
                row2[s3] = "";
                dtExportSummary.Rows.Add(row2);

                DataRow row3 = dtExportSummary.NewRow();
                row3[s1] = "Results as of :";
                row3[s2] = lblResultsAsOf.Text.ToString();
                row3[s3] = "";
                dtExportSummary.Rows.Add(row3);

                DataRow row4 = dtExportSummary.NewRow();
                row4[s1] = "Send Start Date : ";
                row4[s2] = lblSendStartDate.Text.ToString();
                row4[s3] = "";
                dtExportSummary.Rows.Add(row4);

                DataRow row5 = dtExportSummary.NewRow();
                row5[s1] = "Send Completion Date : ";
                row5[s2] = lblSendCompletionDate.Text.ToString();
                row5[s3] = "";
                dtExportSummary.Rows.Add(row5);

                DataRow row6 = dtExportSummary.NewRow();
                row6[s1] = "List(s) Selected : ";
                row6[s2] = str.ToString();
                row6[s3] = "";
                dtExportSummary.Rows.Add(row6);

                DataRow row7 = dtExportSummary.NewRow();
                row7[s1] = "Overall Stats";
                row7[s2] = "";
                row7[s3] = "";
                dtExportSummary.Rows.Add(row7);

                DataRow row8 = dtExportSummary.NewRow();
                row8[s1] = "Contacts Targeted:";
                row8[s2] = lblContactsTargeted.Text;
                row8[s3] = "";
                dtExportSummary.Rows.Add(row8);

                DataRow row9 = dtExportSummary.NewRow();
                row9[s1] = "Successful Deliveries:";
                row9[s2] = lblSuccessfulDeliveries.Text;
                row9[s3] = "";
                dtExportSummary.Rows.Add(row9);

                DataRow row10 = dtExportSummary.NewRow();
                row10[s1] = "Bounced:";
                row10[s2] = lblBounces.Text;
                row10[s3] = "";
                dtExportSummary.Rows.Add(row10);

                DataRow row11 = dtExportSummary.NewRow();
                row11[s1] = "Unsubscribes:";
                row11[s2] = lblUnsubscribe.Text;
                row11[s3] = "";
                dtExportSummary.Rows.Add(row11);

                DataRow row12 = dtExportSummary.NewRow();
                row12[s1] = "Unique Opens:";
                row12[s2] = lblUniqueopens.Text;
                row12[s3] = "";
                dtExportSummary.Rows.Add(row12);

                DataRow row13 = dtExportSummary.NewRow();
                row13[s1] = "Total Opens:";
                row13[s2] = lblTotalOpens.Text;
                row13[s3] = "";
                dtExportSummary.Rows.Add(row13);

                DataRow row14 = dtExportSummary.NewRow();
                row14[s1] = "Unique Clicks:";
                row14[s2] = lblUniqueClicks.Text;
                row14[s3] = "";
                dtExportSummary.Rows.Add(row14);

                DataRow row15 = dtExportSummary.NewRow();
                row15[s1] = "Total Clicks:";
                row15[s2] = lblTotalClicks.Text;
                row15[s3] = "";
                dtExportSummary.Rows.Add(row15);

                DataRow row16 = dtExportSummary.NewRow();
                row16[s1] = "Forwards:";
                row16[s2] = lblForwrds.Text;
                row16[s3] = "";
                dtExportSummary.Rows.Add(row16);

                ViewState["CampaignExportSummary"] = dtExportSummary;
                #endregion
            }
            else
            {
                lblContactsTargeted.Text = "0";
                lblSuccessfulDeliveries.Text = "0";
                lblTotalOpens.Text = "0";
                lblUnsubscribe.Text = "0";
                lblUniqueopens.Text = "0";
                lblBounces.Text = "0";
                lblUniqueClicks.Text = "0";
                lblForwrds.Text = "0";
                lblTotalClicks.Text = "0";
                lblCampaignTitle.Text = string.Empty;
                lblSubject.Text = string.Empty;
                lblResultsAsOf.Text = string.Empty;
                lblSendStartDate.Text = string.Empty;
                lblSendCompletionDate.Text = string.Empty;
                lblsentDateTime.Text = string.Empty;
                lblRecipients.Text = string.Empty;
                lblSelectedList.Text = string.Empty;
                ShowCampaignCountChart.Series["Series1"].Points.Clear();
            }
        }
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;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string ConnectionString = string.Empty;
            string username = txtusername.Text;
            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);
            Int64 MailingID = Convert.ToInt64(txtmailingid.Text);
            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);
                    string[] ListId = objCampaignMaster.SelectCondition.ToString().Split(',');
                    ListMaster listMaster;
                    ListMasterPrimaryKey pkList;
                    if (ListId.Length > 0 && ListId[0].Trim().Length>0)
                    {
                        pkList = new ListMasterPrimaryKey(Convert.ToInt32(ListId[0]));
                        listMaster = ListMaster.SelectOne(pkList, ConnectionString);
                        ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                        lblMailingListName.Text = listMaster.ListName;
                        lblMailingListID.Text = listMaster.ListMasterID.ToString();
                        //DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, MailingID.ToString());
                    }

                    //long ActiveCount = Convert.ToInt64(dtcontacts.Rows.Count);
                    long ActiveCount = Convert.ToInt64(objCampaignjob[0].TotalRecipients);

                    if (objCampaignMaster.SelectCondition.Length > 0)
                        lblListCreatedStatus.Text = "Yes";
                    else
                        lblListCreatedStatus.Text = "No";

                    if (objCampaignjob[0] != null && objCampaignjob[0].ScheduledDatetime.ToString().Length > 0)
                        lblScheduleStatus.Text = "Yes";
                    else
                        lblScheduleStatus.Text = "No";

                    MailApprovals objMailApprovals = MailApproval.SelectByField("MailingID", MailingID, ConnectionString);

                    if (objMailApprovals.Count > 0)
                    {
                        if (objMailApprovals[0].ApprovalStatus == "Approved")
                            lblApprovedStatus.Text = "Yes";
                        else
                            lblApprovedStatus.Text = "Waiting For Approval";
                    }
                    if (objCampaignjob.Count > 0 && objCampaignjob[0].CompletionTime != null)
                    {
                        lblMailSendingProcessStatus.Text = "No";
                        lblMailCompleteStatus.Text = "Yes";
                    }
                    else
                    {
                        lblMailSendingProcessStatus.Text = "Yes";
                        lblMailCompleteStatus.Text = "No";
                    }

                    lblClient.Text = txtusername.Text;
                    lblMailingName.Text = objCampaignMaster.CampaignName.ToString();
                    lblMailingID.Text = objCampaignMaster.CampaignId.ToString();
                    lblFromName.Text = objCampaignMaster.FromName;
                    lblFromMail.Text = objCampaignMaster.FromAddress;
                    lblSubject.Text = objCampaignMaster.Subject;
                    lblReplyToMail.Text = objCampaignMaster.ReplytoAddress;

                    lblMailingListFileQuantity.Text = ActiveCount.ToString();
                    if (objCampaignMaster.SuppressSelection != "0" && objCampaignMaster.SuppressSelection != "")
                    {
                        ListContactMasters objListContacts = ListContactMaster.SelectByField("ListMasterID", objCampaignMaster.SuppressSelection, ConnectionString);
                        lblSuppressListFileQuantity.Text = objListContacts.Count.ToString();
                    }

                    if (objCampaignjob.Count > 0)
                        lblScheduleDate.Text = objCampaignjob[0].ScheduledDatetime.ToString();

                }
                else
                    lblmsg.Text = "Mailing with id: " + MailingID + " not exist";
            }
            else
                lblmsg.Text = "Invalid UserName/Password";
        }
Exemple #18
0
        /// <summary>
        /// Edit Lists save click event / this code is developed by swaraj on 25jan 2010
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lBtnSaveList_Click(object sender, EventArgs e)
        {
            try
            {
                string ListName = txtEditListName.Text.ToString();
                ListMasters list = ListMaster.SelectByField("ListName", txtEditListName.Text.Trim(), ConnectionString);
                ListMaster listMaster = new ListMaster(ConnectionString);
                listMaster.ListName = txtEditListName.Text;
                listMaster.ListDesc = txtEditListDescription.Text;
                listMaster.ListCowner = txtEditListCreationowner.Text;
                if (chkESuppress.Checked)
                    listMaster.Active = false;
                else
                    listMaster.Active = true;

                if (chkESeedList.Checked)
                    listMaster.IsSeedList = true;
                else
                    listMaster.IsSeedList = false;
                // allow if id is greater than 0
                if (Convert.ToInt64(hiddenEditID.Value) > 0)
                {
                    listMaster.ListMasterID = Convert.ToInt64(hiddenEditID.Value);
                    // checking wheather existed list
                    if (list.Count > 0 && list[0].ListMasterID != Convert.ToInt64(hiddenEditID.Value))
                    {
                        lbMsg2.Text = "List:" + txtEditListName.Text + ",  already exists. Please enter other name.";
                        MpextDivEdit.Show();
                    }
                    else
                    {
                        ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hiddenEditID.Value));
                        ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);
                        listMaster.CreatedDate = listMasterNew.CreatedDate;
                        listMaster.ModifiedDate = System.DateTime.Now;
                        if (listMaster.Update() == true)
                        {
                            lblMainMsg.Text = string.Format("List: {0} Updated Successfully.", Server.HtmlEncode(txtEditListName.Text));
                            hiddenEditID.Value = null;
                        }
                        else
                        {
                            lblMainMsg.Text = string.Format("List: {0} Updation Failed.", Server.HtmlEncode(txtEditListName.Text));
                        }
                        bindGrid("", "ASC", "ListName");
                        // if user edit the list in search mode
                    }
                }
                else
                {
                    lbMsg2.Text = "Invalid ID";
                }
            }
            catch (Exception ex)
            {
                lbMsg2.Text = ex.Message.ToString();
            }
            finally
            {
            }
        }
Exemple #19
0
 public XmlDocument EditList(string UserID, string Password, int ListId, string ListName, string ListDes, string ListOwner)
 {
     XmlDocument doc = new System.Xml.XmlDocument();
     StringBuilder str = new StringBuilder();
     str.Append("<ListsEditInfo>");
     string ConnectionString = GetConnectionString(UserID, Password);
     if (ListId > 0 && ConnectionString.Trim().Length != 0)
     {
         ListMasterPrimaryKey pk = new ListMasterPrimaryKey(ListId);
         ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
         if (listMaster.ListName.ToString() == ListName)
         {
             listMaster.ListDesc = ListDes;
             listMaster.ListCowner = ListOwner;
             listMaster.ModifiedDate = System.DateTime.Now;
         }
         else
         {
             listMaster.ListName = ListName;
             listMaster.ListDesc = ListDes;
             listMaster.ListCowner = ListOwner;
             listMaster.ModifiedDate = System.DateTime.Now;
         }
         if (listMaster.Update() == true)
         {
             str.Append("<Message> List Updated Successfully</Message>");
         }
         else
         {
             str.Append("<Message>List Updated Faild</Message>");
         }
     }
     else
     {
         str.Append("<Message>Enter Valid UserName and pwd</Message>");
     }
     str.Append("</ListsEditInfo>");
     doc.LoadXml(str.ToString());
     return doc;
 }
Exemple #20
0
        public void deleteRecipient()
        {
            try
            {
                if (Convert.ToInt64(hdfldDelID.Value) > 0)
                {
                    // get the list details to diplay the list name
                    ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hdfldDelID.Value));
                    ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);

                    //This logic is modified by ganesh on 18jan10
                    ListMaster objListMaster = new ListMaster(ConnectionString);
                    //delete the list from listmaster and listcontactmaster tables.
                    objListMaster.deleteListFromListMasterAndListContactMaster(Convert.ToInt64(hdfldDelID.Value));
                    if (!txtListNameSearch.Text.Equals(string.Empty))
                    {
                        SearchCriteria(0, "");
                    }
                    else
                    {
                        bindGrid("", "ASC", "ListName");
                    }
                    lblMainMsg.Text = string.Format("Successfully deleted list with List Name: {0}", listMaster.ListName.ToString());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #21
0
        public XmlDocument DeleteList(string UserID, string Password, int ListId)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<ListsDeleteInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);

            if (ListId > 0 && ConnectionString.Trim().Length != 0)
            {
                ListMasterPrimaryKey pk = new ListMasterPrimaryKey(ListId);
                ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
                listMaster.deleteListFromListMasterAndListContactMaster(ListId);
                str.Append("<Message>List Successfully Deleted</Message>");
                //ListMaster objListMaster = new ListMaster(ConnectionString);
                //delete the list from listmaster and listcontactmaster tables.
                //objListMaster.deleteListFromListMasterAndListContactMaster(Convert.ToInt64(hdfldDelID.Value));
            }
            else
            {
                str.Append("<Message>Enter Valid UserName and pwd</Message>");
            }
            str.Append("</ListsDeleteInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
        /// <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="ListMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class DomineSupress</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/31/2012 02:55:35 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static DomineSupress SelectAllByForeignKeyFromListMaster(ListMasterPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            DomineSupress 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_DomineSupress_SelectAllByForeignKeyListMaster", ref ExecutionState);
            obj = new DomineSupress();
            obj = DomineSupres.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper, ConnectionString);

            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
        public XmlDocument DeleteList(string UserID, string Password, int ListId)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<ListsDeleteInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0)
            {
                if (ListId > 0)
                {
                    ListMasterPrimaryKey pk = new ListMasterPrimaryKey(ListId);
                    ListMaster listMaster = ListMaster.SelectOne(pk, ConnectionString);
                    listMaster.deleteListFromListMasterAndListContactMaster(ListId);
                    str.Append("<Message>List Successfully Deleted</Message>");

                }
                else
                    str.Append("<Message>List With ID " + ListId + " Not Exist</Message>");
            }
            else
                str.Append("<Message>Enter Valid UserName and password</Message>");
            str.Append("</ListsDeleteInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }