[chronojump] Networks download image of person already on local if image changed
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Networks download image of person already on local if image changed
- Date: Thu, 15 Apr 2021 11:33:34 +0000 (UTC)
commit 6d66a4137ba6f5a08ef5410b8f3cd291cbe84c90
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Apr 15 13:33:03 2021 +0200
Networks download image of person already on local if image changed
src/gui/networks.cs | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index c229d1c6..bf3112fe 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -749,21 +749,7 @@ public partial class ChronoJumpWindow
if(json.LastPersonWasInserted)
{
- string imageFile = json.LastPersonByRFIDImageURL;
- if(imageFile != null && imageFile != "")
- {
- string image_dest = Util.GetPhotoFileName(false,
currentPerson.UniqueID);
- if(UtilMultimedia.GetImageType(imageFile) ==
UtilMultimedia.ImageTypes.PNG)
- image_dest = Util.GetPhotoPngFileName(false,
currentPerson.UniqueID);
-
- bool downloaded =
json.DownloadImage(json.LastPersonByRFIDImageURL, currentPerson.UniqueID);
- if(downloaded)
- File.Copy(
- Path.Combine(Path.GetTempPath(),
currentPerson.UniqueID.ToString()),
- image_dest,
- true); //overwrite
- }
-
+ compujumpDownloadImage (json, json.LastPersonByRFIDImageURL,
currentPerson.UniqueID);
person_added(); //GTK
} else {
personChanged(); //GTK
@@ -785,6 +771,11 @@ public partial class ChronoJumpWindow
}
} else {
LogB.Information("RFID person exists locally!!");
+
+ //if image changed, download it
+ if(pServer.UniqueID != -1 && pServer.LinkServerImage != pLocal.LinkServerImage)
+ compujumpDownloadImage (json, pServer.LinkServerImage, pServer.UniqueID);
+
if(rfidIsDifferent || dialogPersonPopup == null || ! dialogPersonPopup.Visible)
{
string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
@@ -871,6 +862,22 @@ public partial class ChronoJumpWindow
return true;
}
+ private void compujumpDownloadImage (JsonCompujump json, string url, int personID)
+ {
+ if(url == null || url == "")
+ return;
+
+ string image_dest = Util.GetPhotoFileName(false, personID);
+ if(UtilMultimedia.GetImageType(url) == UtilMultimedia.ImageTypes.PNG)
+ image_dest = Util.GetPhotoPngFileName(false, personID);
+
+ if(json.DownloadImage(url, personID))
+ File.Copy(
+ Path.Combine(Path.GetTempPath(), personID.ToString()),
+ image_dest,
+ true); //overwrite
+ }
+
//load current session if MONTHLY and current session is not current month and currentPerson is not
compumpAdminID
private void compujumpPersonChangedShouldChangeSession()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]