Commit 2b733754 authored by Xavier de Blas's avatar Xavier de Blas

0.8.2.6 evaluator code ended with encryption. Only pending the confiable

	0.8.2.6
	evaluator code ended with encryption. Only pending the confiable flag:
	-added BCryp.cs to allow encryption of evaluatorServerUniqueID
	-added code to Sevaluator table;
	-done upload or insert evaluator data

	finished evaluator win:
	-ended fillDialog
	-fixed crash on accept (bad sql)
	-fixed crash on cancel, or delete, or accept (on closing window)
	-accept is shown while no date of birth (done?)
	-unchecked button_accept if needed on start

	dialogMessage again as modal because there where problems (unclickable) 
	when is called from evaluator window until evaluator win is closed

	improved chrash message on start


svn path=/trunk/; revision=469
parent e8f00f79
......@@ -114,7 +114,7 @@ CHRONOJUMP_MINI_DEP = src/chronojump_mini.cs src/chronopic.cs src/util.cs src/lo
#--------Dependences of CHRONOJUMP_SERVER
CHRONOJUMP_SERVER_DEP = chronojump_server/chronojumpServerCSharp.cs src/sqlite/*.cs src/util.cs src/person.cs src/event.cs src/jump.cs src/run.cs src/pulse.cs src/reactionTime.cs src/session.cs src/eventType.cs src/jumpType.cs src/runType.cs src/pulseType.cs src/sport.cs src/constants.cs src/log.cs src/serverPing.cs src/serverEvaluator.cs
CHRONOJUMP_SERVER_DEP = chronojump_server/chronojumpServerCSharp.cs src/sqlite/*.cs src/util.cs src/person.cs src/event.cs src/jump.cs src/run.cs src/pulse.cs src/reactionTime.cs src/session.cs src/eventType.cs src/jumpType.cs src/runType.cs src/pulseType.cs src/sport.cs src/constants.cs src/log.cs src/serverPing.cs src/serverEvaluator.cs chronojump_server/BCrypt.cs
#--------Makefiles
......
......@@ -11,11 +11,24 @@ all this will be release 0.9
do the ping gets real IP
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
5 mar 2009
0.8.2.6
evaluator code ended with encryption. Only pending the confiable flag:
-added BCryp.cs to allow encryption of evaluatorServerUniqueID
-added code to Sevaluator table;
-done upload or insert evaluator data
finished evaluator win:
-ended fillDialog
-fixed crash on accept (bad sql)
-fixed crash on cancel, or delete, or accept (on closing window)
-accept is shown while no date of birth (done?)
-unchecked button_accept if needed on start
dialogMessage again as modal because there where problems (unclickable)
when is called from evaluator window until evaluator win is closed
improved chrash message on start
3 mar 2009
0.8.2.5
......
This diff is collapsed.
......@@ -52,6 +52,8 @@ public class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProt
private System.Threading.SendOrPostCallback UploadEvaluatorOperationCompleted;
private System.Threading.SendOrPostCallback EditEvaluatorOperationCompleted;
private System.Threading.SendOrPostCallback UploadJumpOperationCompleted;
private System.Threading.SendOrPostCallback UploadJumpRjOperationCompleted;
......@@ -100,6 +102,8 @@ public class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProt
private event UploadEvaluatorCompletedEventHandler UploadEvaluatorCompleted;
private event EditEvaluatorCompletedEventHandler EditEvaluatorCompleted;
private event UploadJumpCompletedEventHandler UploadJumpCompleted;
private event UploadJumpRjCompletedEventHandler UploadJumpRjCompleted;
......@@ -682,38 +686,35 @@ public class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProt
}
/// <remarks>
///Upload a evaluator
///Upload an 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, int evalSID) {
public string UploadEvaluator(ServerEvaluator myEval) {
object[] results = this.Invoke("UploadEvaluator", new object[] {
myEval,
evalSID});
return ((int)(results[0]));
myEval});
return ((string)(results[0]));
}
public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, int evalSID, System.AsyncCallback callback, object asyncState) {
public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("UploadEvaluator", new object[] {
myEval,
evalSID}, callback, asyncState);
myEval}, callback, asyncState);
}
public int EndUploadEvaluator(System.IAsyncResult asyncResult) {
public string EndUploadEvaluator(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((int)(results[0]));
return ((string)(results[0]));
}
public void UploadEvaluatorAsync(ServerEvaluator myEval, int evalSID) {
this.UploadEvaluatorAsync(myEval, evalSID, null);
public void UploadEvaluatorAsync(ServerEvaluator myEval) {
this.UploadEvaluatorAsync(myEval, null);
}
public void UploadEvaluatorAsync(ServerEvaluator myEval, int evalSID, object userState) {
public void UploadEvaluatorAsync(ServerEvaluator myEval, object userState) {
if ((this.UploadEvaluatorOperationCompleted == null)) {
this.UploadEvaluatorOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadEvaluatorCompleted);
}
this.InvokeAsync("UploadEvaluator", new object[] {
myEval,
evalSID}, this.UploadEvaluatorOperationCompleted, userState);
myEval}, this.UploadEvaluatorOperationCompleted, userState);
}
private void OnUploadEvaluatorCompleted(object arg) {
......@@ -723,6 +724,48 @@ public class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProt
}
}
/// <remarks>
///Edit an evaluator
///</remarks>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org/EditEvaluator", 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 bool EditEvaluator(ServerEvaluator clientEval, int evalSID) {
object[] results = this.Invoke("EditEvaluator", new object[] {
clientEval,
evalSID});
return ((bool)(results[0]));
}
public System.IAsyncResult BeginEditEvaluator(ServerEvaluator clientEval, int evalSID, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("EditEvaluator", new object[] {
clientEval,
evalSID}, callback, asyncState);
}
public bool EndEditEvaluator(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((bool)(results[0]));
}
public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID) {
this.EditEvaluatorAsync(clientEval, evalSID, null);
}
public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID, object userState) {
if ((this.EditEvaluatorOperationCompleted == null)) {
this.EditEvaluatorOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEditEvaluatorCompleted);
}
this.InvokeAsync("EditEvaluator", new object[] {
clientEval,
evalSID}, this.EditEvaluatorOperationCompleted, userState);
}
private void OnEditEvaluatorCompleted(object arg) {
if ((this.EditEvaluatorCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.EditEvaluatorCompleted(this, new EditEvaluatorCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks>
///Upload a jump
///</remarks>
......@@ -996,7 +1039,6 @@ public class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProt
}
}
}
/*
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")]
......@@ -1240,6 +1282,9 @@ public partial class ServerEvaluator {
/// <remarks/>
public int UniqueID;
/// <remarks/>
public string Code;
/// <remarks/>
public string Name;
......@@ -1414,7 +1459,6 @@ public partial class Pulse : Event {
public string TimesString;
}
*/
public class ConnectDatabaseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
......@@ -1690,16 +1734,35 @@ public class UploadEvaluatorCompletedEventArgs : System.ComponentModel.AsyncComp
this.results = results;
}
public int Result {
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((int)(this.results[0]));
return ((string)(this.results[0]));
}
}
}
public delegate void UploadEvaluatorCompletedEventHandler(object sender, UploadEvaluatorCompletedEventArgs args);
public class EditEvaluatorCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal EditEvaluatorCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
public bool Result {
get {
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[0]));
}
}
}
public delegate void EditEvaluatorCompletedEventHandler(object sender, EditEvaluatorCompletedEventArgs args);
public class UploadJumpCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
......
......@@ -258,18 +258,46 @@ public class ChronojumpServer {
return SqlitePreferences.Select("versionAvailable");
}
[WebMethod(Description="Upload a evaluator")]
public int UploadEvaluator(ServerEvaluator myEval, int evalSID)
[WebMethod(Description="Upload an evaluator")]
public string UploadEvaluator(ServerEvaluator myEval)
{
Console.WriteLine("eval string: " + myEval.ToString());
int id = 0;
Console.WriteLine("upload. eval string: " + myEval.ToString());
if(evalSID == Constants.ServerUndefinedID)
id = myEval.InsertAtDB(false); //do insertion
else
id = myEval.Update(false); //do update
return id;
string idCode;
Random rnd = new Random();
string password = myEval.Name + rnd.Next().ToString();
string hashed = BCrypt.HashPassword(password, BCrypt.GenerateSalt(10));
//insert the password in the server and the hash in the client
myEval.Code = password;
int id = myEval.InsertAtDB(false); //do insertion
return id.ToString() + ":" + hashed;
}
[WebMethod(Description="Edit an evaluator")]
public bool EditEvaluator(ServerEvaluator clientEval, int evalSID)
{
Console.WriteLine("edit. eval string: " + clientEval.ToString());
ServerEvaluator serverEval = SqliteServer.SelectEvaluator(evalSID);
//serveEval.Code is password
//clientEval.Code is hash
bool matches = BCrypt.CheckPassword(serverEval.Code, clientEval.Code);
if(matches) {
//put the uniqueID that corresponds in server
clientEval.UniqueID = evalSID;
//put the pass code instead of the client password hash
clientEval.Code = serverEval.Code;
clientEval.Update(false); //do update
return true;
}
return false;
}
......
......@@ -13939,7 +13939,7 @@ suitable for agility tests)</property>
<property name="title" translatable="yes">Message</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
<property name="modal">False</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
......@@ -26337,7 +26337,7 @@ by you</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
......@@ -112,7 +112,6 @@ public class ChronoJump
protected void sqliteThings () {
bool crashedBefore = checkIfChronojumpExitAbnormally();
/* SERVER COMMUNICATION TESTS */
//try {
......@@ -257,7 +256,7 @@ public class ChronoJump
}
string versionAvailableKnown = SqlitePreferences.Select("versionAvailable");
if( versionAvailable != Constants.ServerOffline && versionAvailable != progVersion ) {
if( versionAvailableKnown.Length > 0 && versionAvailable != Constants.ServerOffline && versionAvailable != progVersion ) {
//versionAvailable is higher than client version
if(versionAvailable != versionAvailableKnown) {
//is the first time we know about this new version
......@@ -273,7 +272,7 @@ public class ChronoJump
//if chronojump chrashed before
if(crashedBefore) {
if( versionAvailableKnown != progVersion )
if( versionAvailableKnown.Length > 0 && versionAvailableKnown != progVersion )
messageToShowOnBoot += "\n" + Catalog.GetString("Chronojump crashed before.") + "\n" +
Catalog.GetString("Please, update to new version: ") + versionAvailableKnown + "\n";
else
......@@ -484,8 +483,9 @@ public class ChronoJump
messageChrashedBefore = "\n" +
string.Format(Catalog.GetString("Chronojump {0} crashed before. Please, report it at forums:"), progVersion) +
"\nhttp://chronojump.org\n\n" + Catalog.GetString("Include also this file:") + "\n\n" +
string.Format(Catalog.GetString("Chronojump {0} crashed before. If this problem persist, please, report it at forums:"), progVersion) +
"\nhttp://chronojump.org\n\n" + Catalog.GetString("Remember to describe on Chronojump software forum how crash happened.") +
"\n" + Catalog.GetString("Optionally, you can include this file:") + "\n\n" +
Log.GetLast() +
//windowsTextLog +
"\n\n" +
......
......@@ -952,7 +952,21 @@ Log.WriteLine("+++++++++++++++++ 7 ++++++++++++++++");
private void on_menuitem_server_evaluator_data (object o, EventArgs args) {
ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
evalWin = new EvaluatorWindow(myEval);
//evalWin = new EvaluatorWindow(myEval);
evalWin = EvaluatorWindow.Show(myEval);
evalWin.FakeButtonAccept.Clicked += new EventHandler(on_evaluator_done);
}
private void on_evaluator_done (object o, EventArgs args) {
string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want to upload evaluator data now?"), "");
confirmWin.Button_accept.Clicked += new EventHandler(on_evaluator_upload_accepted);
}
}
private void on_evaluator_upload_accepted (object o, EventArgs args) {
Server.ServerUploadEvaluator();
}
/*
......
......@@ -91,6 +91,9 @@ public class EvaluatorWindow
ServerEvaluator eval;
bool creating; //true if no record found before. False if updating
//allows to upload data (from gui/chronojump.cs) after has been inserted in sql
public Gtk.Button fakeButtonAccept;
static EvaluatorWindow EvaluatorWindowBox;
......@@ -104,14 +107,17 @@ public class EvaluatorWindow
//put an icon to window
UtilGtk.IconWindow(evaluator_window);
fakeButtonAccept = new Gtk.Button();
this.eval = eval;
if(eval.Name == "")
if(eval.UniqueID == -1)
creating = true;
createComboContinents();
createComboCountries();
putNonStandardIcons();
entry_cp_other.Sensitive = false;
}
......@@ -287,7 +293,8 @@ public class EvaluatorWindow
if(
entry_name.Text.Length > 0 &&
entry_email.Text.Length > 0 &&
label_date.Text != Constants.UndefinedDefault &&
label_date.Text.Length >0 &&
label_date.Text != Catalog.GetString(Constants.UndefinedDefault) &&
UtilGtk.ComboGetActive(combo_countries) != Catalog.GetString(Constants.CountryUndefined) &&
! radio_cp_undef.Active &&
! (radio_cp_other.Active && entry_cp_other.Text.Length == 0) &&
......@@ -301,7 +308,9 @@ public class EvaluatorWindow
}
private void on_button_confiable_clicked(object o, EventArgs args) {
Console.WriteLine("Confiable info");
new DialogMessage(Constants.MessageTypes.INFO,
"Currently we are creating confiable parameters.\n" +
"In nearly future maybe your data can be confiable");
}
private void on_button_cp1_zoom_clicked(object o, EventArgs args) {
......@@ -341,67 +350,74 @@ public class EvaluatorWindow
entry_name.Text = eval.Name;
entry_email.Text = eval.Email;
DateTime dateTime = Util.DateAsDateTime(eval.DateBorn);
if(dateTime == DateTime.MinValue)
Console.Write(creating.ToString());
if(creating)
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]));
else {
dateTime = Util.DateAsDateTime(eval.DateBorn);
if(dateTime == DateTime.MinValue)
label_date.Text = Catalog.GetString(Constants.UndefinedDefault);
else
label_date.Text = dateTime.ToLongDateString();
}
label_confiable.Text = eval.Confiable.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;
}
if(! creating) {
//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]));
}
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;
label_confiable.Text = eval.Confiable.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());
}
......@@ -410,25 +426,28 @@ public class EvaluatorWindow
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();
string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
dateTime.Year.ToString();
eval.DateBorn = dateFull;
eval.CountryID = Convert.ToInt32(
Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries));
eval.Comments = textview_comments.Buffer.Text;
if(radio_cp_undef.Active)
eval.Chronometer = Constants.UndefinedDefault;
......@@ -459,17 +478,18 @@ public class EvaluatorWindow
else
eval.Update(false);
fakeButtonAccept.Click();
EvaluatorWindowBox.evaluator_window.Hide();
//EvaluatorWindowBox = null;
EvaluatorWindowBox = null;
}
/*
public Button Button_accept
public Button FakeButtonAccept
{
set { button_accept = value; }
get { return button_accept; }
set { fakeButtonAccept = value; }
get { return fakeButtonAccept; }
}
*/
~EvaluatorWindow() {}
......
......@@ -567,24 +567,28 @@ public class Server
ChronojumpServer myServer = new ChronojumpServer();
Log.WriteLine(myServer.ConnectDatabase());
//get Data, TODO: do it in a gui/window
//ServerEvaluator myEval = new ServerEvaluator("myName", "myEmail", "myDateBorn",
// Constants.CountryUndefinedID, "myChronometer", "myDevice", false);
ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
bool success = false;
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
if(evalSID == Constants.ServerUndefinedID)
SqlitePreferences.Update("evaluatorServerID", myEval.UniqueID.ToString(), false);
new DialogMessage(Constants.MessageTypes.INFO, "Uploaded with ID: " + myEval.UniqueID);
if(evalSID == Constants.ServerUndefinedID) {
string idCode = myServer.UploadEvaluator(myEval);
myEval.Code = Util.FetchName(idCode);
myEval.Update(false);
evalSID = Util.FetchID(idCode);
SqlitePreferences.Update("evaluatorServerID", evalSID.ToString(), false);
success = true;
} else
success = myServer.EditEvaluator(myEval, evalSID);
if(success)
new DialogMessage(Constants.MessageTypes.INFO,
string.Format(Catalog.GetString("Successfully Uploaded evaluator with ID: {0}"), evalSID));
else
new DialogMessage(Constants.MessageTypes.WARNING,
string.Format(Catalog.GetString("Evaluator {0} has not been correctly uploaded. Maybe codes doesn't match."), evalSID));
Log.WriteLine(myServer.DisConnectDatabase());
} catch {
......
......@@ -27,6 +27,7 @@ using Mono.Unix;
public partial class ServerEvaluator
{
private int uniqueID;
private string code;
private string name;
private string email;
private string dateBorn;
......@@ -41,7 +42,8 @@ public partial class ServerEvaluator
public ServerEvaluator() {
}
public ServerEvaluator(string name, string email, string dateBorn, int countryID, string chronometer, string device, string comments, bool confiable) {
public ServerEvaluator(string code, string name, string email, string dateBorn, int countryID, string chronometer, string device, string comments, bool confiable) {
this.code = code;
this.name = name;
this.email = email;
this.dateBorn = dateBorn;
......@@ -53,12 +55,13 @@ public partial class ServerEvaluator
}
public int InsertAtDB(bool dbconOpened){
int myID = SqliteServer.InsertEvaluator(dbconOpened, name, email, dateBorn, countryID, chronometer, device, comments, confiable);
int myID = SqliteServer.InsertEvaluator(dbconOpened, code, 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);
//confiable will not get updated
SqliteServer.UpdateEvaluator(dbconOpened, uniqueID, code, name, email, dateBorn, countryID, chronometer, device, comments, confiable);
return uniqueID;
}
......@@ -77,6 +80,11 @@ public partial class ServerEvaluator
//"Private, internal, and protected members do not get serialized.
//If the accessor is not specific, it is private by default (and will not get serialized)."
public string Code {
get { return code; }
set { code = value; }
}
public string Name {
get { return name; }
set { name = value; }
......
......@@ -51,6 +51,7 @@ class SqliteServer : Sqlite
dbcmd.CommandText =
"CREATE TABLE " + Constants.ServerEvaluatorTable + " ( " +
"uniqueID INTEGER PRIMARY KEY, " +
"code TEXT, " +
"name TEXT, " +
"email TEXT, " +
"dateborn TEXT, " +
......@@ -89,7 +90,7 @@ class SqliteServer : Sqlite
return myReturn;
}
public static int InsertEvaluator(bool dbconOpened, string name, string email, string dateBorn,
public static int InsertEvaluator(bool dbconOpened, string code, string name, string email, string dateBorn,
int countryID, string chronometer, string device, string comments, bool confiable)
{
if(! dbconOpened)
......@@ -98,8 +99,9 @@ class SqliteServer : Sqlite
string uniqueID = "NULL";
string myString = "INSERT INTO " + Constants.ServerEvaluatorTable +
" (uniqueID, name, email, dateBorn, countryID, chronometer, device, comments, confiable) VALUES (" +
uniqueID + ", '" + name + "', '" +
" (uniqueID, code, name, email, dateBorn, countryID, chronometer, device, comments, confiable) VALUES (" +
uniqueID + ", '" +
code + "', '" + name + "', '" +
email + "', '" + dateBorn + "', " +
countryID + ", '" + chronometer + "', '" +
device + "', '" + comments + "', " +
......@@ -120,13 +122,14 @@ class SqliteServer : Sqlite
return myReturn;