public Int32 GetCampaignCount(string dataCenter, string apiKey) { string resp = GetListCampaign(dataCenter, apiKey); cListCampaign.RootObject parsed = new cListCampaign.RootObject(); parsed = (cListCampaign.RootObject)JsonConvert.DeserializeObject(resp, typeof(cListCampaign.RootObject)); Int32 count = parsed.total_items; return(count); }
public string ConsultaCampaniasPendientes() { // Obtener las Campañas que no tienen asociada una lista y con Status Save csMailChimp campaign = new csMailChimp(); cListCampaign.RootObject parsed = new cListCampaign.RootObject(); cCampaignWithoutList campaign_without_list = new cCampaignWithoutList(); campaign_without_list.lstCampaingWithoutList = new List <cCampaignWithoutList.CampaignWithoutList>(); Int32 count = campaign.GetCampaignCount(ConfigurationManager.AppSettings["DataCenter"].ToString(), ConfigurationManager.AppSettings["MailChimpApiKey"].ToString()); Int32 offset = 0; Int32 intervalo; if (count > Int32.Parse(ConfigurationManager.AppSettings["cntCampaign"])) { intervalo = count / Int32.Parse(ConfigurationManager.AppSettings["cntCampaign"]); count = Int32.Parse(ConfigurationManager.AppSettings["cntCampaign"]); } else { intervalo = 0; } for (Int32 i = 0; i <= intervalo; i++) { string resp = campaign.GetCampaignStatusList(ConfigurationManager.AppSettings["DataCenter"].ToString(), ConfigurationManager.AppSettings["MailChimpApiKey"].ToString(), "Save", count, offset); parsed = (cListCampaign.RootObject)JsonConvert.DeserializeObject(resp, typeof(cListCampaign.RootObject)); string title = string.Empty; foreach (var item in parsed.campaigns) { if (item.recipients.list_id == string.Empty) // Significa que la campaña no tiene asociada una lista y puede aparecer vacio el list_id { if (item.settings.title == string.Empty) // A veces viene vacio el titulo de la campaña pendiente { title = "Sin Titulo - Campaign_id " + item.id; } else { title = item.settings.title; } campaign_without_list.lstCampaingWithoutList.Add(new cCampaignWithoutList.CampaignWithoutList { campaign_id = item.id, name = title }); } } offset = offset + Int32.Parse(ConfigurationManager.AppSettings["cntCampaign"]); } // Por tener la tabla campaign actualizada se basa en el de la Campaña de MailChimp campaign.UpdateTableCampaign(campaign_without_list.lstCampaingWithoutList); // return(JsonConvert.SerializeObject(campaign_without_list.lstCampaingWithoutList)); }