[chronojump] Json GetNewsDatetime method
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Json GetNewsDatetime method
- Date: Tue, 19 Jan 2021 11:05:26 +0000 (UTC)
commit e627d7d32fd7caa72b466d89c431016e66088714
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jan 19 12:03:58 2021 +0100
Json GetNewsDatetime method
src/json/json.cs | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
---
diff --git a/src/json/json.cs b/src/json/json.cs
index 18947617..c362524d 100644
--- a/src/json/json.cs
+++ b/src/json/json.cs
@@ -184,6 +184,46 @@ public class Json
return true;
}
+ /*
+ * ---- news stuff start ---->
+ */
+
+ public bool GetNewsDatetime ()
+ {
+ // Create a request using a URL that can receive a post.
+ if (! createWebRequest(requestType.GENERIC, "/getNewsDatetime"))
+ return false;
+
+ // Set the Method property of the request to GET.
+ request.Method = "GET";
+
+ // Set the ContentType property of the WebRequest.
+ //request.ContentType = "application/x-www-form-urlencoded";
+
+ HttpWebResponse response;
+ if(! getHttpWebResponse (request, out response, "Could not get news datetime"))
+ return false;
+
+ string responseFromServer;
+ using (var sr = new StreamReader(response.GetResponseStream()))
+ {
+ responseFromServer = sr.ReadToEnd();
+ }
+
+ LogB.Information("getNewsServerDatetime:" + responseFromServer);
+
+ //responseFromServer comes as: "2020-01-18_12-13-00", need to remove double quotes because we
do not want to insert them on sql
+
+ int startPos = responseFromServer.IndexOf('"') +1;
+ int endPos = responseFromServer.LastIndexOf('"') -1;
+ if(endPos > 0)
+ responseFromServer = responseFromServer.Substring(startPos,endPos);
+
+ this.ResultMessage = responseFromServer;
+
+ return true;
+ }
+
//get all the news, news class will decide if something have to be inserted or selected
//called by pingThread at start
public List<News> GetNews(List<News> newsAtDB_l)
@@ -288,6 +328,10 @@ public class Json
return true;
}
+ /*
+ * <---- news stuff end ----
+ */
+
/*
* if software just started, ping gets stuck by network problems, and user try to exit software,
* thread.Abort doesn't kill the thread properly
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]