Beispiel #1
0
        private string ReplyWithCampaignsForDate(DateTime dateTime)
        {
            PeopleStageSystemSummary firstSystem = apiClient.GetPeopleStageSystems()?.FirstOrDefault();
            CommunicationStatistics  commsStats  = apiClient.GetPeopleStageCommunicationsStatsForProgramme(firstSystem);

            if (commsStats == null)
            {
                return("I don't know - I don't have any communication stats");
            }

            int dateIndex = commsStats.Days.IndexOf(dateTime.ToString("yyyy-MM-dd"));

            if (dateIndex < 0)
            {
                return("I don't know - I don't have the number of campaigns for " + FormatDateForReply("", dateTime));
            }

            long?campaigns = commsStats.CampaignsCounts.Count < dateIndex? null : commsStats.CampaignsCounts[dateIndex];

            if (campaigns == null)
            {
                return("I don't know - I don't have the number of campaigns for " + FormatDateForReply("", dateTime));
            }
            else
            {
                return(campaigns.Value.ToString("N0") + " campaigns have run " + FormatDateForReply("on", dateTime));
            }
        }
Beispiel #2
0
        public CommunicationStatistics GetPeopleStageCommunicationsStatsForProgramme(PeopleStageSystemSummary systemSummary)
        {
            if (sessionDetails == null)
            {
                throw new Exception("No session has been created - please log in");
            }

            IPeopleStageApi peopleStageApi = apiConnectorFactory.CreatePeopleStageApi(sessionDetails);

            return(peopleStageApi.PeopleStageGetPeopleStageElementCommunicationStatistics(dataView, systemSummary.SystemName, systemSummary.ProgrammeId));
        }
Beispiel #3
0
        public List <ElementStatus> GetPeopleStageCampaigns(PeopleStageSystemSummary systemSummary)
        {
            if (sessionDetails == null)
            {
                throw new Exception("No session has been created - please log in");
            }

            IPeopleStageApi           peopleStageApi = apiConnectorFactory.CreatePeopleStageApi(sessionDetails);
            string                    filter         = "Type eq 'Campaign'";
            PagedResultsElementStatus statuses       = peopleStageApi.PeopleStageGetPeopleStageElementStatusForDescendants(dataView, systemSummary.SystemName, systemSummary.ProgrammeId, filter, null, 0, 1000000);

            return(statuses?.List);
        }
Beispiel #4
0
        private string ReplyWithLastRanCampaign()
        {
            PeopleStageSystemSummary firstSystem     = apiClient.GetPeopleStageSystems()?.FirstOrDefault();
            List <ElementStatus>     campaigns       = apiClient.GetPeopleStageCampaigns(firstSystem);
            ElementStatus            lastRanCampaign = campaigns?.OrderByDescending(c => c.LastRan)?.FirstOrDefault();

            if (lastRanCampaign?.LastRan == null)
            {
                return("I don't know - I don't have any campaign information");
            }
            else
            {
                return(lastRanCampaign.Description + " last ran " + FormatDateForReply("on", lastRanCampaign.LastRan.Value));
            }
        }