[chronojump] GetPersonByRFID downloaded image is stored on client image folder
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] GetPersonByRFID downloaded image is stored on client image folder
- Date: Thu, 25 May 2017 15:17:42 +0000 (UTC)
commit a63f671f3764c79c96728479b04d94028b3afd19
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 25 17:13:52 2017 +0200
GetPersonByRFID downloaded image is stored on client image folder
src/json.cs | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/src/json.cs b/src/json.cs
index 86c9e83..cea0473 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -361,14 +361,49 @@ public class Json
LastPersonByRFIDWeight = Convert.ToDouble(Util.ChangeDecimalSeparator(weight));
str = str.Substring(str.IndexOf('"') +1);
- //LogB.Information("str:|" + str + "|");
+ LogB.Information("str:|" + str + "|");
- string rfid = str.Substring(0, str.LastIndexOf('"'));
+ string rfid = str.Substring(0, str.IndexOf('"'));
LogB.Information("rfid:|" + rfid + "|");
+ str = str.Substring(str.IndexOf('"') +4);
+ LogB.Information("str:|" + str + "|");
+
+ string image = str.Substring(0, str.LastIndexOf('"'));
+ LogB.Information("image:|" + image + "|");
+ LastPersonByRFIDImageURL = image;
+
return new Person(Convert.ToInt32(id), player, rfid);
}
+
+ //to retrieve images from flask (:5050)
+ private string getImagesUrl()
+ {
+ int posOfLastColon = serverUrl.LastIndexOf(':');
+ return serverUrl.Substring(0, posOfLastColon) + ":5000/static/images/";
+ }
+
+ //imageHalfUrl is "jugadors/*.jpg"
+ public bool DownloadImage(string imageHalfUrl, int personID)
+ {
+ try {
+ using (WebClient client = new WebClient())
+ {
+ LogB.Information ("DownloadImage!!");
+ LogB.Information (getImagesUrl() + imageHalfUrl);
+ LogB.Information (Path.Combine(Path.GetTempPath(), personID.ToString()));
+ client.DownloadFile(new Uri(getImagesUrl() + imageHalfUrl),
+ Path.Combine(Path.GetTempPath(), personID.ToString()));
+ }
+ } catch {
+ LogB.Warning("DownloadImage catched");
+ return false;
+ }
+
+ return true;
+ }
+
/*
public bool UploadEncoderData()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]