public void checklistupdate() { try { ListContactMasters listContMastersContacts = ListContactMaster.SelectByField("ContactId", contactID, connectionString); ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(listId.ToString()), contactID, connectionString); ListContactMaster listContMaster = new ListContactMaster(connectionString); listContMaster.ContactId = contactID; listContMaster.ListMasterID = Convert.ToInt64(listId.ToString()); listContMaster.CreatedDate = DateTime.Now; listContMaster.IsActive = true; if (listContactMaster.Count > 0) { } else { bool statusInsert = listContMaster.InsertWithActiveStatus(); } } catch (Exception ex) { throw ex; } }
protected void lbtnSuppress_Click(object sender, EventArgs e) { try { lblGrdMsg.Text = string.Empty; string listids = null; bool statusLocal = false, statusGlobal = false; if (lstBoxListNames.Items.Count > 0) { foreach (ListItem item in lstBoxListNames.Items) listids = listids + item.Value + ','; listids = listids.Substring(0, listids.Length - 1); } if (RBLocal.Checked == true) { ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); statusLocal = objListContactMaster.UpdateStatusByEmail(txtEmailAddress.Text.ToString(), listids.ToString()); } else { SuppressContactsBase objSupAdd = new SuppressContactsBase(ConnectionString); objSupAdd.ChannelType = ddlChannelType.SelectedItem.Value; objSupAdd.CreatedBy = User.Identity.Name; objSupAdd.EmailAddress = txtEmailAddress.Text; objSupAdd.LastActionType = "manual"; //By Anwar on 11Aug12 statusGlobal = objSupAdd.SuppressEmailIDBYGlobalOrLocal(listids); bindgrid(); UdpnlGridRecipients.Update(); } if (statusLocal == true || statusGlobal == true) { lblMsg.Style.Add("color", "Green"); lblMsg.Text = txtEmailAddress.Text + " Suppressed successfully"; txtEmailAddress.Text = string.Empty; if (RBLocal.Checked != true) { lbtnLookup.Style.Add("display", "none"); lstBoxListNames.Style.Add("display", "none"); lbllists.Style.Add("display", "none"); } } else if (statusLocal == false) { lblMsg.Style.Add("color", "Red"); lblMsg.Text = txtEmailAddress.Text + "not Suppressed, Email Address not Contain for Selected List(s)"; } else if (statusGlobal == false) { lblMsg.Style.Add("color", "Red"); lblMsg.Text = txtEmailAddress.Text + " not Suppressed please try again"; } } catch (Exception ex) { lblMsg.Style.Add("color", "Red"); lblMsg.Text = ex.Message; } }
public XmlDocument SingleCampaignReports(string UserID, string Password, int CampaignID) { XmlDocument doc = new XmlDocument(); StringBuilder str = new StringBuilder(); str.Append("<ReportInfo>"); string ConnectionString = GetConnectionString(UserID, Password); if (ConnectionString.Trim().Length != 0 && CampaignID>0) { CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(CampaignID); CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString); CampaignJobPrimaryKey pk=new CampaignJobPrimaryKey(CampaignID); CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", CampaignID, ConnectionString); //CampaignJob job = CampaignJob.SelectOne(pk, ConnectionString); str.Append("<CampaignMasterID>" + objCampaignMaster.CampaignId.ToString() + "</CampaignMasterID> "); str.Append("<CampaignMasterName>" + objCampaignMaster.CampaignName.ToString() + "</CampaignMasterName> "); str.Append("<ResultsAsOf>" + DateTime.Now.ToString() + "</ResultsAsOf> "); str.Append("<Subject>" + objCampaignMaster.Subject.ToString() + "</Subject> "); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtcontacts = objListContactMaster.getContactsWithCampaignID(objCampaignMaster.SelectCondition, CampaignID.ToString()); int ForwardCount = -1; int Fcount = LinkDetailBase.RecipientsForwardCount(ConnectionString, CampaignID, out ForwardCount); long ActiveCount = Convert.ToInt64(dtcontacts.Rows.Count); str.Append("<TotalRecipientsCount>" + ActiveCount.ToString() + "</TotalRecipientsCount> "); str.Append("<ContactsTargetd>" + ActiveCount.ToString() + "</ContactsTargetd> "); foreach (CampaignJob job in objCampaignjob) { str.Append("<SucessfulDeliverdCount>" + job.DeliveredCount.ToString() + "</SucessfulDeliverdCount> "); str.Append("<BounceCount>" + job.BounceCount.ToString() + "</BounceCount> "); str.Append("<OpenCount>" + job.OpenCount.ToString() + "</OpenCount> "); str.Append("<ClickCount>" + job.ClickCount.ToString() + "</ClickCount> "); str.Append("<UnsubscribeCount>" + job.UnSubscribeCount.ToString() + "</UnsubscribeCount> "); str.Append("<ForwardCount>" + Fcount .ToString()+ "</ForwardCount>"); } str.Append("<SucessfulDeliverdCount>"); DataTable ListSuccessfulDelivered = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, CampaignID); if (ListSuccessfulDelivered != null) { for (int i = 0; i < ListSuccessfulDelivered.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + ListSuccessfulDelivered.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</SucessfulDeliverdCount>"); str.Append("<BounceCount>"); int TotalBounceCount, SoftBounceCount, HardBounceCount = -1; DataTable BounceRecipients = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, CampaignID, out TotalBounceCount, out SoftBounceCount, out HardBounceCount); if (BounceRecipients != null) { for (int i = 0; i < BounceRecipients.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + BounceRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</BounceCount>"); str.Append("<OpenCount>"); DataTable emailsOpened = ContactMaster.EmailOpendByCampId(ConnectionString, CampaignID); if (emailsOpened != null) { for (int i = 0; i < emailsOpened.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + emailsOpened.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</OpenCount>"); str.Append("<ClickCount>"); DataTable emailsClicked = ContactMaster.EmailClickedRecByCampId(ConnectionString, CampaignID); if (emailsClicked != null) { for (int i = 0; i < emailsClicked.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + emailsClicked.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</ClickCount>"); str.Append("<UnsubscribeCount>"); int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1; DataTable ListUnsubScribeRecipients = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, CampaignID, out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount); if (ListUnsubScribeRecipients != null) { for (int i = 0; i < ListUnsubScribeRecipients.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + ListUnsubScribeRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</UnsubscribeCount>"); str.Append("<ForwardCount>"); DataTable forwardRecipients = ContactMaster.SelectForwardRecipients(ConnectionString, CampaignID); if (forwardRecipients != null) { for (int i = 0; i < forwardRecipients.Rows.Count; i++) { str.Append("<Row>" + i.ToString() + "</Row>"); str.Append("<EmailAddress>" + forwardRecipients.Rows[i]["EmailAddress"].ToString() + "</EmailAddress> "); } } str.Append("</ForwardCount>"); string ss = str.ToString(); } str.Append("</ReportInfo>"); doc.LoadXml(str.ToString()); return doc; }
/// <summary> /// Populates the fields for multiple objects from the columns found in an open reader. /// </summary> /// /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param> /// /// <returns>Object of ListContactMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 11/6/2009 11:39:08 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static ListContactMasters PopulateObjectsFromReader(IDataReader rdr, string ConnectionString) { ListContactMasters list = new ListContactMasters(); while (rdr.Read()) { ListContactMaster obj = new ListContactMaster(ConnectionString); PopulateObjectFromReader(obj,rdr); list.Add(obj); } return list; }
protected void lbtnRemoveMultipleYes_Click(object sender, EventArgs e) { if (grdReceipients.Rows.Count > 0) { //Get contact Selection rememberContactSelection("chkSelectContact", "lblContactId", grdReceipients, "selectall"); if (Session["SelectedContacts"] != null) { StringBuilder strbDeletedContacts = new StringBuilder(); //adding selected contatIds to stringbuilder for (int i = 0; i < contactsSelected.Count; i++) { strbDeletedContacts.Append(contactsSelected[i] + ", "); } strbDeletedContacts.Remove(strbDeletedContacts.Length - 2, 1); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); objListContactMaster.deleteContactsFromListContactMaster(strbDeletedContacts.ToString(), Convert.ToInt64(hiddenEditID.Value)); if (txtsearchrecipient.Text == "") bindRecipients(""); else Searchrecipient(""); showAddRecipientsToList(" ", 0); lblMessage.Text = string.Format("Successfully removed contact(s): {0}.", strbDeletedContacts.Remove(strbDeletedContacts.Length - 1, 1).ToString()); hdnremselect.Value = "false"; UdPanelRecipients.Update(); hdrchkselected = null; UdPanelAddRecipients.Update(); UdPanelStatistics.Update(); UdPanelHistory.Update(); } } else { lbtnDeleteRecipients.Visible = false; } }
//Fill Recipients grid this Method is used to delete Recipients from List //Modified by Prashanth Kulkarni on 10/1/2009 //Fill AddRecipients grid this Method is used to Add Recipients to List //Modified by Prashanth Kulkarni on 10/1/2009 public void showAddRecipients(string fillflag) { try { //get contacts to be added to the list. ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = objListContactMaster.getRecipientsToBeAdded(Convert.ToInt64(hiddenEditID.Value));//listID=23 if (dtContacts.Rows.Count > 0) { lblSearchRecords.Style.Add("color", "green"); lblSearchRecords.Text = "Records Found: " + dtContacts.Rows.Count; } DataView dv = new DataView(dtContacts); dv.Sort = GridSortExpressionadd + " " + (fillflag == "sort" ? GetSortDirectionadd() : GridViewSortDirectionadd); gridAddRecipients.DataSource = dv; gridAddRecipients.DataBind(); if (gridAddRecipients.Rows.Count == 0) lbtnAdd.Visible = false; else lbtnAdd.Visible = true; GridPrevSortExpressionadd = GridSortExpressionadd; } catch (Exception ex) { throw ex; } }
private void Searchrecipient(string fillflag) { try { StringBuilder sbSearchrecipient = new StringBuilder(); txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("'", "''"); txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("%", "[%]"); txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("_", "[_]"); if (txtsearchrecipient.Text != "") { sbSearchrecipient.Append("p.Address1 like '%" + txtsearchrecipient.Text + "%' or p.IsActive like '%" + txtsearchrecipient.Text + "%' or p.ContactId like '%" + txtsearchrecipient.Text + "%' or p.firstname like '%" + txtsearchrecipient.Text + "%' or p.lastname like '%" + txtsearchrecipient.Text + "%' or p.emailaddress like '%" + txtsearchrecipient.Text + "%'"); string sortdir = (fillflag == "sort" ? GetSortDirectionadd() : GridViewSortDirectionadd); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = objListContactMaster.getShowListRecipients_Statistics_Search(sbSearchrecipient.ToString().Trim(), Convert.ToInt64(hiddenEditID.Value), GridSortExpression, sortdir, out totalCount, out activeCount, out inActiveCount, out unSubCount, out bounceCount, out suppressCount,out other); grdReceipients.DataSource = dtContacts; grdReceipients.DataBind(); if (dtContacts.Rows.Count > 0) { lblMessage.Style.Add("color", "green"); lblMessage.Text = "Records Found: " + dtContacts.Rows.Count; UdpnlSearch.Update(); } else { lblMessage.Style.Add("color", "red"); lblMessage.Text = "No Records Found"; UdpnlSearch.Update(); } GridPrevSortExpressionadd = GridSortExpressionadd; } else { showAddRecipients("sort"); } txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("''", "'"); txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("[%]", "%"); txtsearchrecipient.Text = txtsearchrecipient.Text.Trim().Replace("[_]", "_"); } catch (Exception ex) { throw ex; } }
protected void LBYes_Click(object sender, EventArgs e) { try { ListContactMasters listContMastersContacts = ListContactMaster.SelectByField("ContactId", Convert.ToInt64(hdEcontactId.Value), ConnectionString); ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(hiddenEditID.Value.ToString()), Convert.ToInt64(hdEcontactId.Value), ConnectionString); ListContactMaster listContMaster = new ListContactMaster(ConnectionString); listContMaster.ContactId = Convert.ToInt64(hdEcontactId.Value); listContMaster.ListMasterID = Convert.ToInt64(hiddenEditID.Value.ToString()); listContMaster.CreatedDate = DateTime.Now; listContMaster.IsActive = true; if (listContactMaster.Count > 0) { hdELC.Value = "1"; } else { bool statusInsert = listContMaster.InsertWithActiveStatus(); } if (hdEcontactstatus.Value == "1") { if (hdELC.Value == "1") { statusmessage.Append(string.Format("Contact \"" + txtEmailAddress1.Text + "\" is already exists in this List.")); lbCMsg.Style.Add("color", "Red"); } else { statusmessage.Append(string.Format("Contact \"" + txtEmailAddress1.Text + "\" has been Added successfully in the List.")); lbCMsg.Style.Add("color", "Green"); } lbCMsg.Text = statusmessage.ToString(); lbCMsg.Visible = true; txtContactfirstname.Text = string.Empty; txtContactLastname.Text = string.Empty; txtEmailAddress1.Text = string.Empty; AddContactsPopupExtender.Show(); } else { if (hdELC.Value == "1") { statusmessage.Append(string.Format("Contact \"" + txtEmailAddress1.Text + "\" is already exists in this List.")); lbCMsg.Style.Add("color", "Red"); } else { statusmessage.Append(string.Format("Contact \"" + txtEmailAddress1.Text + "\" has been Added successfully in the List.")); lbCMsg.Style.Add("color", "Green"); } lblMainMsg.Text = statusmessage.ToString(); lblMainMsg.Visible = true; bindGrid("", "ASC", "ListName"); udpnlListGridview.Update(); } } catch (Exception ex) { throw ex; } }
public void updateDeliveryTab() { try { if (hiddenCampaignID.Value != string.Empty) { if (txtCampaignName.Text == string.Empty) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter Mailing name in Mailing Details Tab.')", true); } else if (txtSubject.Text == string.Empty) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter subject from Mailing Details tab.')", true); } else { //checkCampaignStatus(); sbListIds = new StringBuilder(); for (int i = 0; i < lstBoxListNames.Items.Count; i++) { sbListIds.Append(string.Format("{0},", lstBoxListNames.Items[i].Value)); } if (sbListIds.ToString().EndsWith(",")) sbListIds.Remove(sbListIds.Length - 1, 1); StringBuilder sbSuppressListIds = new StringBuilder(); sbSuppressListIds = new StringBuilder(); for (int i = 0; i < lstSuppressList.Items.Count; i++) { sbSuppressListIds.Append(string.Format("{0},", lstSuppressList.Items[i].Value)); } if (sbSuppressListIds.ToString().EndsWith(",")) sbSuppressListIds.Remove(sbSuppressListIds.Length - 1, 1); CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(hiddenCampaignID.Value)); objCampaignMaster = CampaignMaster.SelectOne(objCampaignMasterPrimaryKey, ConnectionString); objCampaignMaster.CampaignId = Convert.ToInt64(hiddenCampaignID.Value); objCampaignMaster.ModifiedDate = DateTime.Now; objCampaignMaster.SelectCondition = sbListIds.ToString(); if (HDSuppressDomain.Value != string.Empty) objCampaignMaster.SuppressDomain = HDSuppressDomain.Value; else { btnSuppress_Click(btnSuppress, EventArgs.Empty); objCampaignMaster.SuppressDomain = HDSuppressDomain.Value; } objCampaignMaster.UpdateDelvertyTab(sbSuppressListIds.ToString()); statusType = "Inserted"; hdCampDeliveryTab5.Value = "0"; //Bellow code written by Swaroop July26-12 //Bellow lines are used to Insert Recs into DomainSupressTable int resflag = 0; //if (ViewState["dtDomains"] != null && hiddenCampaignID.Value != string.Empty) if (lstSuppressedDomain.Items.Count != 0 && hiddenCampaignID.Value != string.Empty) { //Create a DataTable for as a parameter to sp DataTable dtDomains = new DataTable(); dtDomains.Columns.Add("DomainName", typeof(string)); foreach (ListItem item in lstSuppressedDomain.Items) { dtDomains.Rows.Add(item.Text); } objListContactMaster = new ListContactMaster(ConnectionString); resflag = objListContactMaster.InsertInToDomainSuppress_Bulk(Convert.ToInt32(hiddenCampaignID.Value), sbListIds.ToString(), dtDomains);// (DataTable)ViewState["dtDomains"]); //CampaignMasterIDforUddate, id, ListOfContactIds.ToString(), SuppressDomain); } else { //Delete Previous Mailing Recs in DomainSupress Tb with this MailingId(CampaId) DomineSupress objDomineSupress = DomineSupres.SelectByField("CampaignId", Convert.ToInt64(hiddenCampaignID.Value), ConnectionString); if (objDomineSupress.Count > 0) { bool delStatus = DomineSupres.DeleteByField("CampaignId", Convert.ToInt64(hiddenCampaignID.Value), ConnectionString); } } } } } catch (Exception ex) { throw ex; } }
protected void SupressPopup() { //For Suppress Domain DropDown Bind DataSet ds = new DataSet(); objListContactMaster = new ListContactMaster(ConnectionString); ds = objListContactMaster.GetContactsDomain(); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { ChkDomain.DataSource = ds; ChkDomain.DataTextField = "Domain"; ChkDomain.DataValueField = "Domain"; ChkDomain.DataBind(); } } ModalPopupExtenderShowContactsdomain.Show(); ModalPopupExtenderShowContactsdomain.Focus(); }
protected void bindDomains() { DataTable dtDomain = new DataTable(); if (ViewState["ListIds"] != null) { objListContactMaster = new ListContactMaster(ConnectionString); dtDomain = objListContactMaster.getSelectedListsDomains(ViewState["ListIds"].ToString()); } if (dtDomain.Rows.Count > 0) { ViewState["dtDomain"] = dtDomain; ChkDomain.DataSource = dtDomain; ChkDomain.DataTextField = "Domain"; ChkDomain.DataValueField = "Domain"; ChkDomain.DataBind(); } }
protected void lbtnSuppressDomain_Click(object sender, EventArgs e) { try { lblDMessage.Text = string.Empty; lblDMsgUP.Update(); ViewState["CCSDomainPageNumber"] = null; ViewState["CCSDomainPageCount"] = null; sbListIds = new StringBuilder(); for (int i = 0; i < lstBoxListNames.Items.Count; i++) { sbListIds.Append(string.Format("{0},", lstBoxListNames.Items[i].Value)); } if (sbListIds.ToString().EndsWith(",")) sbListIds.Remove(sbListIds.Length - 1, 1); ViewState["ListIds"] = sbListIds.ToString(); objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtDomain = objListContactMaster.getSelectedListsDomains(sbListIds.ToString()); if (dtDomain.Rows.Count > 0) { ViewState["dtDomain"] = dtDomain; //First we are insert the Already selected domain names in ArrayList (Swaroop-Jan16-13) if (lstSuppressedDomain.Items.Count != 0 && ViewState["CCSelectedDomains"] == null) { foreach (ListItem item in lstSuppressedDomain.Items) { SelectedDomains.Add(item.Value); } } rememberSuppresseDomainSelection(); bindDomainNames(); populateSuppresseSelection(); //Write Jan10-13 (8-55PM) if (ViewState["dtDomain"] != null) { if (((DataTable)ViewState["dtDomain"]).Rows.Count.Equals(lstSuppressedDomain.Items.Count)) ChkSelectAllDomain.Checked = true; } if (ViewState["CCDomainSelectedAll"] != null) { populateSuppresseDomainSelectAllSelection(); if (ViewState["dtDomain"] != null) { if (((DataTable)ViewState["dtDomain"]).Rows.Count != ((ArrayList)ViewState["CCDomainSelectedAll"]).Count) ChkSelectAllDomain.Checked = false; } } ModalPopupExtenderShowContactsdomain.Show(); ModalPopupExtenderShowContactsdomain.Focus(); } else { ViewState["dtDomain"] = null; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please select Proper list.')", true); } } catch (Exception ex) { throw ex; } }
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(); } }
public void listRecipients(string fillflag) { try { int ddllistID = 0; if (ddlList1.SelectedIndex != 0) { ddllistID = Convert.ToInt32(ddlList1.SelectedValue); } //get contacts to be added to the list. string sortdir = (fillflag == "sort" ? GetSortDirection() : GridViewSortDirection); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = objListContactMaster.getShowListRecipients(ddllistID, GridSortExpression, sortdir);//listID=23 grdReceipients.Dispose(); grdReceipients.DataSource = dtContacts; grdReceipients.DataBind(); GridPrevSortExpression = GridSortExpression; UdpnlGridRecipients.Update(); } catch (Exception ex) { throw ex; } }
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 **************"); }
public XmlDocument AddRecipientWithListIDs(string UserID, string Password, string ListIds, long contactID) { try { StringBuilder str = new StringBuilder(); str.Append("<RecipientInfo>"); string Con = GetConnectionString(UserID, Password); LogStartInfo("AddRecipientWithListIDs", Con, UserID); if (Con.Trim().Length != 0 && ListIds.Trim().Length != 0 && Convert.ToInt64(contactID) != 0) { String[] list; list = ListIds.Split(','); ListContactMasters listContMastersContacts = ListContactMaster.SelectByField("ContactId", contactID, Con); for (int k = 0; k < list.Length; k++) { ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(list[k].ToString()), contactID, Con); ListContactMaster listContMaster = new ListContactMaster(Con); listContMaster.ContactId = contactID; listContMaster.IsActive = true; listContMaster.ListMasterID = Convert.ToInt64(list[k].ToString()); if (listContactMaster.Count > 0) { } else { bool statusInsert = listContMaster.Insert(); str.Append("<Message>Recipient inserted Successfully</Message>"); Logger.logdata(logforRpService, "Recipient inserted Successfully"); } } } else { str.Append("<Message>Please Enter Valid Inputs</Message>"); Logger.logdata(logforRpService, "Please Enter Valid Inputs"); } LogEndInfo("AddRecipientWithListIDs"); str.Append("</RecipientInfo>"); doc.LoadXml(str.ToString()); } catch (Exception ex) { Logger.logError(logforRpService, ex); } return doc; }
public string ScheduleMailingWithCampaignID(string Con, long CampaignID, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID, string SuppressDomain) { TemplateMaster tempMaster = null; try { TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", TemplateName, Con); if (obj.Count > 0) { TemplateMasterPrimaryKey template = new TemplateMasterPrimaryKey(Convert.ToInt64(obj[0].TemplateId.ToString())); tempMaster = TemplateMaster.SelectOne(template, Con); CampaignMaster objCampaignMaster = new CampaignMaster(Con); objCampaignMaster.CampaignName = CampaignName; objCampaignMaster.CampaignDescription = ""; objCampaignMaster.FromAddress = FromAddress; objCampaignMaster.FromName = FromName; objCampaignMaster.ReplytoAddress = ReplyToAddress; objCampaignMaster.ReplaytoName = FromName; objCampaignMaster.Subject = Subject; objCampaignMaster.TrackReads = true;//"1"; objCampaignMaster.SelectCondition = ListID; objCampaignMaster.TemplateId = tempMaster.TemplateId; objCampaignMaster.ModifiedDate = DateTime.Now; objCampaignMaster.CreatedDate = DateTime.Now; objCampaignMaster.HTMLContent = tempMaster.HTMLContent; objCampaignMaster.TextContent = ""; objCampaignMaster.SuppressDomain = (SuppressDomain == null) ? "" : SuppressDomain; objCampaignMaster.UnsubscribeText = ""; objCampaignMaster.UnsubscribeLinkText = ""; objCampaignMaster.SuppressSelection = ""; objCampaignMaster.AssignedCampaignID = CampaignID; Int64 MailingID = objCampaignMaster.insertCampainMaster(objCampaignMaster); #region Domine suppress //Create a DataTable for as a parameter to sp DataTable dtDomains = new DataTable(); //DataColumn dtDomains.Columns.Add("DomainName", typeof(string)); if (SuppressDomain.Trim().Length > 0) { if (SuppressDomain.Contains(",")) { string[] domains = SuppressDomain.Split(','); for (int i = 0; i < domains.Length; i++) dtDomains.Rows.Add(domains[i]); } else dtDomains.Rows.Add(SuppressDomain); } ListContactMaster objListContactMaster = new ListContactMaster(Con); objListContactMaster.InsertInToDomainSuppress_Bulk((int)MailingID, ListID.ToString(), dtDomains); //CampaignMasterIDforUddate, id, ListOfContactIds.ToString(), SuppressDomain); #endregion if (MailingID > 0) { CampaignJob objCampaignJob = new CampaignJob(Con); objCampaignJob.CampaignMasterID = MailingID; objCampaignJob.CreatedDatetime = DateTime.Now; objCampaignJob.ScheduledDatetime = DateTime.Now.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime); objCampaignJob.SendType = "IMMEDIATE"; objCampaignJob.Status = 1; objCampaignJob.Insert(); } Logger.logdata(logforRpService, "Mailing Inserted Succefully"); return (MailingID.ToString()); } else { return ("False"); } } catch (Exception ex) { Logger.logdata(logforRpService, ex.Message); return ("False"); } }
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"; }
public void bindRecipients(string fillflag) { try { //get contacts to be added to the list. string sortdir = (fillflag == "sort" ? GetSortDirection() : GridViewSortDirection); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = objListContactMaster.getShowListRecipients_Statistics(Convert.ToInt64(hiddenEditID.Value), GridSortExpression, sortdir, out totalCount, out activeCount, out inActiveCount, out unSubCount, out bounceCount, out suppressCount,out other); grdReceipients.DataSource = dtContacts; grdReceipients.DataBind(); lblMembersCount.Text = totalCount.ToString(); lblActive.Text = activeCount.ToString(); lblUnSubCount.Text = unSubCount.ToString(); lblBounceCount.Text = bounceCount.ToString(); lblSuppressed.Text = suppressCount.ToString(); lblOthers.Text = other.ToString(); if (dtContacts.Rows.Count == 0) { lbtnDeleteRecipients.Visible = false; } else lbtnDeleteRecipients.Visible = true; GridPrevSortExpression = GridSortExpression; UdPanelStatistics.Update(); } catch (Exception ex) { throw ex; } }
private string personalizeContent(DataRow drContact, string content, string trackReads) { try { Logger.logdata(logforemailbuilder, "************** in personalizeContent(..) method **************"); Logger.logdata(logforemailbuilder, string.Format("personalizeContent(..) has been started at {0}", DateTime.Now.ToString())); //Add links maually for testing //comment out below lines after testing //content = "<br/>Hi<br/>[!FirstName!]" + content; //content += string.Format("<br/>{0}<br/>{1}<br/>{2}<br/>{3}<br/>{4}<br/>", "[!RPLINK:1!]", "[!RPLINK:9!]", "[!RPLINK:LISTUNSUBSCRIBE!]", "[!RPLINK:GLOBALUNSUBSCRIBE!]", "[!RPLINK:FORWARDTOFRIEND!]"); //Adding yahoo and google links manually, comment out after testing. //content += "<br/>[!RPLINK:1!]<br/>[!RPLINK:2!]<br/>"; //Add open link to the content. #region this logic will add open link to the content string openLinkPath = ConfigurationManager.AppSettings["OpenLinkPath"].ToString(); content += "<img src=\"" + openLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"\" width=1 height=1 border=0>"; #endregion //Replace personalized fields if any in the content. if (!string.IsNullOrEmpty(content)) { #region 4virtuLinks handling if (content.Contains("[!RPLINK:NewLink!]")) { string NewUserLinkPath = ConfigurationManager.AppSettings["NewUserLinkPath"].ToString(); content = content.Replace("[!RPLINK:NewLink!]", NewUserLinkPath + "?GroupID=[!GroupID!]&JoinCode=[!JoinCode!]&Mode=[!Mode!]&ReferedBy=[!RefferdBy!]&Type=[!Type!]"); } if (content.Contains("[!RPLINK:ExLink!]")) { string MemberLinkPath = ConfigurationManager.AppSettings["ExitedUserLinkPath"].ToString(); content = content.Replace("[!RPLINK:ExLink!]", MemberLinkPath + "?GroupID=[!GroupID!]&JoinCode=[!JoinCode!]&Mode=[!Mode!]&ReferedBy=[!RefferdBy!]&Type=[!Type!]"); } if (content.Contains("[!RPLINK:DeclineLink!]")) { string DeclineLinkPath = ConfigurationManager.AppSettings["DeclineLinkPath"].ToString(); content = content.Replace("[!RPLINK:DeclineLink!]", DeclineLinkPath + "?GroupID=[!GroupID!]&JoinCode=[!JoinCode!]"); } #endregion //Add list Forward to Friend link to the content. #region this logic will add list Forward to Friend link to the content if (content.Contains("[!RPLINK:FORWARDTOFRIEND!]")) { string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString(); content = content.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Email=" + drContact["EmailAddress"].ToString() + "&Username="******"[!RPLINK:LISTUNSUBSCRIBE!]")) { string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString(); content = content.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&ListUnSub=YES" + "&Username="******"[!RPLINK:GLOBALUNSUBSCRIBE!]")) { string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString(); content = content.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&GlobalUnSub=YES" + "&Username="******"[!RPLINK:MIRRORWEBLINK!]")) { string MirrorLinkPath = ConfigurationManager.AppSettings["ClickHearURL"].ToString(); content = content.Replace("[!RPLINK:MIRRORWEBLINK!]", MirrorLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&type=campaign" + "&Username="******"!RPLINK")) { string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString(); string[] startDelimiter = new string[] { "[!RPLINK:" }; string[] endDelimiter = new string[] { "!]" }; string[] splittedContent = content.Split(startDelimiter, StringSplitOptions.None); for (int i = 1; i < splittedContent.Length; i++) { string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0]; //get linkDetails using linkID. //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString); if (!string.IsNullOrEmpty(linkID)) { LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString); if (linkData != null) { //Create click link if recordClicks value is true if (Convert.ToBoolean(linkData.RecordClicks)) { string replaceToken = startDelimiter[0] + linkID + endDelimiter[0]; if (trackReads.ToString() == "True") //content = content.Replace(replaceToken, "<A href=\"" + cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"\">" + linkData.LinkName + "</A>"); content = content.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"http://" + linkData.LinkName); content = content.Replace(replaceToken, linkData.LinkURL); //content = content.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"<A href=\"" + linkData.LinkURL + "\">" + linkData.LinkName + "</A>"); content = content.Replace(replaceToken, linkData.LinkURL); } } } } } #endregion //Replace pesonalise fields from the content. #region this logic will replaces personalised fields. if (content.Contains("[!LastName!]")) { content = content.Replace("[!LastName!]", drContact["LastName"].ToString()); } if (content.Contains("[!FirstName!]")) { content = content.Replace("[!FirstName!]", drContact["FirstName"].ToString()); } if (content.Contains("[!EmailAddress!]")) { content = content.Replace("[!EmailAddress!]", drContact["EmailAddress"].ToString()); } if (userName == "4virtu") { ListContactMaster objListContactMaster = new ListContactMaster(connectionString); DataTable tblListContact = objListContactMaster.getContactQueryString(Convert.ToInt64(drContact["ContactId"]), Convert.ToInt64(listID)); if (tblListContact != null && tblListContact.Rows.Count > 0) { string[] FieldSeparators = new string[] { "!RPDynamicField!" }; string[] FieldValueSeparators = new string[] { "!RPFieldValue!" }; string[] queryStrings = tblListContact.Rows[0]["QueryString"].ToString().Split(FieldSeparators, StringSplitOptions.None); string[] CustomField; foreach (string field in queryStrings) { CustomField = field.Split(FieldValueSeparators, StringSplitOptions.None); if (CustomField.Length >= 2 && content.Contains("[!" + CustomField[0] + "!]")) { content = content.Replace("[!" + CustomField[0] + "!]", CustomField[1]); } } } } else { DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString); for (int i = 0; i < customFieldDt.Rows.Count; i++) { string startChars = "[!"; string endChars = "!]"; string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars; string customColName; if (content.Contains(strCustomCtrl)) { customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString(); content = content.Replace(strCustomCtrl, drContact[customColName].ToString()); } } } #endregion return content; } else { return content; } Logger.logdata(logforemailbuilder, string.Format("personalizeContent(..) method has been ended at {0}", DateTime.Now.ToString())); Logger.logdata(logforemailbuilder, "************** Exit personalizeContent(..) method **************"); } catch (Exception ex) { throw ex; } }
public void bindRecipientsToGrid(string fillflag) { try { //get contacts to be added to the list. string sortdir = (fillflag == "sort" ? GetSortDirection() : GridViewSortDirection); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = objListContactMaster.getShowListRecipients(Convert.ToInt64(hiddenEditID.Value), GridSortExpression, sortdir);//listID=23 grdReceipients.DataSource = dtContacts; grdReceipients.DataBind(); if (dtContacts.Rows.Count == 0) { lbtnDeleteRecipients.Visible = false; } else lbtnDeleteRecipients.Visible = true; GridPrevSortExpression = GridSortExpression; } catch (Exception ex) { throw ex; } }
protected void imgbtnExport_Click(object sender, ImageClickEventArgs e) { try { #region Ex1 //CrystalDecisions.Shared.ExportFormatType formateType = ExportFormatType.PortableDocFormat; //if (dpExport.SelectedValue == "PDF") //{ // formateType = ExportFormatType.PortableDocFormat; //} //else if (dpExport.SelectedValue == "Excel") //{ // formateType = ExportFormatType.Excel; //} //else if (dpExport.SelectedValue == "Word") //{ // formateType = ExportFormatType.WordForWindows; //} //else if (dpExport.SelectedValue == "RichText") //{ // formateType = ExportFormatType.RichText; //} //else if (dpExport.SelectedValue == "CrystalReport") //{ // formateType = ExportFormatType.CrystalReport; //} //if (ContactRptname == "Contacts Targeted") //{ // SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString()); // TargetedRpt.SetParameterValue("@ListID", Request.QueryString["ListIds"].ToString()); // TargetedRpt.SetParameterValue("@CampaignID", Request.QueryString["CampId"].ToString()); // TargetedRpt.ExportToHttpResponse(formateType, Response, true, "ContactsTargeted"); //} //else if (ContactRptname == "Advanced") //{ // SetDatabase(AdvancedRpt, Request.QueryString["ListIds"].ToString()); // AdvancedRpt.SetParameterValue("@ListIds", Request.QueryString["ListIds"].ToString()); // AdvancedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // AdvancedRpt.ExportToHttpResponse(formateType, Response, true, "Advanced"); //} //else if (ContactRptname == "Successful Delivered") //{ // SetDatabase(SuccessDRpt, string.Empty); // SuccessDRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // SuccessDRpt.ExportToHttpResponse(formateType, Response, true, "SuccessfulDeliveredContacts"); //} //else if (ContactRptname == "Clicked") //{ // SetDatabase(ClickedRpt, string.Empty); // ClickedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // ClickedRpt.ExportToHttpResponse(formateType, Response, true, "ClickedContacts"); //} //else if (ContactRptname == "Forwards") //{ // SetDatabase(ForwardRpt, string.Empty); // ForwardRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // ForwardRpt.ExportToHttpResponse(formateType, Response, true, "ForwardContacts"); //} //else if (ContactRptname == "Opened") //{ // SetDatabase(OpenMailRpt, string.Empty); // OpenMailRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // OpenMailRpt.ExportToHttpResponse(formateType, Response, true, "OpenedContacts"); //} //else if (ContactRptname == "Unopened") //{ // SetDatabase(UnopenRpt, string.Empty); // UnopenRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // UnopenRpt.ExportToHttpResponse(formateType, Response, true, "UnopenedContacts"); //} //else if (ContactRptname == "Unsubscribed") //{ // SetDatabase(UnsubRpt, string.Empty); // UnsubRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // UnsubRpt.ExportToHttpResponse(formateType, Response, true, "UnsubscribedContacts"); //} //else if (ContactRptname == "Bounced") //{ // SetDatabase(BouncedRpt, string.Empty); // BouncedRpt.SetParameterValue("@CampaignId", Request.QueryString["CampId"].ToString()); // BouncedRpt.ExportToHttpResponse(formateType, Response, true, "BounceContacts"); //} #endregion #region Ex2 //SetDatabase(TargetedRpt, Request.QueryString["ListIds"].ToString()); //if (dpExport.SelectedValue == "PDF") //{ // oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.PortableDocFormat); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/pdf"; // Response.BinaryWrite(oStream.ToArray()); // Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".pdf"); // Response.End(); // //TargetedRpt.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, true, Page.Title); //} //else if (dpExport.SelectedValue == "Excel") //{ // oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.Excel); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/vnd.xls"; // Response.BinaryWrite(oStream.ToArray()); // Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".xls"); // Response.End(); //} //else if (dpExport.SelectedValue == "Word") //{ // oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.WordForWindows); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/vnd.doc"; // Response.BinaryWrite(oStream.ToArray()); // Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".doc"); // Response.End(); //} //else if (dpExport.SelectedValue == "RichText") //{ // oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.RichText); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/rtf"; // Response.BinaryWrite(oStream.ToArray()); // Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rtf"); // Response.End(); //} //else if (dpExport.SelectedValue == "CrystalReport") //{ // oStream = (MemoryStream)TargetedRpt.ExportToStream(ExportFormatType.CrystalReport); // Response.Clear(); // Response.Buffer = true; // Response.ContentType = "application/rpt"; // Response.BinaryWrite(oStream.ToArray()); // Response.AddHeader("Content-disposition", "Attachment;filename=" + filename.ToString().Trim()+ ".rpt"); // Response.End(); //} #endregion string CampName = string.Empty; string campId = HttpContext.Current.Request.QueryString["CampId"] != null ? HttpContext.Current.Request.QueryString["CampId"].ToString() : string.Empty; string mailingId = HttpContext.Current.Request.QueryString["MailingID"] != null ? HttpContext.Current.Request.QueryString["MailingID"].ToString() : string.Empty; //Get the MailingName Using MailingId if (mailingId != string.Empty) { CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId)); CampaignMaster objCampMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(pk, ConnectionString); CampName = objCampMaster.CampaignName.ToString().Trim(); } else { CampaignPrimaryKey pk = new CampaignPrimaryKey(Convert.ToInt64(campId)); Campaign Campaign = Campaign.SelectOne(pk, ConnectionString); CampName = Campaign.CampaignsName; } string listIds = HttpContext.Current.Request.QueryString["ListIds"] != null ? HttpContext.Current.Request.QueryString["ListIds"].ToString() : string.Empty; //string CampName = HttpContext.Current.Request.QueryString["CampName"] != null ? HttpContext.Current.Request.QueryString["CampName"].ToString() : string.Empty; string TabName = string.Empty; DataTable table = new DataTable(); int TotalBounceCount, SoftBounceCount, HardBounceCount = -1; int NeverOptedCount, CommCount, NotInterestedCount, OtherCount = -1, TotalUnsubCount = -1; Export Export = new Export("Web"); #region download using Dll if (ContactRptname == "Contacts Targeted") { TabName = "ContactsTargeted"; ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); if (listIds != string.Empty && mailingId != string.Empty) table = objListContactMaster.getContactsWithCampaignID(listIds, mailingId); else table = objListContactMaster.getContactsWithAssignCampaignID(campId); } else if (ContactRptname == "Successful Delivered") { TabName = "SuccessfulDelivered"; if (campId != string.Empty) table = ContactMaster.SelectSuccDeliveredByAssignCampIdwithDistinct(ConnectionString, Convert.ToInt32(campId)); else table = ContactMaster.SelectSuccessfulDeliveredByCampId(ConnectionString, Convert.ToInt32(mailingId)); } else if (ContactRptname == "Bounced") { TabName = "Bounced"; if (campId != string.Empty) table = ContactMaster.SelectRecipientsBounceRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount); else table = ContactMaster.SelectRecipientsBounceRecByCampId(ConnectionString, Convert.ToInt32(mailingId), out TotalBounceCount, out SoftBounceCount, out HardBounceCount); } else if (ContactRptname == "Opened") { TabName = "Opened"; int TotalOpenCounts = -1; if (campId != string.Empty) table = ContactMaster.EmailOpendByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalOpenCounts); else table = ContactMaster.EmailOpendByCampId(ConnectionString, Convert.ToInt32(mailingId)); } else if (ContactRptname == "Unopened") { TabName = "Unopened"; if (campId != string.Empty) table = ContactMaster.EmailUnopendRecByAssignCampId(ConnectionString, campId); else table = ContactMaster.EmailUnopendByCampId(ConnectionString, Convert.ToInt32(mailingId)); } else if (ContactRptname == "Clicked") { TabName = "Clicked"; int TotalClickCounts = -1; if (campId != string.Empty) table = ContactMaster.EmailClickedRecByAssignCampId(ConnectionString, Convert.ToInt32(campId), out TotalClickCounts); else table = ContactMaster.EmailClickedRecByCampId(ConnectionString, Convert.ToInt32(mailingId)); } else if (ContactRptname == "Forwards") { TabName = "Forwards"; int TotalForwardCount = -1; if (campId != string.Empty) table = ContactMaster.SelectForwardRecipientsByAssignId(ConnectionString, Convert.ToInt32(campId), out TotalForwardCount); else table = ContactMaster.SelectForwardRecipients(ConnectionString, Convert.ToInt32(mailingId)); } else if (ContactRptname == "Unsubscribed") { TabName = "Unsubscribed"; if (campId != string.Empty) table = ContactMaster.SelectUnsubscribeRecipientsByAssignedCampId(ConnectionString, Convert.ToInt32(campId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount, out TotalUnsubCount); else table = ContactMaster.SelectUnsubscribeRecipients(ConnectionString, Convert.ToInt32(mailingId), out NeverOptedCount, out CommCount, out NotInterestedCount, out OtherCount); } else if (ContactRptname == "Advanced") { TabName = "Advanced"; if (campId != string.Empty) table = ContactMaster.SelectRecipientsDomainCountsByAssign(ConnectionString, Convert.ToInt32(campId), "TargetedDomain", string.Empty); else table = ContactMaster.SelectRecipientsDomainCounts(ConnectionString, listIds, Convert.ToInt32(mailingId), "TargetedDomain", string.Empty); table.Columns["TargetedDomain"].ColumnName = "Domains"; table.Columns["Unsubs"].ColumnName = "Unsubscribe"; } if (dpExport.SelectedValue.Equals("CSV")) Export.ExportDetails(table, Export.ExportFormat.CSV, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".csv"); else if (dpExport.SelectedValue.Equals("Excel")) Export.ExportDetails(table, Export.ExportFormat.Excel, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".xls"); else if (dpExport.SelectedValue.Equals("Text")) { Export.ExportDetails(table, Export.ExportFormat.Text, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".txt"); } else ExportToPDF(table, TabName + "_" + CampName + "_" + DateTime.Now.ToShortDateString() + ".pdf"); #endregion } catch (Exception ex) { throw ex; } }
public void showAddRecipientsToList(string fillflag, int pageIndex) { try { pnlPaging.Visible = true; //get contacts to be added to the list. string sortdir = (fillflag == "sort" ? GetSortDirectionadd() : GridViewSortDirectionadd); ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString); DataTable dtContacts = new DataTable(); if (flagreset == true) { sortdir = "ASC"; GridSortExpressionadd = "FirstName"; } dtContacts = objListContactMaster.getRecipientsToBeAddedToList(ConnectionString, Convert.ToInt64(hiddenEditID.Value), GridSortExpressionadd, sortdir, pageIndex, 10, out rowCount); Session["RowCount"] = rowCount; gridAddRecipients.DataSource = dtContacts; gridAddRecipients.DataBind(); managePaging(); if (gridAddRecipients.Rows.Count == 0) lbtnAdd.Visible = false; else lbtnAdd.Visible = true; GridPrevSortExpressionadd = GridSortExpressionadd; } catch (Exception ex) { throw ex; } }
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; }
/// <summary> /// This method will return an object representing the record matching the primary key information specified. /// </summary> /// /// <param name="pk" type="ListContactMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param> /// /// <returns>object of class ListContactMaster</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 11/6/2009 11:39:08 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// public static ListContactMaster SelectOne(ListContactMasterPrimaryKey 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); IDataReader dr=oDatabaseHelper.ExecuteReader("sp_ListContactMaster_SelectbyPrimaryKey", ref ExecutionState); if (dr.Read()) { ListContactMaster obj=new ListContactMaster(ConnectionString); PopulateObjectFromReader(obj,dr); dr.Close(); oDatabaseHelper.Dispose(); return obj; } else { dr.Close(); oDatabaseHelper.Dispose(); return null; } }
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; }
/// <summary> /// Populates the fields for multiple objects from the columns found in an open reader. /// </summary> /// /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param> /// /// <returns>Object of ListContactMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 11/6/2009 11:39:08 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static ListContactMasters PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString) { ListContactMasters list = new ListContactMasters(); if (rdr.Read()) { ListContactMaster obj = new ListContactMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); while (rdr.Read()) { obj = new ListContactMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); } oDatabaseHelper.Dispose(); return list; } else { oDatabaseHelper.Dispose(); return null; } }
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; }
public void checklistupdate() { try { ListContactMasters listContMastersContacts = ListContactMaster.SelectByField("ContactId", contactID, ConnectionString); //Modified By Anwar Jan17 2012 List<int> removelist = new List<int>(); for (int j = 0; j < listContMastersContacts.Count; j++) { if (!list.Contains(listContMastersContacts[j].ListMasterID.ToString())) removelist.Add(Convert.ToInt32(listContMastersContacts[j].ListMasterID)); } for (int k = 0; k < removelist.Count; k++) { ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(removelist[k].ToString()), contactID, ConnectionString); ListContactMaster listContMaster = new ListContactMaster(ConnectionString); listContMaster.ListContactId = listContactMaster[0].ListContactId; if (listContactMaster.Count > 0) { bool statusDelete = listContMaster.Delete(); } } for (int k = 0; k < list.Count; k++) { ListContactMasters listContactMaster = ListContactMaster.SelectAllByListIDAndContactID(Convert.ToInt64(list[k].ToString()), contactID, ConnectionString); ListContactMaster listContMaster = new ListContactMaster(ConnectionString); listContMaster.ContactId = contactID; listContMaster.ListMasterID = Convert.ToInt64(list[k].ToString()); listContMaster.CreatedDate = DateTime.Now; listContMaster.IsActive = true; if (listContactMaster.Count > 0) { } else { bool statusInsert = listContMaster.InsertWithActiveStatus(); } } if (!chkIsActive1.Checked && lstBoxListNames.Items.Count > 0) { bool Status = ListContactMaster.ChangeContactStatusByList(contactID, chkIsActive1.Checked, ConnectionString); } binddata(contactID); } catch (Exception ex) { throw ex; } }
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; } }