/// <summary> /// Gets the mail chimp campaigns. /// </summary> /// <param name="apikey">The apikey.</param> /// <param name="mailChimpListId">The mail chimp list id.</param> /// <returns></returns> public List <campaignsResults.DataItem> GetMailChimpCampaigns(string apikey, string mailChimpListId) { //todo:pass var parms = new campaignsParms(); parms.apikey = apikey; parms.filters = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(mailChimpListId)) { parms.filters.Add("list_id", mailChimpListId); } var input = new campaignsInput(parms); var cmd = new campaigns(input); var output = cmd.Execute(); if (output.api_ErrorMessages.Count > 0) { StringBuilder sbErrDetail = new StringBuilder(); foreach (var apiErrorMessage in output.api_ErrorMessages) { sbErrDetail.AppendLine(string.Format("error code:{0},error msg:{1}", apiErrorMessage.code, apiErrorMessage.error)); } string errMsg = string.Format("apikey:{4}mailChimpListId:{5}\r\n{0}{1}{2}{3}", output.api_Request, output.api_Response, // raw data sbErrDetail, output.api_ValidatorMessages, apikey, mailChimpListId); //int Event_id = 5015; //EventLog.WriteEntry(InfoHubEventLog.LogSource, errMsg, EventLogEntryType.Warning, Event_id, Category); } return(output.result.data); }
void Document_BeforePublish(Document sender, PublishEventArgs e) { try { if (sender.ContentType.Alias == "uBlogsyPost") { bool sendNewsletter = (sender.getProperty("sendNewsletter").Value.ToString() == "0") ? false : true; if (sendNewsletter) { var sum = sender.getProperty("uBlogsyContentSummary").Value; string title = sender.getProperty("uBlogsyContentTitle").Value.ToString(); Dictionary<string, object> lookup = new Dictionary<string, object>() { { "title", "" } }; campaignsInput input = new campaignsInput(lookup); campaigns camps = new campaigns(); if (camps.Execute(input).result.Where(t => t.title == title).Count() == 0) { campaignCreateInput campInput = new campaignCreateInput(); campInput.parms.apikey = PerceptiveMCAPI.MCAPISettings.default_apikey; campInput.parms.options.title = title; campInput.parms.options.list_id = "68972d2e33"; campInput.parms.options.auto_footer = true; campInput.parms.options.subject = "The Newsletter - " + title; campInput.parms.options.tracking = new campaignTracking(true, true, true); campInput.parms.options.template_id = 88565; campInput.parms.options.analytics.Add("google", title); campInput.parms.options.to_email = "*|FNAME|*"; campInput.parms.options.from_email = "*****@*****.**"; campInput.parms.options.from_name = "American City Plumbing"; campInput.parms.content.Add("html_std_content", sum.ToString()); campaignCreate create = new campaignCreate(); campaignCreateOutput campOut = create.Execute(campInput); var r = campOut.result; if (campOut != null) { var c = camps.Execute(new campaignsInput(new Dictionary<string, object>() { { "title", title } })); campaignSendNowInput sendInput = new campaignSendNowInput(r); campaignSendNow now = new campaignSendNow(); var sI = now.Execute(sendInput); var s = sI.result; } } } } } catch (Exception ex) { ex.ToString(); throw; } //cancel the publishing // e.Cancel = true; }