Ejemplo n.º 1
0
        public async Task <BulkUpdateResponseModel> UpdateBulkUpdateData(BulkUpdateModel model)
        {
            BulkUpdateResponseModel respModel = new BulkUpdateResponseModel();

            using (var client = new HttpClient())
            {
                string ApiKey  = ConfigurationManager.AppSettings["ApiKey"];
                string baseUrl = ConfigurationManager.AppSettings["BaseUrl"];
                client.BaseAddress = new Uri(baseUrl);
                string UpdateBulkDataUrl = client.BaseAddress + string.Format("BulkData/Update");
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.TryAddWithoutValidation("ApiKey", ApiKey);
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");

                //HTTP POST
                model.isProcessed = "Y";
                string strPayload = JsonConvert.SerializeObject(model);
                LogUtility.WriteToFile("OCR Process Request PayLoad:" + strPayload);
                HttpContent         c        = new StringContent(strPayload, Encoding.UTF8, "application/json");
                HttpResponseMessage response = client.PostAsync(UpdateBulkDataUrl, c).Result;
                LogUtility.WriteToFile("OCR Process Response:" + response);
                if (response.IsSuccessStatusCode)
                {
                    var cont = await response.Content.ReadAsStringAsync();

                    respModel = JsonConvert.DeserializeObject <BulkUpdateResponseModel>(cont);
                }
            }
            return(respModel);
        }
Ejemplo n.º 2
0
        public async Task <TargetFolderLocation> GetTargetFolderLocation(BulkUpdateModel model)
        {
            TargetFolderResponseModel respModel = new TargetFolderResponseModel();

            using (var client = new HttpClient())
            {
                string ApiKey  = ConfigurationManager.AppSettings["ApiKey"];
                string baseUrl = ConfigurationManager.AppSettings["BaseUrl"];
                client.BaseAddress = new Uri(baseUrl);
                string GetPendingBulkDataUrl = client.BaseAddress + string.Format("Attachment/MoveBulkData?CRN={0}&category={1}&SaveFilename={2}", model.crn, model.type, model.fileName);;
                LogUtility.WriteToFile(GetPendingBulkDataUrl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.TryAddWithoutValidation("ApiKey", ApiKey);
                //client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", string.Format("Bearer {0}", Service1.IsUserLoginToken));
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
                //GET Method
                HttpResponseMessage response = await client.GetAsync(GetPendingBulkDataUrl);

                if (response.IsSuccessStatusCode)
                {
                    var cont = await response.Content.ReadAsStringAsync();

                    LogUtility.WriteToFile(cont);
                    respModel = JsonConvert.DeserializeObject <TargetFolderResponseModel>(cont);
                }
            }
            return(respModel.data);
        }