Esempio n. 1
0
        public static async Task <int> InsertClient()
        {
            int    iTotalClient   = -1;
            string strClientTotal = String.Format(AppSetting.clientLimit, 0);

            HttpResponseMessage resp = await client.GetAsync(strClientTotal);

            if (resp.IsSuccessStatusCode)
            {
                Stream received = await resp.Content.ReadAsStreamAsync();

                StreamReader readStream = new StreamReader(received);
                string       jsonString = readStream.ReadToEnd();
                //Console.WriteLine ("{0}", jsonString);

                RespClient respClient = JsonConvert.DeserializeObject <RespClient> (jsonString);
                iTotalClient = Convert.ToInt32(respClient.total);
                if (iTotalClient > 0)
                {
                    clientService.TruncateTable();
                    for (int iRow = 0; iRow <= iTotalClient; iRow = iRow + 1000) //Max rows returnsed is 1000 per call
                    {
                        await InsertClientRange(1000, iRow);

                        Console.WriteLine("Rows inserted " + iRow);
                        //if(iRow == 1000)break;;
                    }
                }
            }

            return(iTotalClient);
        }
Esempio n. 2
0
        public static async Task <int> GetClientTotal()
        {
            int    iRows          = -1;
            string strClientTotal = String.Format(AppSetting.clientLimit, 0);

            HttpResponseMessage resp = await client.GetAsync(strClientTotal);

            if (resp.IsSuccessStatusCode)
            {
                Stream received = await resp.Content.ReadAsStreamAsync();

                StreamReader readStream = new StreamReader(received);
                string       jsonString = readStream.ReadToEnd();
                //Console.WriteLine ("{0}", jsonString);

                RespClient respClient = JsonConvert.DeserializeObject <RespClient> (jsonString);
                iRows = Convert.ToInt32(respClient.total);
            }
            return(iRows);
        }