chronojump r468 - in trunk: . build/data chronojump_server chronojump_server/bin glade sqlite_diagrams src src/gui src/sqlite



Author: xaviblas
Date: Tue Mar  3 17:17:51 2009
New Revision: 468
URL: http://svn.gnome.org/viewvc/chronojump?rev=468&view=rev

Log:
0.8.2.5
db 0.65
Sevaluator is also local (with only one row (uniqueID==1) for local evaluator
Pending to fix some evaluator window bugs
Hidden name in persons on server


Modified:
   trunk/build/data/chronojump.prg
   trunk/build/data/chronojump_mini.prg
   trunk/build/data/version.txt
   trunk/changelog.txt
   trunk/chronojump_server/ChronojumpServer.cs
   trunk/chronojump_server/bin/chronojumpServer.dll
   trunk/chronojump_server/chronojumpServerCSharp.cs
   trunk/glade/chronojump.glade
   trunk/sqlite_diagrams/chronojump_sqlite.dia
   trunk/src/constants.cs
   trunk/src/gui/chronojump.cs
   trunk/src/gui/evaluator.cs
   trunk/src/server.cs
   trunk/src/serverEvaluator.cs
   trunk/src/sqlite/main.cs
   trunk/src/sqlite/server.cs
   trunk/version.txt

Modified: trunk/build/data/chronojump.prg
==============================================================================
Binary files. No diff available.

Modified: trunk/build/data/chronojump_mini.prg
==============================================================================
Binary files. No diff available.

Modified: trunk/build/data/version.txt
==============================================================================
--- trunk/build/data/version.txt	(original)
+++ trunk/build/data/version.txt	Tue Mar  3 17:17:51 2009
@@ -1 +1 @@
-0.8.2.4
+0.8.2.5

Modified: trunk/changelog.txt
==============================================================================
--- trunk/changelog.txt	(original)
+++ trunk/changelog.txt	Tue Mar  3 17:17:51 2009
@@ -2,8 +2,6 @@
 
 Add Cabedo's tests
 
-add "chronopic3" to ping. maybe need to ask user
-
 add a link to the server page
 
 develop web stats and survey on web site. Maybe done by R script and calling
@@ -13,17 +11,18 @@
 
 do the ping gets real IP
 
-SEvaluator must be also local, and when edit, upload it. On the other hand, if
-it's only on server, we need to call server to know our values And it will be
-easy that users can know the evaluator data of others.
-mybe the best is have an SEvaluator local table iwht only one register.
-There's a need of a bool telling if it has been updated since last change or
-not.
-Then there's no need of evaluatorUniqueID in preferences.
-upload SEvaluator and edit it and re-upload
-add chronopic and device code th SEvaluator and update the diagram
-
-hide name in persons of server: replace it with uniqueID on insertion
+evaluator win TODO:
+-unchecked button_accept if needed on start
+-fix crash on cancel, or delete, or accept (on closing window)
+-fix crash on accept (bad sql)
+-accept is shown while no date of birth
+
+3 mar 2009
+	0.8.2.5
+	db 0.65
+	Sevaluator is also local (with only one row (uniqueID==1) for local evaluator
+	Pending to fix some evaluator window bugs
+	Hidden name in persons on server
 
 2 mar 2009 (3)
 	Fixed 505 is distance 10

Modified: trunk/chronojump_server/ChronojumpServer.cs
==============================================================================
--- trunk/chronojump_server/ChronojumpServer.cs	(original)
+++ trunk/chronojump_server/ChronojumpServer.cs	Tue Mar  3 17:17:51 2009
@@ -685,15 +685,17 @@
 ///Upload a evaluator
 ///</remarks>
     [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org/UploadEvaluator";, RequestNamespace="http://server.chronojump.org/";, ResponseNamespace="http://server.chronojump.org/";, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadEvaluator(ServerEvaluator myEval) {
+    public int UploadEvaluator(ServerEvaluator myEval, int evalSID) {
         object[] results = this.Invoke("UploadEvaluator", new object[] {
-                    myEval});
+                    myEval,
+                    evalSID});
         return ((int)(results[0]));
     }
     
-    public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, object asyncState) {
+    public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, int evalSID, System.AsyncCallback callback, object asyncState) {
         return this.BeginInvoke("UploadEvaluator", new object[] {
-                    myEval}, callback, asyncState);
+                    myEval,
+                    evalSID}, callback, asyncState);
     }
     
     public int EndUploadEvaluator(System.IAsyncResult asyncResult) {
@@ -701,16 +703,17 @@
         return ((int)(results[0]));
     }
     
-    public void UploadEvaluatorAsync(ServerEvaluator myEval) {
-        this.UploadEvaluatorAsync(myEval, null);
+    public void UploadEvaluatorAsync(ServerEvaluator myEval, int evalSID) {
+        this.UploadEvaluatorAsync(myEval, evalSID, null);
     }
     
-    public void UploadEvaluatorAsync(ServerEvaluator myEval, object userState) {
+    public void UploadEvaluatorAsync(ServerEvaluator myEval, int evalSID, object userState) {
         if ((this.UploadEvaluatorOperationCompleted == null)) {
             this.UploadEvaluatorOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadEvaluatorCompleted);
         }
         this.InvokeAsync("UploadEvaluator", new object[] {
-                    myEval}, this.UploadEvaluatorOperationCompleted, userState);
+                    myEval,
+                    evalSID}, this.UploadEvaluatorOperationCompleted, userState);
     }
     
     private void OnUploadEvaluatorCompleted(object arg) {
@@ -1250,6 +1253,15 @@
     public int CountryID;
     
     /// <remarks/>
+    public string Chronometer;
+    
+    /// <remarks/>
+    public string Device;
+    
+    /// <remarks/>
+    public string Comments;
+    
+    /// <remarks/>
     public bool Confiable;
 }
 

Modified: trunk/chronojump_server/bin/chronojumpServer.dll
==============================================================================
Binary files. No diff available.

Modified: trunk/chronojump_server/chronojumpServerCSharp.cs
==============================================================================
--- trunk/chronojump_server/chronojumpServerCSharp.cs	(original)
+++ trunk/chronojump_server/chronojumpServerCSharp.cs	Tue Mar  3 17:17:51 2009
@@ -208,6 +208,9 @@
 		//change value for being inserted with new numeration in server
 		myPerson.UniqueID = -1;
 		
+		//hidden person.Name
+		myPerson.Name = "";
+		
 		//do insertion
 		int id = myPerson.InsertAtDB(false, Constants.PersonTable);
 		
@@ -256,12 +259,15 @@
 	}
 
 	[WebMethod(Description="Upload a evaluator")]
-	public int UploadEvaluator(ServerEvaluator myEval)
+	public int UploadEvaluator(ServerEvaluator myEval, int evalSID)
 	{
 		Console.WriteLine("eval string: " + myEval.ToString());
+		int id = 0;
 
-		//do insertion
-		int id = myEval.InsertAtDB(false);
+		if(evalSID == Constants.ServerUndefinedID) 
+			id = myEval.InsertAtDB(false); //do insertion
+		else
+			id = myEval.Update(false); //do update
 		
 		return id;
 	}

Modified: trunk/glade/chronojump.glade
==============================================================================
--- trunk/glade/chronojump.glade	(original)
+++ trunk/glade/chronojump.glade	Tue Mar  3 17:17:51 2009
@@ -26527,6 +26527,7 @@
 		      <property name="has_frame">True</property>
 		      <property name="invisible_char">*</property>
 		      <property name="activates_default">False</property>
+		      <signal name="changed" handler="on_entries_required_changed" last_modification_time="Tue, 03 Mar 2009 16:27:32 GMT"/>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -27199,6 +27200,7 @@
 		      <property name="has_frame">True</property>
 		      <property name="invisible_char">â</property>
 		      <property name="activates_default">False</property>
+		      <signal name="changed" handler="on_entries_required_changed" last_modification_time="Tue, 03 Mar 2009 16:28:03 GMT"/>
 		    </widget>
 		    <packing>
 		      <property name="left_attach">1</property>
@@ -27506,6 +27508,7 @@
 			  <property name="has_frame">True</property>
 			  <property name="invisible_char">â</property>
 			  <property name="activates_default">False</property>
+			  <signal name="changed" handler="on_entries_required_changed" last_modification_time="Tue, 03 Mar 2009 16:28:16 GMT"/>
 			</widget>
 			<packing>
 			  <property name="left_attach">1</property>
@@ -27517,29 +27520,6 @@
 		      </child>
 
 		      <child>
-			<widget class="GtkRadioButton" id="radio_device_other">
-			  <property name="visible">True</property>
-			  <property name="can_focus">True</property>
-			  <property name="label" translatable="yes">Other. Specify:</property>
-			  <property name="use_underline">True</property>
-			  <property name="relief">GTK_RELIEF_NORMAL</property>
-			  <property name="focus_on_click">True</property>
-			  <property name="active">False</property>
-			  <property name="inconsistent">False</property>
-			  <property name="draw_indicator">True</property>
-			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:47 GMT"/>
-			</widget>
-			<packing>
-			  <property name="left_attach">0</property>
-			  <property name="right_attach">1</property>
-			  <property name="top_attach">4</property>
-			  <property name="bottom_attach">5</property>
-			  <property name="x_options">fill</property>
-			  <property name="y_options"></property>
-			</packing>
-		      </child>
-
-		      <child>
 			<widget class="GtkRadioButton" id="radio_device_undef">
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
@@ -27550,7 +27530,6 @@
 			  <property name="active">True</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
-			  <property name="group">radio_device_other</property>
 			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:38 GMT"/>
 			</widget>
 			<packing>
@@ -27575,7 +27554,7 @@
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
-			  <property name="group">radio_device_other</property>
+			  <property name="group">radio_device_undef</property>
 			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:38 GMT"/>
 			</widget>
 			<packing>
@@ -27600,7 +27579,7 @@
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
-			  <property name="group">radio_device_other</property>
+			  <property name="group">radio_device_undef</property>
 			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:38 GMT"/>
 			</widget>
 			<packing>
@@ -27624,7 +27603,7 @@
 			  <property name="active">False</property>
 			  <property name="inconsistent">False</property>
 			  <property name="draw_indicator">True</property>
-			  <property name="group">radio_device_other</property>
+			  <property name="group">radio_device_undef</property>
 			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:38 GMT"/>
 			</widget>
 			<packing>
@@ -27636,6 +27615,30 @@
 			  <property name="y_options"></property>
 			</packing>
 		      </child>
+
+		      <child>
+			<widget class="GtkRadioButton" id="radio_device_other">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">Other. Specify:</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">False</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			  <property name="group">radio_device_undef</property>
+			  <signal name="toggled" handler="on_radio_device_toggled" last_modification_time="Tue, 24 Feb 2009 16:22:38 GMT"/>
+			</widget>
+			<packing>
+			  <property name="left_attach">0</property>
+			  <property name="right_attach">1</property>
+			  <property name="top_attach">4</property>
+			  <property name="bottom_attach">5</property>
+			  <property name="x_options">fill</property>
+			  <property name="y_options"></property>
+			</packing>
+		      </child>
 		    </widget>
 		    <packing>
 		      <property name="padding">0</property>

Modified: trunk/sqlite_diagrams/chronojump_sqlite.dia
==============================================================================
Binary files. No diff available.

Modified: trunk/src/constants.cs
==============================================================================
--- trunk/src/constants.cs	(original)
+++ trunk/src/constants.cs	Tue Mar  3 17:17:51 2009
@@ -92,17 +92,23 @@
 	public const string ServerActionUploadSession = "uploadSession"; 
 	public const string ServerActionStats = "stats"; 
 	
+	public const string ChronometerCp1 = "Chronopic1";
+	public const string ChronometerCp2 = "Chronopic2";
+	public const string ChronometerCp3 = "Chronopic3";
 	public static string [] Chronometers = {
 		UndefinedDefault, 
-		"Chronopic1",
-		"Chronopic2",
-		"Chronopic3",
+		ChronometerCp1,
+		ChronometerCp2,
+		ChronometerCp3,
 	};
+	public const string DeviceContactSteel = "Contact platform (steel)";
+	public const string DeviceContactCircuit = "Contact platform (circuit board)";
+	public const string DeviceInfrared = "Infrared";
 	public static string [] Devices = {
 		UndefinedDefault + ":" + Catalog.GetString(UndefinedDefault), 
-		"Contact platform (steel)" + ":" + Catalog.GetString("Contact platform (steel)"),
-		"Contact platform (circuit board)" + ":" + Catalog.GetString("Contact platform (circuit board)"),
-		"Infrared" + ":" + Catalog.GetString("Infrared"),
+		DeviceContactSteel + ":" + Catalog.GetString(DeviceContactSteel),
+		DeviceContactCircuit + ":" + Catalog.GetString(DeviceContactCircuit),
+		DeviceInfrared + ":" + Catalog.GetString(DeviceInfrared),
 		"Other" + ":" + Catalog.GetString("Other"),
 	};
 	

Modified: trunk/src/gui/chronojump.cs
==============================================================================
--- trunk/src/gui/chronojump.cs	(original)
+++ trunk/src/gui/chronojump.cs	Tue Mar  3 17:17:51 2009
@@ -323,6 +323,8 @@
 	RepetitiveConditionsWindow repetitiveConditionsWin;
 	ChronopicConnection chronopicWin;
 	GenericWindow genericWin;
+		
+	EvaluatorWindow evalWin;
 	
 	//SessionUploadWindow sessionUploadWin;
 
@@ -899,7 +901,6 @@
 	{
 		int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
 		if(evalSID == Constants.ServerUndefinedID) 
-			//serverUploadEvaluator();
 			Server.ServerUploadEvaluator();
 
 		if(!checkPersonsMissingData()) {
@@ -950,8 +951,8 @@
 	}
 	
 	private void on_menuitem_server_evaluator_data (object o, EventArgs args) {
-		ServerEvaluator myEval = new ServerEvaluator();
-		EvaluatorWindow evalWindow = new EvaluatorWindow(myEval);
+		ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
+		evalWin = new EvaluatorWindow(myEval);
 	}
 
 	/* 

Modified: trunk/src/gui/evaluator.cs
==============================================================================
--- trunk/src/gui/evaluator.cs	(original)
+++ trunk/src/gui/evaluator.cs	Tue Mar  3 17:17:51 2009
@@ -22,7 +22,6 @@
 using Gtk;
 using Gdk;
 using Glade;
-//using Gnome;
 using GLib; //for Value
 using Mono.Unix;
 
@@ -58,6 +57,7 @@
 	[Widget] Gtk.Button button_zoom_cp3;
 	
 	//devices tab
+	[Widget] Gtk.RadioButton radio_device_undef;
 	[Widget] Gtk.RadioButton radio_contact_steel;
 	[Widget] Gtk.RadioButton radio_contact_modular;
 	[Widget] Gtk.RadioButton radio_infrared;
@@ -89,6 +89,9 @@
 	DateTime dateTime;
 
 	ServerEvaluator eval;
+
+	bool creating; //true if no record found before. False if updating
+
 	static EvaluatorWindow EvaluatorWindowBox;
 	
 	public EvaluatorWindow (ServerEvaluator eval)
@@ -102,6 +105,8 @@
 		UtilGtk.IconWindow(evaluator_window);
 		
 		this.eval = eval;
+		if(eval.Name == "")
+			creating = true;
 		
 		createComboContinents();
 		createComboCountries();
@@ -228,8 +233,7 @@
 	}
 
 	private void on_combo_countries_changed(object o, EventArgs args) {
-		//define country is not needed to accept person
-		//on_entries_required_changed(new object(), new EventArgs());
+		on_entries_required_changed(new object(), new EventArgs());
 	}
 
 	private void cp_zoom_buttons_unsensitive() {
@@ -252,6 +256,7 @@
 			else if(radio_cp3.Active) 
 				button_zoom_cp3.Sensitive = true;
 		}
+		on_entries_required_changed(new object(), new EventArgs());
 	}
 	
 	private void device_zoom_buttons_unsensitive() {
@@ -274,11 +279,27 @@
 			else if(radio_infrared.Active) 
 				button_zoom_infrared.Sensitive = true;
 		}
+		on_entries_required_changed(new object(), new EventArgs());
 	}
 	
 	
 	private void on_entries_required_changed(object o, EventArgs args) {
+		if(
+				entry_name.Text.Length > 0 &&
+				entry_email.Text.Length > 0 &&
+				label_date.Text != Constants.UndefinedDefault &&
+				UtilGtk.ComboGetActive(combo_countries) != Catalog.GetString(Constants.CountryUndefined) &&
+				! radio_cp_undef.Active &&
+				! (radio_cp_other.Active && entry_cp_other.Text.Length == 0) &&
+				! radio_device_undef.Active &&
+				! (radio_device_other.Active && entry_device_other.Text.Length == 0)
+		  )
+			button_accept.Sensitive = true;
+		else
+			button_accept.Sensitive = false;
+
 	}
+
 	private void on_button_confiable_clicked(object o, EventArgs args) {
 		Console.WriteLine("Confiable info");
 	}
@@ -317,91 +338,138 @@
 
 	private void fillDialog ()
 	{
-		int myChronometerID;
-//		if(adding) {
-			//dateTime = DateTime.Today;
-			//now dateTime is undefined until user changes it
-			dateTime = DateTime.MinValue;
-			label_date.Text = Catalog.GetString("Undefined");
-			label_confiable.Text = "Not confiable (default, nothing checked)";
-
-//			myChronometerID = currentEvaluator.ChronometerID;
-//		} else {
-			/*
-			Person myPerson = SqlitePersonSession.PersonSelect(personID, currentSession.UniqueID); 
-		
-			entry1.Text = myPerson.Name;
-			if (myPerson.Sex == "M") {
-				radiobutton_man.Active = true;
-			} else {
-				radiobutton_woman.Active = true;
-			}
+		entry_name.Text = eval.Name;
+		entry_email.Text = eval.Email;
 
-			dateTime = Util.DateAsDateTime(myPerson.DateBorn);
-			if(dateTime == DateTime.MinValue)
-				label_date.Text = Catalog.GetString("Undefined");
-			else
-				label_date.Text = dateTime.ToLongDateString();
-
-			spinbutton_height.Value = myPerson.Height;
-			spinbutton_weight.Value = myPerson.Weight;
-			weightIni = myPerson.Weight; //store for tracking if changes
-		
-			mySportID = myPerson.SportID;
-			mySpeciallityID = myPerson.SpeciallityID;
-			myLevelID = myPerson.Practice;
-
-
-			TextBuffer tb = new TextBuffer (new TextTagTable());
-			tb.Text = myPerson.Description;
-			textview2.Buffer = tb;
-
-			//country stuff
-			if(myPerson.CountryID != Constants.CountryUndefinedID) {
-				string [] countryString = SqliteCountry.Select(myPerson.CountryID);
-				combo_continents.Active = UtilGtk.ComboMakeActive(continentsTranslated, 
-						Catalog.GetString(countryString[3]));
-				combo_countries.Active = UtilGtk.ComboMakeActive(countriesTranslated, 
-						Catalog.GetString(countryString[1]));
-			}
-
-			serverUniqueID = myPerson.ServerUniqueID;
-			*/
+		DateTime dateTime = Util.DateAsDateTime(eval.DateBorn);
+		if(dateTime == DateTime.MinValue)
+			label_date.Text = Catalog.GetString(Constants.UndefinedDefault);
+		else
+			label_date.Text = dateTime.ToLongDateString();
+
+		//country stuff
+		if(eval.CountryID != Constants.CountryUndefinedID) {
+			string [] countryString = SqliteCountry.Select(eval.CountryID);
+			combo_continents.Active = UtilGtk.ComboMakeActive(continentsTranslated, 
+					Catalog.GetString(countryString[3]));
+			combo_countries.Active = UtilGtk.ComboMakeActive(countriesTranslated, 
+					Catalog.GetString(countryString[1]));
+		}
 
+		label_confiable.Text = eval.Confiable.ToString();
 
-//	}
-//
-			
-	//	sport = SqliteSport.Select(mySportID);
-	//	combo_sports.Active = UtilGtk.ComboMakeActive(sportsTranslated, sport.ToString());
+		TextBuffer tb = new TextBuffer (new TextTagTable());
+		tb.Text = eval.Comments;
+		textview_comments.Buffer = tb;
+
+		switch(eval.Chronometer) {
+			case "": 
+			case Constants.UndefinedDefault: 
+				radio_cp_undef.Active = true;
+			break;
+			case Constants.ChronometerCp1: 
+				radio_cp1.Active = true;
+			break;
+			case Constants.ChronometerCp2: 
+				radio_cp2.Active = true;
+			break;
+			case Constants.ChronometerCp3: 
+				radio_cp3.Active = true;
+			break;
+			default:
+				radio_cp_other.Active = true;
+				entry_cp_other.Text = eval.Chronometer;
+			break;
+		}
 
+		switch(eval.Device) {
+			case "": 
+			case Constants.UndefinedDefault: 
+				radio_device_undef.Active = true;
+			break;
+			case Constants.DeviceContactSteel: 
+				radio_contact_steel.Active = true;
+			break;
+			case Constants.DeviceContactCircuit: 
+				radio_contact_modular.Active = true;
+			break;
+			case Constants.DeviceInfrared: 
+				radio_infrared.Active = true;
+			break;
+			default:
+				radio_device_other.Active = true;
+				entry_device_other.Text = eval.Device;
+			break;
+		}
 		
+		//show or hide button_accept
+		on_entries_required_changed(new object(), new EventArgs());
 	}
 		
 	
 	protected void on_button_cancel_clicked (object o, EventArgs args)
 	{
 		EvaluatorWindowBox.evaluator_window.Hide();
-		EvaluatorWindowBox = null;
+		//EvaluatorWindowBox = null;
 	}
 	
 	protected void on_delete_event (object o, DeleteEventArgs args)
 	{
 		EvaluatorWindowBox.evaluator_window.Hide();
-		EvaluatorWindowBox = null;
+		//EvaluatorWindowBox = null;
 	}
 
 	protected void on_button_accept_clicked (object o, EventArgs args)
 	{
+		//eval.UniqueID = 1;
+		eval.Name = entry_name.Text.ToString();
+		eval.Email = entry_email.Text.ToString();
+		eval.DateBorn = label_date.Text.ToString();
+
+		eval.CountryID = Convert.ToInt32(
+				Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries));
+
+
+		if(radio_cp_undef.Active)
+			eval.Chronometer = Constants.UndefinedDefault;
+		else if(radio_cp1.Active)
+			eval.Chronometer = Constants.ChronometerCp1;
+		else if(radio_cp2.Active)
+			eval.Chronometer = Constants.ChronometerCp2;
+		else if(radio_cp3.Active)
+			eval.Chronometer = Constants.ChronometerCp3;
+		else
+			eval.Chronometer = entry_cp_other.Text.ToString();
+
+
+		if(radio_device_undef.Active)
+			eval.Device = Constants.UndefinedDefault;
+		else if(radio_contact_steel.Active)
+			eval.Device = Constants.DeviceContactSteel;
+		else if(radio_contact_modular.Active)
+			eval.Device = Constants.DeviceContactCircuit;
+		else if(radio_infrared.Active)
+			eval.Device = Constants.DeviceInfrared;
+		else
+			eval.Device = entry_device_other.Text.ToString();
+
+
+		if(creating) 
+			eval.InsertAtDB(false);
+		else
+			eval.Update(false);
+
 		EvaluatorWindowBox.evaluator_window.Hide();
-		EvaluatorWindowBox = null;
+		//EvaluatorWindowBox = null;
 	}
-	
+
+/*	
 	public Button Button_accept 
 	{
 		set { button_accept = value; }
 		get { return button_accept; }
 	}
+*/
 
 	~EvaluatorWindow() {}
 	

Modified: trunk/src/server.cs
==============================================================================
--- trunk/src/server.cs	(original)
+++ trunk/src/server.cs	Tue Mar  3 17:17:51 2009
@@ -568,11 +568,21 @@
 			Log.WriteLine(myServer.ConnectDatabase());
 			
 			//get Data, TODO: do it in a gui/window
-			ServerEvaluator myEval = new ServerEvaluator("myName", "myEmail", "myDateBorn", Constants.CountryUndefinedID, false);
-			//upload
-			myEval.UniqueID = myServer.UploadEvaluator(myEval);
+			//ServerEvaluator myEval = new ServerEvaluator("myName", "myEmail", "myDateBorn", 
+			//		Constants.CountryUndefinedID, "myChronometer", "myDevice", false);
+			ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
+
+			int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+			/*
+			 * upload to server, will insert if:
+			 * if(evalSID == Constants.ServerUndefinedID) 
+			 * otherwise will update
+			 */
+			myEval.UniqueID = myServer.UploadEvaluator(myEval, evalSID);
+
 			//update evaluatorServerID locally
-			SqlitePreferences.Update("evaluatorServerID", myEval.UniqueID.ToString(), false);
+			if(evalSID == Constants.ServerUndefinedID) 
+				SqlitePreferences.Update("evaluatorServerID", myEval.UniqueID.ToString(), false);
 
 			new DialogMessage(Constants.MessageTypes.INFO, "Uploaded with ID: " + myEval.UniqueID);
 			

Modified: trunk/src/serverEvaluator.cs
==============================================================================
--- trunk/src/serverEvaluator.cs	(original)
+++ trunk/src/serverEvaluator.cs	Tue Mar  3 17:17:51 2009
@@ -31,6 +31,9 @@
 	private string email;
 	private string dateBorn;
 	private int countryID;
+	private string chronometer;
+	private string device;
+	private string comments;
 	private bool confiable;
 
 	//only initializing
@@ -38,20 +41,27 @@
 	public ServerEvaluator() {
 	}
 
-	public ServerEvaluator(string name, string email, string dateBorn, int countryID, bool confiable) {
+	public ServerEvaluator(string name, string email, string dateBorn, int countryID, string chronometer, string device, string comments, bool confiable) {
 		this.name = name;
 		this.email = email;
 		this.dateBorn = dateBorn;
 		this.countryID = countryID;
+		this.chronometer = chronometer;
+		this.device = device;
+		this.comments = comments;
 		this.confiable = confiable;
 	}
 
 	public int InsertAtDB(bool dbconOpened){
-		Console.WriteLine("here" + this.ToString());
-		int myID = SqliteServer.InsertEvaluator(dbconOpened, name, email, dateBorn, countryID, confiable);
+		int myID = SqliteServer.InsertEvaluator(dbconOpened, name, email, dateBorn, countryID, chronometer, device, comments, confiable);
 		return myID;
 	}	
 
+	public int Update (bool dbconOpened){
+		SqliteServer.UpdateEvaluator(dbconOpened, uniqueID, name, email, dateBorn, countryID, chronometer, device, comments, confiable);
+		return uniqueID;
+	}	
+
 	public override string ToString() {
 		return "ID: " + uniqueID + "; Name: " + name + 
 			"; Email: " + email + "; DateBorn: " + dateBorn +
@@ -86,6 +96,21 @@
 		get { return countryID; }
 		set { countryID = value; }
 	}
+	
+	public string Chronometer {
+		get { return chronometer; }
+		set { chronometer = value; }
+	}
+
+	public string Device {
+		get { return device; }
+		set { device = value; }
+	}
+
+	public string Comments {
+		get { return comments; }
+		set { comments = value; }
+	}
 
 	public bool Confiable {
 		get { return confiable; }

Modified: trunk/src/sqlite/main.cs
==============================================================================
--- trunk/src/sqlite/main.cs	(original)
+++ trunk/src/sqlite/main.cs	Tue Mar  3 17:17:51 2009
@@ -72,7 +72,7 @@
 	 * Important, change this if there's any update to database
 	 * Important2: if database version get numbers higher than 1, check if the comparisons with currentVersion works ok
 	 */
-	static string lastChronojumpDatabaseVersion = "0.64";
+	static string lastChronojumpDatabaseVersion = "0.65";
 
 	public Sqlite() {
 	}
@@ -828,7 +828,19 @@
 				dbcon.Close();
 				currentVersion = "0.64";
 			}
+			if(currentVersion == "0.64") {
+				dbcon.Open();
+				
+				SqliteServer sqliteServerObject = new SqliteServer();
+				//user has also an evaluator table with a row (it's row)	
+				sqliteServerObject.CreateEvaluatorTable();
 
+				SqlitePreferences.Update ("databaseVersion", "0.65", true); 
+				
+				Log.WriteLine("Converted DB to 0.65 (added Sevaluator on client)"); 
+				dbcon.Close();
+				currentVersion = "0.65";
+			}
 
 		}
 
@@ -860,10 +872,12 @@
 		creationTotal = 12;
 		creationRate = 1;
 
+		SqliteServer sqliteServerObject = new SqliteServer();
+		//user has also an evaluator table with a row (it's row)	
+		sqliteServerObject.CreateEvaluatorTable();
+		
 		if(server) {
-			SqliteServer sqliteServerObject = new SqliteServer();
 			sqliteServerObject.CreatePingTable();
-			sqliteServerObject.CreateEvaluatorTable();
 			
 			SqliteServerSession sqliteSessionObject = new SqliteServerSession();
 			sqliteSessionObject.createTable(Constants.SessionTable);
@@ -945,6 +959,7 @@
 		SqliteCountry.initialize();
 		
 		//changes [from - to - desc]
+		//0.64 - 0.65 added Sevaluator on client
 		//0.63 - 0.64 added margaria test
 		//0.62 - 0.63 added 'versionAvailable' to preferences
 		//0.61 - 0.62 added hexagon (jumpRj test)

Modified: trunk/src/sqlite/server.cs
==============================================================================
--- trunk/src/sqlite/server.cs	(original)
+++ trunk/src/sqlite/server.cs	Tue Mar  3 17:17:51 2009
@@ -55,6 +55,9 @@
 			"email TEXT, " +
 			"dateborn TEXT, " +
 			"countryID INT, " + //foreign key
+			"chronometer TEXT, " +
+			"device TEXT, " +
+			"comments TEXT, " +
 			"confiable INT ) "; //bool
 		dbcmd.ExecuteNonQuery();
 	 }
@@ -86,7 +89,8 @@
 		return myReturn;
 	}
 
-	public static int InsertEvaluator(bool dbconOpened, string name, string email, string dateBorn, int countryID, bool confiable)
+	public static int InsertEvaluator(bool dbconOpened, string name, string email, string dateBorn, 
+			int countryID, string chronometer, string device, string comments, bool confiable)
 	{
 		if(! dbconOpened)
 			dbcon.Open();
@@ -94,10 +98,14 @@
 		string uniqueID = "NULL";
 
 		string myString = "INSERT INTO " + Constants.ServerEvaluatorTable + 
-			" (uniqueID, name, email, dateBorn, countryID, confiable) VALUES (" + 
+			" (uniqueID, name, email, dateBorn, countryID, chronometer, device, comments, confiable) VALUES (" + 
 			uniqueID + ", '" + name + "', '" + 
 			email + "', '" + dateBorn + "', " +
-			countryID + ", " + Util.BoolToInt(confiable) + ")" ;
+			countryID + ", '" + chronometer + "', '" + 
+			device + "', '" + comments + "', " +
+			//Util.BoolToInt(confiable) + 
+			Util.BoolToInt(false) + //security: cannot directly insert a confiable person
+			")" ;
 		
 		dbcmd.CommandText = myString;
 		
@@ -111,6 +119,58 @@
 
 		return myReturn;
 	}
+	
+	public static void UpdateEvaluator(bool dbconOpened, int uniqueID, string name, string email, string dateBorn, 
+			int countryID, string chronometer, string device, string comments, bool confiable)
+	{
+		if(! dbconOpened)
+			dbcon.Open();
+		dbcmd.CommandText = "UPDATE " + Constants.ServerEvaluatorTable + " " +
+			" SET name = '" + name +
+			"' , email = '" + email +
+			"' , dateBorn = '" + dateBorn +
+			"' , countryID = " + countryID +
+			", chronometer = '" + chronometer +
+			"', device = '" + device +
+			"', comments = '" + comments +
+			//"', confiable = " + Util.BoolToInt(confiable) + //security: update cannot change confiable
+			" WHERE uniqueID == " + uniqueID;
+		Log.WriteLine(dbcmd.CommandText.ToString());
+		dbcmd.ExecuteNonQuery();
+
+		if(! dbconOpened)
+			dbcon.Close();
+	}
+	
+	
+	//when client selects in it's DB, there's only a row with uniqueID: 1
+	//if confiable is read on client, it will be also checked on server
+	public static ServerEvaluator SelectEvaluator(int myUniqueID)
+	{
+		dbcon.Open();
+		dbcmd.CommandText = "SELECT * FROM " + Constants.ServerEvaluatorTable + " WHERE uniqueID == " + myUniqueID ; 
+		Log.WriteLine(dbcmd.CommandText.ToString());
+		
+		SqliteDataReader reader;
+		reader = dbcmd.ExecuteReader();
+	
+		ServerEvaluator myEval = new ServerEvaluator();
+		while(reader.Read()) {
+			myEval.UniqueID = Convert.ToInt32(reader[0].ToString()); 
+			myEval.Name = reader[1].ToString(); 
+			myEval.Email = reader[2].ToString(); 
+			myEval.DateBorn = reader[3].ToString();
+			myEval.CountryID = Convert.ToInt32(reader[4].ToString());
+			myEval.Chronometer = reader[5].ToString();
+			myEval.Device = reader[6].ToString();
+			myEval.Comments = reader[7].ToString();
+			myEval.Confiable = Util.IntToBool(Convert.ToInt32(reader[8].ToString())); 
+		}
+
+		dbcon.Close();
+		return myEval;
+	}
+	
 
 	public static string [] Stats() {
 		ArrayList stats = new ArrayList();

Modified: trunk/version.txt
==============================================================================
--- trunk/version.txt	(original)
+++ trunk/version.txt	Tue Mar  3 17:17:51 2009
@@ -1 +1 @@
-0.8.2.4
+0.8.2.5



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