[chronojump] 0.8.11 Fixed bug when updating a person with a new user defined sport that's not in db,



commit 09b7b51ed5300b97731279864d8e61eec6ecc8f7
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 28 12:42:57 2009 +0200

    0.8.11 Fixed bug when updating a person with a new user defined sport that's not in db,
    this sport was created in server db, and then was locally changed sportID to server db sportID.
    now locally points correctly to local sportID
    when this failed it wasn't shown person in person treeview, because sport doesn't match on:
    
    SELECT person.*, personSessionWeight.weight, sport.name, speciallity.name FROM person, personSessionWeight, sport, speciallity  WHERE personSessionWeight.sessionID == 3 AND person.uniqueID == personSessionWeight.personID  AND person.sportID == sport.uniqueID  AND person.speciallityID == speciallity.uniqueID  ORDER BY upper(person.name)
    
    Also when there's a crash, now points to new version if is newer (not different)

 chronojump_server/bin/chronojumpServer.dll  |  Bin 273920 -> 273920 bytes
 chronojump_server/chronojumpServerCSharp.cs |    2 +-
 configure.ac                                |    2 +-
 src/AssemblyInfo.cs                         |    2 +-
 src/chronojump.cs                           |    6 ++++--
 src/gui/chronojump.cs                       |    1 -
 src/server.cs                               |   17 +++++++++++++++--
 7 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/chronojump_server/bin/chronojumpServer.dll b/chronojump_server/bin/chronojumpServer.dll
index a190679..cd1cb86 100755
Binary files a/chronojump_server/bin/chronojumpServer.dll and b/chronojump_server/bin/chronojumpServer.dll differ
diff --git a/chronojump_server/chronojumpServerCSharp.cs b/chronojump_server/chronojumpServerCSharp.cs
index 4dcda38..c2d2926 100755
--- a/chronojump_server/chronojumpServerCSharp.cs
+++ b/chronojump_server/chronojumpServerCSharp.cs
@@ -63,7 +63,7 @@ public class ChronojumpServer {
 	public bool CanINew(string action, string clientVersion)
 	{
 		Version cv = new Version(clientVersion);
-		if(action == Constants.ServerActionUploadSession && cv >= new Version(0,8,9,6))
+		if(action == Constants.ServerActionUploadSession && cv >= new Version(0,8,11))
 			return true;
 		else if(action == Constants.ServerActionStats && cv >= new Version(0,8))
 			return true;
diff --git a/configure.ac b/configure.ac
index 5958431..3cf5eaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 dnl Warning: This is an automatically generated file, do not edit!
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ([2.54])
-AC_INIT([chronojump], [0.8.10])
+AC_INIT([chronojump], [0.8.11])
 AM_INIT_AUTOMAKE([foreign])
 
 AC_CONFIG_MACRO_DIR([m4])
diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs
index 84d4da8..0fb3416 100755
--- a/src/AssemblyInfo.cs
+++ b/src/AssemblyInfo.cs
@@ -23,7 +23,7 @@ using System.Runtime.CompilerServices;
 // You can specify all values by your own or you can build default build and revision
 // numbers with the '*' character (the default):
 
-[assembly: AssemblyVersion("0.8.10")]
+[assembly: AssemblyVersion("0.8.11")]
 
 // The following attributes specify the key for the sign of your assembly. See the
 // .NET Framework documentation for more information about signing.
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 21a9b18..517a348 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -278,8 +278,10 @@ Log.WriteLine("doing backup");
 
 		string versionAvailableKnown = SqlitePreferences.Select("versionAvailable");
 		if( versionAvailable != Constants.ServerOffline && versionAvailable != progVersion ) {
-			//versionAvailable is higher than client version
-			if(versionAvailable != versionAvailableKnown) {
+			//check if available version is higher than known available version
+			Version versionAvailableAsV = new Version(versionAvailable);
+			Version versionAvailableKnownAsV = new Version(versionAvailableKnown);
+			if(versionAvailableAsV > versionAvailableKnownAsV) {
 				//is the first time we know about this new version
 				//just write on db and show message to user
 				SqlitePreferences.Update(Constants.PrefVersionAvailable, versionAvailable, false);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index aeb0eea..835c5a7 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -991,7 +991,6 @@ public class ChronoJumpWindow
 	private bool connectedAndCanI (string serverAction) {
 		string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
 		if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
-			//if(Server.CanI(serverAction, Util.VersionToDouble(progVersion)))
 			if(Server.CanI(serverAction, progVersion))
 				return true;
 			else
diff --git a/src/server.cs b/src/server.cs
index 53184fb..c6b8009 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -212,7 +212,15 @@ public class Server
 					//if sport is user defined, upload it
 					//and when upload the person, do it with new sportID
 					Sport sport = SqliteSport.Select(person.SportID);
+					//but record old sport ID because locally will be a change in serverUniqueID
+					//(with slite update)
+					//but local sport has not to be changed
+					int sportUserDefinedLocal = -1;
+
 					if(sport.UserDefined) {
+						sportUserDefinedLocal = sport.UniqueID;
+
+						//this will be uploaded
 						int newSport = myServer.UploadSport(sport);
 						if(newSport != -1) {
 							person.SportID = newSport;
@@ -221,7 +229,7 @@ public class Server
 						}
 					}
 
-					person = serverUploadPerson(myServer, person, serverSession.UniqueID);
+					person = serverUploadPerson(myServer, person, serverSession.UniqueID, sportUserDefinedLocal);
 				}
 
 				//a person can be in the database for one session, 
@@ -531,12 +539,17 @@ public class Server
 	
 	
 	//upload a person
-	private static Person serverUploadPerson(ChronojumpServer myServer, Person person, int serverSessionID) 
+	private static Person serverUploadPerson(ChronojumpServer myServer, Person person, int serverSessionID, int sportUserDefinedLocal) 
 	{
 		int idAtServer = myServer.UploadPerson(person, serverSessionID);
 
 		//update person (serverUniqueID) on client database
 		person.ServerUniqueID = idAtServer;
+
+		//when update locally, don't put the user defined sport id at server
+		if(sportUserDefinedLocal != -1)
+			person.SportID = sportUserDefinedLocal;
+
 		SqlitePerson.Update(person);
 
 		return person;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]