상속: Sqlite
예제 #1
0
    protected override void getData()
    {
        //create directory fileName_files/
        string directoryName = Util.GetReportDirectoryName(fileName);

        if (!Directory.Exists(directoryName))
        {
            Directory.CreateDirectory(directoryName);
        }
        else
        {
            //if it exists before, delete all pngs
            string [] pngs = Directory.GetFiles(directoryName, "*.png");
            foreach (string myFile in pngs)
            {
                File.Delete(myFile);
            }
        }

        if (ShowCurrentSessionJumpers)
        {
            myPersonsAndPS = SqlitePersonSession.SelectCurrentSessionPersons(sessionID, true);
        }

        //Leave SQL opened in all this process
        Sqlite.Open();         // ------------------------------

        if (ShowSimpleJumps)
        {
            myJumps = SqliteJump.SelectJumps(true, sessionID, -1, "", "",
                                             Sqlite.Orders_by.DEFAULT, -1);
        }
        if (ShowReactiveJumps)
        {
            myJumpsRj = SqliteJumpRj.SelectJumps(true, sessionID, -1, "", "");
        }
        if (ShowSimpleRuns)
        {
            myRuns = SqliteRun.SelectRuns(true, sessionID, -1, "",
                                          Sqlite.Orders_by.DEFAULT, -1);
        }
        if (ShowIntervalRuns)
        {
            myRunsInterval = SqliteRunInterval.SelectRuns(true, sessionID, -1, "");
        }
        if (ShowReactionTimes)
        {
            myReactionTimes = SqliteReactionTime.SelectReactionTimes(true, sessionID, -1, "",
                                                                     Sqlite.Orders_by.DEFAULT, -1);
        }
        if (ShowPulses)
        {
            myPulses = SqlitePulse.SelectPulses(true, sessionID, -1);
        }

        Sqlite.Close();         // ------------------------------
    }
예제 #2
0
 public override int InsertAtDB(bool dbconOpened, string tableName)
 {
     return(SqliteJump.Insert(dbconOpened, tableName,
                              uniqueID.ToString(),
                              personID, sessionID,
                              type, tv, tc, fall,
                              weight, description,
                              angle, simulated));
 }
예제 #3
0
    protected override void write()
    {
        string tcString = "";

        if (hasFall)
        {
            //Log.WriteLine("TC: {0}", tc.ToString());
            tcString = " " + Catalog.GetString("TC") + ": " + Util.TrimDecimals(tc.ToString(), pDN);
        }
        else
        {
            tc = 0;
        }


        /*
         * string myStringPush =
         *      personName + " " +
         *      type + tcString + " " + Catalog.GetString("TF") + ": " + Util.TrimDecimals( tv.ToString(), pDN ) ;
         * if(weight > 0) {
         *      myStringPush = myStringPush + "(" + weight.ToString() + "%)";
         * }
         */
        if (simulated)
        {
            feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
        }
        else
        {
            feedbackMessage = "";
        }
        needShowFeedbackMessage = true;

        string table = Constants.JumpTable;

        uniqueID = SqliteJump.Insert(false, table, "NULL", personID, sessionID,
                                     type, tv, tc, fall, //type, tv, tc, fall
                                     weight, description, angle, Util.BoolToNegativeInt(simulated));

        //define the created object
        eventDone = new Jump(uniqueID, personID, sessionID, type, tv, tc, fall,
                             weight, description, angle, Util.BoolToNegativeInt(simulated));

        //event will be raised, and managed in chronojump.cs
        fakeButtonFinished.Click();

        PrepareEventGraphJumpSimpleObject = new PrepareEventGraphJumpSimple(tv, tc, sessionID, personID, table, type);
        needUpdateGraphType = eventType.JUMP;
        needUpdateGraph     = true;

        needEndEvent = true;         //used for hiding some buttons on eventWindow
    }
예제 #4
0
    public void Calculate(int personID, int sessionID)
    {
        List <Double> l = SqliteJump.SelectChronojumpProfile(personID, sessionID);

        double sj  = l[0];
        double sjl = l[1];
        double cmj = l[2];
        double abk = l[3];
        double dja = l[4];

        jpi0 = new JumpsProfileIndex(JumpsProfileIndex.Types.FMAX, "SJ", "", sjl, 0, dja);
        jpi1 = new JumpsProfileIndex(JumpsProfileIndex.Types.FEXPL, "SJ", "SJl", sj, sjl, dja);
        jpi2 = new JumpsProfileIndex(JumpsProfileIndex.Types.CELAST, "CMJ", "SJ", cmj, sj, dja);
        jpi3 = new JumpsProfileIndex(JumpsProfileIndex.Types.CARMS, "ABK", "CMJ", abk, cmj, dja);
        jpi4 = new JumpsProfileIndex(JumpsProfileIndex.Types.FREACT, "DJa", "ABK", dja, abk, dja);
    }
예제 #5
0
    protected void on_button_accept_clicked(object o, EventArgs args)
    {
        Gtk.TreeIter iter;

        int  jumpID;
        bool option1;

        if (store.GetIterFirst(out iter))
        {
            //don't catch 0 value
            while (store.IterNext(ref iter))
            {
                option1 = (bool)store.GetValue(iter, columnBool1);

                //only change in database if option is 2
                //because option 1 leaves the same percent and changes Kg (and database is in %)
                if (!option1)
                {
                    //find the jumpID
                    jumpID = Convert.ToInt32(treeview1.Model.GetValue(iter, 0));

                    //find weight (100% 80Kg)
                    string weightString = (string)store.GetValue(iter, columnBool2 + 1);

                    //find percent (it's before the '%' sign)
                    string [] myStringFull = weightString.Split(new char[] { '%' });
                    double    percent      = Convert.ToDouble(myStringFull[0]);

                    //update DB
                    //see if it's reactive
                    string tableName = "jump";
                    if ((string)treeview1.Model.GetValue(iter, 1) == reactiveString)
                    {
                        tableName = "jumpRj";
                    }

                    SqliteJump.UpdateWeight(tableName, jumpID, percent);
                }
            }
        }

        ConvertWeightWindowBox.convert_weight.Hide();
        ConvertWeightWindowBox = null;
    }
예제 #6
0
    public PrepareEventGraphJumpSimple(double tv, double tc, int sessionID, int personID, string table, string type)
    {
        Sqlite.Open();

        //select data from SQL to update graph
        jumpsAtSQL = SqliteJump.SelectJumps(true, sessionID, personID, "", type,
                                            Sqlite.Orders_by.ID_DESC, 10); //select only last 10

        string sqlSelect = "";

        if (tv > 0)
        {
            if (tc <= 0)
            {
                sqlSelect = "100*4.9*(TV/2)*(TV/2)";
            }
            else
            {
                sqlSelect = "TV";                 //if tc is higher than tv it will be fixed on PrepareJumpSimpleGraph
            }
        }
        else
        {
            sqlSelect = "TC";
        }

        personMAXAtSQLAllSessions = SqliteSession.SelectMAXEventsOfAType(true, -1, personID, table, type, sqlSelect);
        personMAXAtSQL            = SqliteSession.SelectMAXEventsOfAType(true, sessionID, personID, table, type, sqlSelect);
        sessionMAXAtSQL           = SqliteSession.SelectMAXEventsOfAType(true, sessionID, -1, table, type, sqlSelect);

        personAVGAtSQL  = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type, sqlSelect);
        sessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, sqlSelect);

        //end of select data from SQL to update graph

        this.tv = tv;
        this.tc = tc;

        Sqlite.Close();
    }
예제 #7
0
    protected virtual void getData()
    {
        myPersonsAndPS = SqlitePersonSession.SelectCurrentSessionPersons(mySession.UniqueID, true);

        //Leave SQL opened in all this process
        Sqlite.Open();         // ------------------------------

        myJumps = SqliteJump.SelectJumps(true, mySession.UniqueID, -1, "", "",
                                         Sqlite.Orders_by.DEFAULT, -1);

        myJumpsRj = SqliteJumpRj.SelectJumps(true, mySession.UniqueID, -1, "", "");
        myRuns    = SqliteRun.SelectRuns(true, mySession.UniqueID, -1, "",
                                         Sqlite.Orders_by.DEFAULT, -1);

        myRunsInterval  = SqliteRunInterval.SelectRuns(true, mySession.UniqueID, -1, "");
        myReactionTimes = SqliteReactionTime.SelectReactionTimes(true, mySession.UniqueID, -1, "",
                                                                 Sqlite.Orders_by.DEFAULT, -1);

        myPulses = SqlitePulse.SelectPulses(true, mySession.UniqueID, -1);
        myMCs    = SqliteMultiChronopic.SelectTests(true, mySession.UniqueID, -1);

        Sqlite.Close();         // ------------------------------
    }
예제 #8
0
파일: main.cs 프로젝트: GNOME/chronojump
    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 ++;
    }
예제 #9
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;
        }
    }
예제 #10
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 ++;
    }