예제 #1
0
        public void binddata(Int64 id)
        {
            try
            {
                hdfield.Value = id.ToString();
                ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(hdfield.Value));
                ContactMaster contMaster = ContactMaster.SelectOne(pk, ConnectionString);
                txtFirstName1.Text = contMaster.FirstName;
                txtLastName1.Text = contMaster.LastName;
                txtEmailAddress1.Text = contMaster.EmailAddress;
                txtAddress11.Text = contMaster.Address1;
                txtAddress21.Text = contMaster.Address2;
                txtCity.Text = contMaster.City;
                txtCountry.Text = contMaster.Country;
                txtFax.Text = contMaster.Fax;
                txtHomePhone.Text = contMaster.HomePhone;
                txtMobilePhone.Text = contMaster.MobilePhone;
                txtPostalCode.Text = contMaster.PostalCode;
                txtState.Text = contMaster.State;
                txtWorkPhone.Text = contMaster.WorkPhone;
                ddlEmailContentType.Text = contMaster.EmailContentType;
                ddlGender.Text = contMaster.Gender;
                ddlMaritalStatus.Text = contMaster.MaritalStatus;

                chkIsActive1.Checked = Convert.ToBoolean(contMaster.IsActive);
                chkMakeVerified1.Checked = Convert.ToBoolean(contMaster.IsVerified);
                ListContactMasters listContMasters = ListContactMaster.SelectByField("ContactId", Convert.ToInt64(hdfield.Value), ConnectionString);
                foreach (ListContactMaster list in listContMasters)
                {
                    ListMasters listMasters = ListMaster.SelectByField("ListMasterID", list.ListMasterID, ConnectionString);
                    lstBoxListNames.Items.Add(new ListItem(listMasters[0].ListName, listMasters[0].ListMasterID.ToString()));
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
예제 #2
0
 public XmlDocument GetRecipientWithRecipientID(string UserID, string Password, long contactID)
 {
     try
     {
         StringBuilder str = new StringBuilder();
         str.Append("<RecipientInfo>");
         string Con = GetConnectionString(UserID, Password);
         LogStartInfo("GetRecipientWithRecipientID", Con, UserID);
         if (Con.Trim().Length != 0 && Convert.ToInt64(contactID) != 0)
         {
             ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(contactID);
             ContactMaster contMaster = ContactMaster.SelectOne(pk, Con);
             str.Append("<EmailAddress>" + contMaster.EmailAddress.ToString() + "</EmailAddress> ");
             str.Append("<CreatedDate>" + contMaster.CreatedDate.ToString() + "</CreatedDate> ");
             str.Append("<ModifiedDate>" + contMaster.ModifiedDate.ToString() + "</ModifiedDate> ");
             str.Append("<Deleted>" + contMaster.IsDeleted.ToString() + "</Deleted> ");
             str.Append("<IsActive>" + contMaster.IsActive.ToString() + "</IsActive> ");
             ListContactMasters listContMasters = ListContactMaster.SelectByField("ContactId", contactID, Con);
             foreach (ListContactMaster list in listContMasters)
             {
                 ListMasters listMasters = ListMaster.SelectByField("ListMasterID", list.ListMasterID, Con);
                 str.Append("<ListName>" + listMasters[0].ListName + "</ListName> ");
                 str.Append("<ListID>" + listMasters[0].ListMasterID.ToString() + "</ListID> ");
             }
         }
         str.Append("</RecipientInfo>");
         LogEndInfo("GetRecipientWithRecipientID");
         doc.LoadXml(str.ToString());
     }
     catch (Exception ex)
     {
         Logger.logError(logforRpService, ex);
     }
     return doc;
 }
예제 #3
0
        public XmlDocument LaunchMailingWithSuppressList(string UserID, string Password, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, DataSet Recipients, DataSet SuppressList, DataSet SeedList, string SchedulteDate, string sendType, string TemplateContent, string toReportMailID, string ApproverMailID)
        {
            string mailingId = string.Empty;
            string templateName = "SBTemplate" + DateTime.Now;
            StringBuilder mailContent = new StringBuilder();
            mailContent.Append("<table  width=\"700\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
            //mailContent.Append("<tr><td align=\"left\" valign=\"top\" ><table width=\"700\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"-webkit-border-radius: 10px;	-moz-border-radius: 10px;	border-radius: 10px;	border:solid #0167b5; 	border-width:1px 1px 1px 1px; background:#e8f3f7;\"><tr><td width=\"248\" align=\"left\" valign=\"top\" style=\"padding:5px;\"><img src=\"http://mta1.1pointinteractive.com/1Point/images/Logo-Login.png\" width=\"81\" height=\"44\" /></td><td width=\"250\" align=\"right\" valign=\"bottom\" style=\"padding:5px; font-family:arial; font-size:13px; color:#039; font-weight:bold;\">API Log Report_" + CampaignName + " </td></tr></table></td></tr>");
            List<string> emailColumns = new List<string>();
            emailColumns.Add("Email Address");
            emailColumns.Add("emailaddress");
            emailColumns.Add("email");
            emailColumns.Add("e-mail");
            emailColumns.Add("Email");
            emailColumns.Add("e-mailaddress");
            emailColumns.Add("emailaddress");
            emailColumns.Add("emailadd");
            emailColumns.Add("e-mailadd");
            emailColumns.Add("emailaddress");

            List<string> fnameColumns = new List<string>();
            fnameColumns.Add("firstname");
            fnameColumns.Add("first name");
            fnameColumns.Add("fname");

            List<string> lnameColumns = new List<string>();
            lnameColumns.Add("lastname");
            lnameColumns.Add("last name");
            lnameColumns.Add("lname");


            foreach (DataColumn clm in Recipients.Tables[0].Columns)
            {
                if (emailColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "EmailAddress";
                else if (fnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "FirstName";
                else if (lnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "LastName";

            }
            if (SuppressList != null && SuppressList.Tables.Count > 0)
            {
                foreach (DataColumn clm in SuppressList.Tables[0].Columns)
                {
                    if (emailColumns.Contains(clm.ToString().ToLower()))
                        SuppressList.Tables[0].Columns[clm.ToString()].ColumnName = "EmailAddress";
                    else if (fnameColumns.Contains(clm.ToString().ToLower()))
                        SuppressList.Tables[0].Columns[clm.ToString()].ColumnName = "FirstName";
                    else if (lnameColumns.Contains(clm.ToString().ToLower()))
                        SuppressList.Tables[0].Columns[clm.ToString()].ColumnName = "LastName";
                }
            }
            if (SeedList != null && SeedList.Tables.Count > 0)
            {
                foreach (DataColumn clm in SeedList.Tables[0].Columns)
                {
                    if (emailColumns.Contains(clm.ToString().ToLower()))
                        SeedList.Tables[0].Columns[clm.ToString()].ColumnName = "EmailAddress";
                    else if (fnameColumns.Contains(clm.ToString().ToLower()))
                        SeedList.Tables[0].Columns[clm.ToString()].ColumnName = "FirstName";
                    else if (lnameColumns.Contains(clm.ToString().ToLower()))
                        SeedList.Tables[0].Columns[clm.ToString()].ColumnName = "LastName";
                }
            }

            int subMailVertion = 1;
            StringBuilder str = new StringBuilder();
            StringBuilder unDeleverdInfo = new StringBuilder();
            str.Append("<MailingInfo>");
            str.Append("<MailingList>");
            try
            {
                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];
                Hashtable contatcInfo = new Hashtable();
                if (Con.Trim().Length != 0)
                {
                    LogStartInfo("LaunchMailingWithSuppressList", Con, UserID);
                    Logger.logdata(logforRpService, "Input Paramiters :Camapign Name = " + CampaignName + "; No.of Contacts=" + Recipients.Tables[0].Rows.Count);
                    if (!(contacts.Columns.IndexOf("EmailAddress") == -1))
                    {
                        string QueryString = "";
                        #region Template

                        TemplateMaster templateMaster = new TemplateMaster(Con);
                        templateMaster.TemplateName = templateName;
                        TemplateMasters tempMasters = TemplateMaster.SelectByField("TemplateName", templateName, Con);
                        if (tempMasters.Count > 0)
                        {
                            str.Append("<Message>Template Name Already Existed</Message>");
                            //mailContent.Append("<tr><td colspan=\"2\">Template Name Already Existed</td></tr>");
                        }
                        else
                        {
                            if (TemplateContent != "" && templateName != "")
                            {
                                TemplateContent = TemplateContent + "<br />If you no longer wish to receive these emails, simply click on the following link:<a href=\"[!RPLINK:GLOBALUNSUBSCRIBE!]\">Unsubscribe</a><br />";
                                templateMaster.HTMLContent = ExtractLinks(TemplateContent, Con);
                                templateMaster.CreatedDate = DateTime.Now;
                                int templateid = templateMaster.InsertReturnID();
                                //templateMaster.InsertWithDefaultValues(true);
                                str.Append("<Message>Template Added Successfully</Message>");
                                //mailContent.Append("<tr><td colspan=\"2\">Template created successfully</td></tr>");

                                str.Append("<TemplateId>" + templateid.ToString() + "</TemplateId>");
                                //mailContent.Append("<tr><td>Template ID</td><td>" + templateid.ToString() + "</td></tr>");
                                //mailContent.Append("<tr><td>Template Name</td><td>" + templateName + "</td></tr>");

                            }
                            else
                            {
                                str.Append("<Error>Please Enter Valid Inputs</Error>");
                                //mailContent.Append("<tr><td colspan=\"2\">No data found in uploaded template</td></tr>");
                            }
                        }
                        #endregion
                        Int64 listid = 0, SupListId = 0, SeedListId = 0;

                        ListMasterBase listMaster = null;
                        #region TargetList
                        if (contacts.Rows.Count > 0 && templateMaster != null)
                        {
                            string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();
                            string eidsString = String.Join(",", EmailIds);
                            Logger.logdata(logforRpService, "EmailIds from User :"******"<UndeliveredList>");

                            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)
                                {
                                    unDeleverdInfo.Append("<Undelivered>");
                                    if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                    {
                                        unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        unDeleverdInfo.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")
                                    {
                                        unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        unDeleverdInfo.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                        hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    unDeleverdInfo.Append("</Undelivered>");
                                }
                                else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                {
                                    unDeleverdInfo.Append("<Undelivered>");
                                    unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                    unDeleverdInfo.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                    unDeleverdInfo.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);

                                            #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();
                                                }
                                                else
                                                    custField = column.ColumnName;

                                                if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {

                                                    switch (custField)
                                                    {
                                                        case "EmailAddress":
                                                            objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "FirstName":
                                                            objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "LastName":
                                                            objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Address1":
                                                            objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "City":
                                                            objContactMaster.City = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "State":
                                                            objContactMaster.State = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "PostalCode":
                                                            objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Country":
                                                            objContactMaster.Country = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "WorkPhone":
                                                            objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "HomePhone":
                                                            objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "MobilePhone":
                                                            objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        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;

                                        #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();
                                            }
                                            else
                                                custField = column.ColumnName;

                                            if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                            {
                                                switch (custField)
                                                {
                                                    case "EmailAddress":
                                                        objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "FirstName":
                                                        objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "LastName":
                                                        objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Address1":
                                                        objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "City":
                                                        objContactMaster.City = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "State":
                                                        objContactMaster.State = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "PostalCode":
                                                        objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Country":
                                                        objContactMaster.Country = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "WorkPhone":
                                                        objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "HomePhone":
                                                        objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "MobilePhone":
                                                        objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    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);

                                    }

                                }

                            }
                            unDeleverdInfo.Append("</UndeliveredList>");

                        }

                        try
                        {

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

                                listMaster = new ListMasterBase(Con);
                                listMaster.ListName = "TL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                                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("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["IsActive"] = true;
                                        dtListContactMaster.Rows.Add(rowListContactMaster);
                                    }

                                    string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                                    string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "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

                        ListMasterBase SuplistMaster = null;
                        #region SuppressList
                        contatcInfo = new Hashtable();
                        if (SuppressList.Tables.Count > 0 && SuppressList.Tables[0].Rows.Count > 0 && SuppressList.Tables[0].Columns.Contains("EmailAddress"))
                        {
                            contacts = SuppressList.Tables[0];
                            string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();
                            string eidsString = String.Join(",", EmailIds);
                            Logger.logdata(logforRpService, "EmailIds from User :"******"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)
                                {
                                    //unDeleverdInfo.Append("<Undelivered>");
                                    //unDeleverdInfo.Append("<ListType>Suppress</ListType>");
                                    if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                    {
                                        //unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        //unDeleverdInfo.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")
                                    {
                                        //unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        //unDeleverdInfo.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                        hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    //unDeleverdInfo.Append("</Undelivered>");
                                }
                                else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                {
                                    //unDeleverdInfo.Append("<Undelivered>");
                                    //unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                    //unDeleverdInfo.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                    //unDeleverdInfo.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);

                                            #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();
                                                }
                                                else
                                                    custField = column.ColumnName;

                                                if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {

                                                    switch (custField)
                                                    {
                                                        case "EmailAddress":
                                                            objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "FirstName":
                                                            objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "LastName":
                                                            objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Address1":
                                                            objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "City":
                                                            objContactMaster.City = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "State":
                                                            objContactMaster.State = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "PostalCode":
                                                            objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Country":
                                                            objContactMaster.Country = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "WorkPhone":
                                                            objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "HomePhone":
                                                            objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "MobilePhone":
                                                            objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        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;

                                        #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();
                                            }
                                            else
                                                custField = column.ColumnName;

                                            if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                            {
                                                switch (custField)
                                                {
                                                    case "EmailAddress":
                                                        objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "FirstName":
                                                        objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "LastName":
                                                        objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Address1":
                                                        objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "City":
                                                        objContactMaster.City = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "State":
                                                        objContactMaster.State = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "PostalCode":
                                                        objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Country":
                                                        objContactMaster.Country = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "WorkPhone":
                                                        objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "HomePhone":
                                                        objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "MobilePhone":
                                                        objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    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);

                                    }

                                }

                            }

                        }

                        if (contatcInfo.Count > 0)
                        {
                            SuplistMaster = new ListMasterBase(Con);
                            SuplistMaster.ListName = "SL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                            SuplistMaster.CreatedDate = System.DateTime.Now;
                            SuplistMaster.Active = false;
                            SuplistMaster.InsertWithDefaultValues(true);
                            SupListId = Convert.ToInt64(SuplistMaster.ListMasterID);

                            ArrayList selectContact = new ArrayList();
                            ContactMasters contemail;
                            foreach (DataRow recipient in SuppressList.Tables[0].Rows)
                            {
                                contemail = ContactMaster.SelectByField("EmailAddress", recipient["EmailAddress"].ToString(), Con);
                                if (contemail.Count > 0)
                                    selectContact.Add(contemail[0].ContactId.ToString());
                            }

                            if (SupListId > 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("IsActive", typeof(bool)));
                                StringBuilder strbAddedContacts = new StringBuilder();

                                foreach (DictionaryEntry item in contatcInfo)
                                {
                                    DataRow rowListContactMaster = dtListContactMaster.NewRow();
                                    rowListContactMaster["ListMasterID"] = SupListId;
                                    rowListContactMaster["ContactId"] = item.Key;
                                    rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                                    rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                                    rowListContactMaster["IsActive"] = true;
                                    dtListContactMaster.Rows.Add(rowListContactMaster);
                                }

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

                            }

                        }

                        #endregion

                        ListMasterBase SeedlistMaster = null;
                        #region SeedList
                        contatcInfo = new Hashtable();
                        if (SeedList.Tables.Count > 0 && SeedList.Tables[0].Rows.Count > 0 && SeedList.Tables[0].Columns.Contains("EmailAddress"))
                        {
                            contacts = SeedList.Tables[0];
                            //DataRow dr;
                            //if (ApproverMailID.Contains(','))
                            //{
                            //    string[] MailIds = ApproverMailID.Split(',');
                            //    foreach (string mail in MailIds)
                            //    {
                            //        dr = contacts.NewRow();
                            //        dr["EmailAddress"] = mail;
                            //        contacts.Rows.Add(dr);
                            //    }
                            //}
                            //else
                            //{
                            //    dr = contacts.NewRow();
                            //    dr["EmailAddress"] = ApproverMailID;
                            //    contacts.Rows.Add(dr);
                            //}

                            string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();
                            string eidsString = String.Join(",", EmailIds);
                            Logger.logdata(logforRpService, "EmailIds from User :"******"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)
                                {
                                    //unDeleverdInfo.Append("<Undelivered>");
                                    // unDeleverdInfo.Append("<ListType>Seed</ListType>");
                                    if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                    {
                                        // unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        //unDeleverdInfo.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")
                                    {
                                        //unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        //unDeleverdInfo.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                        hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    //unDeleverdInfo.Append("</Undelivered>");
                                }
                                else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                {
                                    //unDeleverdInfo.Append("<Undelivered>");
                                    //unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                    //unDeleverdInfo.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                    //unDeleverdInfo.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);

                                            #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();
                                                }
                                                else
                                                    custField = column.ColumnName;

                                                if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {

                                                    switch (custField)
                                                    {
                                                        case "EmailAddress":
                                                            objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "FirstName":
                                                            objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "LastName":
                                                            objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Address1":
                                                            objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "City":
                                                            objContactMaster.City = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "State":
                                                            objContactMaster.State = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "PostalCode":
                                                            objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Country":
                                                            objContactMaster.Country = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "WorkPhone":
                                                            objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "HomePhone":
                                                            objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "MobilePhone":
                                                            objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        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;

                                        #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();
                                            }
                                            else
                                                custField = column.ColumnName;

                                            if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                            {
                                                switch (custField)
                                                {
                                                    case "EmailAddress":
                                                        objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "FirstName":
                                                        objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "LastName":
                                                        objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Address1":
                                                        objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "City":
                                                        objContactMaster.City = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "State":
                                                        objContactMaster.State = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "PostalCode":
                                                        objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "Country":
                                                        objContactMaster.Country = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "WorkPhone":
                                                        objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "HomePhone":
                                                        objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    case "MobilePhone":
                                                        objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                        break;
                                                    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);

                                    }

                                }

                            }

                        }

                        if (contatcInfo.Count > 0)
                        {
                            SeedlistMaster = new ListMasterBase(Con);
                            SeedlistMaster.ListName = "SDL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                            SeedlistMaster.CreatedDate = System.DateTime.Now;
                            SeedlistMaster.Active = true;
                            SeedlistMaster.IsSeedList = true;
                            SeedlistMaster.InsertWithDefaultValues(true);
                            SeedListId = Convert.ToInt64(SeedlistMaster.ListMasterID);

                            ArrayList selectContact = new ArrayList();
                            ContactMasters contemail;
                            foreach (DataRow recipient in SeedList.Tables[0].Rows)
                            {
                                contemail = ContactMaster.SelectByField("EmailAddress", recipient["EmailAddress"].ToString(), Con);
                                if (contemail.Count > 0)
                                    selectContact.Add(contemail[0].ContactId.ToString());
                            }

                            if (SeedListId > 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("IsActive", typeof(bool)));
                                StringBuilder strbAddedContacts = new StringBuilder();

                                foreach (DictionaryEntry item in contatcInfo)
                                {
                                    DataRow rowListContactMaster = dtListContactMaster.NewRow();
                                    rowListContactMaster["ListMasterID"] = SeedListId;
                                    rowListContactMaster["ContactId"] = item.Key;
                                    rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                                    rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                                    rowListContactMaster["IsActive"] = true;
                                    dtListContactMaster.Rows.Add(rowListContactMaster);
                                }

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

                            }

                        }

                        #endregion

                        CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampaignName, Con);
                        if (camp.Count > 0)
                        {
                            Logger.logdata(logforRpService, "LaunchMailingWithSuppressList():Mail sending failed,Mailing with name " + CampaignName + " allready exist");
                            str.Append("<Error>Mailing : " + CampaignName + " allready exist</Error>");
                        }
                        if (CampaignName.Length > 50)
                        {
                            Logger.logdata(logforRpService, "LaunchMailingWithSuppressList():Mail sending failed,MailingName name max length exided");
                            str.Append("<Error>Mailing : Mailing name exided max length of 75 chars </Error>");
                            //mailContent.Append("<tr><td colspan=\"2\">Mailing : Mailing name exided max length of 75 chars</td></tr>");
                        }
                        else if (templateMaster == null)
                        {
                            Logger.logdata(logforRpService, "LaunchMailingWithSuppressList():Mail sending failed,TemplateName with name " + templateName + " not exist");
                            str.Append("<Error>Tempalte : " + templateName + " not found</Error>");
                            //mailContent.Append("<tr><td colspan=\"2\">Tempalte : " + templateName + " not found</td></tr>");
                        }
                        else if (listid <= 0)
                        {
                            Logger.logdata(logforRpService, "LaunchMailingWithSuppressList():Mail sending failed,List with id " + listid.ToString() + " not exist");
                            str.Append("<Error>List :Zero records found(Check contact status)</Error>");
                            //mailContent.Append("<tr><td colspan=\"2\">List :Zero records found(Check contact status)</td></tr>");

                        }
                        #region Schedule Camapign

                        string CampainID = "False";
                        str.Append("<MailingDetails>");
                        if (str.ToString().IndexOf("<Error>") == -1)
                        {
                            CampainID = ScheduleMailingWithSuppressList(Con, CampaignName, Subject, FromName, ReplyToAddress, FromAddress, templateName, listid.ToString(), SupListId.ToString(), SeedListId.ToString(), SchedulteDate, sendType);

                            if (CampainID != "False")
                            {
                                string message = string.Empty;
                                SendTestMail(TemplateContent, CampainID, Convert.ToInt64(SeedListId), ApproverMailID, FromAddress, FromName, ReplyToAddress, Subject, Con);
                                mailingId = CampainID;
                                str.Append("<MailingID>" + CampainID + "</MailingID>");
                                str.Append("<TemplateName>" + templateName + "</TemplateName>");
                                str.Append("<TemplateID>" + templateMaster.TemplateId + "</TemplateID>");
                                str.Append("<ListName>" + listMaster.ListName + "</ListName>");
                                str.Append("<ListID>" + listMaster.ListMasterID + "</ListID>");
                                Logger.logdata(logforRpService, "Success ::Mailing ID: " + CampainID + " ;Mailing Name : " + CampaignName + ";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   :" + softBounceEmailIds);
                                Logger.logdata(logforRpService, "Duplicate EmailIds           :" + duplicateEmailids);
                                string ApproverPagePath = ConfigurationManager.AppSettings["ApproverPagePath"];
                                if (ApproverPagePath.Trim().Length > 0)
                                    ApproverPagePath = ApproverPagePath + "?UserName="******"&MailingID=" + CampainID;
                                mailContent.Append("<tr><td colspan=\"2\" height=\"70\" align=\"left\" valign=\"middle\" style=\"padding-bottom:10px; font-family:arial; font-size:13px; color:#666; font-weight:bold;\">Dear Member,<br/><br/>Your request for Email campaign scheduling has been received to our system successfully via API Call.<br/> Have a look at the Email campaign data submitted to the system and click on Approve Email button provided at end of this email to approve this job.</td></tr>");
                                mailContent.Append("<tr><td align=\"center\" valign=\"top\" style=\"-webkit-border-radius: 10px;	-moz-border-radius: 10px;	border-radius: 10px; border:solid #016ab3; border-width:1px;-webkit-box-shadow: 2px 2px 4px #999;	-moz-box-shadow: 2px 2px 4px #999;	box-shadow: 2px 2px 4px #999;\">");
                                mailContent.Append("<table width=\"500\" border=\"0\" cellpadding=\"8\" cellspacing=\"0\" >");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Client/User</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + UserID + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Mailing Name</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + CampaignName + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Mailing ID</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + mailingId + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">From Name </td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + FromName + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">From Mail</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + FromAddress + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Subject</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + Subject + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Reply To Mail</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + ReplyToAddress + "</td></tr>");
                                if (Recipients.Tables.Count > 0)
                                    mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Mailing List File Quantity </td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + Recipients.Tables[0].Rows.Count + "</td></tr>");
                                if (SuppressList.Tables.Count > 0)
                                    mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Suppress List File Quantity </td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + SuppressList.Tables[0].Rows.Count + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Schedule Date/Time</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + SchedulteDate + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Mailing List Name</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + listMaster.ListName + "</td></tr>");
                                mailContent.Append("<tr><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#0288cd;	font-weight:bold;\">Mailing List ID</td><td align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif;	font-size:13px;	color:#666;	font-weight:bold;\">" + listMaster.ListMasterID + "</td></tr>");
                                mailContent.Append("</table></td></tr>");
                                mailContent.Append("</table>");
                                mailContent.Append("<table width=\"700\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">");
                                mailContent.Append("<tr><td></td><td align=\"center\" valign=\"middle\" style=\"height: 50px\"><a href=\"" + ApproverPagePath + "\" onclick=\"window.open(this.href, 'ApproveMailing','left=20,top=20,width=550,height=200,toolbar=1,resizable=0'); return false;\"><img src=\"http://mta1.1pointinteractive.com/1Point/images/btn-approve-email.png\" /></a></td></tr>");
                                mailContent.Append("<tr><td colspan=\"2\" align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#666;	font-weight:bold;\">Thanks,</td></tr>");
                                mailContent.Append("<tr><td colspan=\"2\" align=\"left\" valign=\"middle\" style=\"font-family:Arial, Helvetica, sans-serif; font-size:13px;	color:#666;	font-weight:bold;\">1Point Support Team</td></tr>");
                                mailContent.Append("</table>");

                                if (toReportMailID.Trim().Length > 0)
                                {
                                    string fromMail = ConfigurationManager.AppSettings["ApiFromMail"];
                                    bool status = true;
                                    if (!ApproverMailID.Contains(','))
                                        status = sendEMail(fromMail, ApproverMailID, ReplyToAddress, "API Log Report_" + CampaignName, false, mailContent.ToString(), out message);
                                    else
                                    {
                                        status = sendEMail(fromMail, ApproverMailID, ReplyToAddress, "API Log Report_" + CampaignName, false, mailContent.ToString(), out message);
                                    }
                                    MailApproval objMailApproval = new MailApproval(Con);
                                    objMailApproval.MailingID = Convert.ToInt64(CampainID);
                                    objMailApproval.ApprovalMail = ApproverMailID;
                                    objMailApproval.ReportMailTo = toReportMailID;
                                    objMailApproval.ApprovalStatus = "NotApproved";
                                    objMailApproval.IsApprovalSent = status;
                                    objMailApproval.IsReportMailied = false;

                                    objMailApproval.IsActive = false;
                                    objMailApproval.OneHr = false;
                                    objMailApproval.TwoHr = false;
                                    objMailApproval.FourHr = false;
                                    objMailApproval.EightHr = false;
                                    objMailApproval.Insert();
                                }
                            }
                            else
                            {
                                str.Append("<Error>ScheduleMailing : Problem at scheduling a mailing</Error>");
                                Logger.logdata(logforRpService, "Problem at scheduling Mailing");
                            }

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


                        #endregion
                    }
                    else
                    {
                        Logger.logdata(logforRpService, "LaunchMailingWithSuppressList():Column with name EmailAddress(and/or)FirstName(and/or)LastName not found in input DataSet");
                        str.Append("<Error>Input DataSet:Contact must contain EmailAddress Field</Error>");
                    }
                }
                else
                {
                    str.Append("<Error>Invalid UserID OR Password</Error>");
                    str.Append("<MailingDetails>");
                    str.Append("<Status>False</Status>");
                    str.Append("</MailingDetails>");
                    Logger.logdata(logforRpService, "Invalid UserID OR Password");
                }
            }
            catch (Exception ex)
            {
                str.Append("<Error>Failed to connect database</Error>");
                str.Append("<MailingDetails>");
                str.Append("<Status>False</Status>");
                str.Append("</MailingDetails>");
                Logger.logError(logforRpService, ex);
            }
            str.Append("</MailingList>");
            if (str.ToString().IndexOf("<Error>") == -1)
                str.Append("<SubMailingCount>" + subMailVertion + "</SubMailingCount>");
            str.Append(unDeleverdInfo);
            str.Append("</MailingInfo>");

            doc.LoadXml(str.ToString());
            return doc;
        }
예제 #4
0
 public XmlDocument DeleteRecipient(string UserID, string Password, long ContactID)
 {
     try
     {
         StringBuilder str = new StringBuilder();
         str.Append("<RecipientInfo>");
         string Con = GetConnectionString(UserID, Password);
         LogStartInfo("DeleteRecipient", Con, UserID);
         if (Con.Trim().Length != 0 && Convert.ToInt64(ContactID) != 0)
         {
             ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(ContactID);
             ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
             if (objContactMaster.ContactId == ContactID)
             {
                 objContactMaster.deleteContactFromContactMasterAndListContactMaster(ContactID);
                 str.Append("<Message>Recipient Deleted Successfully</Message>");
                 Logger.logdata(logforRpService, "Recipient Deleted Successfully");
             }
             else
             {
                 str.Append("<Message>Please Enter Valid CmpaignID</Message>");
                 Logger.logdata(logforRpService, "Please Enter Valid CmpaignID");
             }
         }
         else
         {
             str.Append("<Message>Please Enter Valid Inputs</Message>");
             Logger.logdata(logforRpService, "Please Enter Valid Inputs");
         }
         str.Append("</RecipientInfo>");
         LogEndInfo("DeleteRecipient");
         doc.LoadXml(str.ToString());
     }
     catch (Exception ex)
     {
         Logger.logError(logforRpService, ex);
     }
     return doc;
 }
예제 #5
0
        public XmlDocument EditRecipient(string UserID, string Password, long ContactID, string EmailID)
        {
            try
            {
                StringBuilder str = new StringBuilder();
                str.Append("<RecipientInfo>");
                string Con = GetConnectionString(UserID, Password);
                LogStartInfo("EditRecipient", Con, UserID);
                if (ContactID > 0 && Con.Trim().Length != 0)
                {
                    ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(ContactID);
                    ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);

                    if (IsEmail(EmailID) == true)
                    {
                        objContactMaster.EmailAddress = EmailID;
                    }
                    else
                    {
                        str.Append("<Message>Please Enter Valid Email Format ex:([email protected])</Message>");
                    }
                    if (objContactMaster.Update() == true)
                    {
                        str.Append("<Message>Recipient Updated Successfully</Message>");
                        Logger.logdata(logforRpService, "Recipient Updated Successfully");
                    }
                    else
                    {
                        str.Append("<Message>Recipient  Update Failed</Message>");
                        Logger.logdata(logforRpService, "Recipient  Update Failed");
                    }
                }
                else
                {
                    str.Append("<Message>Please Enter Valid Inputs</Message>");
                    Logger.logdata(logforRpService, "Please Enter Valid Inputs");
                }
                str.Append("</RecipientInfo>");
                LogEndInfo("EditRecipient");
                doc.LoadXml(str.ToString());
            }
            catch (Exception ex)
            {
                Logger.logError(logforRpService, ex);
            }
            return doc;
        }
예제 #6
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;

        }
 public XmlDocument EditRecipientByEmailAddress(string UserID, string Password, string EmailAddress, string FirstName, string LastName)
 {
     try
     {
         StringBuilder str = new StringBuilder();
         str.Append("<RecipientInfo>");
         string Con = GetConnectionString(UserID, Password);
         LogStartInfo("EditRecipient", Con, UserID);
         if (Con.Trim().Length != 0)
         {
             if (IsValidEmail(EmailAddress) == true)
             {
                 ContactMasters objcontacts = ContactMaster.SelectByField("EmailAddress", EmailAddress, Con);
                 if (objcontacts.Count > 0)
                 {
                     ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(objcontacts[0].ContactId));
                     ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
                     objContactMaster.EmailAddress = EmailAddress;
                     objContactMaster.FirstName = FirstName;
                     objContactMaster.LastName = LastName;
                     objContactMaster.Update();
                     str.Append("<Message>Recipient Updated Successfully</Message>");
                 }
                 else
                     str.Append("<Message>" + EmailAddress + " not exist</Message>");
             }
             else
             {
                 str.Append("<Message>Please Enter Valid Email Format ex:([email protected])</Message>");
             }
         }
         else
         {
             str.Append("<Message>Please Enter Valid UserID and Password</Message>");
             Logger.logdata(logforRpService, "Please Enter Valid UserID and Password");
         }
         str.Append("</RecipientInfo>");
         LogEndInfo("EditRecipient");
         doc.LoadXml(str.ToString());
     }
     catch (Exception ex)
     {
         Logger.logError(logforRpService, ex);
     }
     return doc;
 }
예제 #8
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="ContactMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			1/11/2010 2:53:38 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(ContactMasterPrimaryKey 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_ContactMaster_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
예제 #9
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="ContactMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class ContactMaster</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			1/11/2010 2:53:38 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static ContactMaster SelectOneWithUnSubscribeDetailsUsingContactID(ContactMasterPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            ContactMaster 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_ContactMaster_SelectOneWithUnSubscribeDetailsUsingContactID", ref ExecutionState);
            if (dr.Read())
            {
                obj= new ContactMaster(ConnectionString);
                PopulateObjectFromReader(obj,dr);

                dr.NextResult();

                //Get the child records.
                obj.UnSubscribeDetails=UnSubscribeDetail.PopulateObjectsFromReader(dr,ConnectionString);
            }
            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            txtHomePhone.Attributes.Add("onkeypress", "return isNumberKey(event)");
            txtMobilePhone.Attributes.Add("onkeypress", "return isNumberKey(event)");
            if (Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {
                //get cleint database credentials.
                userName = Request.QueryString["Username"].ToString();
                ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();

                //userName = "******"; //user.UserName;
                //ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                //string dbName = "MarketerTest";//objProfileB    ase.GetPropertyValue("DBName").ToString();
                //string dbUserID = "sa";//objProfileBase.GetPropertyValue("DBUserID").ToString();
                //string dbPassword = "******";//objProfileBase.GetPropertyValue("DBPassword").ToString();
                //string dbServerName = "SQLSERVER\\SQL2008";//objProfileBase.GetPropertyValue("DBServerName").ToString();

                //userName = "******"; //user.UserName;
                //ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                //string dbName = "AMMgreg";//objProfileB    ase.GetPropertyValue("DBName").ToString();
                //string dbUserID = "sa";//objProfileBase.GetPropertyValue("DBUserID").ToString();
                //string dbPassword = "******";//objProfileBase.GetPropertyValue("DBPassword").ToString();
                //string dbServerName = "173.48.37.254\\SQL2008";//objProfileBase.GetPropertyValue("DBServerName").ToString();

                connectionString =
                   string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                 dbServerName, dbName, dbUserID, dbPassword);
                ConnectionStringHelper.ConStr = connectionString;

                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                campaignID = Convert.ToInt64(Request.QueryString["CampaignID"]);

                if (!IsPostBack)
                {
                    ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(contactID);
                    ContactMaster contMaster = ContactMaster.SelectOne(pk, connectionString);
                    txtFirstName.Text = contMaster.FirstName;
                    txtLastName.Text = contMaster.LastName;
                    txtAddress.Text = contMaster.Address1;
                    txtEmailAddress.Text = contMaster.EmailAddress;
                    txtCity.Text = contMaster.City;
                    txtCountry.Text = contMaster.Country;
                    txtState.Text = contMaster.State;
                    txtZipCode.Text = contMaster.PostalCode;
                    txtMobilePhone.Text = contMaster.MobilePhone;
                    txtHomePhone.Text = contMaster.HomePhone;
                    DisplayCustomControlValues(contMaster);
                    lblmsg.Text = txtFirstName.Text.ToString().Trim();// +", what are YOUR interests? To personalize Social U page, please choose your perferences below.";
                }
            }
        }
예제 #11
0
 public void deleteRecipient()
 {
     try
     {
         if (hdfield.Value != "0")
         {
             flagreset = true;
             //This is the new  logic developed by ganesh on 29dec09
             ContactMaster objContactMaster = new ContactMaster(ConnectionString);
             //delete the contact from contactmaster and listcontactmaster table and insert a new record in contacdeleted table.
             objContactMaster.deleteContactFromContactMasterAndListContactMaster(Convert.ToInt64(hdfield.Value));
             ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(hdfield.Value));
             ContactMaster contMasterDeleted = ContactMaster.SelectOne(pk, ConnectionString);
             lblMsg.Text = string.Format("Succesfully deleted contact with id: {0}", hdfield.Value);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
        public XmlDocument EditRecipient(string UserID, string Password, long ContactID, string EmailID, string EmilContentType, string Gender, string MaritialStatus)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<RecipientInfo>");
            string Con = GetConnectionString(UserID, Password);

            if (ContactID > 0 && Con.Trim().Length != 0)
            {
                ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(ContactID);
                ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);

                if (objContactMaster.EmailAddress == EmailID)
                {
                    objContactMaster.Gender = Gender;
                    objContactMaster.EmailContentType = EmilContentType;
                    objContactMaster.MaritalStatus = MaritialStatus;
                }
                else
                {
                    objContactMaster.EmailAddress = EmailID;
                    objContactMaster.Gender = Gender;
                    objContactMaster.EmailContentType = EmilContentType;
                    objContactMaster.MaritalStatus = MaritialStatus;
                }

                if (objContactMaster.Update() == true)
                {
                    str.Append("<Message>Recipient Updated Successfully</Message>");
                }
                else
                {
                    str.Append("<Message>Recipient  Update Failed</Message>");
                }
            }
            else
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
            }
            str.Append("</RecipientInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
예제 #13
0
        public XmlDocument DeleteRecipient(string UserID, string Password, long ContactID)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<RecipientInfo>");
            string Con = GetConnectionString(UserID, Password);

            if (Con.Trim().Length != 0 && Convert.ToInt64(ContactID) != 0)
            {
                ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(ContactID);
                ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
                if (objContactMaster.ContactId == ContactID)
                {
                    objContactMaster.deleteContactFromContactMasterAndListContactMaster(ContactID);
                    str.Append("<Message>Recipient Deleted Successfully</Message>");
                }
                else
                {
                    str.Append("<Message>Please Enter Valid CmpaignID</Message>");
                }
            }
            else
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
            }
            str.Append("</RecipientInfo>");
            doc.LoadXml(str.ToString());

            return doc;
        }
예제 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {

                //get cleint database credentials.
                userName = Request.QueryString["Username"].ToString();
                ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();

                //userName = "******"; //user.UserName;
                //ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                //string dbName = "MarketerTest";//objProfileB    ase.GetPropertyValue("DBName").ToString();
                //string dbUserID = "sa";//objProfileBase.GetPropertyValue("DBUserID").ToString();
                //string dbPassword = "******";//objProfileBase.GetPropertyValue("DBPassword").ToString();
                //string dbServerName = "SQLSERVER\\SQL2008";//objProfileBase.GetPropertyValue("DBServerName").ToString();

                connectionString =
                   string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                 dbServerName, dbName, dbUserID, dbPassword);
                ConnectionStringHelper.ConStr = connectionString;

                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                campaignID = Convert.ToInt64(Request.QueryString["CampaignID"]);
                if (!IsPostBack)
                {
                    ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(contactID);
                    ContactMaster contMaster = ContactMaster.SelectOne(pk, connectionString);
                    txtFirstName1.Text = contMaster.FirstName;
                    txtLastName1.Text = contMaster.LastName;
                    txtEmailAddress1.Text = contMaster.EmailAddress;
                    txtCity.Text = contMaster.City;
                    txtCountry.Text = contMaster.Country;
                    txtMobilePhone.Text = contMaster.MobilePhone;
                    txtPostalCode.Text = contMaster.PostalCode;
                    txtState.Text = contMaster.State;
                    txtHomePhone.Text = contMaster.HomePhone;
                    txtAddress.Text = contMaster.Address1;
                }
            }
        }
예제 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            txtMobilePhone.Attributes.Add("onkeypress", "return isNumberKey(event)");
            if (Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {
                //get cleint database credentials.
                userName = Request.QueryString["Username"].ToString();
                ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();

                connectionString =
                   string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                 dbServerName, dbName, dbUserID, dbPassword);
                ConnectionStringHelper.ConStr = connectionString;

                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                campaignID = Convert.ToInt64(Request.QueryString["CampaignID"]);

                if (!IsPostBack)
                {
                    ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(contactID);
                    ContactMaster contMaster = ContactMaster.SelectOne(pk, connectionString);
                    txtFirstName.Text = contMaster.FirstName;
                    txtLastName.Text = contMaster.LastName;
                    txtAddress1.Text = contMaster.Address1;
                    txtAddress2.Text = contMaster.Address2;
                    txtEmailAddress.Text = contMaster.EmailAddress;
                    txtCity.Text = contMaster.City;
                    txtCountry.Text = contMaster.Country;
                    txtState.Text = contMaster.State;
                    txtZipCode.Text = contMaster.PostalCode;
                    txtMobilePhone.Text = contMaster.MobilePhone;
                    DisplayCustomControlValues(contMaster);
                    lblmsg.Text = txtFirstName.Text.ToString().Trim();
                }
            }
        }
        public void campaigns_bindcontent()
        {
            try
            {
                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                ContactMasterPrimaryKey cpk = new ContactMasterPrimaryKey(contactID);
                ContactMaster contact = ContactMaster.SelectOne(cpk, connectionString);

                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(campaignID);
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, connectionString);
                string campaignContent = "";
                //if (campMaster.HTMLContent != "")
                campaignContent = campMaster.HTMLContent;
                //else
                //    campaignContent = campMaster.TextContent;

                if (Request.QueryString["ForwardedEmail"] != null)
                {
                    #region handle standard links

                    if (campaignContent.Contains("[!RPLINK:LISTUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");//"<A style=\"cursor:default;color:Gray\" href=\"#\">List UnSubscribe</A>");
                    }

                    if (campaignContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Global Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Global Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("If you no longer wish to receive these emails, simply click on the following link:"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("If you no longer wish to receive these emails, simply click on the following link:", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }

                    if (campaignContent.ToLower().Contains("forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm2"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM2!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.
                    Int64 CampaignId = Convert.ToInt64(Request.QueryString["CampaignID"]);
                    Int64 ContactId = Convert.ToInt64(Request.QueryString["ContactID"]);
                    string EmailAddress = Request.QueryString["ForwardedEmail"].ToString();

                    string sqlQry ="SELECT *  FROM [ForwardDetails] where [CampaignID]=" + CampaignId + " and [EmailAddress]='" + EmailAddress + "' and [ContactID]=" + ContactId + " ";
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username="******"listunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&ListUnSub=YES" + "&Username="******"globalunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&GlobalUnSub=YES" + "&Username="******"forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.

                    string sqlQry = " select * from ContactMaster where ContactId=" + Convert.ToInt32(Request.QueryString["ContactID"]);
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username=" + userName);
                                    }
                                    else
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, linkData.LinkURL);
                                    }
                                }
                            }

                        }

                    }

                    #endregion

                }

                contentdiv.InnerHtml = campaignContent;

            }
            catch (Exception ex)
            {
            }
        }
예제 #17
0
        private void GetContactdeatails()
        {
            hdfield.Value = Request.QueryString["id"];
            lbMainTitle.Text = "Edit Contacts";
            try
            {
                ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(hdfield.Value));
                ContactMaster contMaster = ContactMaster.SelectOne(pk, ConnectionString);
                txtFirstName1.Text = contMaster.FirstName;
                txtLastName1.Text = contMaster.LastName;
                txtEmailAddress1.Text = contMaster.EmailAddress;
                txtAddress11.Text = contMaster.Address1;
                txtAddress21.Text = contMaster.Address2;
                txtCity.Text = contMaster.City;
                txtCountry.Text = contMaster.Country;
                txtFax.Text = contMaster.Fax;
                txtHomePhone.Text = contMaster.HomePhone;
                txtMobilePhone.Text = contMaster.MobilePhone;
                txtPostalCode.Text = contMaster.PostalCode;
                txtState.Text = contMaster.State;
                txtWorkPhone.Text = contMaster.WorkPhone;
                ddlEmailContentType.Text = contMaster.EmailContentType;
                ddlGender.Text = contMaster.Gender;
                if (contMaster.Gender == null)
                {
                    ddlGender.Items.FindByText("--Select--").Selected = true;
                }
                ddlMaritalStatus.Text = contMaster.MaritalStatus;
                if (contMaster.MaritalStatus == null)
                {
                    ddlMaritalStatus.Items.FindByText("--Select--").Selected = true;
                }
                chkIsActive1.Checked = Convert.ToBoolean(contMaster.IsActive);
                chkMakeVerified1.Checked = Convert.ToBoolean(contMaster.IsVerified);

                //to display the values for custom controls
                DisplayCustomControlValues(contMaster);
                bindListNames();
                string LIds = GetListIds();
                if (LIds != string.Empty)
                {
                    DataTable ListNames = ListMaster.SelectListNamesWithContactCount(LIds, ConnectionString);
                    foreach (DataRow item in ListNames.Rows)
                    {
                        ListMasters objListMaster = ListMaster.SelectByField("ListMasterID", item["ListMasterID"].ToString(), ConnectionString);
                        if (objListMaster.Count > 0 && objListMaster[0].IsDeleted != true)
                            lstBoxListNames.Items.Add(new ListItem(item["ListContacts"].ToString(), item["ListmasterId"].ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ClientScript.IsStartupScriptRegistered("alert"))
                {
                    Page.ClientScript.RegisterStartupScript
                        (this.GetType(), "alert", "alertMe();", true);
                }
                lbMainTitle.Visible = false;
                Save.Visible = false;
                lbtnCancel1.Visible = false;
            }
        }
예제 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            txtMobilePhone.Attributes.Add("onkeypress", "return isNumberKey(event)");
            if (Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {
                //get cleint database credentials.
                userName = Request.QueryString["Username"].ToString();
                ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();

                connectionString =
                   string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                 dbServerName, dbName, dbUserID, dbPassword);
                ConnectionStringHelper.ConStr = connectionString;

                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                campaignID = Convert.ToInt64(Request.QueryString["CampaignID"]);

                if (!IsPostBack)
                {
                    if (Request.QueryString["direct"]==null || Request.QueryString["direct"] == "no")//1Point
                    {
                        ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(contactID);
                        ContactMaster contMaster = ContactMaster.SelectOne(pk, connectionString);
                        txtFirstName.Text = contMaster.FirstName;
                        txtLastName.Text = contMaster.LastName;
                        txtAddress1.Text = contMaster.Address1;
                        txtAddress2.Text = contMaster.Address2;
                        txtEmailAddress.Text = contMaster.EmailAddress;
                        txtCity.Text = contMaster.City;
                        txtCountry.Text = (contMaster.Country!=null)?contMaster.Country.ToUpper():string.Empty;
                        txtState.Text = contMaster.State;
                        txtZipCode.Text = contMaster.PostalCode;
                        txtMobilePhone.Text = contMaster.MobilePhone;
                        DisplayCustomControlValues(contMaster);
                        DataTable dt = ManageFieldsBase.SelectCustomFields(connectionString);
                        lblmsg.Text = txtFirstName.Text.ToString().Trim();
                    }
                    else if (Request.QueryString["direct"] == "yes") //AMM_Adv.
                    {
                        objRecipientMasters = RecipientMaster.SelectByField("ContactId", Convert.ToInt64(Request.QueryString["ContactID"]), connectionString);

                        if (objRecipientMasters.Count > 0)
                        {
                            txtFirstName.Text = objRecipientMasters[0].Firstname;
                            txtLastName.Text = objRecipientMasters[0].Lastname;
                            txtAddress1.Text = objRecipientMasters[0].Address1;
                            txtAddress2.Text = objRecipientMasters[0].Address2;
                            txtEmailAddress.Text = objRecipientMasters[0].EmailAddress;
                            txtParentEmail.Text = objRecipientMasters[0].Parent1eml;
                            txtCity.Text = objRecipientMasters[0].City;
                            txtCountry.Text =(objRecipientMasters[0].Country!=null)?objRecipientMasters[0].Country.ToUpper():string.Empty;
                            txtState.Text = objRecipientMasters[0].State;
                            txtZipCode.Text = objRecipientMasters[0].Postal_Code;
                            txtMobilePhone.Text = objRecipientMasters[0].CellPhone;
                            txtParentEmail.Text = objRecipientMasters[0].Parent1eml;
                            purlValue = objRecipientMasters[0].Purl;
                            DisplayCustomControlValuesForDirectMail(objRecipientMasters[0]);
                            lblmsg.Text = txtFirstName.Text.ToString().Trim();
                            if (objRecipientMasters[0].Major1_Intended_College_Major_Description != null && objRecipientMasters[0].Major1_Intended_College_Major_Description.ToString().Trim().Length>0)
                            {
                                ListItem mapItem = ddlMajor.Items.FindByValue(objRecipientMasters[0].Major1_Intended_College_Major_Description);
                                if (mapItem != null && mapItem.Value != "--Select--")
                                    ddlMajor.Items.FindByValue(mapItem.Value).Selected = true;
                            }
                            if (objRecipientMasters[0].Sports1 != null && objRecipientMasters[0].Sports1.Trim().Length>0)
                            {

                                ListItem mapItem = ddlSports.Items.FindByValue(objRecipientMasters[0].Sports1);
                                if (mapItem != null && mapItem.Value!="--Select--")
                                    ddlSports.Items.FindByValue(mapItem.Value).Selected = true;
                            }
                        }
                    }
                }
            }
        }
예제 #19
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="ContactMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class EmailOpenDetails</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			1/8/2010 12:24:52 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static EmailOpenDetails SelectAllByForeignKeyFromContactMaster(ContactMasterPrimaryKey pk, String ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            EmailOpenDetails 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_EmailOpenDetails_SelectAllByForeignKeyContactMaster", ref ExecutionState);
            obj = new EmailOpenDetails();
            obj = EmailOpenDetail.PopulateObjectsFromReaderWithCheckingReader(dr, oDatabaseHelper,ConnectionString);

            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
예제 #20
0
        public XmlDocument AddMailingWithMinData(string UserID, string Password, string MailingName, string FromName, string FromAddress, string Subject, DataSet Recipients)
        {

            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            StringBuilder unDeleverdInfo = new StringBuilder();
            bool isTargetListHavingEmailIds = false;
            List<string> emailColumns = new List<string>();
            emailColumns.Add("Email Address");
            emailColumns.Add("emailaddress");
            emailColumns.Add("email");
            emailColumns.Add("e-mail");
            emailColumns.Add("Email");
            emailColumns.Add("e-mailaddress");
            emailColumns.Add("emailaddress");
            emailColumns.Add("emailadd");
            emailColumns.Add("e-mailadd");
            emailColumns.Add("emailaddress");
            List<string> fnameColumns = new List<string>();
            fnameColumns.Add("firstname");
            fnameColumns.Add("first name");
            fnameColumns.Add("fname");
            List<string> lnameColumns = new List<string>();
            lnameColumns.Add("lastname");
            lnameColumns.Add("last name");
            lnameColumns.Add("lname");
            foreach (DataColumn clm in Recipients.Tables[0].Columns)
            {
                if (emailColumns.Contains(clm.ToString().ToLower()))
                {
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "EmailAddress";
                    isTargetListHavingEmailIds = true;
                }
                else if (fnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "FirstName";
                else if (lnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "LastName";
            }
            str.Append("<MailingInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);

            string validEmailIds = string.Empty;
            string unsubEmailIds = string.Empty;
            string hardBounceEmailIds = string.Empty;
            string softBounceEmailIds = string.Empty;
            string duplicateEmailids = string.Empty;
            Hashtable contatcInfo = new Hashtable();
            if (ConnectionString.Trim().Length != 0)
            {
                LogStartInfo("AddMailingWithMinData", ConnectionString, UserID);
                Logger.logdata(logforRpService, "Input Paramiters :Mailing Name = " + MailingName + "; No.of Contacts=" + Recipients.Tables[0].Rows.Count);
                if (isTargetListHavingEmailIds)
                {
                    if (MailingName.Trim().Length != 0 && Recipients.Tables.Count > 0 && Recipients.Tables[0].Rows.Count > 0)
                    {
                        Int64 listid = 0;
                        ListMasterBase listMaster = null;
                        DataTable contacts = Recipients.Tables[0];

                        CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", MailingName, ConnectionString);
                        if (camp.Count > 0)
                        {
                            str.Append("<Message>Mailing With Name " + MailingName + " Allready Exist,Please Enter Other Name</Message>");
                            Logger.logdata(logforRpService, "Mailing With Name " + MailingName + " Allready Exist,Please Enter Other Name");
                        }
                        else
                        {
                            #region TargetList
                            if (contacts.Rows.Count > 0)
                            {
                                //string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();                        
                                unDeleverdInfo.Append("<UndeliveredList>");
                                foreach (DataRow contact in contacts.Rows)
                                {
                                    ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", contact["EmailAddress"].ToString(), ConnectionString);
                                    DataTable unSubDetails = new DataTable();
                                    DataTable contactMasters = ContactMaster.GetBouceStatusByEmailIds(ConnectionString, contact["EmailAddress"].ToString());
                                    if (contemail.Count > 0)
                                    {
                                        unSubDetails = UnSubscribeDetail.GetUnSubDetailsByContactId(ConnectionString, contemail[0].ContactId.ToString(), string.Empty);
                                    }
                                    if (unSubDetails.Rows.Count > 0)
                                    {
                                        unDeleverdInfo.Append("<Undelivered>");
                                        if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                        {
                                            unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                            unDeleverdInfo.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")
                                        {
                                            unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                            unDeleverdInfo.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                            hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                        }
                                        unDeleverdInfo.Append("</Undelivered>");
                                    }
                                    else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                    {
                                        unDeleverdInfo.Append("<Undelivered>");
                                        unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        unDeleverdInfo.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                        unDeleverdInfo.Append("</Undelivered>");
                                        softBounceEmailIds = softBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    else if (contemail.Count > 0 && contemail[0].EmailAddress.Trim().Length > 0)
                                    {
                                        try
                                        {
                                            if (contemail[0].IsActive == true)
                                            {

                                                if (!contatcInfo.ContainsKey(contemail[0].ContactId))
                                                {
                                                    contatcInfo.Add(contemail[0].ContactId, "");
                                                    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, ConnectionString);

                                                #region Handling Custom fields

                                                foreach (DataColumn column in contacts.Columns)
                                                {
                                                    DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, ConnectionString);
                                                    string custField = "";
                                                    if (customFieldDt.Rows.Count > 0)
                                                    {
                                                        custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                                    }
                                                    else
                                                        custField = column.ColumnName;

                                                    if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                    {

                                                        switch (custField)
                                                        {
                                                            case "EmailAddress":
                                                                objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "FirstName":
                                                                objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "LastName":
                                                                objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "Address1":
                                                                objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "City":
                                                                objContactMaster.City = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "State":
                                                                objContactMaster.State = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "PostalCode":
                                                                objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "Country":
                                                                objContactMaster.Country = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "WorkPhone":
                                                                objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "HomePhone":
                                                                objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "MobilePhone":
                                                                objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            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(ConnectionString);
                                            objContactMaster.EmailAddress = contact["EmailAddress"].ToString();
                                            objContactMaster.EmailContentType = "Html";
                                            objContactMaster.CreatedDate = DateTime.Now;

                                            #region Handling Custom fields

                                            foreach (DataColumn column in contacts.Columns)
                                            {
                                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, ConnectionString);
                                                string custField = "";
                                                if (customFieldDt.Rows.Count > 0)
                                                {
                                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                                }
                                                else
                                                    custField = column.ColumnName;

                                                if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {
                                                    switch (custField)
                                                    {
                                                        case "EmailAddress":
                                                            objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "FirstName":
                                                            objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "LastName":
                                                            objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Address1":
                                                            objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "City":
                                                            objContactMaster.City = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "State":
                                                            objContactMaster.State = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "PostalCode":
                                                            objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Country":
                                                            objContactMaster.Country = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "WorkPhone":
                                                            objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "HomePhone":
                                                            objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "MobilePhone":
                                                            objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        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 + ",";

                                            if (!contatcInfo.ContainsKey(ContactId))
                                            {
                                                contatcInfo.Add(ContactId, "");
                                                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);

                                        }

                                    }

                                }
                                unDeleverdInfo.Append("</UndeliveredList>");

                            }

                            try
                            {

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

                                    listMaster = new ListMasterBase(ConnectionString);
                                    listMaster.ListName = "TL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                                    listMaster.CreatedDate = System.DateTime.Now;
                                    listMaster.InsertWithDefaultValues(true);
                                    listid = Convert.ToInt64(listMaster.ListMasterID);
                                    Logger.logdata(logforRpService, "List Created,ListID = " + listid + "; ListName=" + listMaster.ListName);
                                    //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("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["IsActive"] = true;
                                            dtListContactMaster.Rows.Add(rowListContactMaster);
                                        }
                                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                                        Logger.logdata(logforRpService, "Added Given Contacts to Created List(ListId :" + listid + ")");

                                    }
                                }


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


                            #endregion

                            try
                            {
                                if (str.ToString().IndexOf("<Error>") == -1)
                                {
                                    MembershipUser objMembershipUser = Membership.GetUser(UserID);
                                    ProfileBase objProfileBase = ProfileBase.Create(UserID, true);

                                    CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                                    objCampaignMaster.CampaignName = MailingName;
                                    objCampaignMaster.CampaignDescription = "";
                                    objCampaignMaster.FromAddress = FromAddress;
                                    objCampaignMaster.FromName = FromName;
                                    objCampaignMaster.ReplytoAddress = "";
                                    objCampaignMaster.ReplaytoName = "";
                                    objCampaignMaster.Subject = Subject;
                                    objCampaignMaster.TrackReads = true;//"1";
                                    objCampaignMaster.SelectCondition = listid.ToString();
                                    objCampaignMaster.TemplateId = 0;
                                    objCampaignMaster.ModifiedDate = DateTime.Now;
                                    objCampaignMaster.CreatedDate = DateTime.Now;
                                    objCampaignMaster.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 = false;
                                    objCampaignMaster.txtHasUnsubLink = false;
                                    objCampaignMaster.AssignedCampaignID = 0;
                                    Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                                    Logger.logdata(logforRpService, "Mailing Inserted Successfully(Mailing Id:" + campaignMasterID + ")");
                                    if (campaignMasterID > 0)
                                    {
                                        CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                                        objCampaignJob.CampaignMasterID = campaignMasterID;
                                        objCampaignJob.CreatedDatetime = DateTime.Now;
                                        objCampaignJob.ScheduledDatetime = DateTime.Now;
                                        objCampaignJob.SendType = "IMMEDIATE";
                                        objCampaignJob.Status = 5;
                                        objCampaignJob.Insert();
                                    }
                                    str.Append("<Message>Mailing Inserted Succefully</Message>");
                                    str.Append("<MailingId>" + campaignMasterID.ToString() + "</MailingId>");
                                    str.Append("<MailingName>" + MailingName + "</MailingName>");
                                    str.Append("<ListID>" + listid + "</ListID>");

                                }
                                else
                                {
                                    str.Append("<Message>Mailing Sending Failed</Message>");
                                    Logger.logdata(logforRpService, "Mailing Sending Failed");

                                }
                            }
                            catch (Exception ex)
                            {
                                str.Append("<Message>Mailing Sending Failed,Problem At Scheduling The Mailing</Message>");
                                Logger.logdata(logforRpService, "Mailing Sending Failed:" + ex.Message);
                            }

                        }
                    }
                    else
                    {
                        str.Append("<Message>Please Enter Mailing Name and Ensure Mailing List File Is Not Empty</Message>");
                        Logger.logdata(logforRpService, "Empty Mailing Not Accepted and Ensure Mailing List File Is Not Empty");
                    }

                }
                else
                {
                    str.Append("<Message>No Email Address Field Found in Targeted List</Message>");
                    Logger.logdata(logforRpService, "No Email Address Field Found in Targeted List");
                }

            }
            else
            {
                str.Append("<Message>Please Enter Valid UserName and Password</Message>");
                Logger.logdata(logforRpService, "Invalid UserName or Password");
            }
            str.Append(unDeleverdInfo);
            str.Append("</MailingInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }