//public static async Task<Stream> GetTanThroughwcf(int id) //{ // // try // { // //SplashManager.ShowText("Dowloading Tan...."); // //using (S3ConnectionClient client = new S3ConnectionClient()) // //{ // // client.Endpoint.Binding.SendTimeout = new TimeSpan(10, 1, 30); // // return await Task<Stream>.Factory.StartNew(() => // // { // // Stream stream; // // ; // // stream = client.GetS3Object(id); // // return stream; // // }); // //} // } // catch (Exception ex) // { // Log.This(ex); // throw; // } //} public static async Task <RestStatus> SaveTan(OfflineDTO ffflineDTO, int currentRoleId) { RestStatus status = new RestStatus(); try { var start = DateTime.Now; string dataToSave = JsonConvert.SerializeObject(ffflineDTO); Debug.WriteLine($"Prepared string from object to pass as Post parameter in {(DateTime.Now - start).TotalSeconds} seconds. Json Lenght: {dataToSave.Length}"); List <string> tanNums = new List <string>(); if (!string.IsNullOrEmpty(Sessionkey)) { HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }; using (var httpClient = new HttpClient(handler)) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(BEARER_HEDER, Sessionkey); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATION_JSON)); StringContent stringContent = new StringContent("productId=1"); HttpResponseMessage response = await httpClient.PostAsync(SAVE_TAN + "?currentUserRole=" + currentRoleId + "&UserName="******"application/json")); using (HttpContent content = response.Content) { string responseText = await content.ReadAsStringAsync(); status.HttpCode = response.StatusCode; status.StatusMessage = responseText; if (status.HttpCode == System.Net.HttpStatusCode.OK) { status.HttpCode = System.Net.HttpStatusCode.OK; } } } } return(status); } catch (Exception ex) { Log.This(ex); status.HttpCode = HttpStatusCode.InternalServerError; status.StatusMessage = "Some error occured."; return(status); } }
public string SaveTan(OfflineDTO offlineDTO, [FromUri] int currentUserRole, [FromUri] string UserName) { var id = claimServices.UserId((ClaimsIdentity)User.Identity); return(TanService.SaveTan(id, offlineDTO, currentUserRole, ip, UserName)); }