public void Automationcampaigns_bindcontent() { try { ACpk = new AutomationMasterPrimaryKey(campaignID); AcampMaster = AutomationMaster.SelectOne(ACpk, ConnectionString); lblCampaignName.Text = AcampMaster.CampaignName; lblFromAddress.Text = AcampMaster.FromAddress; lblFromName.Text = AcampMaster.FromName; if (AcampMaster.Subject.StartsWith("http")) { Byte[] PageHTMLBytes; WebClient MyWebClient = new WebClient(); UTF8Encoding oUTF8 = new UTF8Encoding(); PageHTMLBytes = MyWebClient.DownloadData(AcampMaster.Subject); string tempPageHTMLBytes = oUTF8.GetString(PageHTMLBytes).ToString(); lblSubject.Text = tempPageHTMLBytes; } else { lblSubject.Text = AcampMaster.Subject; } string campaignContent = string.Empty; if (AcampMaster.HTMLContent.StartsWith("http")) { Byte[] PageHTMLBytes; WebClient MyWebClient = new WebClient(); UTF8Encoding oUTF8 = new UTF8Encoding(); PageHTMLBytes = MyWebClient.DownloadData(AcampMaster.HTMLContent); string tempPageHTMLBytes = oUTF8.GetString(PageHTMLBytes).ToString(); campaignContent = tempPageHTMLBytes; } else { campaignContent = AcampMaster.HTMLContent; } if (campaignContent.ToLower().Contains("listunsubscribe")) { campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"] + "\">List UnSubscribe</A>"); } if (campaignContent.ToLower().Contains("globalunsubscribe")) { campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"] + "\">Global UnSubscribe</A>"); } if (campaignContent.ToLower().Contains("forwardtofriend")) { campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["ForwardToFriendLinkPath"] + "\">Forward To Friend</A>"); } if (campaignContent.ToLower().Contains("mirrorweblink")) { campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["ClickHearURL"] + "?ID=" + Convert.ToInt32(campaignID) + "&type=" + Request.QueryString["type"] + "&EditorType=" + "HTML" + "\">click here</A>"); } //Add click link to the content. #region this logic will add click link to the content if (campaignContent.Contains("!RPLINK")) { string[] startDelimiter = new string[] { "[!RPLINK:" }; string[] endDelimiter = new string[] { "!]" }; string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None); for (int i = 1; i < splittedContent.Length; i++) { string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0]; //get linkDetails using linkID. if (!string.IsNullOrEmpty(linkID)) { LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID)); LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString); if (linkData != null) { if (campaignContent.ToLower().Contains(linkID)) { campaignContent = campaignContent.Replace(linkID, linkData.LinkURL.ToString()); } } } } } #endregion contentdiv.InnerHtml = campaignContent; ViewState["Content"] = campaignContent; } catch (Exception ex) { lbltitle.Text = "Invalid Campaign"; } }
protected void lbtnYes_Click(object sender, EventArgs e) { try { AutomationMasterPrimaryKey pk = new AutomationMasterPrimaryKey(Convert.ToInt64(hdfield.Value)); AutomationMaster campMaster = AutomationMaster.SelectOne(pk, ConnectionString); campMaster.Active = false; bool status = campMaster.Update(); if (status == true) { //Response.Redirect("~/pages/Campaigns.aspx"); ModalPopupExtender2.Hide(); } GridPrevSortExpression = ""; bindGrid("sort"); lblMainMsg.Visible = true; lblMainMsg.Text = string.Format("Campaign: " + campMaster.CampaignName + " deleted successfully"); lblMainMsg.Style.Add("color", "Green"); } catch (Exception ex) { throw ex; } }
public void showCampaignSummary(string campaignID) { try { //get summary details of campaign AutomationMasterPrimaryKey objAutomationMasterPrimaryKey = new AutomationMasterPrimaryKey(Convert.ToInt64(campaignID)); AutomationMaster objAutomationMaster = AutomationMaster.SelectOneWithAutomationJobUsingCampaignMasterID(objAutomationMasterPrimaryKey, ConnectionString); //CampaignMasterPrimaryKey objAutomationMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(campaignID)); //CampaignMaster objAutomationMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objAutomationMasterPrimaryKey, ConnectionString); AutomationJobs objAutomationJob = AutomationJob.SelectByField("CampaignMasterID", Convert.ToInt64(campaignID), ConnectionString); //CampaignJobs objAutomationJob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(campaignID), ConnectionString); if (objAutomationMaster.AutomationJobs[0].Status == 4) //if (objAutomationMaster.CampaignJobs[0].Status == 1) { string SelectCondition = objAutomationMaster.SelectCondition; string[] ListIds = SelectCondition.Split(','); //string selectedList=null; StringBuilder selectedList = new StringBuilder(); StringBuilder selectedListExport = new StringBuilder(); foreach (var Id in ListIds) { ListMasters List = ListMaster.SelectByField("ListMasterId", Id, ConnectionString); if (List.Count > 0) { selectedList.Append(List[0].ListName.ToString() + ", "); selectedListExport.Append(List[0].ListName.ToString() + "; "); } else { lblMainMsg.Style.Add("color", "red"); lblMainMsg.Text = "The List has been moved or removed"; } } if (selectedList.Length > 0) { selectedList.Remove(selectedList.Length - 2, 1); } else { //lblMainMsg.Style.Add("color", "red"); //lblMainMsg.Text = "The List has been moved or removed"; selectedList.Append("The List has been moved or removed"); } if (selectedListExport.Length > 0) { selectedListExport.Remove(selectedListExport.Length - 2, 1); } else { //lblMainMsg.Style.Add("color", "red"); //lblMainMsg.Text = "The List has been moved or removed"; selectedListExport.Append("The List has been moved or removed"); } string campaignName = objAutomationMaster.CampaignName; int openCount = 0, sentCount = 0, clickCount = 0, optoutCount = 0, bounceCount = 0; if (objAutomationJob[0].DeliveredCount != 0 || objAutomationJob[0].BounceCount != 0) { //get counts openCount = Convert.ToInt32(objAutomationJob[0].OpenCount); sentCount = Convert.ToInt32(objAutomationJob[0].DeliveredCount); clickCount = Convert.ToInt32(objAutomationJob[0].ClickCount); optoutCount = Convert.ToInt32(objAutomationJob[0].OptoutCount); bounceCount = Convert.ToInt32(objAutomationJob[0].BounceCount); } int totalrecipients = Convert.ToInt32(objAutomationJob[0].TotalRecipients); decimal averageOpenCount = 0, averageClickCount = 0, averageOptOutCount = 0, averageSentCount = 0, averageBounceCount = 0; //calculate averages if (sentCount != 0) averageOpenCount = Decimal.Round(Convert.ToDecimal(openCount) / Convert.ToDecimal(sentCount) * 100, 1); else averageOpenCount = 0; //else // averageOpenCount =0; if (openCount != 0) averageClickCount = Decimal.Round(Convert.ToDecimal(clickCount) / Convert.ToDecimal(openCount) * 100, 1); else averageClickCount = 0; //else // averageClickCount =0; if (sentCount != 0) averageOptOutCount = Decimal.Round(Convert.ToDecimal(optoutCount) / Convert.ToDecimal(sentCount) * 100, 1); else averageOptOutCount = 0; //else // averageOptOutCount=0; if (totalrecipients != 0) averageSentCount = Decimal.Round(Convert.ToDecimal(sentCount) / Convert.ToDecimal(totalrecipients) * 100, 1); else averageSentCount = 0; //else if (bounceCount != 0) averageBounceCount = Decimal.Round(Convert.ToDecimal(bounceCount) / Convert.ToDecimal(totalrecipients) * 100, 1); else averageBounceCount = 0; //build html string for campaign summary. StringBuilder objStringBuilder = new StringBuilder(); objStringBuilder.Append("<table width=\"100%\" border=\"0px\" cellspacing=\"0px\">"); objStringBuilder.Append("<tr><td>"); objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">"); objStringBuilder.Append("<tr><td colspan=3><b>Campaign Details Criteria</b></td></tr>"); objStringBuilder.Append("<tr><td width=\"25%\">Campaign Name</td><td>" + campaignName + "</td><td></td></tr>"); objStringBuilder.Append("<tr><td >Results as Of</td><td>" + DateTime.Now + "</td><td></td></tr>"); objStringBuilder.Append("<tr><td >Send Start Date</td><td>" + objAutomationJob[0].StartTime.ToString() + "</td><td></td></tr>"); objStringBuilder.Append("<tr><td >Send Completion Date</td><td>" + objAutomationJob[0].CompletionTime.ToString() + "</td><td></td></tr>"); objStringBuilder.Append("</table>"); objStringBuilder.Append("</td></tr>"); objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>"); objStringBuilder.Append("<tr><td>"); objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">"); objStringBuilder.Append("<tr><td colspan=3><b>Recipient Criteria</b></td></tr>"); objStringBuilder.Append("<tr><td width=\"25%\">List(s) Selected</td><td>" + selectedList + "</td><td></td></tr>"); objStringBuilder.Append("<tr><td >Recipients Found</td><td>" + (totalrecipients) + "</td><td></td></tr>"); objStringBuilder.Append("</table>"); objStringBuilder.Append("</td></tr>"); objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>"); objStringBuilder.Append("<tr><td>"); objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">"); objStringBuilder.Append("<tr><td width=\"25%\"><b>Send Details</b></td><td><b>Total</b></td><td><b>Average</b></td></tr>"); objStringBuilder.Append("<tr><td >Successful Sends</td><td>" + sentCount + "</td><td>" + averageSentCount + "%</td></tr>"); objStringBuilder.Append("<tr><td >Bounces</td><td>" + bounceCount + "</td><td>" + averageBounceCount + "%</td></tr>"); objStringBuilder.Append("</table>"); objStringBuilder.Append("</td></tr>"); objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>"); objStringBuilder.Append("<tr><td>"); objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">"); objStringBuilder.Append("<tr><td><b>Subscriber Interaction</b></td><td><b>Unique total</b></td><td><b>Average</b></td>"); objStringBuilder.Append("<tr><td width=\"25%\">Open</td><td>" + openCount + "</td><td>" + averageOpenCount + "%</td></tr>"); objStringBuilder.Append("<tr><td >Click</td><td>" + clickCount + "</td><td>" + averageClickCount + "%</td></tr>"); objStringBuilder.Append("<tr><td >OptOut</td><td>" + optoutCount + "</td><td>" + averageOptOutCount + "%</td></tr>"); objStringBuilder.Append("</table>"); objStringBuilder.Append("</td></tr>"); objStringBuilder.Append("</table>"); //bind html string to the the td. tdCampaignSummary.InnerHtml = objStringBuilder.ToString(); DataTable dtExportSummary = new DataTable(); DataColumn s1 = new DataColumn("Details"); DataColumn s2 = new DataColumn("Values"); DataColumn s3 = new DataColumn("AvgValues"); dtExportSummary.Columns.Add(s1); dtExportSummary.Columns.Add(s2); dtExportSummary.Columns.Add(s3); DataRow row1 = dtExportSummary.NewRow(); row1[s1] = "campaignName"; row1[s2] = campaignName; row1[s3] = ""; dtExportSummary.Rows.Add(row1); DataRow row2 = dtExportSummary.NewRow(); row2[s1] = "Result as of"; row2[s2] = DateTime.Now; row2[s3] = ""; dtExportSummary.Rows.Add(row2); DataRow row3 = dtExportSummary.NewRow(); row3[s1] = "Send Start Date"; row3[s2] = objAutomationJob[0].StartTime.ToString(); row3[s3] = ""; dtExportSummary.Rows.Add(row3); DataRow row4 = dtExportSummary.NewRow(); row4[s1] = "Send Completion Date"; row4[s2] = objAutomationJob[0].CompletionTime.ToString(); row4[s3] = ""; dtExportSummary.Rows.Add(row4); DataRow row5 = dtExportSummary.NewRow(); row5[s1] = "List(s) Selected"; row5[s2] = selectedListExport; row5[s3] = ""; dtExportSummary.Rows.Add(row5); DataRow row6 = dtExportSummary.NewRow(); row6[s1] = "Recipients Found"; row6[s2] = totalrecipients; row6[s3] = ""; dtExportSummary.Rows.Add(row6); DataRow row7 = dtExportSummary.NewRow(); row7[s1] = "Successful Sends"; row7[s2] = sentCount; row7[s3] = averageSentCount + "%"; dtExportSummary.Rows.Add(row7); DataRow row8 = dtExportSummary.NewRow(); row8[s1] = "Bounces"; row8[s2] = bounceCount; row8[s3] = averageBounceCount + "%"; dtExportSummary.Rows.Add(row8); DataRow row9 = dtExportSummary.NewRow(); row9[s1] = "Open"; row9[s2] = openCount; row9[s3] = averageOpenCount + "%"; dtExportSummary.Rows.Add(row9); DataRow row10 = dtExportSummary.NewRow(); row10[s1] = "Click"; row10[s2] = clickCount; row10[s3] = averageClickCount + "%"; dtExportSummary.Rows.Add(row10); DataRow row11 = dtExportSummary.NewRow(); row11[s1] = "Opt Out"; row11[s2] = optoutCount; row11[s3] = averageOptOutCount + "%"; dtExportSummary.Rows.Add(row11); ViewState["TempdtExportSummary"] = dtExportSummary; } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method will get row(s) from the database using the value of the field specified /// along with the details of the child table. /// </summary> /// /// <param name="pk" type="CampaignMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param> /// /// <returns>object of class CampaignMaster</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 1/8/2010 11:55:21 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// public static AutomationMaster SelectOneWithAutomationJobUsingCampaignMasterID(AutomationMasterPrimaryKey pk, String ConnectionString) { DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString); bool ExecutionState = false; AutomationMaster obj = null; // Pass the values of all key parameters to the stored procedure. System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues(); foreach (string key in nvc.Keys) { oDatabaseHelper.AddParameter("@" + key, nvc[key]); } // The parameter '@ErrorCode' will contain the status after execution of the stored procedure. oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output); IDataReader dr = oDatabaseHelper.ExecuteReader("sp_AutomationMaster_SelectOneWithCampaignJobUsingAutomationMasterID", ref ExecutionState); if (dr.Read()) { obj = new AutomationMaster(ConnectionString); PopulateObjectFromReader(obj, dr); dr.NextResult(); //Get the child records. obj.AutomationJobs = AutomationJob.PopulateObjectsFromReader(dr, ConnectionString); } dr.Close(); oDatabaseHelper.Dispose(); return obj; }
/// <summary> /// This method will Delete one row from the database using the primary key information /// </summary> /// /// <param name="pk" type="CampaignMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param> /// /// <returns>True if succeeded</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 1/8/2010 11:55:21 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// public static bool Delete(AutomationMasterPrimaryKey pk, String ConnectionString) { DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString); bool ExecutionState = false; // Pass the values of all key parameters to the stored procedure. System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues(); foreach (string key in nvc.Keys) { oDatabaseHelper.AddParameter("@" + key, nvc[key]); } // The parameter '@ErrorCode' will contain the status after execution of the stored procedure. oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output); oDatabaseHelper.ExecuteScalar("sp_AutomationMaster_Delete", ref ExecutionState); oDatabaseHelper.Dispose(); return ExecutionState; }
/// <summary> /// This method will get row(s) from the database using the value of the field specified /// along with the details of the child table. /// </summary> /// /// <param name="pk" type="CampaignMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param> /// /// <returns>object of class CampaignJobs</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 2/3/2010 4:14:00 PM Created function /// /// </RevisionHistory> /// /// </remarks> /// public static AutomationJobs SelectAllByForeignKeyFromCampaignMaster(AutomationMasterPrimaryKey pk, String ConnectionString) { DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString); bool ExecutionState = false; AutomationJobs obj = null; // Pass the values of all key parameters to the stored procedure. System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues(); foreach (string key in nvc.Keys) { oDatabaseHelper.AddParameter("@" + key, nvc[key]); } // The parameter '@ErrorCode' will contain the status after execution of the stored procedure. oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output); IDataReader dr = oDatabaseHelper.ExecuteReader("sp_AutomationJob_SelectAllByForeignKeyAutomationMaster", ref ExecutionState); obj = new AutomationJobs(); obj = AutomationJob.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper, ConnectionString); dr.Close(); oDatabaseHelper.Dispose(); return obj; }