Пример #1
0
    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;
    }
Пример #2
0
    //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);
    }
Пример #3
0
 //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;
 }
Пример #4
0
 //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;
 }
Пример #5
0
    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);
    }
Пример #7
0
    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);
        }
    }
Пример #8
0
 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);
    }
Пример #10
0
 public void UploadEvaluatorAsync(ServerEvaluator myEval)
 {
     this.UploadEvaluatorAsync(myEval, null);
 }
Пример #11
0
 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);
 }
Пример #12
0
 public bool EditEvaluator(ServerEvaluator clientEval, int evalSID)
 {
     object[] results = this.Invoke("EditEvaluator", new object[] {
                 clientEval,
                 evalSID});
     return ((bool)(results[0]));
 }
Пример #13
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;
    }
Пример #14
0
    //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;
    }
Пример #15
0
 public System.IAsyncResult BeginEditEvaluator(ServerEvaluator clientEval, int evalSID, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("EditEvaluator", new object[] {
                 clientEval,
                 evalSID}, callback, asyncState);
 }
Пример #16
0
 public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UploadEvaluator", new object[] {
                 myEval}, callback, asyncState);
 }
Пример #17
0
    public static EvaluatorWindow Show(ServerEvaluator eval)
    {
        if (EvaluatorWindowBox == null) {
            EvaluatorWindowBox = new EvaluatorWindow(eval);
        }
        EvaluatorWindowBox.evaluator_window.Show ();

        EvaluatorWindowBox.fillDialog ();

        return EvaluatorWindowBox;
    }
Пример #18
0
 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;
    }
Пример #20
0
 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;
    }
Пример #22
0
 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);
 }
Пример #23
0
 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;
 }