internal async void getProjList(string argUrl, string argUrlParam, string argUser, string argPwd)
            {
                jsonProjListRoot myJsonResult = new jsonProjListRoot();
                string           myUrl        = Utility.urlBuild(argUrl, argUrlParam);

                snh.HttpClient myHttpClient = new snh.HttpClient();
                myHttpClient.BaseAddress = new Uri(myUrl);

                // Add an Accept header for JSON format.
                myHttpClient.DefaultRequestHeaders.Accept.Add(
                    new snhHeaders.MediaTypeWithQualityHeaderValue("application/json")
                    );

                //myHttpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
                byte[] myByteBuff = Encoding.ASCII.GetBytes(argUser + ":" + argPwd);
                myHttpClient.DefaultRequestHeaders.Authorization = new snhHeaders.AuthenticationHeaderValue("Basic", Convert.ToBase64String(myByteBuff));

                // List data response.
                snh.HttpResponseMessage myHttpResponse = myHttpClient.GetAsync(
                    myUrl
                    ).Result;

                if (myHttpResponse.IsSuccessStatusCode)
                {
                    // Parse the response body.
                    string myJsonData = await myHttpResponse.Content.ReadAsStringAsync();

                    Utility.uHttpResultJsonProjListString = myJsonData;
                    myJsonResult = nj.JsonConvert.DeserializeObject <jsonProjListRoot>(myJsonData);
                    Utility.uHttpResultJsonProjListRoot = myJsonResult;
                }
                else
                {
                    Exception ex = new Exception(String.Format("{0} ({1})", (int)myHttpResponse.StatusCode, myHttpResponse.ReasonPhrase));
                    throw ex;
                }
            }
Esempio n. 2
0
 public jsonProjCommon(jsonProjListRoot argObjData, string argStrData)
 {
     this.objData = argObjData;
     this.strData = argStrData;
 }