private void prepareRequest() { brokerRequest = new BrokerRequest(); brokerDatabase.databaseTransaction("Request Broker Created"); }
/** SERVER REQUEST * Attempts to POST to the server, and deserialises the returned JSON message * to a an instance of a BrokerRequest object */ private void serverRequest(string type) { this.writetoDB(String.Format("Attempting '{0}' Server Interaction on {1}", type, HTTP_ADDR)); try { serverResponse = webClient.UploadValues(HTTP_ADDR, HTTP_POST, dataPOST); if (serverResponse.Equals(null)) throw new Exception("Server Unavailable"); decodedString = System.Text.Encoding.Default.GetString(serverResponse); // DeserializeObject brokerRequest = JsonConvert.DeserializeObject<BrokerRequest>(decodedString); } catch (Exception e) { this.writetoDB(String.Format("'{0}' failed on {1} with Exception {2}", type, HTTP_ADDR, e.ToString())); Debug.WriteLine("Exception occured {0}", e); brokerRequest = new BrokerRequest(); brokerRequest.updateError("9999", e.Source + ": " + e.Message); irrecoverableError = true; } }