/// <summary> /// MaqilChimp Integartion /// </summary> /// <param name="userType"></param> /// <returns></returns> private bool AddMailChimpSubscriber(int userType) { bool returnVal = false; try { if (chkAgreeReceiveNewsletters.Checked == true) { listSubscribeInput input = new listSubscribeInput(); listSubscribe Subscribe = new listSubscribe(); input.api_AccessType = PerceptiveMCAPI.EnumValues.AccessType.Serial; input.api_CustomErrorMessages = true; input.api_MethodType = PerceptiveMCAPI.EnumValues.MethodType.POST; input.api_Validate = true; input.api_OutputType = PerceptiveMCAPI.EnumValues.OutputType.XML; input.parms.email_address = txtEmail.Text; input.parms.send_welcome = true; input.parms.update_existing = true; input.parms.replace_interests = true; input.parms.double_optin = false; input.parms.apikey = WebConfig.MailChimpApiKeyNew; input.parms.id = WebConfig.UserNewsLetterListID; input.parms.merge_vars.Add("EMAIL", txtEmail.Text); // ------------------------------ address List<interestGroupings> groupings = new List<interestGroupings>(); interestGroupings ig = new interestGroupings { name = "Account Status", groups = new List<string> { "New User Personal" } }; if (userType == 2) { ig = new interestGroupings { name = "Account Status", groups = new List<string> { "New User Business" } }; } groupings.Add(ig); input.parms.merge_vars.Add("groupings", groupings); // execution listSubscribeOutput output = Subscribe.Execute(input); //phase-1 enhancement if ((output != null) && (output.api_ErrorMessages.Count > 0)) { string ErrorCode = output.api_ErrorMessages.FirstOrDefault().code; string Error = "Error occured. " + output.api_ErrorMessages.FirstOrDefault().error; lblErrMsg.InnerHtml = ShowMessage(headertext, ErrorCode + "</br>" + Error, 1); lblErrMsg.Visible = true; returnVal = false; } else { if (output.result == true) { returnVal = true; } } } } catch (Exception ex) { lblErrMsg.InnerHtml = ShowMessage(headertext, ex.Message, 1); lblErrMsg.Visible = true; returnVal = false; } return returnVal; }
private void subscribeAddIntererestGroupsToMergeVars(Dictionary<int, List<String>> interestGroups, Dictionary<String, object> mergeVars) { if (interestGroups != null && interestGroups.Count > 0) { var listOfGroups = new List<interestGroupings>(); foreach (var a in interestGroups) { var group = new interestGroupings { id = a.Key, name = "", groups = a.Value }; listOfGroups.Add(group); } mergeVars.Add("groupings", listOfGroups); } }
/// <summary> /// Fetch Interest On Packageid /// </summary> /// <param name="PackageId"></param> /// <param name="packagelist"></param> /// <returns>interestGroupings</returns> private interestGroupings FetchInterestOnPackage(int PackageId, string packagelist) { interestGroupings objIg = new interestGroupings { name = "Tribute Type", groups = new List<string> { packagelist } }; return objIg; }
/// <summary> /// MaqilChimp Integartion /// </summary> /// <param name="UserType"></param> /// <returns></returns> private bool AddMailChimpSubscriber(int UserType) { bool returnVal = false; try { if (chkAgreeReceiveNewsletters.Checked == true) { listBatchSubscribeInput input = new listBatchSubscribeInput(); input.api_AccessType = EnumValues.AccessType.Serial; // access input.api_OutputType = EnumValues.OutputType.XML; // output input.api_MethodType = PerceptiveMCAPI.EnumValues.MethodType.POST;// method input.api_Validate = false;// validate input.parms.double_optin = false; input.parms.replace_interests = true; input.parms.update_existing = true; input.parms.apikey = WebConfig.MailChimpApiKeyNew; input.parms.id = WebConfig.UserNewsLetterListID; // ------------------------------ address List<Dictionary<string, object>> batch = new List<Dictionary<string, object>>(); Dictionary<string, object> entry = new Dictionary<string, object>(); List<interestGroupings> groupings = new List<interestGroupings>(); entry.Add("EMAIL", txtEmail.Text); batch.Add(entry); interestGroupings ig = new interestGroupings { name = "Account Status", groups = new List<string> { "New User Contributor" } }; //if (UserType == 2) //{ // ig = new interestGroupings { name = "Account Status", groups = new List<string> { "New User Business" } }; //} groupings.Add(ig); entry.Add("groupings", groupings); batch.Add(entry); input.parms.batch = batch; // execution listBatchSubscribe cmd = new listBatchSubscribe(input); listBatchSubscribeOutput output = cmd.Execute(); //phase-1 enhancement if ((output != null) && (output.api_ErrorMessages.Count > 0)) { string ErrorCode = output.api_ErrorMessages.FirstOrDefault().code; string Error = "Error occured. " + output.api_ErrorMessages.FirstOrDefault().error; messages.InnerHtml = ShowMessage(headertext, ErrorCode + "</br>" + Error, 1); messages.Visible = true; returnVal = false; } else { if (output.result.success_count > 0) { returnVal = true; } } } } catch (Exception ex) { messages.InnerHtml = ShowMessage(headertext, ex.Message.ToString(), 1); messages.Visible = true; returnVal = false; } return returnVal; }