Пример #1
0
        public void MoveSftpBulkData()
        {
            List <BulkUpdateModel> model = GetBulkUpdateData().Result;
            TargetFolderLocation   targetFolderLocation = null;

            LogUtility.WriteToFile("DataCount:" + model.Count);
            if (model != null && model.Count > 0)
            {
                try
                {
                    LogUtility.WriteToFile("Inside :" + JsonConvert.SerializeObject(model[0]));
                    targetFolderLocation = GetTargetFolderLocation(model[0]).Result;
                    if (targetFolderLocation != null && !string.IsNullOrEmpty(targetFolderLocation.targetFolderLocation))
                    {
                        TransferFileFromSFTP(targetFolderLocation.targetFolderLocation, model[0].filePath);
                        BulkUpdateResponseModel bulkUpdateModel = UpdateBulkUpdateData(model[0]).Result;
                        LogUtility.WriteToFile("SFTP Bulk Data Update:" + model[0].ToString());
                    }
                }catch (Exception)
                {
                    if (targetFolderLocation != null && targetFolderLocation.ridAttachment != 0)
                    {
                        DeleteResponseModel delModel = DeleteAttachment(targetFolderLocation.ridAttachment).Result;
                        LogUtility.WriteToFile("SFTP Bulk Attachment Deleted:" + targetFolderLocation.ridAttachment + targetFolderLocation.targetFolderLocation);
                    }
                    throw;
                }
            }
        }
Пример #2
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);
        }