Example #1
0
        public override string prepareData(ConnectNOAA connect)
        {
            int amountRequested = this.Limit;

            if (amountRequested > DefaultValues.MaxLimit)
            {
                var container     = new StationsResponse();
                var tempContainer = new StationsResponse();

                do
                {
                    // max limit per NOAA API
                    this.Limit = DefaultValues.MaxLimit;

                    // get 1000 records from DB
                    string tempData = connect.Request(this.BuildUrl());

                    // convert to object
                    tempContainer = JsonConvert.DeserializeObject <StationsResponse>(tempData);

                    // update # of records
                    container.metadata.resultset.count += tempContainer.results.Count;

                    // add all records from this request to main container
                    container.results.AddRange(tempContainer.results);

                    // update offset, step 1000.
                    this.OffSet     += DefaultValues.MaxLimit;
                    amountRequested -= DefaultValues.MaxLimit;
                } while (amountRequested > 0);

                // update total # of records found in NOAA db
                container.metadata.resultset.offset = this.OffSet;

                // convert to json
                return(JsonConvert.SerializeObject(container));
            }
            else
            {
                // convert to JSON
                return(connect.Request(this.BuildUrl()));
            }
        }
Example #2
0
        public override string prepareData(ConnectNOAA connect)
        {
            // limits max records requested: 10,000 records
            int amountRequested = this.Limit > DefaultValues.LocalMaxLimit ? DefaultValues.LocalMaxLimit : this.Limit;

            int maxLimit = DefaultValues.MaxLimit;

            var    container     = new StationsResponse();
            var    tempContainer = new StationsResponse();
            string tempData;

            // update total # of records found in NOAA db
            container.copyOffset(this.OffSet);
            container.copyLimit(this.Limit);

            do
            {
                // max limit per NOAA API
                this.Limit = (maxLimit < amountRequested) ? maxLimit : amountRequested;

                // get 1000 records from DB
                tempData = connect.Request(this.BuildUrl());

                // convert to object
                tempContainer = JsonConvert.DeserializeObject <StationsResponse>(tempData);

                container.updateCount(tempContainer.results.Count);

                // add all records from this request to main container
                container.results.AddRange(tempContainer.results);

                // update offset, step 1000.
                this.OffSet     += maxLimit;
                amountRequested -= maxLimit;
            } while (amountRequested > 0);

            container.excludeFields(this.Exclude);
            // convert to json
            return(JsonConvert.SerializeObject(container));
        }