} // Execute private void UnsubscribeFromAllLists() { try { MCApi mailChimpApiClient = new MCApi(ConfigManager.CurrentValues.Instance.MailChimpApiKey, true); MCList <string> lists = mailChimpApiClient.ListsForEmail(this.email); if (lists != null && lists.Any()) { foreach (var list in lists) { var options = new List.UnsubscribeOptions { DeleteMember = true, SendGoodby = false, SendNotify = false }; var optOptions = new Opt <List.UnsubscribeOptions>(options); bool success = mailChimpApiClient.ListUnsubscribe(list, this.email, optOptions); if (success) { Log.Info("{0} was unsubscribed successfully from mail chimp", this.email); } } } } catch (MCException mcEx) { Log.Warn(mcEx.Error.ToString()); } catch (Exception ex) { Log.Warn(ex, "Failed unsubscribe from mail chimp email {0} for customer {1}", this.email, this.customerID); } }
public static void ChangeRSXGrains() { Grain g = MainWindow.RSXMCList.ElementAt(0); MCList neighbours = CalculateEnergy(g, g.Color); int EBefore = neighbours.Energy + g.H; if (EBefore > 0) { List <Color> neighbourColors = neighbours.Colorlist; if (neighbourColors.Count > 0) { Color newColor = neighbourColors.ElementAt(rand.Next(neighbourColors.Count)); int EAfter = CalculateEnergy(g, newColor).Energy; if (EBefore > EAfter) { MainWindow.GrainTable[g.X, g.Y].Seed(newColor); MainWindow.GrainTable[g.X, g.Y].EnergyColor = Color.FromRgb(255, 255, 255); MainWindow.GrainTable[g.X, g.Y].H = 0; MainWindow.GrainTable[g.X, g.Y].Recrystalized = true; g.Seed(newColor); g.EnergyColor = Color.FromRgb(255, 255, 255); g.H = 0; g.Recrystalized = true; } } else { int a = 0; a = 5; } } MainWindow.RSXMCList.Remove(g); }
} // GetLists public void GetGroups(string listId) { MCList <List.InterestGrouping> groups = m_oMcApi.ListInterestGroupings(listId); ms_oLog.Debug("lists {0}", groups.Count); foreach (List.InterestGrouping list in groups) { ms_oLog.Debug("{0} {1}", list.ID, list.Name); foreach (List.InterestGroup group in list.Groups) { ms_oLog.Debug("{0} {1}", group.Name, group.Bit); } } // for each } // GetGroups
} // GetCampaignAnalytics public void UnsubscribeFromAllLists(string email) { MCList <string> lists = m_oMcApi.ListsForEmail(email); if (lists != null && lists.Any()) { foreach (var list in lists) { m_oMcApi.ListUnsubscribe(list, email, new FSharpOption <List.UnsubscribeOptions>(new List.UnsubscribeOptions { DeleteMember = true, SendGoodby = false, SendNotify = false })); } } }
public bool SendCampaign(string url, string urlParams, string fromEmail, string fromName, string list, string emailSubject, string camapaignTitle, List<string> emails, string apiKey) { var mcApi = new MCApi(apiKey, true); var options = new Campaign.Options(list, camapaignTitle, fromEmail, fromName, fromName); var content = new Campaign.Content.Html(); var guid = Guid.NewGuid(); var segmentName = "qi_" + guid; var segmentId = 0; if(segmentId == 0) segmentId = mcApi.ListStaticSegmentAdd(list, segmentName); mcApi.ListStaticSegmentMembersAdd(list, segmentId, emails); var segmentIds = new List<string>(); segmentIds.Add(segmentId.ToString()); var condition = new Campaign.SegmentCondition("static_segment", "eq", segmentIds); var conditions = new MCList<Campaign.SegmentCondition>(); conditions.Add(condition); var segmentOptions = new Campaign.SegmentOptions(Campaign.Match.AND, conditions); content.Url = url; var success = false; LogManager.GetLogger(GetType().FullName + " " + camapaignTitle).Info("Test de campagne" + " / Nb emails : " + emails.Count + " / Url : " + url); try { var id = mcApi.CampaignCreate(Campaign.Type.Regular, options, content, segmentOptions); LogManager.GetLogger(GetType().FullName + " " + camapaignTitle).Info("Création de campagne - " + id); try { success = !string.IsNullOrEmpty(id) && mcApi.CampaignSendNow(id); LogManager.GetLogger(GetType().FullName + " " + camapaignTitle).Info("Envoi de campagne - " + id + " Statut : " + success + " / Nb emails : " + emails.Count + " / Url : " + url); return success; } catch (Exception ex) { LogManager.GetLogger(GetType().FullName + " " + camapaignTitle).Fatal(string.Format("Erreur lors de l'envoi d'une campagne {0} {1}", ex.Message, ex.StackTrace)); } } catch(Exception ex) { LogManager.GetLogger(GetType().FullName + " " + camapaignTitle).Fatal(string.Format("Erreur lors de la création d'une campagne {0} {1}", ex.Message, ex.StackTrace)); } return success; }
public static void ChangeGrains() { Grain g = MainWindow.grainMCList.ElementAt(0); MCList neighbours = CalculateEnergy(g, g.Color); int EBefore = neighbours.Energy; if (EBefore > 0) { List <Color> neighbourColors = neighbours.Colorlist; Color newColor = neighbourColors.ElementAt(rand.Next(neighbourColors.Count)); int EAfter = CalculateEnergy(g, newColor).Energy; if (EBefore >= EAfter) { MainWindow.GrainTable[g.X, g.Y].Seed(newColor); g.Seed(newColor); } } MainWindow.grainMCList.Remove(g); }
} // ListBatchSubscribe public string CreateSegmentedCampaign(string listId, int templateId, string condition, string subject, string title, string group) { try { var conditions = new MCList <McCampaign.SegmentCondition> { new McCampaign.SegmentCondition("interests-" + Constants.SignUpProcessGroupId, "one", @group), new McCampaign.SegmentCondition(condition, "eq", DateTime.Today.ToString("yyyy-MM-dd")) }; var segmentOptions = new McCampaign.SegmentOptions(MailChimp.Types.Campaign.Match.AND, conditions); var options = new McCampaign.Options(listId, subject, Constants.FromEmail, Constants.FromEmailName, ""); var analytics = new Input { { Constants.GoogleAnalyticsKie, Constants.GoogleAnalyticsValue } }; options.Analytics = new Opt <Input>(analytics); options.TemplateID = templateId; options.Title = title + " " + condition + " " + DateTime.Today.ToShortDateString(); var cBase = new McCampaign.Content.Base { Text = string.Empty }; if (m_oMcApi.CampaignSegmentTest(listId, segmentOptions) > 0) { string campaignId = m_oMcApi.CampaignCreate(McCampaign.Type.Regular, options, cBase, segmentOptions); ms_oLog.Debug("Created Segmented Campaign {0} for {1} {2} {3}", campaignId, templateId, title, condition); return(campaignId); } // if ms_oLog.Debug("No customers in this segment: {0} {1} {2}", templateId, title, condition); return(string.Empty); } catch (Exception ex) { ms_oLog.Alert(ex, "CreateSegmentedCampaign error."); return(null); } // try }