Update() public méthode

public Update ( bool dbconOpened ) : int
dbconOpened bool
Résultat int
Exemple #1
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);
        }
    }
    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);
    }
Exemple #3
0
    protected void on_button_accept_clicked(object o, EventArgs args)
    {
        eval.Name      = entry_name.Text.ToString();
        eval.Email     = entry_email.Text.ToString();
        eval.DateBorn  = dateTime;
        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;
        }
        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();
        }


        changed = false;
        if (creating)
        {
            eval.InsertAtDB(false);
            changed = true;
        }
        else
        {
            //1st see if there are changes
            if (eval.Equals(evalBefore))
            {
                //nothing changed
                //
                //new DialogMessage(Constants.MessageTypes.INFO, "nothing changed.\n");
            }
            else
            {
                //changed
                eval.Update(false);
                changed = true;
            }
        }

        fakeButtonAccept.Click();

        EvaluatorWindowBox.evaluator_window.Hide();
        EvaluatorWindowBox = 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;
    }