Exemplo n.º 1
0
 public void bindContent()
 {
     try
     {
         TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(templateID);
         TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        public void bindContent()
        {
            try
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(templateID);
                TemplateMaster tempMaster = TemplateMaster.SelectOne(pk,ConnectionString);
                //contentEditor.Content = campMaster.HTMLContent;

                contentdiv.InnerHtml = tempMaster.HTMLContent;
                textdiv.InnerText = tempMaster.TextContent;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
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");
            }


        }
Exemplo n.º 4
0
        //[WebMethod(EnableSession = true)]
        //public XmlDocument SendCampaign(string UserID, string Password, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, DataSet ds)
        //{
        //    StringBuilder str = new StringBuilder();
        //    try
        //    {

        //        string Con = GetConnectionString(UserID, Password);
        //        #region Contacts
        //        str.Append("<CampaignDetails>");
        //        LogStartInfo("AddRecipient", Con, UserID);
        //        DataTable contacts = ds.Tables[0];
        //        string ContactIds = "";
        //        if (Con.Trim().Length != 0)
        //        {
        //            if (contacts.Rows.Count > 0 && !(contacts.Columns.IndexOf("EmailAddress") == -1))
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at Contacts region");
        //                foreach (DataRow contact in contacts.Rows)
        //                {
        //                    ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", contact["EmailAddress"].ToString(), Con);


        //                    if (contemail.Count > 0)
        //                    {
        //                        try
        //                        {
        //                            ContactIds = ContactIds + contemail[0].ContactId.ToString() + ",";
        //                            ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(contemail[0].ContactId.ToString()));
        //                            ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
        //                            objContactMaster.FirstName = contact["FirstName"].ToString();
        //                            objContactMaster.LastName = contact["LastName"].ToString();
        //                            #region Handling Custom fields

        //                            foreach (DataColumn column in contacts.Columns)
        //                            {
        //                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
        //                                string custField = "";
        //                                if (customFieldDt.Rows.Count > 0)
        //                                {
        //                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
        //                                }
        //                                if (custField != "" && customFieldDt.Rows.Count > 0 && contact[column.ColumnName] != "")
        //                                {
        //                                    switch (custField)
        //                                    {
        //                                        case "CustomField1":
        //                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField2":
        //                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField3":
        //                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField4":
        //                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField5":
        //                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField6":
        //                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField7":
        //                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField8":
        //                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField9":
        //                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField10":
        //                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField11":
        //                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField12":
        //                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField13":
        //                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField14":
        //                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField15":
        //                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField16":
        //                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField17":
        //                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField18":
        //                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField19":
        //                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField20":
        //                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField21":
        //                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField22":
        //                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField23":
        //                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField24":
        //                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField25":
        //                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField26":
        //                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField27":
        //                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField28":
        //                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField29":
        //                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField30":
        //                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField31":
        //                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField32":
        //                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField33":
        //                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField34":
        //                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField35":
        //                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField36":
        //                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField37":
        //                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField38":
        //                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField39":
        //                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField40":
        //                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField41":
        //                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField42":
        //                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField43":
        //                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField44":
        //                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField45":
        //                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField46":
        //                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField47":
        //                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField48":
        //                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField49":
        //                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField50":
        //                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                    }
        //                                }


        //                            }

        //                            #endregion
        //                            if (objContactMaster.Update() == true)
        //                            {
        //                                //str.Append("<Message>Recipient Updated Successfully</Message>");
        //                                Logger.logdata(logforRpService, "Recipient Updated Successfully");
        //                            }
        //                            else
        //                            {
        //                                //str.Append("<Error>Recipient  Update Failed</Error>");
        //                                Logger.logdata(logforRpService, "Recipient  Update Failed");
        //                            }

        //                        }
        //                        catch (Exception ex)
        //                        {
        //                            str.Append("<Error>Edit Contact: Problem at updating contact</Error>");
        //                            Logger.logdata(logforRpService, ex.Message);

        //                        }


        //                    }
        //                    else
        //                    {
        //                        try
        //                        {
        //                            ContactMaster objContactMaster = new ContactMaster(Con);
        //                            objContactMaster.EmailAddress = contact["EmailAddress"].ToString(); ;
        //                            objContactMaster.EmailContentType = "Html";
        //                            objContactMaster.CreatedDate = DateTime.Now;
        //                            objContactMaster.FirstName = contact["FirstName"].ToString();
        //                            objContactMaster.LastName = contact["LastName"].ToString();
        //                            #region Handling Custom fields

        //                            foreach (DataColumn column in contacts.Columns)
        //                            {
        //                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
        //                                string custField = "";
        //                                if (customFieldDt.Rows.Count > 0)
        //                                {
        //                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
        //                                }
        //                                if (custField != "" && customFieldDt.Rows.Count > 0 && contact[column.ColumnName] != "")
        //                                {
        //                                    switch (custField)
        //                                    {
        //                                        case "CustomField1":
        //                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField2":
        //                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField3":
        //                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField4":
        //                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField5":
        //                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField6":
        //                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField7":
        //                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField8":
        //                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField9":
        //                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField10":
        //                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField11":
        //                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField12":
        //                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField13":
        //                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField14":
        //                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField15":
        //                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField16":
        //                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField17":
        //                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField18":
        //                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField19":
        //                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField20":
        //                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField21":
        //                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField22":
        //                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField23":
        //                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField24":
        //                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField25":
        //                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField26":
        //                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField27":
        //                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField28":
        //                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField29":
        //                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField30":
        //                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField31":
        //                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField32":
        //                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField33":
        //                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField34":
        //                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField35":
        //                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField36":
        //                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField37":
        //                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField38":
        //                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField39":
        //                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField40":
        //                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField41":
        //                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField42":
        //                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField43":
        //                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField44":
        //                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField45":
        //                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField46":
        //                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField47":
        //                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField48":
        //                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField49":
        //                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField50":
        //                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                    }
        //                                }


        //                            }

        //                            #endregion
        //                            objContactMaster.IsActive = true;
        //                            objContactMaster.InsertWithDefaultValues(true);
        //                            Int64 ContactId = Convert.ToInt64(objContactMaster.ContactId);
        //                            ContactIds = ContactIds + ContactId + ",";
        //                            Logger.logdata(logforRpService, "Recipient Added Successfully");

        //                        }
        //                        catch (Exception ex)
        //                        {
        //                            str.Append("<Error>Add New Contact: Problem at adding contact</Error>");
        //                            Logger.logdata(logforRpService, ex.Message);

        //                        }

        //                    }

        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at Contacts region end");

        //            }
        //            else
        //            {
        //                str.Append("<Error>No records found to send Campaign</Error>");
        //            }


        //            LogEndInfo("AddRecipient");
        //        #endregion
        //            TemplateMaster tempMaster = null;
        //            #region Template
        //            try
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at Template region");
        //                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);
        //                }
        //                else
        //                {
        //                    str.Append("<Error>" + TemplateName + " Template Not found</Error>");

        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at Template region end");

        //            }
        //            catch (Exception ex)
        //            {

        //                str.Append("<Error>Template: Problem at getting mail content</Error>");
        //                Logger.logdata(logforRpService, ex.Message);
        //            }

        //            #endregion
        //            ListMasterBase listMaster = null;
        //            Int64 listid = 0;
        //            #region List
        //            try
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at List region");
        //                if (str.ToString().IndexOf("Error") == -1)
        //                {
        //                    listMaster = new ListMasterBase(Con);
        //                    listMaster.ListName = "4VL_" + DateTime.Now;
        //                    listMaster.CreatedDate = System.DateTime.Now;
        //                    listMaster.InsertWithDefaultValues(true);
        //                    listid = Convert.ToInt64(listMaster.ListMasterID);
        //                    str.Append("<ListId>" + listid.ToString() + "</ListId>");
        //                    ContactIds = ContactIds.Substring(0, ContactIds.Length - 1);
        //                    string[] selectContact = ContactIds.Split(',');
        //                    if (listid > 0)
        //                    {
        //                        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)));
        //                        StringBuilder strbAddedContacts = new StringBuilder();
        //                        //ArrayList contactsSelected = (ArrayList)Session["SelectedContacts"];
        //                        foreach (string contactID in selectContact)
        //                        {
        //                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
        //                            rowListContactMaster["ListMasterID"] = listid;
        //                            rowListContactMaster["ContactId"] = contactID;
        //                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
        //                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
        //                            dtListContactMaster.Rows.Add(rowListContactMaster);
        //                        }
        //                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate" };
        //                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate" };
        //                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, Con);
        //                        str.Append("<Message>Recipients Add Successfully to Lists</Message>");
        //                    }
        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at List region end");


        //            }
        //            catch (Exception ex)
        //            {
        //                str.Append("<Error>List: Problem at ListCreation contact</Error>");
        //                Logger.logdata(logforRpService, ex.Message);
        //            }


        //            #endregion
        //            #region SendCampaign
        //            if (listMaster != null && listid > 0 && str.ToString().IndexOf("Error") == -1)
        //            {
        //                try
        //                {
        //                    Logger.logdata(logforRpService, "SendCampaign() at SendCampaign region");
        //                    CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampaignName, Con);
        //                    if (camp.Count > 0)
        //                    {
        //                        str.Append("<CampaignId>" + camp[0].CampaignId.ToString() + "</CampaignId>");
        //                        str.Append("<Message>Campaign Name AllReady Exist</Message>");
        //                    }
        //                    else
        //                    {
        //                        CampaignMaster objCampaignMaster = new CampaignMaster(Con);
        //                        objCampaignMaster.CampaignName = CampaignName;
        //                        objCampaignMaster.CampaignDescription = "";
        //                        objCampaignMaster.FromAddress = FromAddress;
        //                        objCampaignMaster.FromName = FromName;
        //                        objCampaignMaster.ReplytoAddress = ReplyToAddress;
        //                        objCampaignMaster.ReplaytoName = "";
        //                        objCampaignMaster.Subject = Subject;
        //                        objCampaignMaster.TrackReads = true;//"1";
        //                        objCampaignMaster.SelectCondition = listid.ToString();
        //                        objCampaignMaster.TemplateId = tempMaster.TemplateId;

        //                        objCampaignMaster.ModifiedDate = DateTime.Now;
        //                        objCampaignMaster.CreatedDate = DateTime.Now;

        //                        objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
        //                        objCampaignMaster.TextContent = "";
        //                        objCampaignMaster.SuppressDomain = "";
        //                        objCampaignMaster.UnsubscribeText = "";
        //                        objCampaignMaster.UnsubscribeLinkText = "";
        //                        objCampaignMaster.SuppressSelection = "";
        //                        Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
        //                        if (campaignMasterID > 0)
        //                        {
        //                            CampaignJob objCampaignJob = new CampaignJob(Con);
        //                            objCampaignJob.CampaignMasterID = campaignMasterID;
        //                            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();
        //                        }
        //                        str.Append("<TemplateID>" + tempMaster.TemplateId.ToString() + "</TemplateID>");
        //                        str.Append("<CampaignId>" + campaignMasterID.ToString() + "</CampaignId>");
        //                        str.Append("<Message>Campaign Inserted Succefully</Message>");
        //                        Logger.logdata(logforRpService, "SendCampaign() at SendCampaign region end");

        //                    }


        //                }
        //                catch (Exception ex)
        //                {
        //                    str.Append("<Error>Send Campaign :" + ex.Message + "</Error>");
        //                    Logger.logdata(logforRpService, ex.Message);
        //                }

        //            }
        //        }
        //        else
        //        {
        //            str.Append("<Error>Failed to Connect Database</Error>");
        //            Logger.logdata(logforRpService, "Please Enter Valid Inputs");
        //        }
        //            #endregion


        //    }
        //    catch (Exception ex)
        //    {
        //        str.Append("<Error>" + ex.Message + "</Error>");
        //        Logger.logError(logforRpService, ex);
        //    }
        //    str.Append("</CampaignDetails>");
        //    doc.LoadXml(str.ToString());
        //    return doc;

        //}
        public string ScheduleCampaign(string Con, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID)
        {
            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 = "";
                    objCampaignMaster.UnsubscribeText = "";
                    objCampaignMaster.UnsubscribeLinkText = "";
                    objCampaignMaster.SuppressSelection = "";
                    objCampaignMaster.AssignedCampaignID = 0;
                    Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                    if (campaignMasterID > 0)
                    {
                        CampaignJob objCampaignJob = new CampaignJob(Con);
                        objCampaignJob.CampaignMasterID = campaignMasterID;
                        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, "Campaign Inserted Succefully");
                    return (campaignMasterID.ToString());
                }
                else
                {
                    return ("False");
                }

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


        }
Exemplo n.º 5
0
        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 XmlDocument EditMailing(string UserID, string Password, long MailingID, string MailingName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<MailingEditInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length > 0)
            {
                if (MailingID != 0 && MailingName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)//(Convert.ToDateTime(LaunchDateTime) > DateTime.Now))
                {
                    TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                    TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);

                    CampaignMasterPrimaryKey CampPk = new CampaignMasterPrimaryKey(MailingID);
                    CampaignMaster campMaster = CampaignMaster.SelectOne(CampPk, ConnectionString);
                    if (campMaster.CampaignName == MailingName)
                    {
                        campMaster.TemplateId = TempId;
                        campMaster.FromName = FromName;
                        campMaster.ReplytoAddress = ReplyEmailAdd;
                        campMaster.SelectCondition = ListIds;
                        campMaster.Subject = Subject;
                        campMaster.ModifiedDate = DateTime.Now;
                        campMaster.htmlHasUnsubLink = true;
                        campMaster.HTMLContent = tempMaster.HTMLContent;
                        campMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                        campMaster.UnsubscribeLinkText = "Unsubscribe";
                    }
                    else
                    {
                        campMaster.CampaignName = MailingName;
                        campMaster.TemplateId = TempId;
                        campMaster.FromName = FromName;
                        campMaster.ReplytoAddress = ReplyEmailAdd;
                        campMaster.SelectCondition = ListIds;
                        campMaster.Subject = Subject;
                        campMaster.htmlHasUnsubLink = true;
                        campMaster.ModifiedDate = DateTime.Now;
                        campMaster.HTMLContent = tempMaster.HTMLContent;
                        campMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                        campMaster.UnsubscribeLinkText = "Unsubscribe";
                    }
                    campMaster.Update();
                    CampaignJobs objCampaignjobs = CampaignJob.SelectByField("CampaignMasterID", MailingID, ConnectionString);
                    if (objCampaignjobs.Count > 0)
                    {
                        objCampaignjobs[0].ID = objCampaignjobs[0].ID;
                        objCampaignjobs[0].BounceCount = objCampaignjobs[0].BounceCount;
                        objCampaignjobs[0].ClickCount = objCampaignjobs[0].ClickCount;
                        objCampaignjobs[0].CreatedDatetime = objCampaignjobs[0].CreatedDatetime;
                        objCampaignjobs[0].OpenCount = objCampaignjobs[0].OpenCount;
                        objCampaignjobs[0].OptoutCount = objCampaignjobs[0].OptoutCount;
                        objCampaignjobs[0].DeliveredCount = objCampaignjobs[0].DeliveredCount;
                        objCampaignjobs[0].Status = 1;
                        objCampaignjobs[0].StatusMessage = objCampaignjobs[0].StatusMessage;
                        objCampaignjobs[0].CampaignMasterID = MailingID;// Convert.ToInt64(hiddenCampaignID.Value);
                        objCampaignjobs[0].ScheduledDatetime = LaunchDateTime.AddMinutes(2); //Convert.ToDateTime(scheduledTime);
                        objCampaignjobs[0].SendType = "IMMEDIATE";
                        objCampaignjobs[0].Update();
                        str.Append("<Message>Mailing Updated Succefully</Message>");
                    }
                }
                else
                {
                    str.Append("<Message>Enter Valid Inputs</Message>");
                }

            }
            else
                str.Append("<Message>Enter Valid UserName and password</Message>");

            str.Append("</MailingEditInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemplo n.º 7
0
        public XmlDocument EditCampaign(string UserID, string Password, long campId, string CampName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignEditInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && campId != 0 && CampName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)//(Convert.ToDateTime(LaunchDateTime) > DateTime.Now))
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);

                CampaignMasterPrimaryKey CampPk = new CampaignMasterPrimaryKey(campId);
                CampaignMaster campMaster = CampaignMaster.SelectOne(CampPk, ConnectionString);
                if (campMaster.CampaignName == CampName)
                {
                    campMaster.TemplateId = TempId;
                    campMaster.FromName = FromName;
                    campMaster.ReplytoAddress = ReplyEmailAdd;
                    campMaster.SelectCondition = ListIds;
                    campMaster.Subject = Subject;
                    campMaster.ModifiedDate = DateTime.Now;
                    campMaster.HTMLContent = tempMaster.HTMLContent;
                }
                else
                {
                    campMaster.CampaignName = CampName;
                    campMaster.TemplateId = TempId;
                    campMaster.FromName = FromName;
                    campMaster.ReplytoAddress = ReplyEmailAdd;
                    campMaster.SelectCondition = ListIds;
                    campMaster.Subject = Subject;
                    campMaster.ModifiedDate = DateTime.Now;
                    campMaster.HTMLContent = tempMaster.HTMLContent;
                }
                campMaster.Update();
                CampaignJobs objCampaignjobs = CampaignJob.SelectByField("CampaignMasterID", campId, ConnectionString);
                if (objCampaignjobs.Count > 0)
                {
                    objCampaignjobs[0].ID = objCampaignjobs[0].ID;
                    objCampaignjobs[0].BounceCount = objCampaignjobs[0].BounceCount;
                    objCampaignjobs[0].ClickCount = objCampaignjobs[0].ClickCount;
                    objCampaignjobs[0].CreatedDatetime = objCampaignjobs[0].CreatedDatetime;
                    objCampaignjobs[0].OpenCount = objCampaignjobs[0].OpenCount;
                    objCampaignjobs[0].OptoutCount = objCampaignjobs[0].OptoutCount;
                    objCampaignjobs[0].DeliveredCount = objCampaignjobs[0].DeliveredCount;
                    objCampaignjobs[0].Status = 1;
                    objCampaignjobs[0].StatusMessage = objCampaignjobs[0].StatusMessage;
                    objCampaignjobs[0].CampaignMasterID = campId;// Convert.ToInt64(hiddenCampaignID.Value);
                    objCampaignjobs[0].ScheduledDatetime = LaunchDateTime.AddMinutes(2); //Convert.ToDateTime(scheduledTime);
                    objCampaignjobs[0].SendType = "IMMEDIATE";
                    objCampaignjobs[0].Update();
                    str.Append("<Message>Campaign Updated Succefully</Message>");
                }
            }
            else
            {
                str.Append("<Message>Enter Valid Inputs</Message>");
            }
            str.Append("</CampaignEditInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemplo n.º 8
0
        /// <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="TemplateMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class TemplateMaster</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/24/2009 12:37:33 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static TemplateMaster SelectOneWithCampaignMasterUsingTemplateId(TemplateMasterPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            TemplateMaster 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_TemplateMaster_SelectOneWithCampaignMasterUsingTemplateId", ref ExecutionState);
            if (dr.Read())
            {
                obj= new TemplateMaster(ConnectionString);
                PopulateObjectFromReader(obj,dr);

                dr.NextResult();

                //Get the child records.
                obj.CampaignMasters=CampaignMaster.PopulateObjectsFromReader(dr,ConnectionString);
            }
            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
Exemplo n.º 9
0
        public XmlDocument GetTemplateIdByTemplateName(string UserID, string Password, string TemplateName)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            try
            {
                str.Append("<TemplateInfo>");
                string Con = GetConnectionString(UserID, Password);

                if (Con.Trim().Length != 0 && TemplateName.Length != 0)
                {
                    object Template = TemplateName;
                    long TemplateID = 0;
                    TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", Template, Con);
                    if (obj.Count > 0)
                    {
                        TemplateID = Convert.ToInt64(obj[0].TemplateId.ToString());

                        TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TemplateID);
                        TemplateMaster objTemplateMaster = TemplateMaster.SelectOne(pk, Con);

                        //if (objTemplateMaster.TemplateId == TemplateID)
                        //{
                        //    objTemplateMaster.Delete();
                        //    str.Append("<Message>Recipient Deleted Successfully</Message>");
                        //}
                        //else
                        //{
                        //    str.Append("<Message>Please Enter Valid TemplateID</Message>");
                        //}
                        str.Append("<TemplateId>" + Server.HtmlEncode(objTemplateMaster.TemplateId.ToString()) + "</TemplateId>");
                        str.Append("<TemplateName>" + Server.HtmlEncode(objTemplateMaster.TemplateName.ToString()) + "</TemplateName>");

                        if (string.IsNullOrEmpty(objTemplateMaster.TemplateDescription))
                            str.Append("<TemplateDescription>" + string.Empty + "</TemplateDescription>");
                        else
                            str.Append("<TemplateDescription>" + Server.HtmlEncode(objTemplateMaster.TemplateDescription.ToString()) + "</TemplateDescription>");
                        if (string.IsNullOrEmpty(objTemplateMaster.CreatedDate.ToString()))
                            str.Append("<TemplateCreatedDate>" + string.Empty + "</TemplateCreatedDate>");
                        else
                            str.Append("<TemplateCreatedDate>" + objTemplateMaster.CreatedDate.ToString() + "</TemplateCreatedDate>");
                        if (string.IsNullOrEmpty(objTemplateMaster.HTMLContent.ToString()))
                            str.Append("<TemplateContent>" + string.Empty + "</TemplateContent>");
                        else
                            str.Append("<TemplateContent>" + objTemplateMaster.HTMLContent.ToString() + "</TemplateContent>");
                    }
                    else
                    {
                        str.Append("<Message>TemplateName " + TemplateName + " not exist</Message>");
                    }

                }
                else
                {
                    str.Append("<Message>Please Enter Valid Inputs</Message>");
                }
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
            catch (Exception)
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
        }
Exemplo n.º 10
0
        //Used to fill the Template details based on the ListMasterID.
        protected void fillTemplateDetails()
        {
            try
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(templateID);
                TemplateMaster template = TemplateMaster.SelectOne(pk, ConnectionString);
                if (template.TemplateDescription != null)
                    txtDescription.Text = Server.HtmlDecode(template.TemplateDescription.ToString());
                else
                    txtDescription.Text = "";
                string tempname = template.TemplateName;
                txtTemplateName.Text = tempname;
                if (template.TextContent != string.Empty && template.HTMLContent != string.Empty)
                {
                    divHtml.Style.Add("display", "block");
                    divtextHtml.Style.Add("display", "none");
                }
                else if (template.HTMLContent == string.Empty && template.TextContent != string.Empty)
                {
                    divHtml.Style.Add("display", "none");
                    divtextHtml.Style.Add("display", "block");
                }
                else
                {
                    divHtml.Style.Add("display", "block");
                    divtextHtml.Style.Add("display", "none");
                }
                textRadEditor.Content = template.TextContent;
                RadEditor1.Content = template.HTMLContent;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 11
0
        /// <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="TemplateMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class CampaignMasters</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			1/8/2010 11:55:21 AM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static CampaignMasters SelectAllByForeignKeyFromTemplateMaster(TemplateMasterPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            CampaignMasters 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_CampaignMaster_SelectAllByForeignKeyTemplateMaster", ref ExecutionState);
            obj = new CampaignMasters();
            obj = CampaignMaster.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper,ConnectionString);

            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
Exemplo n.º 12
0
        protected void RbarBtn_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Create")
            {
                Response.Redirect("~/Editor/CreateTemplateNew.aspx?edit=false");
            }
            else if (e.Item.Text == "Edit")
            {
                for (int i = 0; i < grdCreatives.Rows.Count; i++)
                {
                    CheckBox grdaddchkSelectContact = (CheckBox)grdCreatives.Rows[i].FindControl("grdaddchkSelectRecs");
                    if (grdaddchkSelectContact != null && grdaddchkSelectContact.Checked == true)
                    {
                        Label TId = (Label)grdCreatives.Rows[i].FindControl("lblTemplateId");
                        TempId = Convert.ToInt32(TId.Text);
                    }
                }
                hdfield.Value = TempId.ToString();
                Response.Redirect("~/Editor/CreateTemplateNew.aspx?id=" + hdfield.Value + "&edit=true");
            }
            else if (e.Item.Text == "Delete")
            {
                for (int i = 0; i < grdCreatives.Rows.Count; i++)
                {
                    CheckBox grdaddchkSelectContact = (CheckBox)grdCreatives.Rows[i].FindControl("grdaddchkSelectRecs");
                    if (grdaddchkSelectContact != null && grdaddchkSelectContact.Checked == true)
                    {
                        Label TId = (Label)grdCreatives.Rows[i].FindControl("lblTemplateId");
                        TempId = Convert.ToInt32(TId.Text);
                    }
                }
                hdfldDelID.Value = TempId.ToString();
                divDeletePopup.Style.Add("display", "Block");
                ModalPopupExtender2.Show();
            }
            else if (e.Item.Text == "Preview")
            {
                lblMessage.Text = string.Empty;
                for (int i = 0; i < grdCreatives.Rows.Count; i++)
                {
                    CheckBox grdaddchkSelectContact = (CheckBox)grdCreatives.Rows[i].FindControl("grdaddchkSelectRecs");
                    if (grdaddchkSelectContact != null && grdaddchkSelectContact.Checked == true)
                    {
                        Label TId = (Label)grdCreatives.Rows[i].FindControl("lblTemplateId");
                        TempId = Convert.ToInt32(TId.Text);
                    }
                }
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                TemplateMaster template = TemplateMaster.SelectOne(pk, ConnectionString);
                if (template.HTMLContent != null && template.TextContent != null)
                {
                    TempContent = TempId + "`" + template.HTMLContent.ToString() + "`" + template.TextContent.ToString() + "TEXT";
                }
                else
                {
                    TempContent = TempId + "`" + " " + "`" + " " + "TEXT";
                }
                string[] commandArgs = TempContent.ToString().Split(new char[] { '`' });
                string strTemplateId = commandArgs[0];
                string strHtmlContent = commandArgs[1];
                string strTextContent = commandArgs[2];

                // Hear 'HTML' and 'TEXT' text given by Developer in Creatives.asps based on that we identify the above splited string contain html and text containt  or not.
                if (strTextContent.ToString() != "TEXT")
                {
                    if (strTextContent != "")
                    {
                        string UrlStr = "PreviewTextContent.aspx?ID=" + Convert.ToInt32(strTemplateId) + "&type=creatives";
                        string fullURL = "window.open('" + UrlStr + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW1", fullURL, true);
                    }
                }
                if (strHtmlContent != "HTML")
                {
                    if (strHtmlContent != "")
                    {
                        string UrlStr1 = "Preview.aspx?ID=" + Convert.ToInt32(strTemplateId) + "&type=creatives";
                        string fullURL1 = "window.open('" + UrlStr1 + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
                        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL1, true);
                    }
                }
                RadToolBarItem itemToDelete = RbarBtn.FindItemByText("Delete");
                itemToDelete.Enabled = true;
                RadToolBarItem itemToPreview = RbarBtn.FindItemByText("Preview");
                itemToPreview.Enabled = true;
            }
        }
Exemplo n.º 13
0
        protected void fillTemplateDetails()
        {
            try
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(templateID);
                TemplateMaster template = TemplateMaster.SelectOne(pk, ConnectionString);
                txtDescription.Text = Server.HtmlDecode(template.TemplateDescription.ToString());
                string tempname = template.TemplateName;

                txtTemplateName.Text = Server.HtmlDecode(tempname);//template.TemplateName;
                txtTextContent.Text = template.TextContent;
                contentEditor.Content = template.HTMLContent;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
        public XmlDocument GetTemplateByTemplateId(string UserID, string Password, long TemplateID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            try
            {
                str.Append("<TemplateInfo>");
                string Con = GetConnectionString(UserID, Password);

                if (Con.Trim().Length != 0 && Convert.ToInt64(TemplateID) != 0)
                {
                    TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TemplateID);
                    TemplateMaster objTemplateMaster = TemplateMaster.SelectOne(pk, Con);

                    str.Append("<TemplateId>" + Server.HtmlEncode(objTemplateMaster.TemplateId.ToString()) + "</TemplateId>");
                    str.Append("<TemplateName>" + Server.HtmlEncode(objTemplateMaster.TemplateName.ToString()) + "</TemplateName>");

                    if (string.IsNullOrEmpty(objTemplateMaster.TemplateDescription))
                        str.Append("<TemplateDescription>" + string.Empty + "</TemplateDescription>");
                    else
                        str.Append("<TemplateDescription>" + Server.HtmlEncode(objTemplateMaster.TemplateDescription.ToString()) + "</TemplateDescription>");
                    if (string.IsNullOrEmpty(objTemplateMaster.CreatedDate.ToString()))
                        str.Append("<TemplateCreatedDate>" + string.Empty + "</TemplateCreatedDate>");
                    else
                        str.Append("<TemplateCreatedDate>" + objTemplateMaster.CreatedDate.ToString() + "</TemplateCreatedDate>");
                    if (string.IsNullOrEmpty(objTemplateMaster.HTMLContent.ToString()))
                        str.Append("<TemplateContent>" + string.Empty + "</TemplateContent>");
                    else
                    {
                        String HtmlString = Server.HtmlEncode(objTemplateMaster.HTMLContent.Trim());
                        str.Append("<TemplateContent>" + HtmlString + "</TemplateContent>");
                    }
                }
                else
                {
                    str.Append("<Message>Please Enter Valid UserID and Password and Valid TemplateID</Message>");
                }
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
            catch (Exception ex)
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
        }
Exemplo n.º 15
0
        public XmlDocument EditTemplate(string UserID, string Password, long TemplateID, string TemplateName, string HtmlContent)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<TemplateInfo>");
            string Con = GetConnectionString(UserID, Password);
            if (TemplateID != 0 && TemplateName.Trim().Length != 0 && HtmlContent.Trim().Length != 0 && Con.Trim().Length != 0)
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TemplateID);
                TemplateMaster templateMaster = TemplateMaster.SelectOne(pk, Con);

                if (templateMaster.TemplateName == TemplateName)
                {
                    templateMaster.HTMLContent = HtmlContent;
                    templateMaster.ModifiedDate = DateTime.Now;
                }
                else
                {
                    templateMaster.TemplateName = TemplateName;
                    templateMaster.HTMLContent = HtmlContent;
                    templateMaster.ModifiedDate = DateTime.Now;
                }

                if (templateMaster.Update() == true)
                {
                    str.Append("<Message>Template Updated Successfully</Message>");
                }
                else
                {
                    str.Append("<Message>Template Update Failed</Message>");
                }
            }
            else
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
            }
            str.Append("</TemplateInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemplo n.º 16
0
        public XmlDocument DeleteTemplate(string UserID, string Password, long TemplateID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            try
            {
                str.Append("<TemplateInfo>");
                string Con = GetConnectionString(UserID, Password);

                if (Con.Trim().Length != 0 && Convert.ToInt64(TemplateID) != 0)
                {
                    CampaignMasters campaignMasters = CampaignMaster.SelectByField("TemplateId", TemplateID, Con);
                    if (campaignMasters.Count > 0)
                    {
                        str.Append("<Message>Template cannot be Deleted it is being used in Campaigns.</Message>");
                    }
                    else
                    {
                        TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TemplateID);
                        TemplateMaster objTemplateMaster = TemplateMaster.SelectOne(pk, Con);

                        if (objTemplateMaster.TemplateId == TemplateID)
                        {
                            objTemplateMaster.Delete();
                            str.Append("<Message>Template Deleted Successfully</Message>");
                        }
                        else
                        {
                            str.Append("<Message>Please Enter Valid TemplateID</Message>");
                        }
                    }
                }
                else
                {
                    str.Append("<Message>Please Enter Valid Inputs</Message>");
                }
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
            catch (Exception)
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
                str.Append("</TemplateInfo>");
                doc.LoadXml(str.ToString());
                return doc;
            }
        }
        public void creatives_bindContent()
        {
            try
            {
                TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(templateID);
                TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                string templateContent;
                string editorType = Request.QueryString["EditorType"].ToString();
                if (editorType.Equals("TEXT"))
                {
                    templateContent = tempMaster.TextContent;
                    if (templateContent.ToLower().Contains("listunsubscribe"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]",System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"] );
                    }
                    if (templateContent.ToLower().Contains("globalunsubscribe"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]",System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"]);
                    }
                    if (templateContent.ToLower().Contains("forwardtofriend"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:FORWARDTOFRIEND!]",System.Configuration.ConfigurationManager.AppSettings["ForwardToFriendLinkPath"]);
                    }
                    if (templateContent.ToLower().Contains("mirrorweblink"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "");
                    }
                }
                else
                {
                    templateContent = tempMaster.HTMLContent;
                    if (templateContent.ToLower().Contains("listunsubscribe"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");

                    }
                    if (templateContent.ToLower().Contains("globalunsubscribe"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");

                    }
                    if (templateContent.ToLower().Contains("forwardtofriend"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "");

                    }
                    if (templateContent.ToLower().Contains("mirrorweblink"))
                    {
                        templateContent = templateContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "");
                    }
                }
                contentdiv.InnerHtml = templateContent;
                //txtTextContent.Text = tempMaster.TextContent;
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="TemplateMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/24/2009 12:37:33 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(TemplateMasterPrimaryKey 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_TemplateMaster_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
Exemplo n.º 19
0
        protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                chkAddress.Checked = false;
                RadEditor1.Content = string.Empty;
                textRadEditor.Content = string.Empty;
                if (ddlTemplate.SelectedItem.Text != defaultListItem)
                {
                    hdDdlValue.Value = ddlTemplate.SelectedValue;//Store the selected value in HiddenVariable
                    TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(Convert.ToInt64(ddlTemplate.SelectedItem.Value));
                    TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);

                    RadEditor1.Content = RadEditor1.Content + tempMaster.HTMLContent;// +tempMaster.TextContent;
                    textRadEditor.Content = textRadEditor.Content + tempMaster.TextContent;

                    if (RadEditor1.Content.ToString() != string.Empty && textRadEditor.Content.ToString() != string.Empty)
                    {
                        lbtnHtml.Visible = true;
                        lbtnText.Visible = true;
                        divHtml.Style.Add("display", "block");
                        divtextHtml.Style.Add("display", "none");
                    }
                    else
                    {
                        if (textRadEditor.Content.ToString() != string.Empty)
                        {
                            lbtnText.Visible = true;
                            lbtnHtml.Visible = false;
                            divHtml.Style.Add("display", "none");
                            divtextHtml.Style.Add("display", "block");

                        }
                        if (RadEditor1.Content.ToString() != string.Empty)
                        {
                            lbtnHtml.Visible = true;
                            lbtnText.Visible = false;
                            divHtml.Style.Add("display", "block");
                            divtextHtml.Style.Add("display", "none");
                        }
                    }
                }
                else
                {
                    lbtnHtml.Visible = true;
                    lbtnText.Visible = true;
                    divHtml.Style.Add("display", "block");
                    divtextHtml.Style.Add("display", "none");
                    RadEditor1.Content = string.Empty;
                    textRadEditor.Content = string.Empty;
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 20
0
        public void creatives_bindContent()
        {
            try
            {
                pk = new TemplateMasterPrimaryKey(templateID);
                tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                templateContent = tempMaster.HTMLContent;
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();

                if (templateContent.ToLower().Contains("listunsubscribe"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('List UnSubscribe link will be activated after your email is sent.)'>");
                }
                if (templateContent.ToLower().Contains("globalunsubscribe"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (templateContent.ToLower().Contains("forwardtofriend"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (templateContent.ToLower().Contains("mirrorweblink"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }

                if (templateContent.ToLower().Contains("amm"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:AMM!]", "javascript:onClick=alert('AMM version link Can not be activated in Preview Or Test mode.')");
                }
                if (templateContent.ToLower().Contains("amm2"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:AMM2!]", "javascript:onClick=alert('AMM2 version link Can not be activated in Preview Or Test mode.')");
                }
                #region this logic will add click link to the content

                if (templateContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = templateContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    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);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                if (templateContent.ToLower().Contains(linkID))
                                {
                                    templateContent = templateContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                }
                            }
                        }
                    }
                }

                #endregion
                contentdiv.InnerHtml = templateContent;
                ViewState["Content"] = templateContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Creatives";
            }
        }
Exemplo n.º 21
0
        public XmlDocument SendMail(string UserID, string Password, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, DataSet Recipients)
        {
            StringBuilder str = new StringBuilder();
            try
            {
                str.Append("<CampaignInfo>");
                string Con = GetConnectionString(UserID, Password);
                string validEmailIds = string.Empty;
                string unsubEmailIds = string.Empty;
                string hardBounceEmailIds = string.Empty;
                string softBounceEmailIds = string.Empty;
                string duplicateEmailids = string.Empty;



                DataTable contacts = Recipients.Tables[0];
                // string ContactIds = "";                
                Hashtable contatcInfo = new Hashtable();
                if (Con.Trim().Length != 0)
                {
                    LogStartInfo("SendMail", Con, UserID);
                    Logger.logdata(logforRpService, "Input Paramiters :Camapign Name = " + CampaignName + "; Template Name =" + TemplateName + "; No.of Contacts=" + Recipients.Tables[0].Rows.Count);
                    if (!(contacts.Columns.IndexOf("EmailAddress") == -1) && !(contacts.Columns.IndexOf("FirstName") == -1) && !(contacts.Columns.IndexOf("LastName") == -1))
                    {
                        string QueryString = "";
                        #region Template
                        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);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.logdata(logforRpService, "Template region :" + ex.Message);
                        }

                        #endregion

                        #region Contacts

                        if (contacts.Rows.Count > 0 && tempMaster != null)
                        {
                            string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();
                            string eidsString = String.Join(",", EmailIds);
                            Logger.logdata(logforRpService, "EmailIds from User :"******"<RecipientInfo>");
                            foreach (DataRow contact in contacts.Rows)
                            {
                                ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", contact["EmailAddress"].ToString(), Con);

                                DataTable unSubDetails = new DataTable();
                                DataTable contactMasters = ContactMaster.GetBouceStatusByEmailIds(Con, contact["EmailAddress"].ToString());

                                if (contemail.Count > 0)
                                {
                                    unSubDetails = UnSubscribeDetail.GetUnSubDetailsByContactId(Con, contemail[0].ContactId.ToString(), string.Empty);
                                }
                                if (unSubDetails.Rows.Count > 0)
                                {
                                    str.Append("<Undelivered>");
                                    if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                    {
                                        str.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        str.Append("<FirstName>" + contact["FirstName"].ToString() + "</FirstName>");
                                        str.Append("<LastName>" + contact["LastName"].ToString() + "</LastName>");
                                        str.Append("<RecipientStatus>Unsubscribe</RecipientStatus>");
                                        unsubEmailIds = unsubEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    else if (unSubDetails.Rows[0]["Reason"].ToString() == "bad-mailbox" || unSubDetails.Rows[0]["Reason"].ToString() == "bad-domain")
                                    {
                                        str.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        str.Append("<FirstName>" + contact["FirstName"].ToString() + "</FirstName>");
                                        str.Append("<LastName>" + contact["LastName"].ToString() + "</LastName>");
                                        str.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                        hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    str.Append("</Undelivered>");
                                }
                                else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                {
                                    str.Append("<Undelivered>");
                                    str.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                    str.Append("<FirstName>" + contact["FirstName"].ToString() + "</FirstName>");
                                    str.Append("<LastName>" + contact["LastName"].ToString() + "</LastName>");
                                    str.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                    str.Append("</Undelivered>");
                                    softBounceEmailIds = softBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                }

                                else if (contemail.Count > 0 && contemail[0].EmailAddress.Trim().Length > 0)
                                {
                                    try
                                    {
                                        if (contemail[0].IsActive == true)
                                        {
                                            QueryString = "";
                                            for (int i = 0; i < contact.ItemArray.Length; i++)
                                            {
                                                QueryString = QueryString + contact.Table.Columns[i].ColumnName + "!RPFieldValue!" + contact[contact.Table.Columns[i].ColumnName] + "!RPDynamicField!";
                                            }
                                            if (!contatcInfo.ContainsKey(contemail[0].ContactId))
                                            {
                                                contatcInfo.Add(contemail[0].ContactId, QueryString);
                                                validEmailIds = validEmailIds + contemail[0].EmailAddress + ";";
                                            }
                                            else
                                                duplicateEmailids = duplicateEmailids + contemail[0].EmailAddress + ";";
                                            ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(contemail[0].ContactId.ToString()));
                                            ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
                                            objContactMaster.FirstName = contact["FirstName"].ToString();
                                            objContactMaster.LastName = contact["LastName"].ToString();
                                            #region Handling Custom fields

                                            foreach (DataColumn column in contacts.Columns)
                                            {
                                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
                                                string custField = "";
                                                if (customFieldDt.Rows.Count > 0)
                                                {
                                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                                }
                                                if (custField != "" && customFieldDt.Rows.Count > 0 && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {
                                                    switch (custField)
                                                    {
                                                        case "CustomField1":
                                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField2":
                                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField3":
                                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField4":
                                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField5":
                                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField6":
                                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField7":
                                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField8":
                                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField9":
                                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField10":
                                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField11":
                                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField12":
                                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField13":
                                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField14":
                                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField15":
                                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField16":
                                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField17":
                                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField18":
                                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField19":
                                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField20":
                                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField21":
                                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField22":
                                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField23":
                                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField24":
                                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField25":
                                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField26":
                                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField27":
                                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField28":
                                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField29":
                                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField30":
                                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField31":
                                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField32":
                                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField33":
                                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField34":
                                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField35":
                                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField36":
                                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField37":
                                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField38":
                                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField39":
                                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField40":
                                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField41":
                                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField42":
                                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField43":
                                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField44":
                                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField45":
                                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField46":
                                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField47":
                                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField48":
                                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField49":
                                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField50":
                                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
                                                            break;
                                                    }
                                                }


                                            }

                                            #endregion
                                            if (objContactMaster.Update() == true)
                                            {
                                                //str.Append("<Message>Recipient Updated Successfully</Message>");
                                            }
                                            else
                                            {
                                                //str.Append("<Error>Recipient  Update Failed</Error>");
                                                Logger.logdata(logforRpService, "Recipient  Update Failed");
                                            }
                                        }

                                    }
                                    catch (Exception ex)
                                    {
                                        str.Append("<Error>Edit Contact: Problem at updating contact</Error>");
                                        Logger.logdata(logforRpService, "Update Contact :" + ex.Message);

                                    }

                                }
                                else if (contact["EmailAddress"] != null && contact["EmailAddress"].ToString().Trim().Length > 0)
                                {
                                    try
                                    {
                                        ContactMaster objContactMaster = new ContactMaster(Con);
                                        objContactMaster.EmailAddress = contact["EmailAddress"].ToString();
                                        objContactMaster.EmailContentType = "Html";
                                        objContactMaster.CreatedDate = DateTime.Now;
                                        objContactMaster.FirstName = contact["FirstName"].ToString();
                                        objContactMaster.LastName = contact["LastName"].ToString();
                                        #region Handling Custom fields

                                        foreach (DataColumn column in contacts.Columns)
                                        {
                                            DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
                                            string custField = "";
                                            if (customFieldDt.Rows.Count > 0)
                                            {
                                                custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                            }
                                            if (custField != "" && customFieldDt.Rows.Count > 0 && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                            {
                                                switch (custField)
                                                {
                                                    case "CustomField1":
                                                        objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField2":
                                                        objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField3":
                                                        objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField4":
                                                        objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField5":
                                                        objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField6":
                                                        objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField7":
                                                        objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField8":
                                                        objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField9":
                                                        objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField10":
                                                        objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField11":
                                                        objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField12":
                                                        objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField13":
                                                        objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField14":
                                                        objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField15":
                                                        objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField16":
                                                        objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField17":
                                                        objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField18":
                                                        objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField19":
                                                        objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField20":
                                                        objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField21":
                                                        objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField22":
                                                        objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField23":
                                                        objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField24":
                                                        objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField25":
                                                        objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField26":
                                                        objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField27":
                                                        objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField28":
                                                        objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField29":
                                                        objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField30":
                                                        objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField31":
                                                        objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField32":
                                                        objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField33":
                                                        objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField34":
                                                        objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField35":
                                                        objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField36":
                                                        objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField37":
                                                        objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField38":
                                                        objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField39":
                                                        objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField40":
                                                        objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField41":
                                                        objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField42":
                                                        objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField43":
                                                        objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField44":
                                                        objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField45":
                                                        objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField46":
                                                        objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField47":
                                                        objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField48":
                                                        objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField49":
                                                        objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "CustomField50":
                                                        objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
                                                        break;
                                                }
                                            }


                                        }

                                        #endregion
                                        objContactMaster.IsActive = true;
                                        objContactMaster.InsertWithDefaultValues(true);
                                        Int64 ContactId = Convert.ToInt64(objContactMaster.ContactId);
                                        // ContactIds = ContactIds + ContactId + ",";
                                        QueryString = "";
                                        for (int i = 0; i < contact.ItemArray.Length; i++)
                                        {
                                            QueryString = QueryString + contact.Table.Columns[i].ColumnName + "!RPFieldValue!" + contact[contact.Table.Columns[i].ColumnName] + "!RPDynamicField!";

                                        }
                                        if (!contatcInfo.ContainsKey(ContactId))
                                        {
                                            contatcInfo.Add(ContactId, QueryString);
                                            validEmailIds = validEmailIds + contact["EmailAddress"].ToString() + ";";
                                        }
                                        else
                                            duplicateEmailids = duplicateEmailids + contact["EmailAddress"].ToString() + ";";

                                    }
                                    catch (Exception ex)
                                    {
                                        str.Append("<Error>Add New Contact: Problem at adding contact</Error>");
                                        Logger.logdata(logforRpService, "Add New Contact: " + ex.Message);

                                    }

                                }

                            }
                            str.Append("</RecipientInfo>");

                        }


                        #endregion

                        #region List
                        ListMasterBase listMaster = null;
                        Int64 listid = 0;
                        try
                        {

                            if (str.ToString().IndexOf("<Error>") == -1 && tempMaster != null && contatcInfo.Count > 0)
                            {

                                listMaster = new ListMasterBase(Con);
                                listMaster.ListName = "4VL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss:ffff");
                                listMaster.CreatedDate = System.DateTime.Now;
                                listMaster.InsertWithDefaultValues(true);
                                listid = Convert.ToInt64(listMaster.ListMasterID);
                                //ContactIds = ContactIds.Substring(0, ContactIds.Length - 1);
                                //string[] selectContact = ContactIds.Split(',');
                                if (listid > 0)
                                {

                                    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("QueryString", typeof(string)));
                                    dtListContactMaster.Columns.Add(new DataColumn("IsActive", typeof(bool)));
                                    StringBuilder strbAddedContacts = new StringBuilder();

                                    foreach (DictionaryEntry item in contatcInfo)
                                    {

                                        DataRow rowListContactMaster = dtListContactMaster.NewRow();
                                        rowListContactMaster["ListMasterID"] = listid;
                                        rowListContactMaster["ContactId"] = item.Key;
                                        rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                                        rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                                        rowListContactMaster["QueryString"] = item.Value;
                                        rowListContactMaster["IsActive"] = true;
                                        dtListContactMaster.Rows.Add(rowListContactMaster);

                                    }

                                    string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "QueryString", "IsActive" };
                                    string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "QueryString", "IsActive" };
                                    ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, Con);

                                }
                            }


                        }
                        catch (Exception ex)
                        {
                            str.Append("<Error>List: Problem at ListCreation contact</Error>");
                            Logger.logdata(logforRpService, "List: " + ex.Message);
                        }


                        #endregion

                        CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampaignName, Con);
                        if (camp.Count > 0)
                        {
                            Logger.logdata(logforRpService, "SendMail():Campaign sending failed,CampaignName with name " + CampaignName + " allready exist");
                            str.Append("<Error>Camapign : " + CampaignName + " allready exist</Error>");

                        }
                        if (CampaignName.Length > 75)
                        {
                            Logger.logdata(logforRpService, "SendMail():Campaign sending failed,CampaignName name max length exided");
                            str.Append("<Error>Camapign : Campaign name exided max length of 75 chars </Error>");

                        }
                        else if (tempMaster == null)
                        {
                            Logger.logdata(logforRpService, "SendMail():Campaign sending failed,TemplateName with name " + TemplateName + " not exist");
                            str.Append("<Error>Tempalte : " + TemplateName + " not found</Error>");
                        }
                        else if (listid <= 0)
                        {
                            Logger.logdata(logforRpService, "SendMail():Campaign sending failed,List with id " + listid.ToString() + " not exist");
                            str.Append("<Error>List :Zero records found(Check contact status)</Error>");
                        }
                        #region Schedule Camapign

                        string CampainID = "False";
                        str.Append("<CampaignDetails>");
                        if (str.ToString().IndexOf("<Error>") == -1)
                        {
                            CampainID = ScheduleCampaign(Con, CampaignName, Subject, FromName, ReplyToAddress, FromAddress, TemplateName, listid.ToString());

                            if (CampainID != "False")
                            {
                                str.Append("<CampaignID>" + CampainID + "</CampaignID>");
                                str.Append("<TemplateName>" + TemplateName + "</TemplateName>");
                                str.Append("<TemplateID>" + tempMaster.TemplateId + "</TemplateID>");
                                str.Append("<ListName>" + listMaster.ListName + "</ListName>");
                                str.Append("<ListID>" + listMaster.ListMasterID + "</ListID>");
                                Logger.logdata(logforRpService, "Success ::Campaign ID: " + CampainID + " ;Camapign Name : " + CampaignName + " ;Template Name : " + TemplateName + " ;List Name: " + listMaster.ListName);
                                Logger.logdata(logforRpService, "No. of valid Contacts found  : " + contatcInfo.Count);
                                Logger.logdata(logforRpService, "No. of invalid Contacts found: " + (contacts.Rows.Count - contatcInfo.Count));
                                Logger.logdata(logforRpService, "valid Contacts found         : " + validEmailIds);
                                Logger.logdata(logforRpService, "Unsubscribed Mails           :" + unsubEmailIds);
                                Logger.logdata(logforRpService, "HardBounce triggered Mails   :" + hardBounceEmailIds);
                                Logger.logdata(logforRpService, "SoftBounce triggered Mails   :" + hardBounceEmailIds);
                                Logger.logdata(logforRpService, "Duplicate EmailIds           :" + duplicateEmailids);

                            }
                            else
                            {
                                str.Append("<Error>ScheduleCampaign : Problem at scheduling campaign</Error>");
                                Logger.logdata(logforRpService, "Problem at scheduling campaign");
                            }


                        }
                        str.Append("</CampaignDetails>");
                        if (str.ToString().IndexOf("<Error>") == -1)
                            str.Append("<Status>True</Status>");
                        else
                            str.Append("<Status>False</Status>");
                        LogEndInfo("SendMail");


                        #endregion
                    }
                    else
                    {
                        Logger.logdata(logforRpService, "SendMail():Column with name EmailAddress(and/or)FirstName(and/or)LastName not found in input DataSet");
                        str.Append("<Error>Input DataSet:Contact must contain EmailAddress,FirstName and LastName fields</Error>");
                    }

                }
                else
                {
                    str.Append("<Status>False</Status>");
                    str.Append("<Error>Invalid UserID OR Password</Error>");
                    Logger.logdata(logforRpService, "Invalid UserID OR Password");
                }


            }
            catch (Exception ex)
            {
                str.Append("<Status>False</Status>");
                str.Append("<Error>Failed to connect database</Error>");
                Logger.logError(logforRpService, ex);
            }
            str.Append("</CampaignInfo>");

            doc.LoadXml(str.ToString());
            return doc;

        }
Exemplo n.º 22
0
        public XmlDocument AddCampaign(string UserID, string Password, string CampName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && CampName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)//(Convert.ToDateTime(LaunchDateTime) > DateTime.Now))
            {
                //ListMasters list = ListMaster.SelectByField("ListName", ListName, ConnectionString);
                CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampName, ConnectionString);
                if (camp.Count > 0)
                {
                    str.Append("<Message>Campaign Name AllRedy Existed</Message>");
                }
                else
                {
                    TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                    TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                    if (tempMaster != null)
                    {
                        CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                        objCampaignMaster.CampaignName = CampName;
                        objCampaignMaster.CampaignDescription = "";
                        objCampaignMaster.FromAddress = FromAdd;
                        objCampaignMaster.FromName = FromName;
                        objCampaignMaster.ReplytoAddress = ReplyEmailAdd;
                        objCampaignMaster.ReplaytoName = "";
                        objCampaignMaster.Subject = Subject;
                        objCampaignMaster.TrackReads = true;//"1";
                        objCampaignMaster.SelectCondition = ListIds;
                        objCampaignMaster.TemplateId = TempId;

                        objCampaignMaster.ModifiedDate = DateTime.Now;
                        objCampaignMaster.CreatedDate = DateTime.Now;

                        objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                        objCampaignMaster.TextContent = "";
                        objCampaignMaster.SuppressDomain = "";
                        Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                        if (campaignMasterID > 0)
                        {
                            CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                            objCampaignJob.CampaignMasterID = campaignMasterID;
                            objCampaignJob.CreatedDatetime = DateTime.Now;
                            objCampaignJob.ScheduledDatetime = LaunchDateTime.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                            objCampaignJob.SendType = "IMMEDIATE";
                            objCampaignJob.Status = 1;
                            objCampaignJob.Insert();
                        }
                        str.Append("<Message>Campaign Inserted Succefully</Message>");
                    }
                    else
                    {
                        str.Append("<Message>Enter Valid TemplateId</Message>");
                    }
                }
            }
            else
            {
                str.Append("<Message>Enter Valid Inputs</Message>");
            }
            str.Append("</CampaignInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Exemplo n.º 23
0
 public XmlDocument AddMailing(string UserID, string Password, string MailingName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
 {
     XmlDocument doc = new System.Xml.XmlDocument();
     StringBuilder str = new StringBuilder();
     str.Append("<MailingInfo>");
     string ConnectionString = GetConnectionString(UserID, Password);
     if (ConnectionString.Trim().Length != 0)
     {
         if (IsValidEmail(FromAdd) && IsValidEmail(ReplyEmailAdd) && MailingName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)
         {
             CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", MailingName, ConnectionString);
             if (camp.Count > 0)
             {
                 str.Append("<MailingId>" + camp[0].CampaignId.ToString() + "</MailingId>");
                 str.Append("<Message>Mailing Name Allredy Exist</Message>");
             }
             else
             {
                 TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                 TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                 if (tempMaster != null)
                 {
                     CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                     objCampaignMaster.CampaignName = MailingName;
                     objCampaignMaster.CampaignDescription = "";
                     objCampaignMaster.FromAddress = FromAdd;
                     objCampaignMaster.FromName = FromName;
                     objCampaignMaster.ReplytoAddress = ReplyEmailAdd;
                     objCampaignMaster.ReplaytoName = "";
                     objCampaignMaster.Subject = Subject;
                     objCampaignMaster.TrackReads = true;//"1";
                     objCampaignMaster.SelectCondition = ListIds;
                     objCampaignMaster.TemplateId = TempId;
                     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.SuppressSelection = "";
                     objCampaignMaster.htmlHasUnsubLink = true;
                     objCampaignMaster.txtHasUnsubLink = true;
                     objCampaignMaster.AssignedCampaignID = 0;
                     Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                     if (campaignMasterID > 0)
                     {
                         CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                         objCampaignJob.CampaignMasterID = campaignMasterID;
                         objCampaignJob.CreatedDatetime = DateTime.Now;
                         objCampaignJob.ScheduledDatetime = LaunchDateTime.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                         objCampaignJob.SendType = "IMMEDIATE";
                         objCampaignJob.Status = 1;
                         objCampaignJob.Insert();
                     }
                     str.Append("<MailingId>" + campaignMasterID.ToString() + "</MailingId>");
                     str.Append("<Message>Mailing Inserted Succefully</Message>");
                 }
                 else
                 {
                     str.Append("<Error>Enter Valid TemplateId</Error>");
                 }
             }
         }
         else
         {
             str.Append("<Error>Please Enter Valid Email Addresses and Ensure All The Fields are not empty</Error>");
         }
     }
     else
         str.Append("<Message>Please Enter Valid UserName and Password</Message>");
     str.Append("</MailingInfo>");
     doc.LoadXml(str.ToString());
     return doc;
 }