Exemplo n.º 1
0
    /*
     * combos changed signals
     */

    private void on_combo_test_types_changed(object o, EventArgs args)
    {
        if (UtilGtk.ComboGetActive(combo_test_types) == Catalog.GetString(Constants.UndefinedDefault))
        {
            tests     = new String[1];
            tests [0] = Catalog.GetString(Constants.UndefinedDefault);
            UtilGtk.ComboUpdate(combo_tests, tests, "");
            UtilGtk.ComboUpdate(combo_variables, tests, "");
        }
        else if (UtilGtk.ComboGetActive(combo_test_types) == Catalog.GetString(Constants.JumpSimpleName))
        {
            UtilGtk.ComboUpdate(combo_tests,
                                SqliteJumpType.SelectJumpTypes(false, "", "", true), "");
        }
        else if (UtilGtk.ComboGetActive(combo_test_types) == Catalog.GetString(Constants.JumpReactiveName))
        {
            UtilGtk.ComboUpdate(combo_tests,
                                SqliteJumpType.SelectJumpRjTypes("", true), "");
        }
        else if (UtilGtk.ComboGetActive(combo_test_types) == Catalog.GetString(Constants.RunSimpleName))
        {
            UtilGtk.ComboUpdate(combo_tests,
                                SqliteRunType.SelectRunTypes("", true), "");
        }

        combo_tests.Active = 0;

        on_entries_required_changed(new object(), new EventArgs());
    }
    public string UploadRunType(RunType type, int evalSID)
    {
        string typeServer = type.Name + "-" + evalSID.ToString();

        Console.WriteLine("RUN" + typeServer + ":" + type.Distance + ":" + type.Description);
        if (!Sqlite.Exists(false, Constants.RunTypeTable, typeServer))
        {
            type.Name = typeServer;
            SqliteRunType.Insert(type, Constants.RunTypeTable, false);
            return(typeServer);
        }
        return("-1");
    }
Exemplo n.º 3
0
 //used by Sqlite.convertTables
 //public override int InsertAtDB (bool dbconOpened, string tableName, bool interval) {
 public int InsertAtDB(bool dbconOpened, string tableName, bool interval)
 {
     if (interval)
     {
         /*
          * return SqliteRunIntervalType.Insert(dbconOpened, tableName,
          *              name, distance, tracksLimited, fixedValue,
          *              unlimited, description);
          */
         return(SqliteRunIntervalType.Insert(this, tableName, dbconOpened));
     }
     else
     {
         /*
          * return SqliteRunType.Insert(dbconOpened, tableName,
          *              name, distance, description);
          */
         return(SqliteRunType.Insert(this, tableName, dbconOpened));
     }
 }
Exemplo n.º 4
0
 protected override void select()
 {
     l_types = (List <object>)SqliteRunType.SelectRunTypesNew("", false);         //without allrunsname, not only name
 }
Exemplo n.º 5
0
    void on_button_accept_clicked(object o, EventArgs args)
    {
        //ConsoleB.Information(getEntriesString());
        string name = Util.RemoveTildeAndColonAndDot(entry_name.Text);

        //check if this run type exists, and check it's name is not AllRunsName
        bool runTypeExists = Sqlite.Exists(false, Constants.RunTypeTable, name);

        if (name == Constants.AllRunsName)
        {
            runTypeExists = true;
        }

        if (runTypeExists)
        {
            string myString = string.Format(Catalog.GetString("Race type: '{0}' exists. Please, use another name"), name);
            LogB.Information(myString);
            ErrorWindow.Show(myString);
        }
        else
        {
            RunType type = new RunType();
            type.Name        = name;
            type.Description = Util.RemoveTildeAndColon(textview_description.Buffer.Text);

            if (radiobutton_dist_variable.Active)
            {
                type.Distance = 0;
            }
            else if (radiobutton_dist_fixed.Active)
            {
                type.Distance = spin_distance_fixed.Value;
            }
            else
            {
                //dist_different (only on intervallic)
                type.Distance        = -1;
                type.DistancesString = getEntriesString();
            }

            if (radiobutton_simple.Active)
            {
                SqliteRunType.Insert(type, Constants.RunTypeTable, false);                 //false, because dbcon is not opened
                InsertedSimple = true;
            }
            else
            {
                if (radiobutton_unlimited.Active)
                {
                    //unlimited (but in runs do like if it's limited by seconds: TracksLimited = false
                    //(explanation in sqlite/jumpType.cs)
                    type.TracksLimited = false;
                    type.FixedValue    = 0;
                    type.Unlimited     = true;
                }
                else
                {
                    type.TracksLimited = radiobutton_limited_tracks.Active;

                    if (checkbutton_limited_fixed.Active)
                    {
                        type.FixedValue = Convert.ToInt32(spin_fixed_tracks_or_time.Value);
                    }
                    else
                    {
                        type.FixedValue = 0;
                    }


                    type.Unlimited = false;
                }

                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, false);                 //false, because dbcon is not opened
                InsertedSimple = false;
            }

            //LogB.Information(string.Format("Inserted: {0}", type));

            fakeButtonAccept.Click();

            RunTypeAddWindowBox.run_type_add.Hide();
            RunTypeAddWindowBox = null;
        }
    }
Exemplo n.º 6
0
    public static void CreateTables(bool server)
    {
        Sqlite.Open();

        creationTotal = 14;
        creationRate = 1;

        SqliteServer sqliteServerObject = new SqliteServer();
        //user has also an evaluator table with a row (it's row)
        sqliteServerObject.CreateEvaluatorTable();

        if(server) {
            sqliteServerObject.CreatePingTable();

            SqliteServerSession sqliteSessionObject = new SqliteServerSession();
            sqliteSessionObject.createTable(Constants.SessionTable);
        } else {
            SqliteSession sqliteSessionObject = new SqliteSession();
            sqliteSessionObject.createTable(Constants.SessionTable);

            //add SIMULATED session if doesn't exists. Unique session where tests can be simulated.
            SqliteSession.insertSimulatedSession();

            SqlitePersonSessionNotUpload.CreateTable();
            creationRate ++;
        }

        SqlitePerson sqlitePersonObject = new SqlitePerson();
        sqlitePersonObject.createTable(Constants.PersonTable);

        //graphLinkTable
        SqliteEvent.createGraphLinkTable();
        creationRate ++;

        //jumps
        SqliteJump sqliteJumpObject = new SqliteJump();
        SqliteJumpRj sqliteJumpRjObject = new SqliteJumpRj();
        sqliteJumpObject.createTable(Constants.JumpTable);
        sqliteJumpRjObject.createTable(Constants.JumpRjTable);
        sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);

        //jump Types
        creationRate ++;
        SqliteJumpType.createTableJumpType();
        SqliteJumpType.createTableJumpRjType();
        SqliteJumpType.initializeTableJumpType();
        SqliteJumpType.initializeTableJumpRjType();

        //runs
        creationRate ++;
        SqliteRun sqliteRunObject = new SqliteRun();
        SqliteRunInterval sqliteRunIntervalObject = new SqliteRunInterval();
        sqliteRunObject.createTable(Constants.RunTable);
        sqliteRunIntervalObject.createTable(Constants.RunIntervalTable);
        sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

        //run Types
        creationRate ++;
        SqliteRunType sqliteRunTypeObject = new SqliteRunType();
        sqliteRunTypeObject.createTable(Constants.RunTypeTable);
        SqliteRunType.initializeTable();

        SqliteRunIntervalType sqliteRunIntervalTypeObject = new SqliteRunIntervalType();
        sqliteRunIntervalTypeObject.createTable(Constants.RunIntervalTypeTable);
        SqliteRunIntervalType.initializeTable();

        //reactionTimes
        creationRate ++;
        SqliteReactionTime sqliteReactionTimeObject = new SqliteReactionTime();
        sqliteReactionTimeObject.createTable(Constants.ReactionTimeTable);

        //pulses and pulseTypes
        creationRate ++;
        SqlitePulse sqlitePulseObject = new SqlitePulse();
        sqlitePulseObject.createTable(Constants.PulseTable);
        SqlitePulseType.createTablePulseType();
        SqlitePulseType.initializeTablePulseType();

        //multiChronopic tests
        creationRate ++;
        SqliteMultiChronopic sqliteMultiChronopicObject = new SqliteMultiChronopic();
        sqliteMultiChronopicObject.createTable(Constants.MultiChronopicTable);

        //encoder
        creationRate ++;
        SqliteEncoder.createTableEncoder();
        SqliteEncoder.createTableEncoderSignalCurve();
        SqliteEncoder.createTableEncoderExercise();
        SqliteEncoder.initializeTableEncoderExercise();
        SqliteEncoder.createTable1RM();

        //sports
        creationRate ++;
        SqliteSport.createTable();
        SqliteSport.initialize();
        SqliteSpeciallity.createTable();
        SqliteSpeciallity.initialize();
        SqliteSpeciallity.InsertUndefined(true);

        creationRate ++;
        SqlitePersonSession sqlitePersonSessionObject = new SqlitePersonSession();
        sqlitePersonSessionObject.createTable(Constants.PersonSessionTable);

        creationRate ++;
        SqlitePreferences.createTable();
        SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);

        creationRate ++;
        SqliteCountry.createTable();
        SqliteCountry.initialize();

        SqliteExecuteAuto.createTableExecuteAuto();
        SqliteExecuteAuto.addChronojumpProfileAndBilateral();

        SqliteChronopicRegister.createTableChronopicRegister();

        //changes [from - to - desc]
        //1.33 - 1.34 Converted DB to 1.34 Added thresholdJumps, thresholdRuns, thresholdOther to preferences
        //1.32 - 1.33 Converted DB to 1.33 Added chronopicRegister table
        //1.31 - 1.32 Converted DB to 1.32 encoderCaptureOptionsWin -> preferences
        //1.30 - 1.31 Converted DB to 1.31 Insert encoderCaptureCheckFullyExtended and ...Value at preferences
        //1.29 - 1.30 Converted DB to 1.30 Added SIMULATED session
        //1.28 - 1.29 Converted DB to 1.29 Changed reaction time rows have reactionTime as default value
        //1.27 - 1.28 Converted DB to 1.28 Changed encoderAutoSaveCurve BESTMEANPOWER to BEST
        //1.26 - 1.27 Converted DB to 1.27 Changing runDoubleContactsMS and runIDoubleContactsMS from 1000ms to 300ms
        //1.25 - 1.26 Converted DB to 1.26 Changed Inclinated to Inclined
        //1.24 - 1.25 Converted DB to 1.25 Language defaults to (empty string), means detected
        //1.23 - 1.24 Converted DB to 1.24 Delete runISpeedStartArrival and add 4 double contacts configs
        //1.22 - 1.23 Converted DB to 1.23 Added encoder configuration
        //1.21 - 1.22 Converted DB to 1.22 Encoder laterality in english again
        //1.20 - 1.21 Converted DB to 1.21 Fixing loosing of encoder videoURL after recalculate
        //1.19 - 1.20 Converted DB to 1.20 Preferences: added user email
        //1.18 - 1.19 Converted DB to 1.19 Preferences deleted showHeight, added showStiffness
        //1.17 - 1.18 Converted DB to 1.18 deleted Negative runInterval runs (bug from last version)
        //1.16 - 1.17 Converted DB to 1.17 Deleted Max jump (we already have "Free")
        //1.15 - 1.16 Converted DB to 1.16 Cyprus moved to Europe
        //1.14 - 1.15 Converted DB to 1.15 added Chronojump profile and bilateral profile
        //1.13 - 1.14 Converted DB to 1.14 slCMJ -> slCMJleft, slCMJright
        //1.12 - 1.13 Converted DB to 1.13 Added ExecuteAuto table
        //1.11 - 1.12 Converted DB to 1.12 URLs from absolute to relative
        //1.10 - 1.11 Converted DB to 1.11 Added option on autosave curves on capture (all/bestmeanpower/none)
        //1.09 - 1.10 Converted DB to 1.10 Added RSA RAST on runType
        //1.08 - 1.09 Converted DB to 1.09 Added option on preferences to useHeightsOnJumpIndexes (default) or not
        //1.07 - 1.08 Converted DB to 1.08 Added translate statistics graph option to preferences
        //1.06 - 1.07 Converted DB to 1.07 Added jump_dj_a.png
        //1.05 - 1.06 Converted DB to 1.06 Curves are now linked to signals
        //1.04 - 1.05 Converted DB to 1.05 Removed inertial curves, because sign was not checked on 1.04 when saving curves
        //1.03 - 1.04 Converted DB to 1.04 Encoder table improved
        //1.02 - 1.03 Converted DB to 1.03 Updated encoder exercise, angle is now on encoder configuration
        //1.01 - 1.02 Converted DB to 1.02 Added Agility Tests: Agility-T-Test, Agility-3L3R
        //1.00 - 1.01 Converted DB to 1.01 Added export to CSV configuration on preferences
        //0.99 - 1.00 Converted DB to 1.00 Encoder added Free and Inclined Exercises
        //0.98 - 0.99 Converted DB to 0.99 Encoder table improved
        //0.97 - 0.98 Converted DB to 0.98 Fixed encoder laterality
        //0.96 - 0.97 Converted DB to 0.97 Added inertialmomentum in preferences
        //0.95 - 0.96 Converted DB to 0.96 Encoder signal future3 three modes
        //0.94 - 0.95 Converted DB to 0.95 Added encoder1RMMethod
        //0.93 - 0.94 Converted DB to 0.94 Added encoder1RM table
        //0.92 - 0.93 Converted DB to 0.93 Added speed1RM on encoder exercise
        //0.91 - 0.92 Converted DB to 0.92 Added videoDevice to preferences
        //0.90 - 0.91 Converted DB to 0.91 Encoder Squat 75% -> 100%
        //0.89 - 0.90 Converted DB to 0.90 Preferences added propulsive and encoder smooth
        //0.88 - 0.89 Converted DB to 0.89 Added encoder exercise: Free
        //0.87 - 0.88 Converted DB to 0.88 Deleted fake RSA test and added known RSA tests
        //0.86 - 0.87 Converted DB to 0.87 Added run speed start preferences on sqlite
        //0.85 - 0.86 Converted DB to 0.86 videoOn: TRUE
        //0.84 - 0.85 Converted DB to 0.85 Added slCMJ jump
        //0.83 - 0.84 Converted DB to 0.84 Added first RSA test
        //0.82 - 0.83 Converted DB to 0.83 Created encoder table
        //0.81 - 0.82 Converted DB to 0.82 Added videoOn
        //0.80 - 0.81 Converted DB to 0.81 Added tempRunInterval initial speed
        //0.79 - 0.80 Converted DB to 0.80 Added run and runInterval initial speed (if not done in 0.56 conversion)
        //0.78 - 0.79 Converted DB to 0.79 (Added multimediaStorage structure id)
        //0.77 - 0.78 Converted DB to 0.78 (Added machineID to preferences, takeOffWeight has no weight in db conversions since 0.66)
        //0.76 - 0.77 Converted DB to 0.77 (person77, personSession77)
        //0.75 - 0.76 Converted DB to 0.76 (jump & jumpRj falls as double)
        //0.74 - 0.75 Converted DB to 0.75 (person, and personSessionWeight have height and weight as double)
        //0.73 - 0.74 Converted DB to 0.74 (All DJ converted to DJna)
        //0.72 - 0.73 Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table))
        //0.71 - 0.72 dates to YYYY-MM-DD
        //0.70 - 0.71 created personNotUploadTable on client
        //0.69 - 0.70 added showPower to preferences
        //0.68 - 0.69 added Gesell-DBT test
        //0.67 - 0.68 added multiChronopic tests table
        //0.66 - 0.67 added TakeOff jumps
        //0.65 - 0.66 added done nothing
        //0.64 - 0.65 added Sevaluator on client
        //0.63 - 0.64 added margaria test
        //0.62 - 0.63 added 'versionAvailable' to preferences
        //0.61 - 0.62 added hexagon (jumpRj test)
        //0.60 - 0.61 added RunIntervalType distancesString (now we van have interval tests with different distances of tracks). Added MTGUG
        //0.59 - 0.60 added volumeOn and evaluatorServerID to preferences. Session has now serverUniqueID. Simulated now are -1, because 0 is real and positive is serverUniqueID
        //0.58 - 0.59 Added 'showAngle' to preferences, changed angle on jump to double
        //0.57 - 0.58 Countries without kingdom or republic (except when needed)
        //0.56 - 0.57 Added simulated column to each event table on client. person: race, country, serverID. Convert to sport related done here if needed. Added also run and runInterval initial speed);
        //0.55 - 0.56 Added session default sport stuff into session table
        //0.54 - 0.55 Added undefined to speciallity table
        //0.53 - 0.54 created sport tables. Added sport data, speciallity and level of practice to person table
        //0.52 - 0.53 added table weightSession, moved person weight data to weightSession table for each session that has performed
        //0.51 - 0.52 added graphLinks for cmj_l and abk_l. Fixed CMJ_l name
        //0.50 - 0.51 added graphLinks for run simple and interval
        //0.49 - 0.50: changed SJ+ to SJl, same for CMJ+ and ABK+, added jump and jumpRj graph links
        //0.48 - 0.49: added graphLinkTable, added rocket jump and 5 agility tests: (20Yard, 505, Illinois, Shuttle-Run & ZigZag). Added graphs pof the 5 agility tests
        //0.47 - 0.48: added tempJumpReactive and tempRunInterval tables
        //0.46 - 0.47: added reactionTime table
        //0.45 - 0.46: added "Free" jump type
        //0.44 - 0.45: added allowFinishRjAfterTime
        //0.43 - 0.44: added showQIndex and showDjIndex
        //0.42 - 0.43: added 'free' pulseType & language preference
        //0.41 - 0.42: added pulse and pulseType tables
        //0.4 - 0.41: jump, jumpRj weight is double (always a percent)

        Sqlite.Close();
        creationRate ++;
    }
Exemplo n.º 7
0
    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;
        }
    }
Exemplo n.º 8
0
    public static void CreateTables(bool server)
    {
        dbcon.Open();

        creationTotal = 14;
        creationRate = 1;

        SqliteServer sqliteServerObject = new SqliteServer();
        //user has also an evaluator table with a row (it's row)
        sqliteServerObject.CreateEvaluatorTable();

        if(server) {
            sqliteServerObject.CreatePingTable();

            SqliteServerSession sqliteSessionObject = new SqliteServerSession();
            sqliteSessionObject.createTable(Constants.SessionTable);
        } else {
            SqliteSession sqliteSessionObject = new SqliteSession();
            sqliteSessionObject.createTable(Constants.SessionTable);
            SqlitePersonSessionNotUpload.CreateTable();
            creationRate ++;
        }

        SqlitePerson sqlitePersonObject = new SqlitePerson();
        sqlitePersonObject.createTable(Constants.PersonTable);

        //graphLinkTable
        SqliteEvent.createGraphLinkTable();
        creationRate ++;

        //jumps
        SqliteJump sqliteJumpObject = new SqliteJump();
        SqliteJumpRj sqliteJumpRjObject = new SqliteJumpRj();
        sqliteJumpObject.createTable(Constants.JumpTable);
        sqliteJumpRjObject.createTable(Constants.JumpRjTable);
        sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);

        //jump Types
        creationRate ++;
        SqliteJumpType.createTableJumpType();
        SqliteJumpType.createTableJumpRjType();
        SqliteJumpType.initializeTableJumpType();
        SqliteJumpType.initializeTableJumpRjType();

        //runs
        creationRate ++;
        SqliteRun sqliteRunObject = new SqliteRun();
        SqliteRunInterval sqliteRunIntervalObject = new SqliteRunInterval();
        sqliteRunObject.createTable(Constants.RunTable);
        sqliteRunIntervalObject.createTable(Constants.RunIntervalTable);
        sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

        //run Types
        creationRate ++;
        SqliteRunType sqliteRunTypeObject = new SqliteRunType();
        sqliteRunTypeObject.createTable(Constants.RunTypeTable);
        SqliteRunType.initializeTable();

        SqliteRunIntervalType sqliteRunIntervalTypeObject = new SqliteRunIntervalType();
        sqliteRunIntervalTypeObject.createTable(Constants.RunIntervalTypeTable);
        SqliteRunIntervalType.initializeTable();

        //reactionTimes
        creationRate ++;
        SqliteReactionTime sqliteReactionTimeObject = new SqliteReactionTime();
        sqliteReactionTimeObject.createTable(Constants.ReactionTimeTable);

        //pulses and pulseTypes
        creationRate ++;
        SqlitePulse sqlitePulseObject = new SqlitePulse();
        sqlitePulseObject.createTable(Constants.PulseTable);
        SqlitePulseType.createTablePulseType();
        SqlitePulseType.initializeTablePulseType();

        //multiChronopic tests
        creationRate ++;
        SqliteMultiChronopic sqliteMultiChronopicObject = new SqliteMultiChronopic();
        sqliteMultiChronopicObject.createTable(Constants.MultiChronopicTable);

        //encoder
        creationRate ++;
        SqliteEncoder.createTableEncoder();
        SqliteEncoder.createTableEncoderExercise();
        SqliteEncoder.initializeTableEncoderExercise();

        //sports
        creationRate ++;
        SqliteSport.createTable();
        SqliteSport.initialize();
        SqliteSpeciallity.createTable();
        SqliteSpeciallity.initialize();
        SqliteSpeciallity.InsertUndefined(true);

        creationRate ++;
        SqlitePersonSession sqlitePersonSessionObject = new SqlitePersonSession();
        sqlitePersonSessionObject.createTable(Constants.PersonSessionTable);

        creationRate ++;
        SqlitePreferences.createTable();
        SqlitePreferences.initializeTable(lastChronojumpDatabaseVersion, creatingBlankDatabase);

        creationRate ++;
        SqliteCountry.createTable();
        SqliteCountry.initialize();

        //changes [from - to - desc]
        //0.83 - 0.84 Converted DB to 0.84 Added first RSA test
        //0.82 - 0.83 Converted DB to 0.83 Created encoder table
        //0.81 - 0.82 Converted DB to 0.82 Added videoOn
        //0.80 - 0.81 Converted DB to 0.81 Added tempRunInterval initial speed
        //0.79 - 0.80 Converted DB to 0.80 Added run and runInterval initial speed (if not done in 0.56 conversion)
        //0.78 - 0.79 Converted DB to 0.79 (Added multimediaStorage structure id)
        //0.77 - 0.78 Converted DB to 0.78 (Added machineID to preferences, takeOffWeight has no weight in db conversions since 0.66)
        //0.76 - 0.77 Converted DB to 0.77 (person77, personSession77)
        //0.75 - 0.76 Converted DB to 0.76 (jump & jumpRj falls as double)
        //0.74 - 0.75 Converted DB to 0.75 (person, and personSessionWeight have height and weight as double)
        //0.73 - 0.74 Converted DB to 0.74 (All DJ converted to DJna)
        //0.72 - 0.73 Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table))
        //0.71 - 0.72 dates to YYYY-MM-DD
        //0.70 - 0.71 created personNotUploadTable on client
        //0.69 - 0.70 added showPower to preferences
        //0.68 - 0.69 added Gesell-DBT test
        //0.67 - 0.68 added multiChronopic tests table
        //0.66 - 0.67 added TakeOff jumps
        //0.65 - 0.66 added done nothing
        //0.64 - 0.65 added Sevaluator on client
        //0.63 - 0.64 added margaria test
        //0.62 - 0.63 added 'versionAvailable' to preferences
        //0.61 - 0.62 added hexagon (jumpRj test)
        //0.60 - 0.61 added RunIntervalType distancesString (now we van have interval tests with different distances of tracks). Added MTGUG
        //0.59 - 0.60 added volumeOn and evaluatorServerID to preferences. Session has now serverUniqueID. Simulated now are -1, because 0 is real and positive is serverUniqueID
        //0.58 - 0.59 Added 'showAngle' to preferences, changed angle on jump to double
        //0.57 - 0.58 Countries without kingdom or republic (except when needed)
        //0.56 - 0.57 Added simulated column to each event table on client. person: race, country, serverID. Convert to sport related done here if needed. Added also run and runInterval initial speed);
        //0.55 - 0.56 Added session default sport stuff into session table
        //0.54 - 0.55 Added undefined to speciallity table
        //0.53 - 0.54 created sport tables. Added sport data, speciallity and level of practice to person table
        //0.52 - 0.53 added table weightSession, moved person weight data to weightSession table for each session that has performed
        //0.51 - 0.52 added graphLinks for cmj_l and abk_l. Fixed CMJ_l name
        //0.50 - 0.51 added graphLinks for run simple and interval
        //0.49 - 0.50: changed SJ+ to SJl, same for CMJ+ and ABK+, added jump and jumpRj graph links
        //0.48 - 0.49: added graphLinkTable, added rocket jump and 5 agility tests: (20Yard, 505, Illinois, Shuttle-Run & ZigZag). Added graphs pof the 5 agility tests
        //0.47 - 0.48: added tempJumpReactive and tempRunInterval tables
        //0.46 - 0.47: added reactionTime table
        //0.45 - 0.46: added "Free" jump type
        //0.44 - 0.45: added allowFinishRjAfterTime
        //0.43 - 0.44: added showQIndex and showDjIndex
        //0.42 - 0.43: added 'free' pulseType & language preference
        //0.41 - 0.42: added pulse and pulseType tables
        //0.4 - 0.41: jump, jumpRj weight is double (always a percent)

        dbcon.Close();
        creationRate ++;
    }