From b50fce7ac22951bcc897bb5ca7427c1beabf6134 Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Tue, 25 Feb 2014 01:29:35 +0100 Subject: [PATCH] No time for comments --- Mono/RemoteAgents/GTKLinux/MainWindow.cs | 12 ++++++++--- .../GTKLinux/Model/CallRemoteProcedure.cs | 25 +++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Mono/RemoteAgents/GTKLinux/MainWindow.cs b/Mono/RemoteAgents/GTKLinux/MainWindow.cs index 7fb8be7..85a31d4 100644 --- a/Mono/RemoteAgents/GTKLinux/MainWindow.cs +++ b/Mono/RemoteAgents/GTKLinux/MainWindow.cs @@ -34,10 +34,16 @@ namespace Example.RemoteAgents.GTKLinux async private void ButtonGetDateClicked(object sender, EventArgs a) { - string currentDate = await view.getCurrentDate(); - if (currentDate != null) + try { + string currentDate = await view.getCurrentDate(); + if (currentDate != null) + { + this.RemoteDate.Buffer.Text = currentDate; + } + } + catch (Exception e) { - this.RemoteDate.Buffer.Text = currentDate; + Console.WriteLine("ButtonGetDateClicked. Message: {0} Stacktrace: {1}", e.Message, e.StackTrace); } } } diff --git a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs index 3ec0a97..548ea92 100644 --- a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs +++ b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs @@ -18,7 +18,6 @@ namespace Example.RemoteAgents.GTKLinux.Model async public Task callRemoteService(string uri, string method) { - TResult result = default(TResult); var postData = new POST(); postData.id = "2114567586433855105"; postData.jsonrpc = "2.0"; @@ -31,23 +30,19 @@ namespace Example.RemoteAgents.GTKLinux.Model } }; - try { - string data = JsonConvert.SerializeObject(postData, jsonSettings); - HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json-rpc"); + string data = JsonConvert.SerializeObject(postData, jsonSettings); + HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json-rpc"); + + HttpResponseMessage response = await this.issueCall(uri, content); - HttpResponseMessage response = await this.issueCall(uri, content); + TResult result = default(TResult); - if (response.StatusCode == HttpStatusCode.OK) { - Task responseBytes = response.Content.ReadAsByteArrayAsync(); - string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result); + if (response.StatusCode == HttpStatusCode.OK) { + Task responseBytes = response.Content.ReadAsByteArrayAsync(); + string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result); - POSTResult postResult = JsonConvert.DeserializeObject>(responseString, jsonSettings); - result = postResult.result; - } - } - catch (Exception e) - { - Console.WriteLine("callRemoteService exception. Message: {0} Stacktrace: {1} ", e.Message, e.StackTrace); + POSTResult postResult = JsonConvert.DeserializeObject>(responseString, jsonSettings); + result = postResult.result; } return result; -- 2.1.4