public static async Task <Entity.Result <T> > JsonStringToObject <T>(string responseString) { Entity.Result <T> result = new Entity.Result <T> { }; try { if (!string.IsNullOrEmpty(responseString)) { JavaScriptSerializer serializer = new JavaScriptSerializer(); result.Data = serializer.Deserialize <T>(responseString); } } catch (Exception ex) { result.StatusCode = System.Net.HttpStatusCode.OK; Log.Exception(ex, "DigitalWare.Billing.Common.Util.Serialization.JsonStringToObject"); } return(result); }
/// <summary> /// Json HttpResponse to object /// </summary> /// <typeparam name="T"></typeparam> /// <param name="httpResponseMessage"></param> /// <returns><typeparam name="T"></typeparam></returns> /// <history> /// Version Author Date Description /// 1.0.0.0 David Vanegas 27/11/2021 Creation /// </history> public static async Task <Entity.Result <T> > JsonHttpResponseToObject <T>(System.Net.Http.HttpResponseMessage httpResponseMessage) { Entity.Result <T> result = new Entity.Result <T> { }; try { var responseString = await httpResponseMessage.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(responseString)) { JavaScriptSerializer serializer = new JavaScriptSerializer(); result.Data = serializer.Deserialize <T>(responseString); } } catch (Exception ex) { result.StatusCode = System.Net.HttpStatusCode.OK; Log.Exception(ex, "DigitalWare.Billing.Common.Util.Serialization.JsonHttpResponseToObject"); } return(result); }
public ResultPush(Entity.Result result) { InitializeComponent(); tbStatusID.Text = result.StatusID.ToString(); tbLanguage.Text = result.Language.ToString(); tbSubmittion.Text = result.SubmissionTime.ToString(); tbTime.Text = result.TimeUsage != null?result.TimeUsage.ToString() + " ms" : "??"; tbMemory.Text = result.MemoryUsage != null ? (Convert.ToInt32(result.MemoryUsage / 1024)).ToString() + " KiB" : "??"; tbStatus.Text = result.Status.ToString(); if (result.Status == Entity.RecordStatus.Accepted) { tbStatus.Foreground = new SolidColorBrush(Colors.Green); } else if (result.Status == Entity.RecordStatus.SystemError || result.Status == Entity.RecordStatus.ValidatorError || result.Status == Entity.RecordStatus.CompileError) { tbStatus.Foreground = new SolidColorBrush(Colors.Orange); } else { tbStatus.Foreground = new SolidColorBrush(Colors.Red); } tbDetail.Text = result.Detail.Trim('\r').Trim('\n'); }