示例#1
0
        // runs simple shaped download
        public static async Task RunDownloadShapedAsync(Output output)
        {
            // get our sample selection
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            // set up api object for making call
            var api = new ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            // set up simple configuration for shape request
            var config = new ShapeConfigurationDto()
            {
                Pivot           = false,
                StackedQuarters = false,
                Frequency       = FrequencyEnum.Annual,
                Format          = Mandoline.Api.Client.ServiceModels.FormatEnum.Default,
            };

            // run download
            var shapedResult = await api.DownloadShapedAsync(
                sampleSelect,
                config,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).ConfigureAwait(true);

            // process output data
            output.PrintData(shapedResult.Result);
        }
示例#2
0
        // runs a download and returns a list of dataseries lists, effectively preserving
        // the pages as they arrived
        private static async Task <List <List <DataseriesDto> > > DownloadPages()
        {
            // get our sample selection
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            // set the number of items (i.e. in this case DataseriesDto objects) to be included in each page of data
            const int PAGE_SIZE = 5;

            // initialize api object
            var api = new ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            // this will track which page of data is currently being requested from the api
            int page = 0;
            List <DataseriesDto> newPage;
            var pageList = new List <List <DataseriesDto> >();

            // loop till the number of elements in the new page of data doesn't equal the page size we expect
            do
            {
                // make the download request
                var downloadResult = await api.DownloadAsync(
                    sampleSelect,
                    new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token,
                    page,
                    PAGE_SIZE).ConfigureAwait(true);

                newPage = downloadResult.Result;

                pageList.Add(newPage);

                Console.WriteLine("Downloaded page {0}...", ++page);
            }while (newPage.Count == PAGE_SIZE);

            return(pageList);
        }
示例#3
0
        // runs the download request operation, which queues a download and returns a ready URL
        public static async Task RunRequestDownloadAsync(Output output)
        {
            // get our sample selection
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            // set up api object for making call
            var api = new ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            string filename = "SampleDownload-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".csv";

            // run download request
            var requestResult = await api.RequestDownloadAsync(
                sampleSelect,
                FileFormat.Csv,
                filename,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).ConfigureAwait(true);

            // run ready check
            var readyResult = await api.DownloadReadyAsync(
                requestResult.Result,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).ConfigureAwait(true);

            // print results
            output.PrintData(requestResult.Result, filename, readyResult.Result);
        }
示例#4
0
        public void CreatSelectionRepoDonnes(SelectionDto selection)
        {
            SelectionDonnes selectionDonnes = new SelectionDonnes
            {
                FkBoisson       = selection.FkBoissonDto,
                FkQuantiteSucre = selection.FkQuantiteSucreDto,
                MugPerson       = selection.MugPersonDto
            };

            selectionDonnes.CreatSelectionDonnes(selectionDonnes);
        }
示例#5
0
        public void CreatSelectionRepoMetier(SelectionDto selection)
        {
            SelectionMetier selectionMetier = new SelectionMetier
            {
                FkBoisson       = selection.FkBoissonDto,
                FkQuantiteSucre = selection.FkQuantiteSucreDto,
                MugPerson       = selection.MugPersonDto
            };

            selectionMetier.CreatSelectionMetier(selectionMetier);
        }
        public static void Initialize(TestContext context)
        {
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            var api = new Mandoline.Api.Client.ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            var newSelection = api.CreateSavedSelectionAsync(
                sampleSelect,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).Result;

            AppConstants.SavedSelectionId = newSelection.Result.Id;
        }
        // updates gridview with selection object information
        public override void PrintData(SelectionDto s)
        {
            // create table for displaying selection data
            var dt = new Table.SelectionTable();

            // process output
            var output = s;

            Console.WriteLine("SELECTION ID: {0}...", s.Id);

            // pass databanks list to DataGridView object
            dt.Rows.Add(output.Id, output.Name, output.DatabankCode, output.MeasureCode, output.DownloadUrl);

            this.PrintTable(dt);
        }
        public IHttpActionResult CreateSelection(int id, SelectionDto selectionDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Model, try again."));
            }

            var selection = Mapper.Map <SelectionDto, Selection>(selectionDto);

            _context.Selections.Add(selection);
            _context.SaveChanges();

            selectionDto.SelectionId = selection.SelectionId;
            return(Created(new Uri(Request.RequestUri + "/" + selection.SelectionId), selectionDto));
        }
示例#9
0
        // updates gridview with selection object information
        public override void PrintData(SelectionDto s)
        {
            // create table for displaying selection data
            var dt = new Table.SelectionTable();

            // process output
            var output = s;

            Console.WriteLine("SELECTION ID: {0}...", s.Id);

            // pass databanks list to DataGridView object
            dt.Rows.Add(output.Id, output.Name, output.DatabankCode, output.MeasureCode, output.DownloadUrl);
            this.DataGridInstance = dt;

            // hide loading indicator
            this.StatusLabelVisible = false;
        }
示例#10
0
        // creates a new saved selection based on SelectionDto sampleSelect
        public static async Task RunCreateSavedSelection(Output output)
        {
            // get our sample selection
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            // make sure id is empty
            sampleSelect.Id = Guid.Empty;

            // set up api object for making call
            var api = new ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            var selectionResult = await api.CreateSavedSelectionAsync(
                sampleSelect,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).ConfigureAwait(true);

            await RunGetSavedSelection(selectionResult.Result.Id, output);
        }
        public IHttpActionResult UpdateSelection(int id, SelectionDto selectionDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Model, try again."));
            }

            var selectionInDb = _context.Selections.SingleOrDefault(s => s.SelectionId == id);

            if (selectionInDb == null)
            {
                return(NotFound());
            }

            Mapper.Map(selectionDto, selectionInDb);

            _context.SaveChanges();

            return(Ok("Selection was successfully updated."));
        }
示例#12
0
        // runs the download file request operation, which queues a download and returns a string
        public static async Task RunDownloadFileAsync(Output output)
        {
            // get our sample selection
            SelectionDto sampleSelect = AppConstants.SampleSelection.GetInstance();

            // set up api object for making call
            var api = new ApiClient(AppConstants.BaseURL, AppConstants.ApiToken);

            // set up download request
            var req = new ControllerDownloadRequestDto()
            {
                selections = new SelectionDto[] { sampleSelect },
                format     = FileFormat.Csv,
                name       = "SampleFileDownload-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".csv"
            };

            // make file request
            var fileResult = await api.DownloadFileAsync(
                req,
                new System.Threading.CancellationTokenSource(TimeSpan.FromMinutes(5)).Token).ConfigureAwait(true);

            output.PrintData(fileResult.Result);
        }
示例#13
0
 // updates gridview with selection object information
 public override void PrintData(SelectionDto s)
 {
     this.ReturnValueDate = s.LastUpdate;
     this.ReturnValueStr  = s.Id.ToString();
 }
 public IHttpActionResult CreatSelectionAPI(SelectionDto data3)
 {
     repo.CreatSelectionRepoDonnes(data3);
     return(Ok());
 }
            public static SelectionDto GetInstance()
            {
                if (instance == null)
                {
                    instance = new SelectionDto()
                    {
                        Name                 = "Selection - Created: " + DateTime.Now,
                        DatabankCode         = "WDMacro",
                        MeasureCode          = "L",
                        StartYear            = 2015,
                        EndYear              = 2021,
                        StackedQuarters      = false,
                        Frequency            = FrequencyEnum.Annual,
                        Sequence             = SequenceEnum.EarliestToLatest,
                        Precision            = 1,
                        Order                = OrderEnum.IndicatorLocation,
                        GroupingMode         = false,
                        SelectionType        = SelectionTypeEnum.DataseriesSelection,
                        IsTemporarySelection = false,
                        ListingType          = ListingTypeEnum.Private,
                        Regions              = new List <SelectionRegionDto>
                        {
                            new SelectionRegionDto
                            {
                                DatabankCode = "WDMacro",
                                RegionCode   = "GBR",
                            },

                            new SelectionRegionDto
                            {
                                DatabankCode = "WDMacro",
                                RegionCode   = "USA",
                            },

                            new SelectionRegionDto
                            {
                                DatabankCode = "WDMacro",
                                RegionCode   = "FRA",
                            },

                            new SelectionRegionDto
                            {
                                DatabankCode = "WDMacro",
                                RegionCode   = "DEU",
                            }
                        },
                        Variables = new List <SelectionVariableDto>
                        {
                            new SelectionVariableDto
                            {
                                ProductTypeCode = "WMC",
                                VariableCode    = "GDP$",
                                MeasureCodes    = new string[] { "L", "PY", "DY" }
                            },
                            new SelectionVariableDto
                            {
                                ProductTypeCode = "WMC",
                                VariableCode    = "CPI",
                                MeasureCodes    = new string[]
                                {
                                    "L"
                                }
                            }
                        }
                    };
                }

                return(instance);
            }
 public abstract void PrintData(SelectionDto s);