コード例 #1
0
ファイル: personSession.cs プロジェクト: ylatuya/chronojump-1
    //use this in the future:
    public static List <PersonSession> SelectPersonSessionList(int sessionID)
    {
        string tps = Constants.PersonSessionTable;

        Sqlite.Open();
        dbcmd.CommandText = "SELECT " + tps + ".*" +
                            " FROM " + tps +
                            " WHERE " + tps + ".sessionID == " + sessionID;
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        List <PersonSession> list = new List <PersonSession>();

        while (reader.Read())
        {
            PersonSession ps = new PersonSession(
                Convert.ToInt32(reader[0].ToString()),                               //uniqueID
                Convert.ToInt32(reader[1].ToString()),                               //personID
                Convert.ToInt32(reader[2].ToString()),                               //sessionID
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), //height
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //weight
                Convert.ToInt32(reader[5].ToString()),                               //sportID
                Convert.ToInt32(reader[6].ToString()),                               //speciallityID
                Convert.ToInt32(reader[7].ToString()),                               //practice
                reader[8].ToString()                                                 //comments
                );
            list.Add(ps);
        }
        reader.Close();
        Sqlite.Close();
        return(list);
    }
コード例 #2
0
        public virtual void GetGrantCodeUrl(bool pSwitchUser)
        {
            var    perSess   = new PersonSession(MockConfig.Object, new OauthService(null));
            string expectUrl = BuildGrantCodeUrl(perSess, pSwitchUser);

            string url = perSess.GetGrantCodeUrl(pSwitchUser);

            Assert.AreEqual(expectUrl, url, "Incorrect URL.");
        }
コード例 #3
0
 /*--------------------------------------------------------------------------------------------*/
 private string BuildGrantCodeUrl(PersonSession pPerSess, bool pSwitchUser = false)
 {
     return(MockConfig.Object.ApiPath + "/Oauth/Login?" +
            "response_type=code" +
            "&client_id=" + MockConfig.Object.AppId +
            "&redirect_uri=" + MockConfig.Object.GetOauthRedirectUri() +
            "&scope=" +
            "&state=" + pPerSess.SessionId +
            "&switchMode=" + (pSwitchUser ? "1" : "0"));
 }
コード例 #4
0
        public virtual void GetGrantWindowOpenScript(string pGrantCodeUrl)
        {
            var    perSess      = new PersonSession(MockConfig.Object, new OauthService(null));
            string url          = (pGrantCodeUrl ?? BuildGrantCodeUrl(perSess));
            string expectScript = "window.open('" + url + "', 'fabOauth', 'status=0,toolbar=0,menubar=0," +
                                  "directories=0,width=500,height=400,resizable=1,scrollbars=1');";

            string script = perSess.GetGrantWindowOpenScript(pGrantCodeUrl);

            Assert.AreEqual(expectScript, script, "Incorrect script.");
        }
コード例 #5
0
    public static PersonSession Select(bool dbconOpened, int personID, int sessionID)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        string tps = Constants.PersonSessionTable;

        string sessionIDString = " AND sessionID == " + sessionID;

        if (sessionID == -1)
        {
            sessionIDString = " ORDER BY sessionID DESC limit 1";
        }

        dbcmd.CommandText = "SELECT * FROM " + tps +
                            " WHERE personID == " + personID +
                            sessionIDString;

        LogB.SQL(dbcmd.CommandText.ToString());

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        PersonSession ps = new PersonSession();

        ps.UniqueID = -1;
        while (reader.Read())
        {
            ps = new PersonSession(
                Convert.ToInt32(reader[0].ToString()),                               //uniqueID
                personID,                                                            //personID
                sessionID,                                                           //sessionID
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), //height
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //weight
                Convert.ToInt32(reader[5].ToString()),                               //sportID
                Convert.ToInt32(reader[6].ToString()),                               //speciallityID
                Convert.ToInt32(reader[7].ToString()),                               //practice
                reader[8].ToString()                                                 //comments
                );
        }

        reader.Close();

        if (!dbconOpened)
        {
            Sqlite.Close();
        }

        return(ps);
    }
コード例 #6
0
 public int UploadPersonSessionIfNeeded(PersonSession ps)
 {
     if (!SqlitePersonSession.PersonSelectExistsInSession(ps.PersonID, ps.SessionID))
     {
         Console.WriteLine("personSession needed");
         Console.WriteLine(ps.ToString());
         ps.InsertAtDB(false, Constants.PersonSessionTable);
         Console.WriteLine("done");
         return(1);            //unused
     }
     else
     {
         Console.WriteLine("personSession NOT needed");
     }
     return(0);        //unused
 }
コード例 #7
0
ファイル: personSession.cs プロジェクト: ylatuya/chronojump-1
 public static void Update(PersonSession ps)
 {
     Sqlite.Open();
     dbcmd.CommandText = "UPDATE " + Constants.PersonSessionTable +
                         " SET personID = " + ps.PersonID +
                         ", sessionID = " + ps.SessionID +
                         ", height = " + Util.ConvertToPoint(ps.Height) +
                         ", weight = " + Util.ConvertToPoint(ps.Weight) +
                         ", sportID = " + ps.SportID +
                         ", speciallityID = " + ps.SpeciallityID +
                         ", practice = " + ps.Practice +
                         ", comments = \"" + ps.Comments +
                         "\" WHERE uniqueID == " + ps.UniqueID;
     LogB.SQL(dbcmd.CommandText.ToString());
     dbcmd.ExecuteNonQuery();
     Sqlite.Close();
 }
コード例 #8
0
ファイル: ChronojumpServer.cs プロジェクト: GNOME/chronojump
 public int UploadPersonSessionIfNeeded(PersonSession ps)
 {
     object[] results = this.Invoke("UploadPersonSessionIfNeeded", new object[] {
                 ps});
     return ((int)(results[0]));
 }
コード例 #9
0
ファイル: ChronojumpServer.cs プロジェクト: GNOME/chronojump
 public void UploadPersonSessionIfNeededAsync(PersonSession ps, object userState)
 {
     if ((this.UploadPersonSessionIfNeededOperationCompleted == null)) {
         this.UploadPersonSessionIfNeededOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadPersonSessionIfNeededCompleted);
     }
     this.InvokeAsync("UploadPersonSessionIfNeeded", new object[] {
                 ps}, this.UploadPersonSessionIfNeededOperationCompleted, userState);
 }
コード例 #10
0
    private void on_recuperate_persons_from_session_accepted(object o, EventArgs args)
    {
        currentPerson = personsRecuperateFromOtherSessionWin.CurrentPerson;
        currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
        label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
        label_current_person.UseMarkup = true;

        treeview_persons_storeReset();
        fillTreeView_persons();
        int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
        if(rowToSelect != -1) {
            selectRowTreeView_persons(treeview_persons,
                    treeview_persons_store,
                    rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
コード例 #11
0
    //return true if selection is done (there's any person)
    private bool selectRowTreeView_persons(Gtk.TreeView tv, TreeStore store, int rowNum)
    {
        myTreeViewPersons.SelectRow(rowNum);

        //the selection of row in treeViewPersons.SelectRow is not a real selection
        //and unfortunately doesn't raises the on_treeview_persons_cursor_changed ()
        //for this reason we reproduce the method here
        TreeModel model;
        TreeIter iter;
        if (tv.Selection.GetSelected (out model, out iter)) {
            string selectedID = (string) model.GetValue (iter, 0); //ID, Name
            currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
            currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), currentSession.UniqueID);
            label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
            label_current_person.UseMarkup = true;

            return true;
        } else {
            return false;
        }
    }
コード例 #12
0
    //private void on_treeview_persons_cursor_changed (object o, EventArgs args) {
    private void onTreeviewPersonsSelectionEntry(object o, EventArgs args)
    {
        TreeModel model;
        TreeIter iter;

        // you get the iter and the model if something is selected
        if (((TreeSelection)o).GetSelected(out model, out iter)) {
            string selectedID = (string) model.GetValue (iter, 0); //ID, Name

            currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
            currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), currentSession.UniqueID);
            label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
            label_current_person.UseMarkup = true;

            encoderPersonChanged();
        }
    }
コード例 #13
0
    private void on_person_add_multiple_accepted(object o, EventArgs args)
    {
        if (personAddMultipleWin.CurrentPerson != null)
        {
            currentPerson = personAddMultipleWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
            label_current_person.UseMarkup = true;
            treeview_persons_storeReset();
            fillTreeView_persons();
            int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();

                string myString = string.Format(
                        Catalog.GetPluralString(
                            "Successfully added one person.",
                            "Successfully added {0} persons.",
                            personAddMultipleWin.PersonsCreatedCount),
                        personAddMultipleWin.PersonsCreatedCount);
                //appbar2.Push( 1, Catalog.GetString(myString) );
            }
        }
    }
コード例 #14
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_recuperate_persons_from_session_accepted(object o, EventArgs args)
    {
        currentPerson = personsRecuperateFromOtherSessionWin.CurrentPerson;
        currentPersonSession = personsRecuperateFromOtherSessionWin.CurrentPersonSession;
        label_person_change();

        treeview_persons_storeReset();
        fillTreeView_persons();
        int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
        if(rowToSelect != -1) {
            selectRowTreeView_persons(treeview_persons,
                    treeview_persons_store,
                    rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
コード例 #15
0
ファイル: person.cs プロジェクト: GNOME/chronojump
    protected virtual void on_button_recuperate_clicked(object o, EventArgs args)
    {
        if(selected != "-1")
        {
            currentPerson = SqlitePerson.Select(Convert.ToInt32(selected));

            PersonSession myPS = SqlitePersonSession.Select(currentPerson.UniqueID, -1); //if sessionID == -1 we search data in last sessionID
            //this inserts in DB
            currentPersonSession = new PersonSession (
                    currentPerson.UniqueID, currentSession.UniqueID,
                    myPS.Height, myPS.Weight,
                    myPS.SportID, myPS.SpeciallityID,
                    myPS.Practice,
                    myPS.Comments,
                    false); //dbconOpened

            store = new TreeStore( typeof (string), typeof (string), typeof (string), typeof (string), typeof (string) );
            treeview_person_recuperate.Model = store;

            fillTreeView(treeview_person_recuperate,store, entry_search_filter.Text.ToString());

            statusbar1.Push( 1, Catalog.GetString("Loaded") + " " + currentPerson.Name );

            //no posible to recuperate until one person is selected
            button_recuperate.Sensitive = false;

            fakeButtonDone.Click();
        }
    }
コード例 #16
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_person_add_multiple_accepted(object o, EventArgs args)
    {
        if (personAddMultipleWin.CurrentPerson != null)
        {
            currentPerson = personAddMultipleWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_person_change();
            treeview_persons_storeReset();
            fillTreeView_persons();
            int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();

                // string myString = string.Format(
                //		Catalog.GetPluralString(
                //			"Successfully added one person.",
                //			"Successfully added {0} persons.",
                //			personAddMultipleWin.PersonsCreatedCount),
                //		personAddMultipleWin.PersonsCreatedCount);
                //appbar2.Push( 1, Catalog.GetString(myString) );
            }
        }
    }
コード例 #17
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_person_add_single_accepted(object o, EventArgs args)
    {
        if (personAddModifyWin.CurrentPerson != null)
        {
            currentPerson = personAddModifyWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_person_change();
            myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);

            //when adding new person, photos cannot be recorded as currentPerson.UniqueID
            //because it was undefined. Copy them now
            if(File.Exists(Util.GetPhotoTempFileName(false)) && File.Exists(Util.GetPhotoTempFileName(true))) {
                try {
                    File.Move(Util.GetPhotoTempFileName(false),
                            Util.GetPhotoFileName(false, currentPerson.UniqueID));
                } catch {
                    File.Copy(Util.GetPhotoTempFileName(false),
                            Util.GetPhotoFileName(false, currentPerson.UniqueID), true);
                }
                try {
                    File.Move(Util.GetPhotoTempFileName(true),
                            Util.GetPhotoFileName(true, currentPerson.UniqueID));
                } catch {
                    File.Copy(Util.GetPhotoTempFileName(true),
                            Util.GetPhotoFileName(true, currentPerson.UniqueID), true);
                }
            }

            int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();
                //appbar2.Push( 1, Catalog.GetString("Successfully added") + " " + currentPerson.Name );
            }

            if(person_add_single_called_from_person_select_window) {
                ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
                        currentSession.UniqueID,
                        false); //means: do not returnPersonAndPSlist
                personSelectWin.Update(myPersons);
            }
        }
    }
コード例 #18
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_edit_current_person_accepted(object o, EventArgs args)
    {
        if (personAddModifyWin.CurrentPerson != null)
        {
            currentPerson = personAddModifyWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_person_change();
            treeview_persons_storeReset();
            fillTreeView_persons();

            int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();
            }

            on_combo_result_jumps_changed(combo_result_jumps, args);
            on_combo_result_jumps_rj_changed(combo_result_jumps_rj, args);
            on_combo_result_runs_changed(combo_result_runs, args);
            on_combo_result_runs_interval_changed(combo_result_runs_interval, args);
            on_combo_pulses_changed(combo_pulses, args);

            if(createdStatsWin) {
                stats_win_fillTreeView_stats(false, true);
            }

        //			personAddModifyWin.Destroy();

            if(person_edit_single_called_from_person_select_window) {
                ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
                        currentSession.UniqueID,
                        false); //means: do not returnPersonAndPSlist
                personSelectWin.Update(myPersons);
            }
        }
    }
コード例 #19
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_button_encoder_person_change_done(object o, EventArgs args)
    {
        currentPerson = personSelectWin.SelectedPerson;
        currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
        label_person_change();

        personChanged();
    }
コード例 #20
0
ファイル: main.cs プロジェクト: GNOME/chronojump
    protected static void convertPersonAndPersonSessionTo77()
    {
        //create person77
        SqlitePerson sqlitePersonObject = new SqlitePerson();
        sqlitePersonObject.createTable(Constants.PersonTable);

        //create personSession77
        SqlitePersonSession sqlitePersonSessionObject = new SqlitePersonSession();
        sqlitePersonSessionObject.createTable(Constants.PersonSessionTable);

        //select all personOld data
        SqlitePersonOld sqlitePersonOldObject = new SqlitePersonOld();
        ArrayList personsOld = sqlitePersonOldObject.SelectAllPersons();

        conversionRateTotal = personsOld.Count;
        conversionRate = 1;
        foreach (PersonOld pOld in personsOld) {
            Person p = new Person(
                       pOld.UniqueID,
                       pOld.Name,
                       pOld.Sex,
                       pOld.DateBorn,
                       pOld.Race,
                       pOld.CountryID,
                       pOld.Description,
                       pOld.ServerUniqueID
                       );
            p.InsertAtDB(true, Constants.PersonTable);

            //select all personSessionOld data of this person
            SqlitePersonSessionOld sqlitePersonSessionOldObject = new SqlitePersonSessionOld();
            ArrayList personSessionsOld = sqlitePersonSessionOldObject.SelectAllPersonSessionsOfAPerson(p.UniqueID);
            conversionSubRateTotal = personSessionsOld.Count;
            conversionSubRate = 1;
            foreach (PersonSessionOld psOld in personSessionsOld) {
                PersonSession ps = new PersonSession(
                        psOld.UniqueID,
                        psOld.PersonID,
                        psOld.SessionID,
                        pOld.Height,
                        psOld.Weight,
                        pOld.SportID,
                        pOld.SpeciallityID,
                        pOld.Practice,
                        "" 		//comments
                        );
                ps.InsertAtDB(true, Constants.PersonSessionTable);
                conversionSubRate ++;
            }
            conversionRate ++;
        }

        //drop old tables
        Sqlite.dropTable(Constants.PersonOldTable);
        Sqlite.dropTable(Constants.PersonSessionOldWeightTable);
    }
コード例 #21
0
ファイル: server.cs プロジェクト: kleopatra999/chronojump
    private static void serverUploadPersonSessionIfNeeded(ChronojumpServer myServer,
                                                          int personServerID, int sessionServerID, PersonSession ps, int sportUserDefinedLocal)
    {
        //when update locally, don't put the user defined sport id at server
        if (sportUserDefinedLocal != -1)
        {
            ps.SportID = sportUserDefinedLocal;
        }

        ps.UniqueID  = -1;
        ps.PersonID  = personServerID;
        ps.SessionID = sessionServerID;

        myServer.UploadPersonSessionIfNeeded(ps);
    }
コード例 #22
0
ファイル: chronojump.cs プロジェクト: GNOME/chronojump
    private void on_recuperate_person_accepted(object o, EventArgs args)
    {
        LogB.Information("here!!!");
        currentPerson = personRecuperateWin.CurrentPerson;
        currentPersonSession = personRecuperateWin.CurrentPersonSession;
        label_person_change();

        myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);

        int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
        if(rowToSelect != -1) {
            selectRowTreeView_persons(treeview_persons,
                    treeview_persons_store,
                    rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
コード例 #23
0
ファイル: server.cs プロジェクト: dineshkummarc/chronojump
    private static void serverUploadPersonSessionIfNeeded(ChronojumpServer myServer, 
        int personServerID, int sessionServerID, PersonSession ps, int sportUserDefinedLocal)
    {
        //when update locally, don't put the user defined sport id at server
        if(sportUserDefinedLocal != -1)
            ps.SportID = sportUserDefinedLocal;

        ps.UniqueID = -1;
        ps.PersonID = personServerID;
        ps.SessionID = sessionServerID;

        myServer.UploadPersonSessionIfNeeded(ps);
    }
コード例 #24
0
ファイル: person.cs プロジェクト: GNOME/chronojump
 //default constructor
 public PersonAndPS(Person p, PersonSession ps)
 {
     this.p = p;
     this.ps = ps;
 }
コード例 #25
0
ファイル: person.cs プロジェクト: GNOME/chronojump
    private void recordChanges()
    {
        //separate by '/' for not confusing with the ':' separation between the other values
        //string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
        //	dateTime.Year.ToString();

        double weight = (double) spinbutton_weight.Value;

        //convert margarias (it's power is calculated using weight and it's written on description)
        string [] myMargarias = SqliteRun.SelectRuns(false, currentSession.UniqueID, currentPerson.UniqueID, "Margaria",
                Sqlite.Orders_by.DEFAULT, -1);

        foreach(string myStr in myMargarias) {
            string [] margaria = myStr.Split(new char[] {':'});
            Run mRun = SqliteRun.SelectRunData(Convert.ToInt32(margaria[1]), false);
            double distanceMeters = mRun.Distance / 1000;
            mRun.Description = "P = " + Util.TrimDecimals ( (weight * 9.8 * distanceMeters / mRun.Time).ToString(), pDN) + " (Watts)";
            SqliteRun.Update(mRun.UniqueID, mRun.Type, mRun.Distance.ToString(), mRun.Time.ToString(), mRun.PersonID, mRun.Description);
        }

        if(adding) {
            //here we add rows in the database
            LogB.Information("Going to insert person");
            currentPerson = new Person (entry1.Text, sex, dateTime,
                    Constants.RaceUndefinedID,
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries)),
                    textview_description.Buffer.Text,
                    Constants.ServerUndefinedID, false); //dbconOpened

            LogB.Information("Going to insert personSession");
            currentPersonSession = new PersonSession (
                    currentPerson.UniqueID, currentSession.UniqueID,
                    (double) spinbutton_height.Value, (double) weight,
                    sport.UniqueID,
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
                    Util.FetchID(UtilGtk.ComboGetActive(combo_levels)),
                    textview_ps_comments.Buffer.Text, false); //dbconOpened
            LogB.Information("inserted both");
        } else {
            //here we update rows in the database
            currentPerson = new Person (currentPerson.UniqueID, entry1.Text, sex, dateTime,
                    Constants.RaceUndefinedID,
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries)),
                    textview_description.Buffer.Text,
                    serverUniqueID);
            SqlitePerson.Update (currentPerson);

            //we only need to update personSession
            //1.- search uniqueID
            PersonSession ps = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);

            //2.- create new instance
            currentPersonSession = new PersonSession (
                    ps.UniqueID,
                    currentPerson.UniqueID, currentSession.UniqueID,
                    (double) spinbutton_height.Value, (double) weight,
                    sport.UniqueID,
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
                    Util.FetchID(UtilGtk.ComboGetActive(combo_levels)),
                    textview_ps_comments.Buffer.Text);

            //3.- update in database
            SqlitePersonSession.Update (currentPersonSession);
        }

        PersonAddModifyWindowBox.person_win.Hide();
        PersonAddModifyWindowBox = null;

        fakeButtonAccept.Click();
    }
コード例 #26
0
    //if sessionID == -1
    //then we search data in last sessionID
    //this is used to know personSession attributes
    //in a newly created person
    //This is like SqlitePerson.Selectbut this returns a PersonSession
    public static PersonSession Select(int personID, int sessionID)
    {
        string tps = Constants.PersonSessionTable;

        string sessionIDString = " AND sessionID == " + sessionID;
        if(sessionID == -1)
            sessionIDString = " ORDER BY sessionID DESC limit 1";

        dbcon.Open();
        dbcmd.CommandText = "SELECT * FROM " + tps +
            " WHERE personID == " + personID +
            sessionIDString;

        Log.WriteLine(dbcmd.CommandText.ToString());

        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        PersonSession ps = new PersonSession();
        while(reader.Read()) {
            ps = new PersonSession(
                    Convert.ToInt32(reader[0].ToString()), 	//uniqueID
                    personID,				//personID
                    sessionID, 				//sessionID
                    Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), //height
                    Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //weight
                    Convert.ToInt32(reader[5].ToString()), 	//sportID
                    Convert.ToInt32(reader[6].ToString()), 	//speciallityID
                    Convert.ToInt32(reader[7].ToString()),	//practice
                    reader[8].ToString() 			//comments
                    );
        }

        reader.Close();
        dbcon.Close();
        return ps;
    }
コード例 #27
0
    private void on_edit_current_person_accepted(object o, EventArgs args)
    {
        if (personAddModifyWin.CurrentPerson != null)
        {
            currentPerson = personAddModifyWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
            label_current_person.UseMarkup = true;
            treeview_persons_storeReset();
            fillTreeView_persons();

            int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();
            }

            on_combo_jumps_changed(combo_jumps, args);
            on_combo_jumps_rj_changed(combo_jumps_rj, args);
            on_combo_runs_changed(combo_runs, args);
            on_combo_runs_interval_changed(combo_runs_interval, args);
            on_combo_pulses_changed(combo_pulses, args);

            if(createdStatsWin) {
                stats_win_fillTreeView_stats(false, true);
            }

        //			personAddModifyWin.Destroy();
        }
    }
コード例 #28
0
 public static void Update(PersonSession ps)
 {
     dbcon.Open();
     dbcmd.CommandText = "UPDATE " + Constants.PersonSessionTable +
         " SET personID = " + ps.PersonID +
         ", sessionID = " + ps.SessionID +
         ", height = " + Util.ConvertToPoint(ps.Height) +
         ", weight = " + Util.ConvertToPoint(ps.Weight) +
         ", sportID = " + ps.SportID +
         ", speciallityID = " + ps.SpeciallityID +
         ", practice = " + ps.Practice +
         ", comments = '" + ps.Comments +
         "' WHERE uniqueID == " + ps.UniqueID;
     Log.WriteLine(dbcmd.CommandText.ToString());
     dbcmd.ExecuteNonQuery();
     dbcon.Close();
 }
コード例 #29
0
    private void on_person_add_single_accepted(object o, EventArgs args)
    {
        if (personAddModifyWin.CurrentPerson != null)
        {
            currentPerson = personAddModifyWin.CurrentPerson;
            currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
            label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
            label_current_person.UseMarkup = true;
            myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);

            //when adding new person, photos cannot be recorded as currentPerson.UniqueID
            //because it was undefined. Copy them now
            if(File.Exists(Util.GetPhotoTempFileName(false)) && File.Exists(Util.GetPhotoTempFileName(true))) {
                try {
                    File.Move(Util.GetPhotoTempFileName(false),
                            Util.GetPhotoFileName(false, currentPerson.UniqueID));
                } catch {
                    File.Copy(Util.GetPhotoTempFileName(false),
                            Util.GetPhotoFileName(false, currentPerson.UniqueID));
                }
                try {
                    File.Move(Util.GetPhotoTempFileName(true),
                            Util.GetPhotoFileName(true, currentPerson.UniqueID));
                } catch {
                    File.Move(Util.GetPhotoTempFileName(true),
                            Util.GetPhotoFileName(true, currentPerson.UniqueID));
                }
            }

            int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
            if(rowToSelect != -1) {
                selectRowTreeView_persons(treeview_persons,
                        treeview_persons_store,
                        rowToSelect);
                sensitiveGuiYesPerson();
                //appbar2.Push( 1, Catalog.GetString("Successfully added") + " " + currentPerson.Name );
            }
        }
    }
コード例 #30
0
ファイル: person.cs プロジェクト: dineshkummarc/chronojump
    private void fillDialog()
    {
        int mySportID;
        int mySpeciallityID;
        int myLevelID;
        if(adding) {
            //now dateTime is undefined until user changes it
            dateTime = DateTime.MinValue;
            label_date.Text = Catalog.GetString("Undefined");

            mySportID = currentSession.PersonsSportID;
            mySpeciallityID = currentSession.PersonsSpeciallityID;
            myLevelID = currentSession.PersonsPractice;
        } else {
            //PERSON STUFF
            entry1.Text = currentPerson.Name;
            if (currentPerson.Sex == Constants.M) {
                radiobutton_man.Active = true;
            } else {
                radiobutton_woman.Active = true;
            }

            dateTime = currentPerson.DateBorn;
            if(dateTime == DateTime.MinValue)
                label_date.Text = Catalog.GetString("Undefined");
            else
                label_date.Text = dateTime.ToLongDateString();
            //country stuff
            if(currentPerson.CountryID != Constants.CountryUndefinedID) {
                string [] countryString = SqliteCountry.Select(currentPerson.CountryID);
                combo_continents.Active = UtilGtk.ComboMakeActive(continentsTranslated,
                        Catalog.GetString(countryString[3]));
                combo_countries.Active = UtilGtk.ComboMakeActive(countriesTranslated,
                        Catalog.GetString(countryString[1]));
            }

            TextBuffer tb1 = new TextBuffer (new TextTagTable());
            tb1.Text = currentPerson.Description;
            textview_description.Buffer = tb1;

            serverUniqueID = currentPerson.ServerUniqueID;

            //PERSONSESSION STUFF
            PersonSession myPS = new PersonSession();
            if(comesFromRecuperateWin)
                //select a personSession of last session to obtain it's attributes
                myPS = SqlitePersonSession.Select(currentPerson.UniqueID, -1);
            else
                //we edit a person that is already on this session, then take personSession data from this session
                myPS = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);

            spinbutton_height.Value = myPS.Height;
            spinbutton_weight.Value = myPS.Weight;

            weightIni = myPS.Weight; //store for tracking if changes

            mySportID = myPS.SportID;
            mySpeciallityID = myPS.SpeciallityID;
            myLevelID = myPS.Practice;

            TextBuffer tb2 = new TextBuffer (new TextTagTable());
            tb2.Text = myPS.Comments;
            textview_ps_comments.Buffer = tb2;

        }

        sport = SqliteSport.Select(mySportID);
        combo_sports.Active = UtilGtk.ComboMakeActive(sportsTranslated, sport.ToString());

        combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, SqliteSpeciallity.Select(mySpeciallityID));

        combo_levels.Active = UtilGtk.ComboMakeActive(levels, myLevelID + ":" + Util.FindLevelName(myLevelID));
    }
コード例 #31
0
    private void on_recuperate_person_accepted(object o, EventArgs args)
    {
        currentPerson = personRecuperateWin.CurrentPerson;
        currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);
        label_current_person.Text = "<b>" + currentPerson.Name + "</b>";
        label_current_person.UseMarkup = true;

        myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);

        int rowToSelect = findRowOfCurrentPerson(treeview_persons, treeview_persons_store, currentPerson);
        if(rowToSelect != -1) {
            selectRowTreeView_persons(treeview_persons,
                    treeview_persons_store,
                    rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
コード例 #32
0
ファイル: personSession.cs プロジェクト: ylatuya/chronojump-1
    //the difference between this select and others, is that this returns and ArrayList of Persons
    //this is better than return the strings that can produce bugs in the future
    //use this in the future:
    public static ArrayList SelectCurrentSessionPersons(int sessionID, bool returnPersonAndPSlist)
    {
        string tp  = Constants.PersonTable;
        string tps = Constants.PersonSessionTable;

        string tpsString = "";

        if (returnPersonAndPSlist)
        {
            tpsString = ", " + tps + ".* ";
        }

        Sqlite.Open();
        dbcmd.CommandText = "SELECT " + tp + ".*" + tpsString +
                            " FROM " + tp + ", " + tps +
                            " WHERE " + tps + ".sessionID == " + sessionID +
                            " AND " + tp + ".uniqueID == " + tps + ".personID " +
                            " ORDER BY upper(" + tp + ".name)";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        ArrayList myArray = new ArrayList(1);

        while (reader.Read())
        {
            Person person = new Person(
                Convert.ToInt32(reader[0].ToString()),                          //uniqueID
                reader[1].ToString(),                                           //name
                reader[2].ToString(),                                           //sex
                UtilDate.FromSql(reader[3].ToString()),                         //dateBorn
                Convert.ToInt32(reader[4].ToString()),                          //race
                Convert.ToInt32(reader[5].ToString()),                          //countryID
                reader[6].ToString(),                                           //description
                Convert.ToInt32(reader[9].ToString())                           //serverUniqueID
                );

            if (returnPersonAndPSlist)
            {
                PersonSession ps = new PersonSession(
                    Convert.ToInt32(reader[10].ToString()),                               //uniqueID
                    Convert.ToInt32(reader[11].ToString()),                               //personID
                    Convert.ToInt32(reader[12].ToString()),                               //sessionID
                    Convert.ToDouble(Util.ChangeDecimalSeparator(reader[13].ToString())), //height
                    Convert.ToDouble(Util.ChangeDecimalSeparator(reader[14].ToString())), //weight
                    Convert.ToInt32(reader[15].ToString()),                               //sportID
                    Convert.ToInt32(reader[16].ToString()),                               //speciallityID
                    Convert.ToInt32(reader[17].ToString()),                               //practice
                    reader[18].ToString()                                                 //comments
                    );
                myArray.Add(new PersonAndPS(person, ps));
            }
            else
            {
                myArray.Add(person);
            }
        }
        reader.Close();
        Sqlite.Close();
        return(myArray);
    }
コード例 #33
0
ファイル: ChronojumpServer.cs プロジェクト: GNOME/chronojump
 public System.IAsyncResult BeginUploadPersonSessionIfNeeded(PersonSession ps, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UploadPersonSessionIfNeeded", new object[] {
                 ps}, callback, asyncState);
 }
コード例 #34
0
ファイル: server.cs プロジェクト: kleopatra999/chronojump
    private static void on_server_upload_session_started()
    {
        int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));

        try {
            ChronojumpServer myServer = new ChronojumpServer();
            LogB.Information(myServer.ConnectDatabase());

            int state = (int)Constants.ServerSessionStates.UPLOADINGSESSION;
            //create ServerSession based on Session currentSession
            ServerSession serverSession = new ServerSession(currentSession, evalSID, progName + " " + progVersion,
                                                            UtilAll.GetOS(), DateTime.Now, state);

            //if uploading session for first time
            if (currentSession.ServerUniqueID == Constants.ServerUndefinedID)
            {
                //upload ServerSession
                int idAtServer = myServer.UploadSession(serverSession);

                //update session currentSession (serverUniqueID) on client database
                currentSession.ServerUniqueID = idAtServer;
                SqliteSession.UpdateServerUniqueID(currentSession.UniqueID, currentSession.ServerUniqueID);
            }

            state = (int)Constants.ServerSessionStates.UPLOADINGDATA;
            myServer.UpdateSession(currentSession.ServerUniqueID, state);

            sessionUploadPersonData.testTypes = "";
            string testTypesSeparator = "";
            sessionUploadPersonData.sports = "";
            string sportsSeparator = "";

            //upload persons (updating also person.serverUniqueID locally)
            ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
                serverSession.UniqueID,
                false);                         //means: do not returnPersonAndPSlist

            Constants.UploadCodes uCode;
            ArrayList             notToUpload = SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);

            //store in variable for updating progressBar from other thread
            progressBarPersonsNum = persons.Count - notToUpload.Count;

            foreach (Person p in persons)
            {
                Person person = p;

                //do not continue with this person if has been banned to upload
                if (Util.FoundInArrayList(notToUpload, person.UniqueID.ToString()))
                {
                    continue;
                }

                PersonSession ps = SqlitePersonSession.Select(person.UniqueID, currentSession.UniqueID);

                //check person if exists
                if (person.ServerUniqueID != Constants.ServerUndefinedID)
                {
                    uCode = Constants.UploadCodes.EXISTS;
                }
                else
                {
                    uCode = Constants.UploadCodes.OK;

                    person = serverUploadPerson(myServer, person, serverSession.UniqueID);
                }

                //if sport is user defined, upload it
                //and when upload the person, do it with new sportID
                Sport sport = SqliteSport.Select(false, ps.SportID);
                //but record old sport ID because locally will be a change in serverUniqueID
                //(with slite update)
                //but local sport has not to be changed
                int sportUserDefinedLocal = -1;

                if (sport.UserDefined)
                {
                    sportUserDefinedLocal = sport.UniqueID;

                    //this will be uploaded
                    int newSport = myServer.UploadSport(sport);
                    if (newSport != -1)
                    {
                        ps.SportID = newSport;
                        sessionUploadPersonData.sports += sportsSeparator + sport.Name;
                        sportsSeparator = ", ";
                    }
                }

                //a person can be in the database for one session,
                //but maybe now we add jumps from another session and we should add an entry at personsession
                serverUploadPersonSessionIfNeeded(myServer, person.ServerUniqueID,
                                                  currentSession.ServerUniqueID, ps, sportUserDefinedLocal);

                //other thread updates the gui:
                sessionUploadPersonData.person     = person;
                sessionUploadPersonData.personCode = uCode;

                //upload jumps
                int countU = 0;
                int countE = 0;
                int countS = 0;

                string [] jumps = SqliteJump.SelectJumps(false, currentSession.UniqueID, person.UniqueID, "", "",
                                                         Sqlite.Orders_by.DEFAULT, -1);
                Sqlite.Open();
                foreach (string myJump in jumps)
                {
                    string [] js = myJump.Split(new char[] { ':' });
                    //select jump
                    Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    //if test is not simulated and has not been uploaded,
                    //see if it's type is not predefined and is not in the database
                    //then upload it first
                    if (test.Simulated == 0)
                    {
                        //upload jumpType if is user defined and doesn't exists in server database
                        //JumpType type = new JumpType(test.Type);
                        JumpType type = SqliteJumpType.SelectAndReturnJumpType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            //Console.WriteLine("USER DEFINED TEST: " + test.Type);
                            //
                            //this uploads the new type, as it's user created, it will be like this
                            //eg: for user defined jumpType: "supra" of evaluatorServerID: 9
                            //at server will be "supra-9"
                            //then two problems get solved:
                            //1.- every evaluator that uploads a type will have a different name
                            //than other evaluator uploading a type that is named the same but could be different
                            //(one can think that "supra" is another thing
                            //2- when the same evaluator upload some supra's, only a new type is created

                            //test.Type = myServer.UploadJumpType(type, evalSID);
                            //int testType = (int) Constants.TestTypes.JUMP;
                            //string insertedType = myServer.UploadTestType(Constants.TestTypes.JUMP, type, evalSID);
                            //string insertedType = myServer.UploadTestType(testType, type, evalSID);
                            string insertedType = myServer.UploadJumpType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                //record type in test (with the "-7" if it's done by evaluator 7)
                                test.Type = insertedType;

                                //show user uploaded type (without the "-7")
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }

                            //test.Type in the server will have the correct name "supra-9"
                        }
                    }

                    //upload... (if not because of simulated or uploaded before, report also the user)
                    uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP, Constants.JumpTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.jumpsU = countU;
                sessionUploadPersonData.jumpsE = countE;
                sessionUploadPersonData.jumpsS = countS;

                //upload jumpsRj
                countU = 0;
                countE = 0;
                countS = 0;

                string [] jumpsRj = SqliteJumpRj.SelectJumps(false, currentSession.UniqueID, person.UniqueID, "", "");
                Sqlite.Open();
                foreach (string myJump in jumpsRj)
                {
                    string [] js = myJump.Split(new char[] { ':' });
                    //select jump
                    JumpRj test = SqliteJumpRj.SelectJumpData(Constants.JumpRjTable, Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        JumpType type = SqliteJumpType.SelectAndReturnJumpRjType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadJumpRjType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }

                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP_RJ, Constants.JumpRjTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.jumpsRjU = countU;
                sessionUploadPersonData.jumpsRjE = countE;
                sessionUploadPersonData.jumpsRjS = countS;

                //upload runs
                countU = 0;
                countE = 0;
                countS = 0;

                string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, person.UniqueID, "",
                                                      Sqlite.Orders_by.DEFAULT, -1);

                Sqlite.Open();
                foreach (string myRun in runs)
                {
                    string [] js = myRun.Split(new char[] { ':' });
                    //select run
                    Run test = SqliteRun.SelectRunData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        RunType type = SqliteRunType.SelectAndReturnRunType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadRunType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }

                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RUN, Constants.RunTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.runsU = countU;
                sessionUploadPersonData.runsE = countE;
                sessionUploadPersonData.runsS = countS;

                //upload runs intervallic
                countU = 0;
                countE = 0;
                countS = 0;

                string [] runsI = SqliteRunInterval.SelectRuns(false, currentSession.UniqueID, person.UniqueID, "");
                Sqlite.Open();
                foreach (string myRun in runsI)
                {
                    string [] js = myRun.Split(new char[] { ':' });
                    //select run
                    RunInterval test = SqliteRunInterval.SelectRunData(Constants.RunIntervalTable, Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;

                    if (test.Simulated == 0)
                    {
                        RunType type = SqliteRunIntervalType.SelectAndReturnRunIntervalType(test.Type, true);
                        if (!type.IsPredefined)
                        {
                            string insertedType = myServer.UploadRunIntervalType(type, evalSID);
                            if (insertedType != "-1")
                            {
                                test.Type = insertedType;
                                sessionUploadPersonData.testTypes += testTypesSeparator + type.Name;
                                testTypesSeparator = ", ";
                            }
                        }
                    }
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RUN_I, Constants.RunIntervalTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.runsIU = countU;
                sessionUploadPersonData.runsIE = countE;
                sessionUploadPersonData.runsIS = countS;

                //upload reaction times
                countU = 0;
                countE = 0;
                countS = 0;

                string [] rts = SqliteReactionTime.SelectReactionTimes(false, currentSession.UniqueID, person.UniqueID,
                                                                       Sqlite.Orders_by.DEFAULT, -1);

                Sqlite.Open();
                foreach (string myRt in rts)
                {
                    string [] js = myRt.Split(new char[] { ':' });
                    //select rt
                    ReactionTime test = SqliteReactionTime.SelectReactionTimeData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.RT, Constants.ReactionTimeTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.rtsU = countU;
                sessionUploadPersonData.rtsE = countE;
                sessionUploadPersonData.rtsS = countS;

                //upload pulses
                countU = 0;
                countE = 0;
                countS = 0;

                string [] pulses = SqlitePulse.SelectPulses(false, currentSession.UniqueID, person.UniqueID);
                Sqlite.Open();
                foreach (string myPulse in pulses)
                {
                    string [] js = myPulse.Split(new char[] { ':' });
                    //select pulse
                    Pulse test = SqlitePulse.SelectPulseData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.PULSE, Constants.PulseTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.pulsesU = countU;
                sessionUploadPersonData.pulsesE = countE;
                sessionUploadPersonData.pulsesS = countS;

                //upload multiChronopic
                countU = 0;
                countE = 0;
                countS = 0;

                string [] mcs = SqliteMultiChronopic.SelectTests(false, currentSession.UniqueID, person.UniqueID);
                Sqlite.Open();
                foreach (string mc in mcs)
                {
                    string [] js = mc.Split(new char[] { ':' });
                    //select mc
                    MultiChronopic test = SqliteMultiChronopic.SelectMultiChronopicData(Convert.ToInt32(js[1]), true);                     //uniqueID
                    //fix it to server person, session keys
                    test.PersonID  = person.ServerUniqueID;
                    test.SessionID = currentSession.ServerUniqueID;
                    //upload...
                    uCode = serverUploadTest(myServer, Constants.TestTypes.MULTICHRONOPIC, Constants.MultiChronopicTable, test);

                    if (uCode == Constants.UploadCodes.OK)
                    {
                        countU++;
                    }
                    else if (uCode == Constants.UploadCodes.EXISTS)
                    {
                        countE++;
                    }
                    else                     //SIMULATED
                    {
                        countS++;
                    }
                }
                Sqlite.Close();

                //other thread updates the gui:
                sessionUploadPersonData.mcsU = countU;
                sessionUploadPersonData.mcsE = countE;
                sessionUploadPersonData.mcsS = countS;

                needUpdateServerSession = true;
                while (needUpdateServerSession)
                {
                    //wait until data is printed on the other thread
                }
            }

            state = (int)Constants.ServerSessionStates.DONE;
            //myServer.UpdateSession(currentSession.ServerUniqueID, (ServerSessionStates)  Constants.ServerSessionStates.DONE);
            myServer.UpdateSession(currentSession.ServerUniqueID, state);

            LogB.Information(myServer.DisConnectDatabase());
        } catch {
            //other thread updates the gui:
            serverSessionError = true;
        }
    }
コード例 #35
0
ファイル: ChronojumpServer.cs プロジェクト: GNOME/chronojump
 public void UploadPersonSessionIfNeededAsync(PersonSession ps)
 {
     this.UploadPersonSessionIfNeededAsync(ps, null);
 }
コード例 #36
0
 public int UploadPersonSessionIfNeeded(PersonSession ps)
 {
     if(!SqlitePersonSession.PersonSelectExistsInSession(ps.PersonID, ps.SessionID)) {
         Console.WriteLine("personSession needed");
         Console.WriteLine(ps.ToString());
         ps.InsertAtDB(false, Constants.PersonSessionTable);
         Console.WriteLine("done");
         return 1; //unused
     } else
         Console.WriteLine("personSession NOT needed");
     return 0; //unused
 }
コード例 #37
0
ファイル: person.cs プロジェクト: davidfombella/chronojump
 //default constructor
 public PersonAndPS(Person p, PersonSession ps)
 {
     this.p  = p;
     this.ps = ps;
 }
コード例 #38
0
ファイル: personSession.cs プロジェクト: GNOME/chronojump
    //the difference between this select and others, is that this returns and ArrayList of Persons
    //this is better than return the strings that can produce bugs in the future
    //use this in the future:
    public static ArrayList SelectCurrentSessionPersons(int sessionID, bool returnPersonAndPSlist)
    {
        string tp = Constants.PersonTable;
        string tps = Constants.PersonSessionTable;

        string tpsString = "";
        if(returnPersonAndPSlist)
            tpsString = ", " + tps + ".* ";

        Sqlite.Open();
        dbcmd.CommandText = "SELECT " + tp + ".*" + tpsString +
            " FROM " + tp + ", " + tps +
            " WHERE " + tps + ".sessionID == " + sessionID +
            " AND " + tp + ".uniqueID == " + tps + ".personID " +
            " ORDER BY upper(" + tp + ".name)";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        ArrayList myArray = new ArrayList(1);
        while(reader.Read()) {
            Person person = new Person(
                    Convert.ToInt32(reader[0].ToString()),	//uniqueID
                    reader[1].ToString(),			//name
                    reader[2].ToString(),			//sex
                    UtilDate.FromSql(reader[3].ToString()),	//dateBorn
                    Convert.ToInt32(reader[4].ToString()),	//race
                    Convert.ToInt32(reader[5].ToString()),	//countryID
                    reader[6].ToString(),			//description
                    Convert.ToInt32(reader[9].ToString())	//serverUniqueID
                    );

            if(returnPersonAndPSlist) {
                PersonSession ps = new PersonSession(
                        Convert.ToInt32(reader[10].ToString()), 	//uniqueID
                        Convert.ToInt32(reader[11].ToString()), 	//personID
                        Convert.ToInt32(reader[12].ToString()), 	//sessionID
                        Convert.ToDouble(Util.ChangeDecimalSeparator(reader[13].ToString())), //height
                        Convert.ToDouble(Util.ChangeDecimalSeparator(reader[14].ToString())), //weight
                        Convert.ToInt32(reader[15].ToString()), 	//sportID
                        Convert.ToInt32(reader[16].ToString()), 	//speciallityID
                        Convert.ToInt32(reader[17].ToString()),	//practice
                        reader[18].ToString() 			//comments
                        );
                myArray.Add(new PersonAndPS(person, ps));

            } else
                myArray.Add (person);
        }
        reader.Close();
        Sqlite.Close();
        return myArray;
    }