public XmlDocument AddTemplate(string UserID, string Password, string TemplateName, string HtmlContent)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<TemplateInfo>");
            string Con = GetConnectionString(UserID, Password);
            if (TemplateName.Trim().Length != 0 && Con.Trim().Length != 0 && HtmlContent.Trim().Length != 0)
            {
                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>");

                }
                else
                {
                    if (HtmlContent != "" && TemplateName != "")
                    {
                        templateMaster.HTMLContent = HtmlContent;
                        templateMaster.CreatedDate = DateTime.Now;
                        templateMaster.Insert();
                        str.Append("<Message>Template Added Successfully</Message>");
                        str.Append("</TemplateInfo>");
                        doc.LoadXml(str.ToString());
                    }
                    else
                    {
                        str.Append("<Message>Please Enter Valid Inputs</Message>");
                    }
                }
            }
            else
            {
                str.Append("<Message>Please Enter Valid Inputs</Message>");
            }
            str.Append("</TemplateInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Beispiel #2
0
        public void creatives_bindContent()
        {
            try
            {
                pk = new TemplateMasterPrimaryKey(templateID);
                tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                templateContent = tempMaster.HTMLContent;
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();

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

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

                if (templateContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = templateContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                if (templateContent.ToLower().Contains(linkID))
                                {
                                    templateContent = templateContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                }
                            }
                        }
                    }
                }

                #endregion
                contentdiv.InnerHtml = templateContent;
                ViewState["Content"] = templateContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Creatives";
            }
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of TemplateMasters</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/24/2009 12:37:33 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static TemplateMasters PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            TemplateMasters list = new TemplateMasters();

            if (rdr.Read())
            {
                TemplateMaster obj = new TemplateMaster(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new TemplateMaster(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of TemplateMasters</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/24/2009 12:37:33 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static TemplateMasters PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            TemplateMasters list = new TemplateMasters();

            while (rdr.Read())
            {
                TemplateMaster obj = new TemplateMaster( ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified 
        /// along with the details of the child table.
        /// </summary>
        ///
        /// <param name="pk" type="TemplateMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class TemplateMaster</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			11/24/2009 12:37:33 PM				Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static TemplateMaster SelectOneWithCampaignMasterUsingTemplateId(TemplateMasterPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;
            TemplateMaster obj=null;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }

            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_TemplateMaster_SelectOneWithCampaignMasterUsingTemplateId", ref ExecutionState);
            if (dr.Read())
            {
                obj= new TemplateMaster(ConnectionString);
                PopulateObjectFromReader(obj,dr);

                dr.NextResult();

                //Get the child records.
                obj.CampaignMasters=CampaignMaster.PopulateObjectsFromReader(dr,ConnectionString);
            }
            dr.Close();
            oDatabaseHelper.Dispose();
            return obj;
        }
Beispiel #6
0
        public XmlDocument GetAllTemplates(string UserID, string Password)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<TemplateInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0)
            {
                TemplateMaster templateMasters = new TemplateMaster(ConnectionString);
                DataTable templateMasterDt = new DataTable();
                templateMasterDt = templateMasters.SelectAll(ConnectionString, "CreatedDate", "asc");

                if (templateMasters != null)
                {
                    for (int i = 0; i < templateMasterDt.Rows.Count; i++)//templateMasterDt.Rows.Count
                    {
                        str.Append("<Template Row=\"" + i.ToString() + "\">");
                        str.Append("<TemplateId>" + templateMasterDt.Rows[i]["TemplateId"].ToString() + "</TemplateId>");
                        str.Append("<TemplateName>" + Server.HtmlEncode(templateMasterDt.Rows[i]["TemplateName"].ToString()) + "</TemplateName>");
                        str.Append("<TemplateDescription>" + Server.HtmlEncode(templateMasterDt.Rows[i]["TemplateDescription"].ToString()) + "</TemplateDescription>");
                        str.Append("<TemplateCreatedDatetime>" + Convert.ToDateTime(templateMasterDt.Rows[i]["CreatedDate"]).ToString() + "</TemplateCreatedDatetime>");
                        str.Append("<Errormessage></Errormessage>");
                        str.Append("</Template>");
                        string ss = str.ToString();
                    }
                }
                else
                {
                    str.Append("<Message> Please Enter Valid Inputs</Message>");
                }
            }
            str.Append("</TemplateInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Beispiel #7
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;
        }
Beispiel #8
0
        public bool Insert_template_ctegory(TemplateMaster objTemplateMaster, int CategoryTemplate)
        {
            try
            {
                bool ExecutionState = false;
                DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);

                // Pass the value of '_templateName' as parameter 'TemplateName' of the stored procedure.
                oDatabaseHelper.AddParameter("@TemplateName", objTemplateMaster.TemplateName);
                // Pass the value of '_templateDescription' as parameter 'TemplateDescription' of the stored procedure.
                oDatabaseHelper.AddParameter("@TemplateDescription", objTemplateMaster.TemplateDescription);
                // Pass the value of '_clientId' as parameter 'ClientId' of the stored procedure.
                oDatabaseHelper.AddParameter("@ClientId", objTemplateMaster.ClientId);
                // Pass the value of '_hTMLContent' as parameter 'HTMLContent' of the stored procedure.
                oDatabaseHelper.AddParameter("@HTMLContent", objTemplateMaster.HTMLContent);
                // Pass the value of '_textContent' as parameter 'TextContent' of the stored procedure.
                oDatabaseHelper.AddParameter("@TextContent", objTemplateMaster.TextContent);
                // Pass the value of '_modifiedBy' as parameter 'ModifiedBy' of the stored procedure.
                oDatabaseHelper.AddParameter("@ModifiedBy", objTemplateMaster.ModifiedBy);
                // Pass the value of '_modifiedDate' as parameter 'ModifiedDate' of the stored procedure.
                oDatabaseHelper.AddParameter("@ModifiedDate", objTemplateMaster.ModifiedDate);
                // Pass the value of '_createdDate' as parameter 'CreatedDate' of the stored procedure.
                oDatabaseHelper.AddParameter("@CreatedDate", objTemplateMaster.CreatedDate);
                // Pass the value of '_createdBy' as parameter 'CreatedBy' of the stored procedure.
                oDatabaseHelper.AddParameter("@CreatedBy", objTemplateMaster.CreatedBy);
                // Pass the value of '_CategoryID' as parameter 'CategoryID' of the stored procedure.
                oDatabaseHelper.AddParameter("@CategoryID", CategoryTemplate);
                // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
                oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

                oDatabaseHelper.ExecuteScalar("sp_TemplateMaster_Insert_CategoryTemplate", ref ExecutionState);
                oDatabaseHelper.Dispose();

                return ExecutionState;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //This method is modified by swaraj on 27 jan 2010

        public void Save()
        {
            try
            {
                bool status;

                TemplateMaster templateMaster = new TemplateMaster(ConnectionString);
                string templatename = txtTemplateName.Text.Trim();

                templateMaster.TemplateName = templatename;  // txtTemplateName.Text; 
                templateMaster.TemplateDescription = txtDescription.Text;
                //templateMaster.HTMLContent = RadEditor1.Content;//hdHtmlContent.Value.ToString();

                if (RadEditor1.Content.Contains(verify))//(RadEditor1.Content.Contains("[!RPLINK:"))
                {
                    htmlContent = ExtractLinks(RadEditor1.Content.ToString());
                    templateMaster.HTMLContent = htmlContent;
                }
                else
                {
                    templateMaster.HTMLContent = RadEditor1.Content;
                }

                if (textRadEditor.Content.Contains(verify))
                {
                    textContent = ExtractLinks(textRadEditor.Content.ToString());
                    templateMaster.TextContent = textContent;
                }
                else
                {
                    templateMaster.TextContent = textRadEditor.Content;
                }

                lblMessage.Visible = true;
                TemplateMasters tempMasters = TemplateMaster.SelectByField("TemplateName", templatename, ConnectionString); //txtTemplateName.Text); 

                if (templateID == 0)
                {
                    if (tempMasters.Count > 0)
                    {
                        templateMaster.TemplateId = templateID;
                        lblMessage.Visible = true;
                        lblMessage.ForeColor = System.Drawing.Color.Red;
                        lblMessage.Text = "Template Name: " + txtTemplateName.Text + " exists already.";
                        stat = false;
                        return;
                    }
                    else
                    {
                        templateMaster.CreatedDate = System.DateTime.Now;
                        //templateMaster.ModifiedDate = System.DateTime.Now;
                        status = templateMaster.Insert();
                        if (status == true)
                        {
                            lblMessage.ForeColor = System.Drawing.Color.Green;
                            lblMessage.Text = "Template Name: " + txtTemplateName.Text + " has been Created Successfully";
                            stat = true;
                            insert = true;
                        }
                    }
                }
                else
                {
                    templateMaster.TemplateId = Convert.ToInt64(templateID);//tempMasters[0].TemplateId;
                    if (tempMasters.Count > 0 && tempMasters[0].TemplateId != Convert.ToInt64(templateID))
                    {
                        lblMessage.Visible = true;
                        lblMessage.ForeColor = System.Drawing.Color.Red;
                        lblMessage.Text = "Template Name: " + txtTemplateName.Text + " exists already please select another Name.";
                        stat = false;

                    }
                    else
                    {
                        TemplateMasters template = TemplateMaster.SelectByField("TemplateId", templateID, ConnectionString);
                        templateMaster.CreatedDate = template[0].CreatedDate;
                        templateMaster.ModifiedDate = System.DateTime.Now;

                        status = templateMaster.Update();

                        if (status == true)
                        {
                            lblMessage.ForeColor = System.Drawing.Color.Green;
                            lblMessage.Text = "Template Name: " + txtTemplateName.Text + " Updated Successfully.";

                            stat = true;
                            insert = false;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        public void bindGrid(string fillflag, DataTable searchResult)
        {
            try
            {
                if (searchResult.Rows.Count != 0)
                {
                    if (searchResult.Rows.Count > 0)
                    {
                        fillflag = "sort";
                        string sortdir = (fillflag == "sort" ? GetSortDirection() : GridViewSortDirection);
                        DataView searchDataView = new DataView(searchResult);
                        searchDataView.Sort = GridSortExpression + " " + sortdir;
                        grdCreatives.DataSource = searchDataView;
                        grdCreatives.DataBind();
                        GridPrevSortExpression = GridSortExpression;
                    }
                }
                else
                {
                    string sortdir = (fillflag == "sort" ? GetSortDirection() : GridViewSortDirection);
                    if (flagreset == true)
                    {
                        sortdir = "DESC";//"ASC";
                        GridSortExpression = "CreatedDate"; //"TemplateName";

                    }
                    TemplateMaster templateMasters = new TemplateMaster(ConnectionString);
                    DataTable templateMasterDt = new DataTable();
                    templateMasterDt = templateMasters.SelectAll(ConnectionString, GridSortExpression, sortdir);
                    grdCreatives.DataSource = templateMasterDt;
                    grdCreatives.DataBind();
                    GridPrevSortExpression = GridSortExpression;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public XmlDocument AddTemplate(string UserID, string Password, string TemplateName, string HtmlContent)
        {
            XmlDocument doc = new XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<TemplateInfo>");
            string Con = GetConnectionString(UserID, Password);
            if (Con.Trim().Length != 0)
            {
                if (TemplateName.Trim().Length > 0)
                {
                    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>");
                    }
                    else
                    {
                        if (HtmlContent != "")
                        {
                            templateMaster.HTMLContent = ExtractLinks(HtmlContent, Con);
                            templateMaster.CreatedDate = DateTime.Now;
                            int id = templateMaster.InsertReturnID();
                            str.Append("<Message>Template Added Successfully</Message>");
                            str.Append("<TemplateId>" + id.ToString() + "</TemplateId>");
                        }
                        else
                        {
                            str.Append("<Error>Please Enter HTML Content</Error>");
                        }
                    }
                }
                else
                    str.Append("<Message>Please Enter Valid Template Name</Message>");

            }
            else
            {
                str.Append("<Message>Please Enter Valid UserID and Password</Message>");
            }
            str.Append("</TemplateInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }