示例#1
0
        public string ScheduleMailingWithSuppressList(string Con, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID, string SupListId, string SeedId, string scheduleTime, string sendType)
        {
            TemplateMaster tempMaster = null;
            try
            {
                long listid = 0;
                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 = "";
                    objCampaignMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                    objCampaignMaster.UnsubscribeLinkText = "Unsubscribe";
                    objCampaignMaster.AssignedCampaignID = 0;
                    objCampaignMaster.SuppressSelection = SupListId.ToString();
                    objCampaignMaster.htmlHasUnsubLink = true;
                    objCampaignMaster.txtHasUnsubLink = false;

                    Int64 campaignMasterID = objCampaignMaster.insertMailing(objCampaignMaster);
                    if (campaignMasterID > 0)
                    {
                        CampaignJob objCampaignJob = new CampaignJob(Con);
                        objCampaignJob.CampaignMasterID = campaignMasterID;
                        objCampaignJob.CreatedDatetime = DateTime.Now;
                        objCampaignJob.ScheduledDatetime = Convert.ToDateTime(scheduleTime);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                        Logger.logdata(logforRpService, "Mailing Schedule Date Time :" + scheduleTime + "");
                        objCampaignJob.SendType = sendType;
                        objCampaignJob.Status = 5;
                        objCampaignJob.Insert();

                    }
                    Logger.logdata(logforRpService, "Mailing Inserted Succefully");
                    return (campaignMasterID.ToString());
                }
                else
                {
                    return ("False");
                }

            }
            catch (Exception ex)
            {
                Logger.logdata(logforRpService, ex.Message);
                return ("False");
            }


        }
        public bool saveCampaignDetailsTab(bool Rflag)
        {
            if (txtCampaignName.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter Mailing name in Mailing Details Tab.')", true);
                Rflag = false;
            }
            else if (ddlFromAddress.SelectedItem.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter FromAddress.')", true);
                Rflag = false;
            }
            else if (txtFromName.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter FromName.')", true);
                Rflag = false;
            }
            else if (txtSubject.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter subject from Mailing Details tab.')", true);
                Rflag = false;
            }
            else
            {
                if (hiddenCampaignID.Value == string.Empty)
                {
                    objCampaignMaster = new CampaignMaster(ConnectionString);
                    DataTable campMaster = CampaignMasterBase.SelectByName("CampaignName", txtCampaignName.Text.ToString(), ConnectionString);
                    if (campMaster.Rows.Count != 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Mailing already Exists with this Name.')", true);
                        Rflag = false;
                    }
                    else
                    {
                        objCampaignMaster.CampaignName = txtCampaignName.Text;
                        objCampaignMaster.CampaignDescription = txtCampaignDescription.Text;
                        objCampaignMaster.FromAddress = ddlFromAddress.SelectedItem.Text;
                        objCampaignMaster.FromName = txtFromName.Text;
                        objCampaignMaster.ReplytoAddress = txtReplytoAddress.Text;
                        objCampaignMaster.ReplaytoName = txtReplaytoName.Text;
                        objCampaignMaster.Subject = txtSubject.Text;
                        objCampaignMaster.TrackReads = chkTrackReads.Checked;

                        if (RadEditor1.Content.ToString().Trim().Length != 0)
                            objCampaignMaster.htmlHasUnsubLink = chkAddress.Checked;
                        else
                            objCampaignMaster.htmlHasUnsubLink = false;
                        if (textRadEditor.Content.ToString().Trim().Length != 0)
                            objCampaignMaster.txtHasUnsubLink = chkTxtAddress.Checked;
                        else
                            objCampaignMaster.txtHasUnsubLink = false;

                        objCampaignMaster.UnsubscribeText = txtUnsubscribe.Text;
                        objCampaignMaster.UnsubscribeLinkText = DDLinktext.SelectedItem.Text;
                        if (ddlCampsNames.Text != defaultListItem)
                            objCampaignMaster.AssignedCampaignID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);
                        else
                            objCampaignMaster.AssignedCampaignID = 0;
                        lblunsubinfo.Text = txtUnsubscribe.Text;
                        lblunsublinktext.Text = DDLinktext.SelectedItem.Text;
                        DivUnsubtext.InnerHtml = lblunsubinfo.Text + " \n" + lblunsublinktext.Text;

                        objCampaignMaster.TemplateId = 0;
                        objCampaignMaster.HTMLContent = string.Empty;
                        objCampaignMaster.TextContent = string.Empty;
                        objCampaignMaster.SelectCondition = string.Empty;
                        objCampaignMaster.SuppressDomain = string.Empty;
                        objCampaignMaster.SuppressSelection = string.Empty;

                        Int64 campaignMasterID = objCampaignMaster.insertMailing(objCampaignMaster);
                        if (campaignMasterID > 0)
                        {
                            //Insert In CampaignJob Table
                            CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                            objCampaignJob.CampaignMasterID = campaignMasterID;
                            objCampaignJob.CreatedDatetime = DateTime.Now;
                            objCampaignJob.ScheduledDatetime = DateTime.Now; //Convert.ToDateTime(scheduledTime);
                            objCampaignJob.SendType = sendType;
                            objCampaignJob.Status = 5;
                            objCampaignJob.Insert();

                            //Insert in CampaignMailing Table
                            if (ddlCampsNames.Text != defaultListItem)
                            {
                                CampaignMailing objCampaignMailing = new CampaignMailing(ConnectionString);
                                objCampaignMailing.CampaignId = campaignMasterID;
                                objCampaignMailing.CampaignsID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);//Mailing Id
                                objCampaignMailing.CreatedDate = DateTime.Now;
                                objCampaignMailing.ModifiedDate = DateTime.Now;
                                objCampaignMailing.IsActive = true;
                                objCampaignMailing.Insert();
                            }
                            status = true;
                            insert = true;
                        }
                        hiddenCampaignID.Value = campaignMasterID.ToString();
                        lblCampName.Text = objCampaignMaster.CampaignName.ToString().Trim();
                        Rflag = true;
                        statusType = "Inserted";
                        //statusType = "Updated";
                        ViewState["statusType"] = "Inserted";
                        hdCampDetailsTab1.Value = "0"; //After Save CampaignDetails Iam Change the Value of Hidden Variable value to Zero.
                    }
                }
                else
                {
                    updateCampaignDetailsTab();
                    Rflag = true;
                }
            }
            return Rflag;
        }