/// <summary> /// Feecback sender /// </summary> /// <param name="status"></param> /// <returns></returns> public bool SendAppFeedback(string feedback_type, string message, string messageid, string update_id) { UpdateCheck updatecheck = new UpdateCheck(); stopwatch.Start(); bool ret = false; DateTime startedOnUtc = DateTime.UtcNow; string responseData = null; string responseHeaders = null; int responseStatusCode = 0; try { BetterWebClient webClient = new BetterWebClient(); webClient.Proxy = null; webClient.Headers.Add(HttpRequestHeader.Accept, "application/json charset=utf-8"); var webRequest = webClient.GetWebRequestX(new Uri(CreateCheckURL(feedback_type, message, messageid, update_id))); webRequest.Method = WebRequestMethods.Http.Get; using (WebResponse response = webRequest.GetResponse()) { internet.processResponse(response, out responseData, out responseHeaders, out responseStatusCode); } } catch (WebException ex) { using (ex.Response) { internet.processResponse(ex.Response, out responseData, out responseHeaders, out responseStatusCode); } // stop stopwatch stopwatch.Stop(); #region Prepare Error Log // get error log contains string errorlog = ":Date: " + DateTime.UtcNow.ToString() + Environment.NewLine; errorlog = errorlog + ":ExMessage: " + ex.Message + Environment.NewLine + Environment.NewLine; errorlog = errorlog + ":ExtentedExMEssage: " + ex.ToString() + Environment.NewLine + Environment.NewLine; errorlog = errorlog + ":HttpStatus: " + responseStatusCode + Environment.NewLine; errorlog = errorlog + ":ResponseData: " + responseData + Environment.NewLine; errorlog = errorlog + ":TimeElapsed: " + stopwatch.Elapsed; // get error log id string errorid = aes256.AES256Engine(Info.current_username + "+" + DateTime.UtcNow.ToString(), Info.current_username); #endregion // save errorlog for feedback common.saveErrorLog(errorlog, errorid, updatecheck.update_id); } Debug.WriteLine("respoınse---->>>>>>>>>>>>>>>>>>" + responseStatusCode); // All 2xx HTTP statuses are OK if (responseStatusCode >= 200 && responseStatusCode < 300) { // response json data RootobjectforFeedback jobj = JsonConvert.DeserializeObject <RootobjectforFeedback>(responseData); if (jobj.status && jobj.feed_status) { ret = true; } else { ret = false; } } return(ret); }
/// <summary> /// Returns update check response /// </summary> /// <returns></returns> public string GetUpdaterResponse() { stopwatch.Start(); DateTime startedOnUtc = DateTime.UtcNow; string responseData = null; string responseHeaders = null; int responseStatusCode = 0; try { BetterWebClient webClient = new BetterWebClient(); webClient.Proxy = null; webClient.Headers.Add(HttpRequestHeader.Accept, "application/" + OutputFormat.ToLower() + " charset=utf-8"); var webRequest = webClient.GetWebRequestX(new Uri(CreateCheckURL())); webRequest.Method = WebRequestMethods.Http.Get; using (WebResponse response = webRequest.GetResponse()) { internet.processResponse(response, out responseData, out responseHeaders, out responseStatusCode); } } catch (WebException ex) { using (ex.Response) { internet.processResponse(ex.Response, out responseData, out responseHeaders, out responseStatusCode); } // stop stopwatch stopwatch.Stop(); #region Prepare Error Log // get error log contains string errorlog = ":Date: " + DateTime.UtcNow.ToString() + Environment.NewLine; errorlog = errorlog + ":ExMessage: " + ex.Message + Environment.NewLine + Environment.NewLine; errorlog = errorlog + ":ExtentedExMEssage: " + ex.ToString() + Environment.NewLine + Environment.NewLine; errorlog = errorlog + ":HttpStatus: " + responseStatusCode + Environment.NewLine; errorlog = errorlog + ":ResponseData: " + responseData + Environment.NewLine; errorlog = errorlog + ":TimeElapsed: " + stopwatch.Elapsed; // get error log id string errorid = aes256.AES256Engine(Info.current_username + "+" + DateTime.UtcNow.ToString(), Info.current_username); #endregion // send errorlog feedback if (!feedback.SendAppFeedback("error", errorlog, errorid, update_id)) { // save error log for next time sending try common.saveErrorLog(errorlog, errorid, update_id); } } // All 2xx HTTP statuses are OK if (responseStatusCode >= 200 && responseStatusCode < 300) { return(responseData); } return(String.Empty); }