public JobOut getJobById(int jobId) { File.AppendAllText(string.Format("{0}\\Validation_{1}.txt", pathLog, DateTime.Now.ToString("yyyyMMdd")), string.Format("**** Método: getJobById. JobId: {0}. Data: {1} ****", jobId, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")) + Environment.NewLine); JobOut jobOut = new JobOut(); try { RestClient client = new RestClient(WebConfigurationManager.AppSettings["API.URL"].ToString() + string.Format(WebConfigurationManager.AppSettings["API.GetJobById"].ToString(), jobId)); RestRequest request = RestRequestHelper.Get(Method.GET); client.Timeout = (1000 * 60 * 60); client.ReadWriteTimeout = (1000 * 60 * 60); IRestResponse response = client.Execute(request); jobOut = SimpleJson.DeserializeObject <JobOut>(response.Content); if (!jobOut.success) { throw new Exception(jobOut.messages.FirstOrDefault()); } } catch (Exception ex) { File.AppendAllText(string.Format("{0}\\Error_{1}.txt", pathLog, DateTime.Now.ToString("yyyyMMdd")), string.Format("**** Método: getJobById. Erro: {0}. JobId: {1}. Data: {2} ****", ex.Message, jobId, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")) + Environment.NewLine); jobOut.successMessage = null; jobOut.messages.Add(ex.Message); } return(jobOut); }
public async static Task <ExchangeRateHistoryServiceResponseModel> GetExchangeRateHistory(string startat, string endat, string baseCurrency, string symbol) { // call to app.config to get url string url = string.Format(ConfigurationManager.AppSettings["ExchangeRateServiceURL"] + "history?start_at={0}&end_at={1}&base={2}&symbols={3}", startat, endat, baseCurrency.ToUpper(), symbol.ToUpper()); var _json = await RestRequestHelper.Get(url); return(JsonConvert.DeserializeObject <ExchangeRateHistoryServiceResponseModel>(_json)); }
public async static Task <ExchangeRateRatePerDateServiceResponseModel> GetExchangeRateForSelectedDate(string date, string baseCurrency, string symbol) { // https://api.exchangeratesapi.io/2018-05-03?base=SEK&symbols=NOK // call to app.config to get url string url = string.Format(ConfigurationManager.AppSettings["ExchangeRateServiceURL"] + "{0}?base={1}&symbols={2}", date, baseCurrency.ToUpper(), symbol.ToUpper()); var _json = await RestRequestHelper.Get(url); return(JsonConvert.DeserializeObject <ExchangeRateRatePerDateServiceResponseModel>(_json)); }
public JobCategorySaveOut setJobCategorySave(int jobCategoryId, string archive) { File.AppendAllText(string.Format("{0}\\Validation_{1}.txt", pathLog, DateTime.Now.ToString("yyyyMMdd")), string.Format("**** Método: setJobCategorySave. JobCategoryId: {0}, Archive: {1}. Data: {2} ****", jobCategoryId, archive.Length, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")) + Environment.NewLine); JobCategorySaveOut jobCategorySaveOut = new JobCategorySaveOut(); try { JobCategorySaveIn jobCategorySaveIn = new JobCategorySaveIn { jobCategoryId = jobCategoryId, archive = archive }; RestClient client = new RestClient(WebConfigurationManager.AppSettings["API.URL"].ToString() + string.Format(WebConfigurationManager.AppSettings["API.SetJobCategorySave"].ToString())); RestRequest request = RestRequestHelper.Get(Method.POST, SimpleJson.SerializeObject(jobCategorySaveIn)); client.Timeout = (1000 * 60 * 60); client.ReadWriteTimeout = (1000 * 60 * 60); IRestResponse response = client.Execute(request); jobCategorySaveOut = SimpleJson.DeserializeObject <JobCategorySaveOut>(response.Content); if (!jobCategorySaveOut.success) { throw new Exception(jobCategorySaveOut.messages.FirstOrDefault()); } } catch (Exception ex) { File.AppendAllText(string.Format("{0}\\Error_{1}.txt", pathLog, DateTime.Now.ToString("yyyyMMdd")), string.Format("**** Método: setJobCategorySave. Erro: {0}. JobCategoryId: {1}, Archive: {2}. Data: {3} ****", ex.Message, jobCategoryId, archive.Length, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")) + Environment.NewLine); jobCategorySaveOut.successMessage = null; jobCategorySaveOut.messages.Add(ex.Message); } return(jobCategorySaveOut); }