public EvaluatorWindow(ServerEvaluator eval) { //Setup (text, table, uniqueID); Glade.XML gladeXML; gladeXML = Glade.XML.FromAssembly(Util.GetGladePath() + "chronojump.glade", "evaluator_window", "chronojump"); gladeXML.Autoconnect(this); //put an icon to window UtilGtk.IconWindow(evaluator_window); fakeButtonAccept = new Gtk.Button(); this.eval = eval; if (eval.UniqueID == -1) { creating = true; } //copy to see if there are changes evalBefore = new ServerEvaluator(eval); createComboContinents(); createComboCountries(); putNonStandardIcons(); entry_cp_other.Sensitive = false; }
//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) { Sqlite.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.ServerEvaluatorTable + " WHERE uniqueID == " + myUniqueID; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ServerEvaluator myEval = new ServerEvaluator(); //will return a -1 on uniqueID to know that evaluator data is not in the database myEval.UniqueID = -1; while (reader.Read()) { myEval.UniqueID = Convert.ToInt32(reader[0].ToString()); myEval.Code = reader[1].ToString(); myEval.Name = reader[2].ToString(); myEval.Email = reader[3].ToString(); myEval.DateBorn = UtilDate.FromSql(reader[4].ToString()); myEval.CountryID = Convert.ToInt32(reader[5].ToString()); myEval.Chronometer = reader[6].ToString(); myEval.Device = reader[7].ToString(); myEval.Comments = reader[8].ToString(); myEval.Confiable = Util.IntToBool(Convert.ToInt32(reader[9].ToString())); } reader.Close(); Sqlite.Close(); return(myEval); }
//allows to do a copy on gui/evaluator.cs public ServerEvaluator(ServerEvaluator oldEval) { this.code = oldEval.Code; this.name = oldEval.Name; this.email = oldEval.Email; this.dateBorn = oldEval.DateBorn; this.countryID = oldEval.CountryID; this.chronometer = oldEval.Chronometer; this.device = oldEval.Device; this.comments = oldEval.Comments; this.confiable = oldEval.Confiable; }
static public EvaluatorWindow Show(ServerEvaluator eval) { if (EvaluatorWindowBox == null) { EvaluatorWindowBox = new EvaluatorWindow(eval); } EvaluatorWindowBox.evaluator_window.Show(); EvaluatorWindowBox.fillDialog(); return(EvaluatorWindowBox); }
public string UploadEvaluator(ServerEvaluator myEval) { Console.WriteLine("upload. eval string: " + myEval.ToString()); 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); }
public static void ServerUploadEvaluator() { try { ChronojumpServer myServer = new ChronojumpServer(); LogB.Information(myServer.ConnectDatabase()); ServerEvaluator myEval = SqliteServer.SelectEvaluator(1); bool success = false; int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID")); 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)); } LogB.Information(myServer.DisConnectDatabase()); } catch { new DialogMessage(Constants.MessageTypes.WARNING, Constants.ServerOffline); } }
public bool Equals(ServerEvaluator oldEval) { if ( this.code == oldEval.Code && this.name == oldEval.Name && this.email == oldEval.Email && this.dateBorn == oldEval.DateBorn && this.countryID == oldEval.CountryID && this.chronometer == oldEval.Chronometer && this.device == oldEval.Device && this.comments == oldEval.Comments && this.confiable == oldEval.Confiable ) { return(true); } else { return(false); } }
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); }
public void UploadEvaluatorAsync(ServerEvaluator myEval) { this.UploadEvaluatorAsync(myEval, 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); }
public bool EditEvaluator(ServerEvaluator clientEval, int evalSID) { object[] results = this.Invoke("EditEvaluator", new object[] { clientEval, evalSID}); return ((bool)(results[0])); }
public EvaluatorWindow(ServerEvaluator eval) { //Setup (text, table, uniqueID); Glade.XML gladeXML; gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "evaluator_window.glade", "evaluator_window", "chronojump"); gladeXML.Autoconnect(this); //put an icon to window UtilGtk.IconWindow(evaluator_window); fakeButtonAccept = new Gtk.Button(); this.eval = eval; if(eval.UniqueID == -1) creating = true; //copy to see if there are changes evalBefore = new ServerEvaluator(eval); createComboContinents(); createComboCountries(); putNonStandardIcons(); entry_cp_other.Sensitive = false; }
//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) { Sqlite.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.ServerEvaluatorTable + " WHERE uniqueID == " + myUniqueID ; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ServerEvaluator myEval = new ServerEvaluator(); //will return a -1 on uniqueID to know that evaluator data is not in the database myEval.UniqueID = -1; while(reader.Read()) { myEval.UniqueID = Convert.ToInt32(reader[0].ToString()); myEval.Code = reader[1].ToString(); myEval.Name = reader[2].ToString(); myEval.Email = reader[3].ToString(); myEval.DateBorn = UtilDate.FromSql(reader[4].ToString()); myEval.CountryID = Convert.ToInt32(reader[5].ToString()); myEval.Chronometer = reader[6].ToString(); myEval.Device = reader[7].ToString(); myEval.Comments = reader[8].ToString(); myEval.Confiable = Util.IntToBool(Convert.ToInt32(reader[9].ToString())); } reader.Close(); Sqlite.Close(); return myEval; }
public System.IAsyncResult BeginEditEvaluator(ServerEvaluator clientEval, int evalSID, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("EditEvaluator", new object[] { clientEval, evalSID}, callback, asyncState); }
public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UploadEvaluator", new object[] { myEval}, callback, asyncState); }
public static EvaluatorWindow Show(ServerEvaluator eval) { if (EvaluatorWindowBox == null) { EvaluatorWindowBox = new EvaluatorWindow(eval); } EvaluatorWindowBox.evaluator_window.Show (); EvaluatorWindowBox.fillDialog (); return EvaluatorWindowBox; }
public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID) { this.EditEvaluatorAsync(clientEval, evalSID, null); }
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; }
public string UploadEvaluator(ServerEvaluator myEval) { object[] results = this.Invoke("UploadEvaluator", new object[] { myEval}); return ((string)(results[0])); }
public string UploadEvaluator(ServerEvaluator myEval) { Console.WriteLine("upload. eval string: " + myEval.ToString()); 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; }
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}, this.UploadEvaluatorOperationCompleted, userState); }
public bool Equals(ServerEvaluator oldEval) { if( this.code == oldEval.Code && this.name == oldEval.Name && this.email == oldEval.Email && this.dateBorn == oldEval.DateBorn && this.countryID == oldEval.CountryID && this.chronometer == oldEval.Chronometer && this.device == oldEval.Device && this.comments == oldEval.Comments && this.confiable == oldEval.Confiable ) return true; else return false; }