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"); } }
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; } }