//Ganesh on 30nov09 //This method will insert a new job in AutomationJob table. public void insertAutomationJob(AutomationMaster objAutomationMaster, string ScheduledTime, string sendType, Int64 campaignMasterID) { AutomationJob objAutomationJob = new AutomationJob(ConnectionString); objAutomationJob.CampaignMasterID = campaignMasterID; objAutomationJob.CreatedDatetime = DateTime.Now; objAutomationJob.ScheduledDatetime = Convert.ToDateTime(ScheduledTime); objAutomationJob.AutomationScheduledDate = Convert.ToDateTime(ScheduledTime); objAutomationJob.SendType = sendType; objAutomationJob.Status = 1; objAutomationJob.Insert(); }
public void insertAutomationJobUpdateCampaignMaster(AutomationMaster objAutomationMaster, string ScheduledTime, int CampaignMasterID) { //int CampaignMasterID = insertCampainMaster(objAutomationMaster); if (CampaignMasterID != 0) { AutomationJob objAutomationJob = new AutomationJob(ConnectionString); //objCampaignJob.CampaignMasterID = CampaignMasterID; //objCampaignJob.CreatedDatetime = DateTime.Now; objAutomationJob.ScheduledDatetime = Convert.ToDateTime(ScheduledTime); objAutomationJob.AutomationScheduledDate = Convert.ToDateTime(ScheduledTime); //objCampaignJob.ModifiedDate = Convert.ToDateTime(DateTime.Now); //objCampaignJob.Status = 1; objAutomationJob.Update(); } }
//Ganesh on 30nov09 //This method will insert a new job in CampaignMaster table. public int insertAutomationMaster(AutomationMaster objAutomationMaster) { try { using (DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString)) { bool ExecutionState = false; oDatabaseHelper.AddParameter("@CampaignName", objAutomationMaster.CampaignName); oDatabaseHelper.AddParameter("@CampaignDescription", objAutomationMaster.CampaignDescription); oDatabaseHelper.AddParameter("@FromAddress", objAutomationMaster.FromAddress); oDatabaseHelper.AddParameter("@FromName", objAutomationMaster.FromName); oDatabaseHelper.AddParameter("@ReplytoAddress", objAutomationMaster.ReplytoAddress); oDatabaseHelper.AddParameter("@ReplaytoName", objAutomationMaster.ReplaytoName); oDatabaseHelper.AddParameter("@TemplateId", objAutomationMaster.TemplateId); oDatabaseHelper.AddParameter("@Subject", objAutomationMaster.Subject); oDatabaseHelper.AddParameter("@TrackReads", objAutomationMaster.TrackReads); oDatabaseHelper.AddParameter("@SelectCondition", objAutomationMaster.SelectCondition); oDatabaseHelper.AddParameter("@HTMLContent", objAutomationMaster.HTMLContent); oDatabaseHelper.AddParameter("@TextContent", objAutomationMaster.TextContent); oDatabaseHelper.AddParameter("@AutomationScheduledDate", objAutomationMaster.AutomationScheduledDate); oDatabaseHelper.AddParameter("@DayOfWeek", objAutomationMaster.DayOfWeek); oDatabaseHelper.AddParameter("@ExpAutomationScheduledDate", objAutomationMaster.ExpAutomationScheduledDate); oDatabaseHelper.AddParameter("@SuppressDomain", objAutomationMaster.SuppressDomain); oDatabaseHelper.AddParameter("@URLText", objAutomationMaster.URLText); oDatabaseHelper.AddParameter("@CampaignID", -1, System.Data.ParameterDirection.Output); oDatabaseHelper.ExecuteScalar("sp_AutomationMaster_Insert_CustomProc", ref ExecutionState); int CampaignID = (int)oDatabaseHelper.GetParameterValue("@CampaignID"); oDatabaseHelper.Dispose(); return CampaignID; } } catch (Exception ex) { throw ex; } }
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"; } }
/// <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> /// 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 CampaignMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 1/8/2010 11:55:21 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static AutomationMasters PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString) { AutomationMasters list = new AutomationMasters(); if (rdr.Read()) { AutomationMaster obj = new AutomationMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); while (rdr.Read()) { obj = new AutomationMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); } oDatabaseHelper.Dispose(); return list; } else { oDatabaseHelper.Dispose(); return null; } }
/// <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 CampaignMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 1/8/2010 11:55:21 AM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static AutomationMasters PopulateObjectsFromReader(IDataReader rdr, string ConnectionString) { AutomationMasters list = new AutomationMasters(); while (rdr.Read()) { AutomationMaster obj = new AutomationMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); } return list; }