コード例 #1
0
        public async Task FormDataToList()
        {
            DateTime dateForCycle = StartDate.AddDays(DaysInterval);

            while (dateForCycle <= EndDate)
            {
                FilterDate  filterDate        = new FilterDate(StartDate, dateForCycle);
                var         jsonStringCreator = new JsonStringCreator(filter: new FilterType(filterDate), dimension: new string[] { "date" }, metrics: TypeOfMetrics);
                string      output            = jsonStringCreator.CreateJsonString(jsonStringCreator);
                HttpContent contentPost       = new StringContent(output, Encoding.UTF8, "application/json");
                var         respons           = await Client.PostAsync("https://api.adform.com/v1/reportingstats/publisher/reportdata", contentPost);

                if (respons.ReasonPhrase != "OK")
                {
                    throw new HttpRequestException(message: "Issue with request HTTP cleint post. Reason: " + respons.ReasonPhrase);
                }
                var responseString = await respons.Content.ReadAsStringAsync();

                DataFromResponse dataFromResponse = JsonConvert.DeserializeObject <DataFromResponse>(responseString);
                Console.WriteLine("Deserializing JSON and parsing");
                foreach (var item in dataFromResponse.reportData.rows)
                {
                    DataSetFormat tempElement = new DataSetFormat();
                    tempElement.FormDataFromString(item);
                    DataSet.Add(tempElement);
                }
                dateForCycle = dateForCycle.AddDays(1);
                StartDate    = dateForCycle;
                dateForCycle = dateForCycle.AddDays(DaysInterval);
                Console.WriteLine("Data is being configured");
            }
        }
コード例 #2
0
ファイル: FilterType.cs プロジェクト: cinis77/Adform_HomeWork
 public FilterType(FilterDate date)
 {
     this.date = date;
 }