createTable() protected method

protected createTable ( string tableName ) : void
tableName string
return void
Exemplo n.º 1
0
    public static bool ConvertToLastChronojumpDBVersion()
    {
        LogB.SQL("SelectChronojumpProfile ()");

        //if(checkIfIsSqlite2())
        //	convertSqlite2To3();

        addChronopicPortNameIfNotExists();

        currentVersion = SqlitePreferences.Select("databaseVersion");

        //LogB.SQL("lastDB: {0}", Convert.ToDouble(lastChronojumpDatabaseVersion));
        //LogB.SQL("currentVersion: {0}", Convert.ToDouble(currentVersion));

        bool returnSoftwareIsNew = true; //-1 if software is too old for database (moved db to other computer)
        if(
                Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) ==
                Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion)))
            LogB.SQL("Database is already latest version");
        else if(
                Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) <
                Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion))) {
            LogB.SQL("User database newer than program, need to update software");
            returnSoftwareIsNew = false;
        } else {
            LogB.Warning("Old database, need to convert");
            LogB.Warning("db version: " + currentVersion);

            bool needToConvertPersonToSport = false;
            bool jumpFallAsDouble = false;
         		bool runAndRunIntervalInitialSpeedAdded = false;
            bool addedRSA = false;

            SqliteJumpRj sqliteJumpRjObject = new SqliteJumpRj();
            SqliteRunInterval sqliteRunIntervalObject = new SqliteRunInterval();
            SqliteReactionTime sqliteReactionTimeObject = new SqliteReactionTime();
            SqlitePulse sqlitePulseObject = new SqlitePulse();
            SqliteMultiChronopic sqliteMultiChronopicObject = new SqliteMultiChronopic();
            SqlitePersonSessionOld sqlitePersonSessionOldObject = new SqlitePersonSessionOld();

            if(currentVersion == "0.41") {
                Sqlite.Open();

                //SqlitePulse.createTable(Constants.PulseTable);
                sqlitePulseObject.createTable(Constants.PulseTable);
                SqlitePulseType.createTablePulseType();
                SqlitePulseType.initializeTablePulseType();

                SqlitePreferences.Update ("databaseVersion", "0.42", true);
                LogB.SQL("Converted DB to 0.42 (added pulse and pulseType tables)");

                Sqlite.Close();
                currentVersion = "0.42";
            }

            if(currentVersion == "0.42") {
                Sqlite.Open();
                SqlitePulseType.Insert ("Free:-1:-1:free PulseStep mode", true);
                SqlitePreferences.Insert ("language", "es-ES");
                SqlitePreferences.Update ("databaseVersion", "0.43", true);
                LogB.SQL("Converted DB to 0.43 (added 'free' pulseType & language peference)");
                Sqlite.Close();
                currentVersion = "0.43";
            }

            if(currentVersion == "0.43") {
                Sqlite.Open();
                SqlitePreferences.Insert ("showQIndex", "False");
                SqlitePreferences.Insert ("showDjIndex", "False");
                SqlitePreferences.Update ("databaseVersion", "0.44", true);
                LogB.SQL("Converted DB to 0.44 (added showQIndex, showDjIndex)");
                Sqlite.Close();
                currentVersion = "0.44";
            }

            if(currentVersion == "0.44") {
                Sqlite.Open();
                SqlitePreferences.Insert ("allowFinishRjAfterTime", "True");
                SqlitePreferences.Update ("databaseVersion", "0.45", true);
                LogB.SQL("Converted DB to 0.45 (added allowFinishRjAfterTime)");
                Sqlite.Close();
                currentVersion = "0.45";
            }

            if(currentVersion == "0.45") {
                Sqlite.Open();
                SqliteJumpType.JumpTypeInsert ("Free:1:0:Free jump", true);
                SqlitePreferences.Update ("databaseVersion", "0.46", true);
                LogB.SQL("Added Free jump type");
                Sqlite.Close();
                currentVersion = "0.46";
            }

            if(currentVersion == "0.46") {
                Sqlite.Open();

                //SqliteReactionTime.createTable(Constants.ReactionTimeTable);
                sqliteReactionTimeObject.createTable(Constants.ReactionTimeTable);

                SqlitePreferences.Update ("databaseVersion", "0.47", true);
                LogB.SQL("Added reaction time table");
                Sqlite.Close();
                currentVersion = "0.47";
            }

            if(currentVersion == "0.47") {
                Sqlite.Open();

                //SqliteJumpRj.createTable(Constants.TempJumpRjTable);
                sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);
                //SqliteRun.intervalCreateTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

                SqlitePreferences.Update ("databaseVersion", "0.48", true);
                LogB.SQL("created tempJumpReactive and tempRunInterval tables");
                Sqlite.Close();
                currentVersion = "0.48";
            }

            if(currentVersion == "0.48") {
                Sqlite.Open();

                SqliteJumpType.JumpTypeInsert ("Rocket:1:0:Rocket jump", true);

                string [] iniRunTypes = {
                    "Agility-20Yard:18.28:20Yard Agility test",
                    "Agility-505:10:505 Agility test",
                    "Agility-Illinois:60:Illinois Agility test",
                    "Agility-Shuttle-Run:40:Shuttle Run Agility test",
                    "Agility-ZigZag:17.6:ZigZag Agility test"
                };
                foreach(string myString in iniRunTypes) {
                    string [] s = myString.Split(new char[] {':'});
                    RunType type = new RunType();
                    type.Name = s[0];
                    type.Distance = Convert.ToDouble(s[1]);
                    type.Description = s[2];
                    SqliteRunType.Insert(type, Constants.RunTypeTable, true);
                }

                SqliteEvent.createGraphLinkTable();
                SqliteRunType.AddGraphLinksRunSimpleAgility();

                SqlitePreferences.Update ("databaseVersion", "0.49", true);
                LogB.SQL("Added graphLinkTable, added Rocket jump and 5 agility tests: (20Yard, 505, Illinois, Shuttle-Run & ZigZag. Added graphs pof the 5 agility tests)");

                Sqlite.Close();
                currentVersion = "0.49";
            }

            if(currentVersion == "0.49") {
                Sqlite.Open();
                SqliteJumpType.Update ("SJ+", "SJl");
                SqliteJumpType.Update ("CMJ+", "CJl");
                SqliteJumpType.Update ("ABK+", "ABKl");
                SqliteJump.ChangeWeightToL();
                SqliteJumpType.AddGraphLinks();
                SqliteJumpType.AddGraphLinksRj();
                SqlitePreferences.Update ("databaseVersion", "0.50", true);
                LogB.SQL("changed SJ+ to SJl, same for CMJ+ and ABK+, added jump and jumpRj graph links");
                Sqlite.Close();
                currentVersion = "0.50";
            }

            if(currentVersion == "0.50") {
                Sqlite.Open();
                SqliteRunType.AddGraphLinksRunSimple();
                SqliteRunIntervalType.AddGraphLinksRunInterval();
                SqlitePreferences.Update ("databaseVersion", "0.51", true);
                LogB.SQL("added graphLinks for run simple and interval");
                Sqlite.Close();
                currentVersion = "0.51";
            }

            if(currentVersion == "0.51") {
                Sqlite.Open();
                SqliteJumpType.Update ("CJl", "CMJl");
                SqliteEvent.GraphLinkInsert (Constants.JumpTable, "CMJl", "jump_cmj_l.png", true);
                SqliteEvent.GraphLinkInsert (Constants.JumpTable, "ABKl", "jump_abk_l.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.52", true);
                LogB.SQL("added graphLinks for cmj_l and abk_l, fixed CMJl name");
                Sqlite.Close();
                currentVersion = "0.52";
            }

            if(currentVersion == "0.52") {
                Sqlite.Open();
                sqlitePersonSessionOldObject.createTable ();
                Sqlite.Close();

                //this needs the dbCon closed
                SqlitePersonSessionOld.moveOldTableToNewTable ();

                Sqlite.Open();
                SqlitePreferences.Update ("databaseVersion", "0.53", true);
                Sqlite.Close();

                LogB.SQL("created weightSession table. Moved person weight data to weightSession table for each session that has performed");
                currentVersion = "0.53";
            }

            if(currentVersion == "0.53") {
                Sqlite.Open();

                SqliteSport.createTable();
                SqliteSport.initialize();
                SqliteSpeciallity.createTable();
                SqliteSpeciallity.initialize();

                //SqlitePersonOld.convertTableToSportRelated ();
                needToConvertPersonToSport = true;

                SqlitePreferences.Update ("databaseVersion", "0.54", true);
                Sqlite.Close();

                LogB.SQL("Created sport tables. Added sport data, speciallity and level of practice to person table");
                currentVersion = "0.54";
            }
            if(currentVersion == "0.54") {
                Sqlite.Open();

                SqliteSpeciallity.InsertUndefined(true);

                SqlitePreferences.Update ("databaseVersion", "0.55", true);
                Sqlite.Close();

                LogB.SQL("Added undefined to speciallity table");
                currentVersion = "0.55";
            }
            if(currentVersion == "0.55") {
                Sqlite.Open();

                SqliteSessionOld.convertTableAddingSportStuff();

                SqlitePreferences.Update ("databaseVersion", "0.56", true);
                Sqlite.Close();

                LogB.SQL("Added session default sport stuff into session table");
                currentVersion = "0.56";
            }
            if(currentVersion == "0.56") {
                Sqlite.Open();

                //jump and jumpRj
                ArrayList arrayAngleAndSimulated = new ArrayList(1);
                arrayAngleAndSimulated.Add("-1"); //angle
                arrayAngleAndSimulated.Add("-1"); //simulated

                //run and runInterval
                ArrayList arraySimulatedAndInitialSpeed = new ArrayList(1);
                arraySimulatedAndInitialSpeed.Add("-1"); //simulated
                arraySimulatedAndInitialSpeed.Add("0"); //initial speed

                //others
                ArrayList arraySimulated = new ArrayList(1);
                arraySimulated.Add("-1"); //simulated

                conversionRateTotal = 9;
                conversionRate = 1;
                convertTables(new SqliteJump(), Constants.JumpTable, 9, arrayAngleAndSimulated, false);
                conversionRate ++;
                convertTables(new SqliteJumpRj(), Constants.JumpRjTable, 16, arrayAngleAndSimulated, false);
                conversionRate ++;
                convertTables(new SqliteRun(), Constants.RunTable, 7, arraySimulated, false);
                conversionRate ++;
                convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 11, arraySimulated, false);
                runAndRunIntervalInitialSpeedAdded = true;

                conversionRate ++;
                convertTables(new SqliteReactionTime(), Constants.ReactionTimeTable, 6, arraySimulated, false);
                conversionRate ++;
                convertTables(new SqlitePulse(), Constants.PulseTable, 8, arraySimulated, false);

                //reacreate temp tables for have also the simulated column
                conversionRate ++;
                Sqlite.dropTable(Constants.TempJumpRjTable);
                sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);
                Sqlite.dropTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

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

                conversionRate ++;
                int columnsBefore = 10;
                bool putDescriptionInMiddle = false;
                ArrayList arrayPersonRaceCountryServerID = new ArrayList(1);
                if(needToConvertPersonToSport) {
                    columnsBefore = 7;
                    arrayPersonRaceCountryServerID.Add(Constants.SportUndefinedID.ToString());
                    arrayPersonRaceCountryServerID.Add(Constants.SpeciallityUndefinedID.ToString());
                    arrayPersonRaceCountryServerID.Add(Constants.LevelUndefinedID.ToString());
                    putDescriptionInMiddle = true;
                }
                arrayPersonRaceCountryServerID.Add(Constants.RaceUndefinedID.ToString());
                arrayPersonRaceCountryServerID.Add(Constants.CountryUndefinedID.ToString());
                arrayPersonRaceCountryServerID.Add(Constants.ServerUndefinedID.ToString());
                convertTables(new SqlitePersonOld(), Constants.PersonOldTable, columnsBefore, arrayPersonRaceCountryServerID, putDescriptionInMiddle);

                SqlitePreferences.Update ("databaseVersion", "0.57", true);
                Sqlite.Close();

                LogB.SQL("Added simulated column to each event table on client. Added to person: race, country, serverUniqueID. Convert to sport related done here if needed. Added also run and runInterval initial speed");
                currentVersion = "0.57";
            }
            if(currentVersion == "0.57") {
                Sqlite.Open();

                //check if "republic" is in country table
                if(SqliteCountry.TableHasOldRepublicStuff()){
                    conversionRateTotal = 4;
                    conversionRate = 1;
                    Sqlite.dropTable(Constants.CountryTable);
                    conversionRate ++;
                    SqliteCountry.createTable();
                    conversionRate ++;
                    SqliteCountry.initialize();
                    conversionRate ++;
                    LogB.SQL("Countries without kingdom or republic (except when needed)");
                }

                SqlitePreferences.Update ("databaseVersion", "0.58", true);
                Sqlite.Close();

                currentVersion = "0.58";
            }

            if(currentVersion == "0.58") {
                Sqlite.Open();
                conversionRateTotal = 2;
                conversionRate = 1;
                SqlitePreferences.Insert ("showAngle", "False");
                alterTableColumn(new SqliteJump(), Constants.JumpTable, 11);

                //jump fall is also converted to double (don't need to do at conversion to 0.76)
                jumpFallAsDouble = true;

                SqlitePreferences.Update ("databaseVersion", "0.59", true);
                LogB.SQL("Converted DB to 0.59 (added 'showAngle' to preferences, changed angle on jump to double)");
                conversionRate = 2;
                Sqlite.Close();
                currentVersion = "0.59";
            }

            if(currentVersion == "0.59") {
                Sqlite.Open();
                conversionRateTotal = 4;

                conversionRate = 1;
                SqlitePreferences.Insert ("volumeOn", "True");
                SqlitePreferences.Insert ("evaluatorServerID", "-1");

                conversionRate = 2;

                int columnsBefore = 8;
                ArrayList arrayServerID = new ArrayList(1);
                arrayServerID.Add(Constants.ServerUndefinedID.ToString());
                convertTables(new SqliteSession(), Constants.SessionTable, columnsBefore, arrayServerID, false);

                conversionRate = 3;
                SqliteEvent.SimulatedConvertToNegative();

                SqlitePreferences.Update ("databaseVersion", "0.60", true);
                LogB.SQL("Converted DB to 0.60 (added volumeOn and evaluatorServerID to preferences. session has now serverUniqueID. Simulated now are -1, because 0 is real and positive is serverUniqueID)");

                conversionRate = 4;
                Sqlite.Close();
                currentVersion = "0.60";
            }

            if(currentVersion == "0.60") {
                Sqlite.Open();
                conversionRateTotal = 3;
                conversionRate = 1;

                ArrayList arrayDS = new ArrayList(1);
                arrayDS.Add("-1"); //distancesString
                convertTables(new SqliteRunIntervalType(), Constants.RunIntervalTypeTable, 7, arrayDS, false);

                conversionRate = 2;

                //SqliteRunType.RunIntervalTypeInsert ("MTGUG:-1:true:3:false:Modified time Getup and Go test:1-7-19", true);
                RunType type = new RunType();
                type.Name = "MTGUG";
                type.Distance = -1;
                type.TracksLimited = true;
                type.FixedValue = 3;
                type.Unlimited = false;
                type.Description = "Modified time Getup and Go test";
                type.DistancesString = "1-7-19";
                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);

                SqlitePreferences.Update ("databaseVersion", "0.61", true);
                LogB.SQL("Converted DB to 0.61 added RunIntervalType distancesString (now we van have interval tests with different distances of tracks). Added MTGUG");

                conversionRate = 3;
                Sqlite.Close();
                currentVersion = "0.61";
            }
            if(currentVersion == "0.61") {
                Sqlite.Open();
                SqliteJumpType.JumpRjTypeInsert ("RJ(hexagon):1:0:1:18:Reactive Jump on a hexagon until three full revolutions are done", true);
                SqlitePreferences.Update ("databaseVersion", "0.62", true);
                LogB.SQL("Converted DB to 0.62 added hexagon");
                Sqlite.Close();
                currentVersion = "0.62";
            }
            if(currentVersion == "0.62") {
                Sqlite.Open();
                SqlitePreferences.Insert ("versionAvailable", "");
                SqlitePreferences.Update ("databaseVersion", "0.63", true);
                LogB.SQL("Converted DB to 0.63 (added 'versionAvailable' to preferences)");
                Sqlite.Close();
                currentVersion = "0.63";
            }
            if(currentVersion == "0.63") {
                Sqlite.Open();

                RunType type = new RunType();
                type.Name = "Margaria";
                type.Distance = 0;
                type.Description = "Margaria-Kalamen test";
                SqliteRunType.Insert(type, Constants.RunTypeTable, true);

                SqliteEvent.GraphLinkInsert (Constants.RunTable, "Margaria", "margaria.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.64", true);

                LogB.SQL("Converted DB to 0.64 (added margaria test)");
                Sqlite.Close();
                currentVersion = "0.64";
            }
            if(currentVersion == "0.64") {
                Sqlite.Open();

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

                SqlitePreferences.Update ("databaseVersion", "0.65", true);

                LogB.SQL("Converted DB to 0.65 (added Sevaluator on client)");
                Sqlite.Close();
                currentVersion = "0.65";
            }
            if(currentVersion == "0.65") {
                Sqlite.Open();
                //now runAnalysis is a multiChronopic event
                //SqliteJumpType.JumpRjTypeInsert ("RunAnalysis:0:0:1:-1:Run between two photocells recording contact and flight times in contact platform/s. Until finish button is clicked.", true);

                SqlitePreferences.Update ("databaseVersion", "0.66", true);

                //LogB.SQL("Converted DB to 0.66 (added RunAnalysis Reactive jump)");
                LogB.SQL("Converted DB to 0.66 (done nothing)");
                Sqlite.Close();
                currentVersion = "0.66";
            }
            if(currentVersion == "0.66") {
                Sqlite.Open();
                SqliteJumpType.JumpTypeInsert ("TakeOff:0:0:Take off", true);
                SqliteJumpType.JumpTypeInsert ("TakeOffWeight:0:0:Take off with weight", true);

                SqlitePreferences.Update ("databaseVersion", "0.67", true);

                LogB.SQL("Converted DB to 0.67 (added TakeOff jumps)");
                Sqlite.Close();
                currentVersion = "0.67";
            }
            if(currentVersion == "0.67") {
                Sqlite.Open();
                sqliteMultiChronopicObject.createTable(Constants.MultiChronopicTable);

                SqlitePreferences.Update ("databaseVersion", "0.68", true);

                LogB.SQL("Converted DB to 0.68 (added multiChronopic tests table)");
                Sqlite.Close();
                currentVersion = "0.68";
            }
            if(currentVersion == "0.68") {
                Sqlite.Open();

                RunType type = new RunType();
                type.Name = "Gesell-DBT";
                type.Distance = 2.5;
                type.Description = "Gesell Dynamic Balance Test";
                SqliteRunType.Insert(type, Constants.RunTypeTable, true);

                SqliteEvent.GraphLinkInsert (Constants.RunTable, "Gesell-DBT", "gesell_dbt.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.69", true);

                LogB.SQL("Converted DB to 0.69 (added Gesell-DBT test)");
                Sqlite.Close();
                currentVersion = "0.69";
            }
            if(currentVersion == "0.69") {
                Sqlite.Open();
                SqlitePreferences.Insert ("showPower", "True");
                SqlitePreferences.Update ("databaseVersion", "0.70", true);
                LogB.SQL("Converted DB to 0.70 (added showPower)");
                Sqlite.Close();
                currentVersion = "0.70";
            }
            if(currentVersion == "0.70") {
                Sqlite.Open();

                SqlitePersonSessionNotUpload.CreateTable();

                SqlitePreferences.Update ("databaseVersion", "0.71", true);

                LogB.SQL("Converted DB to 0.71 (created personNotUploadTable on client)");
                Sqlite.Close();
                currentVersion = "0.71";
            }
            if(currentVersion == "0.71") {
                Sqlite.Open();

                datesToYYYYMMDD();

                SqlitePreferences.Update ("databaseVersion", "0.72", true);

                LogB.SQL("Converted DB to 0.72 (dates to YYYY-MM-DD)");
                Sqlite.Close();
                currentVersion = "0.72";
            }
            if(currentVersion == "0.72") {
                Sqlite.Open();

                deleteOrphanedPersonsOld();

                SqlitePreferences.Update ("databaseVersion", "0.73", true);

                LogB.SQL("Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table)");
                Sqlite.Close();
                currentVersion = "0.73";
            }
            if(currentVersion == "0.73") {
                //dbcon open laters on mid convertDJinDJna()

                convertDJInDJna();

                SqlitePreferences.Update ("databaseVersion", "0.74", true);

                LogB.SQL("Converted DB to 0.74 (All DJ converted to DJna)");
                Sqlite.Close();
                currentVersion = "0.74";
            }
            if(currentVersion == "0.74") {
                conversionRateTotal = 3;
                conversionRate = 1;

                Sqlite.Open();

                convertTables(new SqlitePersonOld(), Constants.PersonOldTable, 13, new ArrayList(), false);
                conversionRate++;

                convertTables(new SqlitePersonSessionOld(), Constants.PersonSessionOldWeightTable, 4, new ArrayList(), false);

                SqlitePreferences.Update ("databaseVersion", "0.75", true);
                conversionRate++;

                LogB.SQL("Converted DB to 0.75 (person, and personSessionWeight have height and weight as double)");
                Sqlite.Close();
                currentVersion = "0.75";
            }
            if(currentVersion == "0.75") {
                conversionRateTotal = 3;
                conversionRate = 1;
                Sqlite.Open();

                if(!jumpFallAsDouble)
                    alterTableColumn(new SqliteJump(), Constants.JumpTable, 11);

                conversionRate++;

                alterTableColumn(new SqliteJumpRj(), Constants.JumpRjTable, 18);

                SqlitePreferences.Update ("databaseVersion", "0.76", true);
                conversionRate++;

                LogB.SQL("Converted DB to 0.76 (jump & jumpRj falls as double)");
                Sqlite.Close();
                currentVersion = "0.76";
            }
            if(currentVersion == "0.76") {
                Sqlite.Open();

                convertPersonAndPersonSessionTo77();
                SqlitePreferences.Update ("databaseVersion", "0.77", true);
                LogB.SQL("Converted DB to 0.77 (person77, personSession77)");

                Sqlite.Close();
                currentVersion = "0.77";
            }
            if(currentVersion == "0.77") {
                Sqlite.Open();

                SqliteJumpType.UpdateOther ("weight", Constants.TakeOffWeightName, "1");

                Random rnd = new Random();
                string machineID = rnd.Next().ToString();
                SqlitePreferences.Insert ("machineID", machineID);

                SqlitePreferences.Update ("databaseVersion", "0.78", true);
                LogB.SQL("Converted DB to 0.78 (Added machineID to preferences, takeOffWeight has no weight in db conversions since 0.66)");

                Sqlite.Close();
                currentVersion = "0.78";
            }
            if(currentVersion == "0.78") {
                Sqlite.Open();

                SqlitePreferences.Insert ("multimediaStorage", Constants.MultimediaStorage.BYSESSION.ToString());

                SqlitePreferences.Update ("databaseVersion", "0.79", true);
                LogB.SQL("Converted DB to 0.79 (Added multimediaStorage structure id)");

                Sqlite.Close();
                currentVersion = "0.79";
            }
            if(currentVersion == "0.79") {
                Sqlite.Open();

         			if(! runAndRunIntervalInitialSpeedAdded) {
                    ArrayList myArray = new ArrayList(1);
                    myArray.Add("0"); //initial speed

                    conversionRateTotal = 3;
                    conversionRate = 1;
                    convertTables(new SqliteRun(), Constants.RunTable, 8, myArray, false);
                    conversionRate ++;
                    convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 12, myArray, false);
                    conversionRate ++;
                    LogB.SQL("Converted DB to 0.80 Added run and runInterval initial speed (if not done in 0.56 conversion)");
                }

                SqlitePreferences.Update ("databaseVersion", "0.80", true);

                Sqlite.Close();
                currentVersion = "0.80";
            }
            if(currentVersion == "0.80") {
                Sqlite.Open();

                ArrayList myArray = new ArrayList(1);
                myArray.Add("0"); //initial speed

                conversionRateTotal = 2;
                conversionRate = 1;
                Sqlite.dropTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);
                conversionRate ++;
                LogB.SQL("Converted DB to 0.81 Added tempRunInterval initial speed");

                SqlitePreferences.Update ("databaseVersion", "0.81", true);

                Sqlite.Close();
                currentVersion = "0.81";
            }
            if(currentVersion == "0.81") {
                Sqlite.Open();
                conversionRateTotal = 2;

                conversionRate = 1;
                SqlitePreferences.Insert ("videoOn", "False");
                conversionRate = 2;
                LogB.SQL("Converted DB to 0.82 Added videoOn");

                SqlitePreferences.Update ("databaseVersion", "0.82", true);

                Sqlite.Close();
                currentVersion = "0.82";
            }
            if(currentVersion == "0.82") {
                Sqlite.Open();
                conversionRateTotal = 2;

                conversionRate = 1;
                SqliteEncoder.createTableEncoder();
                SqliteEncoder.createTableEncoderExercise();
                SqliteEncoder.initializeTableEncoderExercise();
                conversionRate = 2;
                LogB.SQL("Created encoder tables.");

                SqlitePreferences.Update ("databaseVersion", "0.83", true);
                Sqlite.Close();
                currentVersion = "0.83";
            }
            if(currentVersion == "0.83") {
                Sqlite.Open();

                RunType type = new RunType();
                type.Name = "RSA 8-4-R3-5";
                type.Distance = -1;
                type.TracksLimited = true;
                type.FixedValue = 4;
                type.Unlimited = false;
                type.Description = "RSA testing";
                type.DistancesString = "8-4-R3-5";
                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);

                LogB.SQL("Added 1st RSA test.");

                SqlitePreferences.Update ("databaseVersion", "0.84", true);
                Sqlite.Close();
                currentVersion = "0.84";
            }
            if(currentVersion == "0.84") {
                Sqlite.Open();
                SqliteJumpType.JumpTypeInsert ("slCMJ:1:0:Single-leg CMJ jump", true);

                SqlitePreferences.Update ("databaseVersion", "0.85", true);

                LogB.SQL("Converted DB to 0.85 (added slCMJ jump)");
                Sqlite.Close();
                currentVersion = "0.85";
            }
            if(currentVersion == "0.85") {
                Sqlite.Open();
                LogB.SQL("Converted DB to 0.86 videoOn: TRUE");

                SqlitePreferences.Update("videoOn", "True", true);
                SqlitePreferences.Update ("databaseVersion", "0.86", true);

                Sqlite.Close();
                currentVersion = "0.86";
            }
            if(currentVersion == "0.86") {
                Sqlite.Open();
                LogB.SQL("Added run speed start preferences on sqlite");

                SqlitePreferences.Insert ("runSpeedStartArrival", "True");
                SqlitePreferences.Insert ("runISpeedStartArrival", "True");
                SqlitePreferences.Update ("databaseVersion", "0.87", true);

                Sqlite.Close();
                currentVersion = "0.87";
            }
            if(currentVersion == "0.87") {
                //delete runInterval type
                SqliteRunIntervalType.Delete("RSA 8-4-R3-5");

                //delete all it's runs
                Sqlite.Open();
                dbcmd.CommandText = "DELETE FROM " + Constants.RunIntervalTable +
                    " WHERE type == \"RSA 8-4-R3-5\"";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();

                //add know RSAs
                SqliteRunIntervalType.addRSA();
                addedRSA = true;

                LogB.SQL("Deleted fake RSA test and added known RSA tests.");

                SqlitePreferences.Update ("databaseVersion", "0.88", true);
                Sqlite.Close();

                currentVersion = "0.88";
            }
            if(currentVersion == "0.88") {
                Sqlite.Open();

                SqliteEncoder.addEncoderFreeExercise();

                LogB.SQL("Added encoder exercise: Free");

                SqlitePreferences.Update ("databaseVersion", "0.89", true);
                Sqlite.Close();

                currentVersion = "0.89";
            }
            if(currentVersion == "0.89") {
                Sqlite.Open();

                SqlitePreferences.Insert("encoderPropulsive", "True");
                SqlitePreferences.Insert("encoderSmoothEccCon", "0.6");
                SqlitePreferences.Insert("encoderSmoothCon", "0.7");
                LogB.SQL("Preferences added propulsive and encoder smooth");

                SqlitePreferences.Update ("databaseVersion", "0.90", true);
                Sqlite.Close();

                currentVersion = "0.90";
            }
            if(currentVersion == "0.90") {
                Sqlite.Open();

                SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "", "");
                LogB.SQL("Encoder Squat 75% -> 100%");

                SqlitePreferences.Update ("databaseVersion", "0.91", true);
                Sqlite.Close();

                currentVersion = "0.91";
            }
            if(currentVersion == "0.91") {
                Sqlite.Open();

                SqlitePreferences.Insert("videoDevice", "0");
                LogB.SQL("Added videoDevice to preferences");

                SqlitePreferences.Update ("databaseVersion", "0.92", true);
                Sqlite.Close();

                currentVersion = "0.92";
            }
            if(currentVersion == "0.92") {
                Sqlite.Open();

                SqliteEncoder.UpdateExercise(true, "Bench press", "Bench press", 0, "weight bar", "","0.185");
                SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "","0.31");
                LogB.SQL("Added speed1RM on encoder exercise");

                SqlitePreferences.Update ("databaseVersion", "0.93", true);
                Sqlite.Close();

                currentVersion = "0.93";
            }
            if(currentVersion == "0.93") {
                Sqlite.Open();

                SqliteEncoder.createTable1RM();
                LogB.SQL("Added encoder1RM table");

                SqlitePreferences.Update ("databaseVersion", "0.94", true);
                Sqlite.Close();

                currentVersion = "0.94";
            }
            if(currentVersion == "0.94") {
                Sqlite.Open();

                SqlitePreferences.Insert ("encoder1RMMethod",
                        Constants.Encoder1RMMethod.WEIGHTED2.ToString());
                LogB.SQL("Added encoder1RMMethod");

                SqlitePreferences.Update ("databaseVersion", "0.95", true);
                Sqlite.Close();

                currentVersion = "0.95";
            }
            if(currentVersion == "0.95") {
                Sqlite.Open();

                Update(true, Constants.EncoderTable, "future3", "", Constants.EncoderConfigurationNames.LINEAR.ToString(),
                        "signalOrCurve", "signal");
                Update(true, Constants.EncoderTable, "future3", "0", Constants.EncoderConfigurationNames.LINEAR.ToString(),
                        "signalOrCurve", "signal");
                Update(true, Constants.EncoderTable, "future3", "1", Constants.EncoderConfigurationNames.LINEARINVERTED.ToString(),
                        "signalOrCurve", "signal");

                LogB.SQL("Encoder signal future3 three modes");

                SqlitePreferences.Update ("databaseVersion", "0.96", true);
                Sqlite.Close();

                currentVersion = "0.96";
            }
            if(currentVersion == "0.96") {
                Sqlite.Open();

                SqlitePreferences.Insert ("inertialmomentum", "0.01");
                LogB.SQL("Added inertialmomentum in preferences");

                SqlitePreferences.Update ("databaseVersion", "0.97", true);
                Sqlite.Close();

                currentVersion = "0.97";
            }
            if(currentVersion == "0.97") {
                Sqlite.Open();

                Update(true, Constants.EncoderTable, "laterality", "both", "RL", "", "");
                Update(true, Constants.EncoderTable, "laterality", "Both", "RL", "", "");
                Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Both"), "RL", "", "");
                Update(true, Constants.EncoderTable, "laterality", "right", "R", "", "");
                Update(true, Constants.EncoderTable, "laterality", "Right", "R", "", "");
                Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Right"), "R", "", "");
                Update(true, Constants.EncoderTable, "laterality", "left", "L", "", "");
                Update(true, Constants.EncoderTable, "laterality", "Left", "L", "", "");
                Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Left"), "L", "", "");
                LogB.SQL("Fixed encoder laterality");

                SqlitePreferences.Update ("databaseVersion", "0.98", true);
                Sqlite.Close();

                currentVersion = "0.98";
            }
            if(currentVersion == "0.98") {
                Sqlite.Open();

                ArrayList array = SqliteOldConvert.EncoderSelect098(true,-1,-1,-1,"all",false);

                conversionRateTotal = array.Count;

                dropTable(Constants.EncoderTable);

                //CAUTION: do like this and never do createTableEncoder,
                //because method will change in the future and will break updates
                SqliteOldConvert.createTableEncoder99();

                int count = 1;
                foreach( EncoderSQL098 es in array) {
                    conversionRate = count;

                    //do not use SqliteEncoder.Insert because that method maybe changes in the future,
                    //and here we need to do a conversion that works from 0.98 to 0.99
                    dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable +
                        " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " +
                        "signalOrCurve, filename, url, time, minHeight, smooth, description, status, " +
                        "videoURL, mode, inertiaMomentum, diameter, future1, future2, future3)" +
                        " VALUES (" + es.uniqueID + ", " +
                        es.personID + ", " + es.sessionID + ", " +
                        es.exerciseID + ", \"" + es.eccon + "\", \"" +
                        es.laterality + "\", \"" + es.extraWeight + "\", \"" +
                        es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
                        es.url + "\", " + es.time + ", " + es.minHeight + ", " +
                        Util.ConvertToPoint(es.smooth) + ", \"" + es.description + "\", \"" +
                        es.future1 + "\", \"" + es.future2 + "\", \"LINEAR\", " + //status, videoURL, mode
                        "0, 0, \"\", \"\", \"\")"; //inertiaMomentum, diameter, future1, 2, 3
                    LogB.SQL(dbcmd.CommandText.ToString());
                    dbcmd.ExecuteNonQuery();
                    count ++;
                }

                conversionRate = count;
                LogB.SQL("Encoder table improved");
                SqlitePreferences.Update ("databaseVersion", "0.99", true);
                Sqlite.Close();

                currentVersion = "0.99";
            }
            if(currentVersion == "0.99") {
                Sqlite.Open();

                SqliteEncoder.putEncoderExerciseAnglesAt90();
                SqliteEncoder.addEncoderJumpExercise();
                SqliteEncoder.addEncoderInclinedExercises();

                LogB.SQL("Added Free and inclinedExercises");
                SqlitePreferences.Update ("databaseVersion", "1.00", true);
                Sqlite.Close();

                currentVersion = "1.00";
            }
            if(currentVersion == "1.00") {
                Sqlite.Open();

                SqlitePreferences.Insert ("CSVExportDecimalSeparator", Util.GetDecimalSeparatorFromLocale());

                LogB.SQL("Added export to CSV configuration on preferences");
                SqlitePreferences.Update ("databaseVersion", "1.01", true);
                Sqlite.Close();

                currentVersion = "1.01";
            }
            if(currentVersion == "1.01") {
                Sqlite.Open();

                RunType type = new RunType("Agility-T-Test");
                SqliteRunType.Insert(type, Constants.RunTypeTable, true);
                type = new RunType("Agility-3L3R");
                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);

                LogB.SQL("Added Agility Tests: Agility-T-Test, Agility-3l3R");
                SqlitePreferences.Update ("databaseVersion", "1.02", true);
                Sqlite.Close();

                currentVersion = "1.02";
            }
            if(currentVersion == "1.02") {
                Sqlite.Open();

                DeleteFromName(true, Constants.EncoderExerciseTable, "Inclinated plane Custom");
                SqliteEncoder.removeEncoderExerciseAngles();

                LogB.SQL("Updated encoder exercise, angle is now on encoder configuration");
                SqlitePreferences.Update ("databaseVersion", "1.03", true);
                Sqlite.Close();

                currentVersion = "1.03";
            }
            if(currentVersion == "1.03") {
                Sqlite.Open();

                ArrayList array = SqliteOldConvert.EncoderSelect103(true,-1,-1,-1,"all",false);

                conversionRateTotal = array.Count;

                dropTable(Constants.EncoderTable);

                //CAUTION: do like this and never do createTableEncoder,
                //because method will change in the future and will break updates
                SqliteOldConvert.createTableEncoder104();

                //in this conversion put this as default for all SQL rows
                EncoderConfiguration econf = new EncoderConfiguration();

                int count = 1;
                foreach(EncoderSQL103 es in array) {
                    conversionRate = count;

                    //do not use SqliteEncoder.Insert because that method maybe changes in the future,
                    //and here we need to do a conversion that works from 1.03 to 1.04
                    dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable +
                        " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " +
                        "signalOrCurve, filename, url, time, minHeight, description, status, " +
                        "videoURL, encoderConfiguration, future1, future2, future3)" +
                        " VALUES (" + es.uniqueID + ", " +
                        es.personID + ", " + es.sessionID + ", " +
                        es.exerciseID + ", \"" + es.eccon + "\", \"" +
                        es.laterality + "\", \"" + es.extraWeight + "\", \"" +
                        es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
                        es.url + "\", " + es.time + ", " + es.minHeight + ", \"" + es.description + "\", \"" +
                        es.status + "\", \"" + es.videoURL + "\", \"" +
                        econf.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\", \"" + //in this conversion put this as default for all SQL rows.
                        es.future1 + "\", \"" + es.future2 + "\", \"" + es.future3 + "\")";
                    LogB.SQL(dbcmd.CommandText.ToString());
                    dbcmd.ExecuteNonQuery();
                    count ++;
                }

                conversionRate = count;
                LogB.SQL("Encoder table improved");
                SqlitePreferences.Update ("databaseVersion", "1.04", true);
                Sqlite.Close();

                currentVersion = "1.04";
            }
            if(currentVersion == "1.04") {
                Sqlite.Open();

                dbcmd.CommandText = "DELETE FROM " + Constants.EncoderTable +
                    " WHERE encoderConfiguration LIKE \"%INERTIAL%\" AND " +
                    " signalOrCurve == \"curve\"";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();

                LogB.SQL("Removed inertial curves, because sign was not checked on 1.04 when saving curves");
                SqlitePreferences.Update ("databaseVersion", "1.05", true);
                Sqlite.Close();

                currentVersion = "1.05";
            }
            if(currentVersion == "1.05") {
                Sqlite.Open();

                SqliteEncoder.createTableEncoderSignalCurve();

                ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1, Constants.EncoderGI.ALL,
                        -1, "signal", EncoderSQL.Eccons.ALL, false, false);
                ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1, Constants.EncoderGI.ALL,
                        -1, "curve", EncoderSQL.Eccons.ALL, false, false);
                int signalID;
                conversionRateTotal = signals.Count;
                conversionRate = 1;
                //in 1.05 curves can be related to signals only by date
                foreach(EncoderSQL s in signals) {
                    conversionRate ++;
                    conversionSubRateTotal = curves.Count;
                    conversionSubRate = 1;

                    //needed to know if there are duplicates
                    ArrayList curvesStored = new ArrayList();

                    foreach(EncoderSQL c in curves) {
                        conversionSubRate ++;
                        if(s.GetDate(false) == c.GetDate(false) && s.eccon == c.eccon) {
                            int msCentral = SqliteEncoder.FindCurveInSignal(
                                    s.GetFullURL(false), c.GetFullURL(false));

                            signalID = Convert.ToInt32(s.uniqueID);
                            if(msCentral == -1)
                                signalID = -1; //mark as an orphaned curve (without signal)

                            /*
                             * about duplicated curves from 1.05 and before:
                             * There are two kind of duplicates, in both, eccon is the same, and they overlap.
                             *
                             * Overlapings situations:
                             * - they are saved two times (same msCentral), or
                             * - they are saved two times with different smoothing (different msCentral)
                             *
                             * from now on (1.06) there will be no more duplicates
                             * about the old duplicated curves, is the user problem,
                             * except the curves of the first kind, that we know exactly that they are duplicated
                             */

                            //curves come sorted by UniqueID DESC (selected with orderIDascendent = false)
                            //if does not exist: insert in encoderSignalCurve
                            bool exists = false;
                            foreach(int ms in curvesStored)
                                if(ms == msCentral)
                                    exists = true;
                            if(exists) {
                                //delete this (newer will not be deleted)
                                Sqlite.Delete(true,
                                        Constants.EncoderTable, Convert.ToInt32(c.uniqueID));
                            } else {
                                curvesStored.Add(msCentral);
                                SqliteEncoder.SignalCurveInsert(true,
                                        signalID, Convert.ToInt32(c.uniqueID), msCentral);
                            }
                        }
                    }
                }

                conversionSubRate ++;
                conversionRate ++;
                LogB.SQL("Curves are now linked to signals");
                SqlitePreferences.Update ("databaseVersion", "1.06", true);

                Sqlite.Close();
                currentVersion = "1.06";
            }
            if(currentVersion == "1.06") {
                Sqlite.Open();

                Update(true, Constants.GraphLinkTable, "graphFileName", "jump_dj.png", "jump_dj_a.png",
                        "eventName", "DJa");

                LogB.SQL("Added jump_dj_a.png");
                SqlitePreferences.Update ("databaseVersion", "1.07", true);
                Sqlite.Close();

                currentVersion = "1.07";
            }
            if(currentVersion == "1.07") {
                Sqlite.Open();

                LogB.SQL("Added translate statistics graph option to preferences");

                SqlitePreferences.Insert ("RGraphsTranslate", "True");
                SqlitePreferences.Update ("databaseVersion", "1.08", true);
                Sqlite.Close();

                currentVersion = "1.08";
            }
            if(currentVersion == "1.08") {
                Sqlite.Open();

                LogB.SQL("Added option on preferences to useHeightsOnJumpIndexes (default) or not");

                SqlitePreferences.Insert ("useHeightsOnJumpIndexes", "True");
                SqlitePreferences.Update ("databaseVersion", "1.09", true);
                Sqlite.Close();

                currentVersion = "1.09";
            }
            if(currentVersion == "1.09") {
                Sqlite.Open();

                LogB.SQL("Added RSA RAST on runType");

                /*
                 * addRSA() contains RAST since 1.10
                 * database started at 1.10 or more contains RAST
                 * database started before 0.87 adds RAST on the addRSA() method
                 * satabase started after 0.87 adds RAST now
                 */
                if(! addedRSA) {
                    RunType type = new RunType();
                    type.Name = "RSA RAST 35, R10 x 6";
                    type.Distance = -1;
                    type.TracksLimited = true;
                    type.FixedValue = 12;
                    type.Unlimited = false;
                    type.Description = "RSA RAST Test";
                    type.DistancesString = "35-R10";

                    SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);
                    addedRSA = true;
                }

                SqlitePreferences.Update ("databaseVersion", "1.10", true);
                Sqlite.Close();

                currentVersion = "1.10";
            }
            if(currentVersion == "1.10") {
                Sqlite.Open();

                LogB.SQL("Added option on autosave curves on capture (all/bestmeanpower/none)");

                SqlitePreferences.Insert ("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.BEST.ToString());
                SqlitePreferences.Update ("databaseVersion", "1.11", true);
                Sqlite.Close();

                currentVersion = "1.11";
            }
            if(currentVersion == "1.11") {
                Sqlite.Open();

                LogB.SQL("URLs from absolute to relative)");

                SqliteOldConvert.ConvertAbsolutePathsToRelative();
                SqlitePreferences.Update ("databaseVersion", "1.12", true);
                Sqlite.Close();

                currentVersion = "1.12";
            }
            if(currentVersion == "1.12") {
                Sqlite.Open();

                LogB.SQL("Added ExecuteAuto table");

                SqliteExecuteAuto.createTableExecuteAuto();
                SqlitePreferences.Update ("databaseVersion", "1.13", true);
                Sqlite.Close();

                currentVersion = "1.13";
            }
            if(currentVersion == "1.13") {
                Sqlite.Open();

                LogB.SQL("slCMJ -> slCMJleft, slCMJright");

                SqliteOldConvert.slCMJDivide();
                SqlitePreferences.Update ("databaseVersion", "1.14", true);
                Sqlite.Close();

                currentVersion = "1.14";
            }
            if(currentVersion == "1.14") {
                Sqlite.Open();

                LogB.SQL("added Chronojump profile and bilateral profile");

                SqliteExecuteAuto.addChronojumpProfileAndBilateral();
                SqlitePreferences.Update ("databaseVersion", "1.15", true);
                Sqlite.Close();

                currentVersion = "1.15";
            }
            if(currentVersion == "1.15") {
                Sqlite.Open();

                LogB.SQL("Cyprus moved to Europe");

                Update(true, Constants.CountryTable, "continent", "Asia", "Europe", "code", "CYP");
                SqlitePreferences.Update ("databaseVersion", "1.16", true);
                Sqlite.Close();

                currentVersion = "1.16";
            }
            if(currentVersion == "1.16") {
                Sqlite.Open();

                LogB.SQL("Deleting Max jump");

                Update(true, Constants.JumpTable, "type", "Max", "Free", "", "");
                DeleteFromName(true, Constants.JumpTypeTable, "Max");
                SqlitePreferences.Update ("databaseVersion", "1.17", true);
                Sqlite.Close();

                currentVersion = "1.17";
            }
            if(currentVersion == "1.17") {
                Sqlite.Open();

                LogB.SQL("Deleted Negative runInterval runs (bug from last version)");

                SqliteOldConvert.deleteNegativeRuns();
                SqlitePreferences.Update ("databaseVersion", "1.18", true);
                Sqlite.Close();

                currentVersion = "1.18";
            }
            if(currentVersion == "1.18") {
                LogB.SQL("Preferences deleted showHeight, added showStiffness");

                Sqlite.Open();
                DeleteFromName(true, Constants.PreferencesTable, "showHeight");
                SqlitePreferences.Insert ("showStiffness", "True");
                SqlitePreferences.Update ("databaseVersion", "1.19", true);
                Sqlite.Close();

                currentVersion = "1.19";
            }
            if(currentVersion == "1.19") {
                LogB.SQL("Preferences: added user email");

                Sqlite.Open();
                SqlitePreferences.Insert ("email", "");
                SqlitePreferences.Update ("databaseVersion", "1.20", true);
                Sqlite.Close();

                currentVersion = "1.20";
            }
            if(currentVersion == "1.20") {
                LogB.SQL("Fixing loosing of encoder videoURL after recalculate");

                Sqlite.Open();

                SqliteOldConvert.ConvertAbsolutePathsToRelative(); //videoURLs got absolute again
                SqliteOldConvert.FixLostVideoURLAfterEncoderRecalculate();

                SqlitePreferences.Update ("databaseVersion", "1.21", true);
                Sqlite.Close();

                currentVersion = "1.21";
            }
            if(currentVersion == "1.21") {
                LogB.SQL("Encoder laterality in english again");

                Sqlite.Open();

                if(Catalog.GetString("RL") != "RL")
                    Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("RL"), "RL", "", "");

                if(Catalog.GetString("R") != "R")
                    Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("R"), "R", "", "");

                if(Catalog.GetString("L") != "L")
                    Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("L"), "L", "", "");

                SqlitePreferences.Update ("databaseVersion", "1.22", true);
                Sqlite.Close();

                currentVersion = "1.22";
            }
            if(currentVersion == "1.22") {
                LogB.SQL("Added encoder configuration");

                Sqlite.Open();
                SqlitePreferences.Insert ("encoderConfiguration", new EncoderConfiguration().ToStringOutput(EncoderConfiguration.Outputs.SQL));
                SqlitePreferences.Update ("databaseVersion", "1.23", true);
                Sqlite.Close();

                currentVersion = "1.23";
            }

            // ----------------------------------------------
            // IMPORTANT HERE IS DEFINED sqliteOpened == true
            // this is useful to not do more than 50 SQL open close
            // that crashes mac (Linux 100)
            // ----------------------------------------------
            LogB.SQL("Leaving Sqlite opened before DB updates");

            Sqlite.Open(); //------------------------------------------------

            if(currentVersion == "1.23") {
                LogB.SQL("Delete runISpeedStartArrival and add 4 double contacts configs");

                DeleteFromName(true, Constants.PreferencesTable, "runISpeedStartArrival");
                SqlitePreferences.Insert ("runDoubleContactsMode", Constants.DoubleContact.LAST.ToString());
                SqlitePreferences.Insert ("runDoubleContactsMS", "1000");
                SqlitePreferences.Insert ("runIDoubleContactsMode", Constants.DoubleContact.AVERAGE.ToString());
                SqlitePreferences.Insert ("runIDoubleContactsMS", "1000");

                currentVersion = updateVersion("1.24");
            }
            if(currentVersion == "1.24") {
                LogB.SQL("Language defaults to (empty string), means detected");
                SqlitePreferences.Update("language", "", true);

                currentVersion = updateVersion("1.25");
            }
            if(currentVersion == "1.25") {
                LogB.SQL("Changed Inclinated to Inclined");
                Update(true, Constants.EncoderExerciseTable, "name", "Inclinated plane", "Inclined plane", "", "");
                Update(true, Constants.EncoderExerciseTable, "name", "Inclinated plane BW", "Inclined plane BW", "", "");

                currentVersion = updateVersion("1.26");
            }
            if(currentVersion == "1.26") {
                LogB.SQL("Changing runDoubleContactsMS and runIDoubleContactsMS from 1000ms to 300ms");
                SqlitePreferences.Update("runDoubleContactsMS", "300", true);
                SqlitePreferences.Update("runIDoubleContactsMS", "300", true);

                currentVersion = updateVersion("1.27");
            }
            if(currentVersion == "1.27") {
                LogB.SQL("Changed encoderAutoSaveCurve BESTMEANPOWER to BEST");
                Update(true, Constants.PreferencesTable, "value", "BESTMEANPOWER", "BEST", "name", "encoderAutoSaveCurve");

                currentVersion = updateVersion("1.28");
            }
            if(currentVersion == "1.28") {
                LogB.SQL("Changed reaction time rows have reactionTime as default value");
                Update(true, Constants.ReactionTimeTable, "type", "", "reactionTime", "", "");

                currentVersion = updateVersion("1.29");
            }
            if(currentVersion == "1.29") {
                LogB.SQL("Added SIMULATED session");

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

                currentVersion = updateVersion("1.30");
            }
            if(currentVersion == "1.30") {
                LogB.SQL("Insert encoderCaptureCheckFullyExtended and ...Value at preferences");

                SqlitePreferences.Insert ("encoderCaptureCheckFullyExtended", "True");
                SqlitePreferences.Insert ("encoderCaptureCheckFullyExtendedValue", "4");

                currentVersion = updateVersion("1.31");
            }
            if(currentVersion == "1.31") {
                LogB.SQL("encoderCaptureOptionsWin -> preferences");

                SqlitePreferences.Insert ("encoderCaptureTime", "60");
                SqlitePreferences.Insert ("encoderCaptureInactivityEndTime", "3");
                SqlitePreferences.Insert ("encoderCaptureMainVariable", Constants.EncoderVariablesCapture.MeanPower.ToString());
                SqlitePreferences.Insert ("encoderCaptureMinHeightGravitatory", "20");
                SqlitePreferences.Insert ("encoderCaptureMinHeightInertial", "5");
                SqlitePreferences.Insert ("encoderShowStartAndDuration", "False");

                currentVersion = updateVersion("1.32");
            }
            if(currentVersion == "1.32") {
                LogB.SQL("Added chronopicRegister table");

                SqliteChronopicRegister.createTableChronopicRegister();

                currentVersion = updateVersion("1.33");
            }
            if(currentVersion == "1.33") {
                LogB.SQL("Added thresholdJumps, thresholdRuns, thresholdOther to preferences");

                SqlitePreferences.Insert ("thresholdJumps", "50");
                SqlitePreferences.Insert ("thresholdRuns", "10");
                SqlitePreferences.Insert ("thresholdOther", "50");

                currentVersion = updateVersion("1.34");
            }

            // --- add more updates here

            // --- end of update, close DB

            LogB.SQL("Closing Sqlite after DB updates");

            Sqlite.Close(); //------------------------------------------------
        }

        //if changes are made here, remember to change also in CreateTables()
        //remember to change also the databaseVersion below

        return returnSoftwareIsNew;
    }
Exemplo n.º 2
0
    public static bool ConvertToLastChronojumpDBVersion()
    {
        //if(checkIfIsSqlite2())
        //	convertSqlite2To3();

        addChronopicPortNameIfNotExists();

        currentVersion = SqlitePreferences.Select("databaseVersion");

        //Log.WriteLine("lastDB: {0}", Convert.ToDouble(lastChronojumpDatabaseVersion));
        //Log.WriteLine("currentVersion: {0}", Convert.ToDouble(currentVersion));

        bool returnSoftwareIsNew = true; //-1 if software is too old for database (moved db to other computer)
        if(
                Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) ==
                Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion)))
            Log.WriteLine("Database is already latest version");
        else if(
                Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) <
                Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion))) {
            Log.WriteLine("User database newer than program, need to update software");
            returnSoftwareIsNew = false;
        } else {
            Log.WriteLine("Old database, need to convert");
            Log.WriteLine("db version: " + currentVersion);

            bool needToConvertPersonToSport = false;
            bool jumpFallAsDouble = false;
         		bool runAndRunIntervalInitialSpeedAdded = false;

            SqliteJumpRj sqliteJumpRjObject = new SqliteJumpRj();
            SqliteRunInterval sqliteRunIntervalObject = new SqliteRunInterval();
            SqliteReactionTime sqliteReactionTimeObject = new SqliteReactionTime();
            SqlitePulse sqlitePulseObject = new SqlitePulse();
            SqliteMultiChronopic sqliteMultiChronopicObject = new SqliteMultiChronopic();
            SqlitePersonSessionOld sqlitePersonSessionOldObject = new SqlitePersonSessionOld();

            if(currentVersion == "0.41") {
                dbcon.Open();

                //SqlitePulse.createTable(Constants.PulseTable);
                sqlitePulseObject.createTable(Constants.PulseTable);
                SqlitePulseType.createTablePulseType();
                SqlitePulseType.initializeTablePulseType();

                SqlitePreferences.Update ("databaseVersion", "0.42", true);
                Log.WriteLine("Converted DB to 0.42 (added pulse and pulseType tables)");

                dbcon.Close();
                currentVersion = "0.42";
            }

            if(currentVersion == "0.42") {
                dbcon.Open();
                SqlitePulseType.Insert ("Free:-1:-1:free PulseStep mode", true);
                SqlitePreferences.Insert ("language", "es-ES");
                SqlitePreferences.Update ("databaseVersion", "0.43", true);
                Log.WriteLine("Converted DB to 0.43 (added 'free' pulseType & language peference)");
                dbcon.Close();
                currentVersion = "0.43";
            }

            if(currentVersion == "0.43") {
                dbcon.Open();
                SqlitePreferences.Insert ("showQIndex", "False");
                SqlitePreferences.Insert ("showDjIndex", "False");
                SqlitePreferences.Update ("databaseVersion", "0.44", true);
                Log.WriteLine("Converted DB to 0.44 (added showQIndex, showDjIndex)");
                dbcon.Close();
                currentVersion = "0.44";
            }

            if(currentVersion == "0.44") {
                dbcon.Open();
                SqlitePreferences.Insert ("allowFinishRjAfterTime", "True");
                SqlitePreferences.Update ("databaseVersion", "0.45", true);
                Log.WriteLine("Converted DB to 0.45 (added allowFinishRjAfterTime)");
                dbcon.Close();
                currentVersion = "0.45";
            }

            if(currentVersion == "0.45") {
                dbcon.Open();
                SqliteJumpType.JumpTypeInsert ("Free:1:0:Free jump", true);
                SqlitePreferences.Update ("databaseVersion", "0.46", true);
                Log.WriteLine("Added Free jump type");
                dbcon.Close();
                currentVersion = "0.46";
            }

            if(currentVersion == "0.46") {
                dbcon.Open();

                //SqliteReactionTime.createTable(Constants.ReactionTimeTable);
                sqliteReactionTimeObject.createTable(Constants.ReactionTimeTable);

                SqlitePreferences.Update ("databaseVersion", "0.47", true);
                Log.WriteLine("Added reaction time table");
                dbcon.Close();
                currentVersion = "0.47";
            }

            if(currentVersion == "0.47") {
                dbcon.Open();

                //SqliteJumpRj.createTable(Constants.TempJumpRjTable);
                sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);
                //SqliteRun.intervalCreateTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

                SqlitePreferences.Update ("databaseVersion", "0.48", true);
                Log.WriteLine("created tempJumpReactive and tempRunInterval tables");
                dbcon.Close();
                currentVersion = "0.48";
            }

            if(currentVersion == "0.48") {
                dbcon.Open();

                SqliteJumpType.JumpTypeInsert ("Rocket:1:0:Rocket jump", true);

                string [] iniRunTypes = {
                    "Agility-20Yard:18.28:20Yard Agility test",
                    "Agility-505:10:505 Agility test",
                    "Agility-Illinois:60:Illinois Agility test",
                    "Agility-Shuttle-Run:40:Shuttle Run Agility test",
                    "Agility-ZigZag:17.6:ZigZag Agility test"
                };
                foreach(string myString in iniRunTypes) {
                    string [] s = myString.Split(new char[] {':'});
                    RunType type = new RunType();
                    type.Name = s[0];
                    type.Distance = Convert.ToDouble(s[1]);
                    type.Description = s[2];
                    SqliteRunType.Insert(type, Constants.RunTypeTable, true);
                }

                SqliteEvent.createGraphLinkTable();
                SqliteRunType.AddGraphLinksRunSimpleAgility();

                SqlitePreferences.Update ("databaseVersion", "0.49", true);
                Log.WriteLine("Added graphLinkTable, added Rocket jump and 5 agility tests: (20Yard, 505, Illinois, Shuttle-Run & ZigZag. Added graphs pof the 5 agility tests)");

                dbcon.Close();
                currentVersion = "0.49";
            }

            if(currentVersion == "0.49") {
                dbcon.Open();
                SqliteJumpType.Update ("SJ+", "SJl");
                SqliteJumpType.Update ("CMJ+", "CJl");
                SqliteJumpType.Update ("ABK+", "ABKl");
                SqliteJump.ChangeWeightToL();
                SqliteJumpType.AddGraphLinks();
                SqliteJumpType.AddGraphLinksRj();
                SqlitePreferences.Update ("databaseVersion", "0.50", true);
                Log.WriteLine("changed SJ+ to SJl, same for CMJ+ and ABK+, added jump and jumpRj graph links");
                dbcon.Close();
                currentVersion = "0.50";
            }

            if(currentVersion == "0.50") {
                dbcon.Open();
                SqliteRunType.AddGraphLinksRunSimple();
                SqliteRunIntervalType.AddGraphLinksRunInterval();
                SqlitePreferences.Update ("databaseVersion", "0.51", true);
                Log.WriteLine("added graphLinks for run simple and interval");
                dbcon.Close();
                currentVersion = "0.51";
            }

            if(currentVersion == "0.51") {
                dbcon.Open();
                SqliteJumpType.Update ("CJl", "CMJl");
                SqliteEvent.GraphLinkInsert (Constants.JumpTable, "CMJl", "jump_cmj_l.png", true);
                SqliteEvent.GraphLinkInsert (Constants.JumpTable, "ABKl", "jump_abk_l.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.52", true);
                Log.WriteLine("added graphLinks for cmj_l and abk_l, fixed CMJl name");
                dbcon.Close();
                currentVersion = "0.52";
            }

            if(currentVersion == "0.52") {
                dbcon.Open();
                sqlitePersonSessionOldObject.createTable ();
                dbcon.Close();

                //this needs the dbCon closed
                SqlitePersonSessionOld.moveOldTableToNewTable ();

                dbcon.Open();
                SqlitePreferences.Update ("databaseVersion", "0.53", true);
                dbcon.Close();

                Log.WriteLine("created weightSession table. Moved person weight data to weightSession table for each session that has performed");
                currentVersion = "0.53";
            }

            if(currentVersion == "0.53") {
                dbcon.Open();

                SqliteSport.createTable();
                SqliteSport.initialize();
                SqliteSpeciallity.createTable();
                SqliteSpeciallity.initialize();

                //SqlitePersonOld.convertTableToSportRelated ();
                needToConvertPersonToSport = true;

                SqlitePreferences.Update ("databaseVersion", "0.54", true);
                dbcon.Close();

                Log.WriteLine("Created sport tables. Added sport data, speciallity and level of practice to person table");
                currentVersion = "0.54";
            }
            if(currentVersion == "0.54") {
                dbcon.Open();

                SqliteSpeciallity.InsertUndefined(true);

                SqlitePreferences.Update ("databaseVersion", "0.55", true);
                dbcon.Close();

                Log.WriteLine("Added undefined to speciallity table");
                currentVersion = "0.55";
            }
            if(currentVersion == "0.55") {
                dbcon.Open();

                SqliteSessionOld.convertTableAddingSportStuff();

                SqlitePreferences.Update ("databaseVersion", "0.56", true);
                dbcon.Close();

                Log.WriteLine("Added session default sport stuff into session table");
                currentVersion = "0.56";
            }
            if(currentVersion == "0.56") {
                dbcon.Open();

                //jump and jumpRj
                ArrayList arrayAngleAndSimulated = new ArrayList(1);
                arrayAngleAndSimulated.Add("-1"); //angle
                arrayAngleAndSimulated.Add("-1"); //simulated

                //run and runInterval
                ArrayList arraySimulatedAndInitialSpeed = new ArrayList(1);
                arraySimulatedAndInitialSpeed.Add("-1"); //simulated
                arraySimulatedAndInitialSpeed.Add("0"); //initial speed

                //others
                ArrayList arraySimulated = new ArrayList(1);
                arraySimulated.Add("-1"); //simulated

                conversionRateTotal = 9;
                conversionRate = 1;
                convertTables(new SqliteJump(), Constants.JumpTable, 9, arrayAngleAndSimulated, false);
                conversionRate ++;
                convertTables(new SqliteJumpRj(), Constants.JumpRjTable, 16, arrayAngleAndSimulated, false);
                conversionRate ++;
                convertTables(new SqliteRun(), Constants.RunTable, 7, arraySimulated, false);
                conversionRate ++;
                convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 11, arraySimulated, false);
                runAndRunIntervalInitialSpeedAdded = true;

                conversionRate ++;
                convertTables(new SqliteReactionTime(), Constants.ReactionTimeTable, 6, arraySimulated, false);
                conversionRate ++;
                convertTables(new SqlitePulse(), Constants.PulseTable, 8, arraySimulated, false);

                //reacreate temp tables for have also the simulated column
                conversionRate ++;
                Sqlite.dropTable(Constants.TempJumpRjTable);
                sqliteJumpRjObject.createTable(Constants.TempJumpRjTable);
                Sqlite.dropTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);

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

                conversionRate ++;
                int columnsBefore = 10;
                bool putDescriptionInMiddle = false;
                ArrayList arrayPersonRaceCountryServerID = new ArrayList(1);
                if(needToConvertPersonToSport) {
                    columnsBefore = 7;
                    arrayPersonRaceCountryServerID.Add(Constants.SportUndefinedID.ToString());
                    arrayPersonRaceCountryServerID.Add(Constants.SpeciallityUndefinedID.ToString());
                    arrayPersonRaceCountryServerID.Add(Constants.LevelUndefinedID.ToString());
                    putDescriptionInMiddle = true;
                }
                arrayPersonRaceCountryServerID.Add(Constants.RaceUndefinedID.ToString());
                arrayPersonRaceCountryServerID.Add(Constants.CountryUndefinedID.ToString());
                arrayPersonRaceCountryServerID.Add(Constants.ServerUndefinedID.ToString());
                convertTables(new SqlitePersonOld(), Constants.PersonOldTable, columnsBefore, arrayPersonRaceCountryServerID, putDescriptionInMiddle);

                SqlitePreferences.Update ("databaseVersion", "0.57", true);
                dbcon.Close();

                Log.WriteLine("Added simulated column to each event table on client. Added to person: race, country, serverUniqueID. Convert to sport related done here if needed. Added also run and runInterval initial speed");
                currentVersion = "0.57";
            }
            if(currentVersion == "0.57") {
                dbcon.Open();

                //check if "republic" is in country table
                if(SqliteCountry.TableHasOldRepublicStuff()){
                    conversionRateTotal = 4;
                    conversionRate = 1;
                    Sqlite.dropTable(Constants.CountryTable);
                    conversionRate ++;
                    SqliteCountry.createTable();
                    conversionRate ++;
                    SqliteCountry.initialize();
                    conversionRate ++;
                    Log.WriteLine("Countries without kingdom or republic (except when needed)");
                }

                SqlitePreferences.Update ("databaseVersion", "0.58", true);
                dbcon.Close();

                currentVersion = "0.58";
            }

            if(currentVersion == "0.58") {
                dbcon.Open();
                conversionRateTotal = 2;
                conversionRate = 1;
                SqlitePreferences.Insert ("showAngle", "False");
                alterTableColumn(new SqliteJump(), Constants.JumpTable, 11);

                //jump fall is also converted to double (don't need to do at conversion to 0.76)
                jumpFallAsDouble = true;

                SqlitePreferences.Update ("databaseVersion", "0.59", true);
                Log.WriteLine("Converted DB to 0.59 (added 'showAngle' to preferences, changed angle on jump to double)");
                conversionRate = 2;
                dbcon.Close();
                currentVersion = "0.59";
            }

            if(currentVersion == "0.59") {
                dbcon.Open();
                conversionRateTotal = 4;

                conversionRate = 1;
                SqlitePreferences.Insert ("volumeOn", "True");
                SqlitePreferences.Insert ("evaluatorServerID", "-1");

                conversionRate = 2;

                int columnsBefore = 8;
                ArrayList arrayServerID = new ArrayList(1);
                arrayServerID.Add(Constants.ServerUndefinedID.ToString());
                convertTables(new SqliteSession(), Constants.SessionTable, columnsBefore, arrayServerID, false);

                conversionRate = 3;
                SqliteEvent.SimulatedConvertToNegative();

                SqlitePreferences.Update ("databaseVersion", "0.60", true);
                Log.WriteLine("Converted DB to 0.60 (added volumeOn and evaluatorServerID to preferences. session has now serverUniqueID. Simulated now are -1, because 0 is real and positive is serverUniqueID)");

                conversionRate = 4;
                dbcon.Close();
                currentVersion = "0.60";
            }

            if(currentVersion == "0.60") {
                dbcon.Open();
                conversionRateTotal = 3;
                conversionRate = 1;

                ArrayList arrayDS = new ArrayList(1);
                arrayDS.Add("-1"); //distancesString
                convertTables(new SqliteRunIntervalType(), Constants.RunIntervalTypeTable, 7, arrayDS, false);

                conversionRate = 2;

                //SqliteRunType.RunIntervalTypeInsert ("MTGUG:-1:true:3:false:Modified time Getup and Go test:1-7-19", true);
                RunType type = new RunType();
                type.Name = "MTGUG";
                type.Distance = -1;
                type.TracksLimited = true;
                type.FixedValue = 3;
                type.Unlimited = false;
                type.Description = "Modified time Getup and Go test";
                type.DistancesString = "1-7-19";
                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);

                SqlitePreferences.Update ("databaseVersion", "0.61", true);
                Log.WriteLine("Converted DB to 0.61 added RunIntervalType distancesString (now we van have interval tests with different distances of tracks). Added MTGUG");

                conversionRate = 3;
                dbcon.Close();
                currentVersion = "0.61";
            }
            if(currentVersion == "0.61") {
                dbcon.Open();
                SqliteJumpType.JumpRjTypeInsert ("RJ(hexagon):1:0:1:18:Reactive Jump on a hexagon until three full revolutions are done", true);
                SqlitePreferences.Update ("databaseVersion", "0.62", true);
                Log.WriteLine("Converted DB to 0.62 added hexagon");
                dbcon.Close();
                currentVersion = "0.62";
            }
            if(currentVersion == "0.62") {
                dbcon.Open();
                SqlitePreferences.Insert ("versionAvailable", "");
                SqlitePreferences.Update ("databaseVersion", "0.63", true);
                Log.WriteLine("Converted DB to 0.63 (added 'versionAvailable' to preferences)");
                dbcon.Close();
                currentVersion = "0.63";
            }
            if(currentVersion == "0.63") {
                dbcon.Open();

                RunType type = new RunType();
                type.Name = "Margaria";
                type.Distance = 0;
                type.Description = "Margaria-Kalamen test";
                SqliteRunType.Insert(type, Constants.RunTypeTable, true);

                SqliteEvent.GraphLinkInsert (Constants.RunTable, "Margaria", "margaria.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.64", true);

                Log.WriteLine("Converted DB to 0.64 (added margaria test)");
                dbcon.Close();
                currentVersion = "0.64";
            }
            if(currentVersion == "0.64") {
                dbcon.Open();

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

                SqlitePreferences.Update ("databaseVersion", "0.65", true);

                Log.WriteLine("Converted DB to 0.65 (added Sevaluator on client)");
                dbcon.Close();
                currentVersion = "0.65";
            }
            if(currentVersion == "0.65") {
                dbcon.Open();
                //now runAnalysis is a multiChronopic event
                //SqliteJumpType.JumpRjTypeInsert ("RunAnalysis:0:0:1:-1:Run between two photocells recording contact and flight times in contact platform/s. Until finish button is clicked.", true);

                SqlitePreferences.Update ("databaseVersion", "0.66", true);

                //Log.WriteLine("Converted DB to 0.66 (added RunAnalysis Reactive jump)");
                Log.WriteLine("Converted DB to 0.66 (done nothing)");
                dbcon.Close();
                currentVersion = "0.66";
            }
            if(currentVersion == "0.66") {
                dbcon.Open();
                SqliteJumpType.JumpTypeInsert ("TakeOff:0:0:Take off", true);
                SqliteJumpType.JumpTypeInsert ("TakeOffWeight:0:0:Take off with weight", true);

                SqlitePreferences.Update ("databaseVersion", "0.67", true);

                Log.WriteLine("Converted DB to 0.67 (added TakeOff jumps)");
                dbcon.Close();
                currentVersion = "0.67";
            }
            if(currentVersion == "0.67") {
                dbcon.Open();
                sqliteMultiChronopicObject.createTable(Constants.MultiChronopicTable);

                SqlitePreferences.Update ("databaseVersion", "0.68", true);

                Log.WriteLine("Converted DB to 0.68 (added multiChronopic tests table)");
                dbcon.Close();
                currentVersion = "0.68";
            }
            if(currentVersion == "0.68") {
                dbcon.Open();

                RunType type = new RunType();
                type.Name = "Gesell-DBT";
                type.Distance = 2.5;
                type.Description = "Gesell Dynamic Balance Test";
                SqliteRunType.Insert(type, Constants.RunTypeTable, true);

                SqliteEvent.GraphLinkInsert (Constants.RunTable, "Gesell-DBT", "gesell_dbt.png", true);
                SqlitePreferences.Update ("databaseVersion", "0.69", true);

                Log.WriteLine("Converted DB to 0.69 (added Gesell-DBT test)");
                dbcon.Close();
                currentVersion = "0.69";
            }
            if(currentVersion == "0.69") {
                dbcon.Open();
                SqlitePreferences.Insert ("showPower", "True");
                SqlitePreferences.Update ("databaseVersion", "0.70", true);
                Log.WriteLine("Converted DB to 0.70 (added showPower)");
                dbcon.Close();
                currentVersion = "0.70";
            }
            if(currentVersion == "0.70") {
                dbcon.Open();

                SqlitePersonSessionNotUpload.CreateTable();

                SqlitePreferences.Update ("databaseVersion", "0.71", true);

                Log.WriteLine("Converted DB to 0.71 (created personNotUploadTable on client)");
                dbcon.Close();
                currentVersion = "0.71";
            }
            if(currentVersion == "0.71") {
                dbcon.Open();

                datesToYYYYMMDD();

                SqlitePreferences.Update ("databaseVersion", "0.72", true);

                Log.WriteLine("Converted DB to 0.72 (dates to YYYY-MM-DD)");
                dbcon.Close();
                currentVersion = "0.72";
            }
            if(currentVersion == "0.72") {
                dbcon.Open();

                deleteOrphanedPersonsOld();

                SqlitePreferences.Update ("databaseVersion", "0.73", true);

                Log.WriteLine("Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table)");
                dbcon.Close();
                currentVersion = "0.73";
            }
            if(currentVersion == "0.73") {
                //dbcon open laters on mid convertDJinDJna()

                convertDJInDJna();

                SqlitePreferences.Update ("databaseVersion", "0.74", true);

                Log.WriteLine("Converted DB to 0.74 (All DJ converted to DJna)");
                dbcon.Close();
                currentVersion = "0.74";
            }
            if(currentVersion == "0.74") {
                conversionRateTotal = 3;
                conversionRate = 1;

                dbcon.Open();

                convertTables(new SqlitePersonOld(), Constants.PersonOldTable, 13, new ArrayList(), false);
                conversionRate++;

                convertTables(new SqlitePersonSessionOld(), Constants.PersonSessionOldWeightTable, 4, new ArrayList(), false);

                SqlitePreferences.Update ("databaseVersion", "0.75", true);
                conversionRate++;

                Log.WriteLine("Converted DB to 0.75 (person, and personSessionWeight have height and weight as double)");
                dbcon.Close();
                currentVersion = "0.75";
            }
            if(currentVersion == "0.75") {
                conversionRateTotal = 3;
                conversionRate = 1;
                dbcon.Open();

                if(!jumpFallAsDouble)
                    alterTableColumn(new SqliteJump(), Constants.JumpTable, 11);

                conversionRate++;

                alterTableColumn(new SqliteJumpRj(), Constants.JumpRjTable, 18);

                SqlitePreferences.Update ("databaseVersion", "0.76", true);
                conversionRate++;

                Log.WriteLine("Converted DB to 0.76 (jump & jumpRj falls as double)");
                dbcon.Close();
                currentVersion = "0.76";
            }
            if(currentVersion == "0.76") {
                dbcon.Open();

                convertPersonAndPersonSessionTo77();
                SqlitePreferences.Update ("databaseVersion", "0.77", true);
                Log.WriteLine("Converted DB to 0.77 (person77, personSession77)");

                dbcon.Close();
                currentVersion = "0.77";
            }
            if(currentVersion == "0.77") {
                dbcon.Open();

                SqliteJumpType.UpdateOther ("weight", Constants.TakeOffWeightName, "1");

                Random rnd = new Random();
                string machineID = rnd.Next().ToString();
                SqlitePreferences.Insert ("machineID", machineID);

                SqlitePreferences.Update ("databaseVersion", "0.78", true);
                Log.WriteLine("Converted DB to 0.78 (Added machineID to preferences, takeOffWeight has no weight in db conversions since 0.66)");

                dbcon.Close();
                currentVersion = "0.78";
            }
            if(currentVersion == "0.78") {
                dbcon.Open();

                SqlitePreferences.Insert ("multimediaStorage", Constants.MultimediaStorage.BYSESSION.ToString());

                SqlitePreferences.Update ("databaseVersion", "0.79", true);
                Log.WriteLine("Converted DB to 0.79 (Added multimediaStorage structure id)");

                dbcon.Close();
                currentVersion = "0.79";
            }
            if(currentVersion == "0.79") {
                dbcon.Open();

         			if(! runAndRunIntervalInitialSpeedAdded) {
                    ArrayList myArray = new ArrayList(1);
                    myArray.Add("0"); //initial speed

                    conversionRateTotal = 3;
                    conversionRate = 1;
                    convertTables(new SqliteRun(), Constants.RunTable, 8, myArray, false);
                    conversionRate ++;
                    convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 12, myArray, false);
                    conversionRate ++;
                    Log.WriteLine("Converted DB to 0.80 Added run and runInterval initial speed (if not done in 0.56 conversion)");
                }

                SqlitePreferences.Update ("databaseVersion", "0.80", true);

                dbcon.Close();
                currentVersion = "0.80";
            }
            if(currentVersion == "0.80") {
                dbcon.Open();

                ArrayList myArray = new ArrayList(1);
                myArray.Add("0"); //initial speed

                conversionRateTotal = 2;
                conversionRate = 1;
                Sqlite.dropTable(Constants.TempRunIntervalTable);
                sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable);
                conversionRate ++;
                Log.WriteLine("Converted DB to 0.81 Added tempRunInterval initial speed");

                SqlitePreferences.Update ("databaseVersion", "0.81", true);

                dbcon.Close();
                currentVersion = "0.81";
            }
            if(currentVersion == "0.81") {
                dbcon.Open();
                conversionRateTotal = 2;

                conversionRate = 1;
                SqlitePreferences.Insert ("videoOn", "False");
                conversionRate = 2;
                Log.WriteLine("Converted DB to 0.82 Added videoOn");

                SqlitePreferences.Update ("databaseVersion", "0.82", true);

                dbcon.Close();
                currentVersion = "0.82";
            }
            if(currentVersion == "0.82") {
                dbcon.Open();
                conversionRateTotal = 2;

                conversionRate = 1;
                SqliteEncoder.createTableEncoder();
                SqliteEncoder.createTableEncoderExercise();
                SqliteEncoder.initializeTableEncoderExercise();
                conversionRate = 2;
                Log.WriteLine("Created encoder tables.");

                SqlitePreferences.Update ("databaseVersion", "0.83", true);
                dbcon.Close();
                currentVersion = "0.83";
            }
            if(currentVersion == "0.83") {
                dbcon.Open();

                RunType type = new RunType();
                type.Name = "RSA 8-4-R3-5";
                type.Distance = -1;
                type.TracksLimited = true;
                type.FixedValue = 4;
                type.Unlimited = false;
                type.Description = "RSA testing";
                type.DistancesString = "8-4-R3-5";
                SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true);

                Log.WriteLine("Added 1st RSA test.");

                SqlitePreferences.Update ("databaseVersion", "0.84", true);
                dbcon.Close();
                currentVersion = "0.84";
            }
        }

        //if changes are made here, remember to change also in CreateTables()
        //remember to change also the databaseVersion below

        return returnSoftwareIsNew;
    }
Exemplo n.º 3
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.º 4
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 ++;
    }