示例#1
0
    public PrepareEventGraphReactionTime(double time, int sessionID, int personID, string table, string type)
    {
        Sqlite.Open();

        //obtain data
        rtsAtSQL = SqliteReactionTime.SelectReactionTimes(true, sessionID, personID, type,
                                                          Sqlite.Orders_by.ID_DESC, 10); //select only last 10

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

        personMINAtSQL = SqliteSession.SelectMINEventsOfAType(
            true, sessionID, personID, table, type, "time");
        sessionMINAtSQL = SqliteSession.SelectMINEventsOfAType(
            true, sessionID, -1, table, type, "time");

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

        Sqlite.Close();

        this.time = time;
    }
        public void InsertUsingSystemTransactions()
        {
            var options = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted };

            SqliteSession.Trace = true;

            using (var db = new SqliteSession("Data Source=TempDb" + DateTime.Now.Ticks + ".db;DefaultTimeout=100", false))
            {
                db.Connection.Open();
                db.CreateTable<TestObj>();
                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj { Text = "My Text" });
                }

                Assert.AreEqual(0, db.Table<TestObj>().Count());

                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj { Text = "My Text" });
                    trans.Complete();
                }

                Assert.AreEqual(1, db.Table<TestObj>().Count());
            }
        }
示例#3
0
    public string[] SelectAllSessions(string filterName)
    {
        if (type == DatabaseType.DEFAULT)
        {
            return(SqliteSession.SelectAllSessions(filterName));
        }
        else
        {
            SqliteGeneral sqliteGeneral = new SqliteGeneral(databasePath);
            if (!sqliteGeneral.IsOpened)
            {
                List <string> emptyResult = new List <string> ();
                return(emptyResult.ToArray());
            }
            SqliteConnection dbcon = sqliteGeneral.connection;

            string[] allSessions = SqliteSession.SelectAllSessions(filterName, dbcon);

            // Filtered sessions will contain all sessions but not the "SIMULATED"
            List <string> filteredSessions = new List <string> ();

            foreach (string session in allSessions)
            {
                if (session.Split(':') [1] != "SIMULATED")
                {
                    filteredSessions.Add(session);
                }
            }

            return(filteredSessions.ToArray());
        }
    }
示例#4
0
    public PrepareEventGraphRunSimple(double time, double speed, int sessionID, int personID, string table, string type)
    {
        Sqlite.Open();

        //obtain data
        runsAtSQL = SqliteRun.SelectRuns(true, sessionID, personID, type,
                                         Sqlite.Orders_by.ID_DESC, 10); //select only last 10


        string sqlSelect = "distance/time";

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

        //distancePersonAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type, "distance");
        //distanceSessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, "distance");
        //better to know speed like:
        //SELECT AVG(distance/time) from run; than
        //SELECT AVG(distance) / SELECT AVG(time)
        //first is ok, because is the speed AVG
        //2nd is not good because it tries to do an AVG of all distances and times
        personAVGAtSQL  = SqliteSession.SelectAVGEventsOfAType(true, sessionID, personID, table, type, sqlSelect);
        sessionAVGAtSQL = SqliteSession.SelectAVGEventsOfAType(true, sessionID, -1, table, type, sqlSelect);

        this.time  = time;
        this.speed = speed;

        Sqlite.Close();
    }
示例#5
0
        public static SqliteSession GetConnection(string connectionString)
        {
            SqliteSession session = SqliteConnectionPool.Shared.GetConnection(connectionString);

            SqliteSession.Trace = true;
            Debug.WriteLine(session.Connection.ConnectionString);

            return(session);
        }
        public static SqliteSession GetConnection(string connectionString)
        {
            SqliteSession session = new SqliteSession(connectionString, false);
            session.OpenAsync().Wait();

            SqliteSession.Trace = true;
            Debug.WriteLine(session.Connection.ConnectionString);

            return session;
        }
示例#7
0
        public static SqliteSession GetConnection(string connectionString)
        {
            SqliteSession session = new SqliteSession(connectionString, false);

            session.OpenAsync().Wait();

            SqliteSession.Trace = true;
            Debug.WriteLine(session.Connection.ConnectionString);

            return(session);
        }
示例#8
0
    public ArrayList GetSelectedSessions(string sessionsString)
    {
        ArrayList sendSelectedSessions = new ArrayList(1);

        string [] sessionsStrFull = sessionsString.Split(new char[] { ':' });
        for (int j = 0; j < sessionsStrFull.Length; j++)
        {
            Session tempSession = SqliteSession.Select(sessionsStrFull[j]);
            sendSelectedSessions.Add(tempSession.UniqueID + ":" + tempSession.Name + ":" + tempSession.DateShort);
        }
        return(sendSelectedSessions);
    }
示例#9
0
    public virtual int InsertAtDB(bool dbconOpened, string tableName)
    {
        int myID = SqliteSession.Insert(dbconOpened, tableName,
                                        uniqueID.ToString(), name,
                                        place, date,
                                        personsSportID,
                                        personsSpeciallityID,
                                        personsPractice,
                                        comments,
                                        serverUniqueID);

        return(myID);
    }
示例#10
0
        public void ShouldSelect()
        {
            var sut    = new SqliteSession("Data Source=TestDatabase.sqlite");
            var result = sut.Select(
                "SELECT * FROM SqliteTestTableTwo WHERE Id IN (@Id1, @Id2)",
                new ParameterSet {
                new Parameter <int>("Id1", 1), new Parameter <int>("Id2", 2)
            }).ToList();

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0]["Id"], Is.EqualTo(1));
            Assert.That(result[0]["TestValue"], Is.EqualTo(5));
            Assert.That(result[1]["Id"], Is.EqualTo(2));
            Assert.That(result[1]["TestValue"], Is.EqualTo(6));
        }
示例#11
0
        public void ShouldExecute()
        {
            var sut = new SqliteSession("Data Source=TestDatabase.sqlite");

            sut.Execute("INSERT INTO SqliteTestTableTwo VALUES(5, @Value)", new ParameterSet {
                new Parameter <int>("Value", 7)
            });

            using (var connection = new SQLiteConnection("Data Source=TestDatabase.sqlite"))
            {
                var command = connection.CreateCommand();
                command.CommandText = "SELECT TestValue FROM SqliteTestTableTwo WHERE Id = 5";
                connection.Open();
                var result = int.Parse(command.ExecuteScalar().ToString());

                Assert.That(result, Is.EqualTo(7));
            }
        }
示例#12
0
    public Report(int sessionID)
    {
        this.SessionID            = sessionID;
        ShowCurrentSessionData    = true;
        ShowCurrentSessionJumpers = true;
        ShowSimpleJumps           = true;
        ShowReactiveJumps         = true;
        ShowSimpleRuns            = true;
        ShowIntervalRuns          = true;
        ShowReactionTimes         = true;
        ShowPulses = true;

        spreadsheetString = "";

        StatisticsData = new ArrayList(1);

        mySession = SqliteSession.Select(sessionID.ToString());
    }
示例#13
0
        public void InsertUsingSystemTransactions()
        {
            var options = new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            };

#if NETFX_CORE
            var tempFileName = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path + "\\TempDb" + DateTime.Now.Ticks + ".db";
#else
            var tempFileName = Path.GetTempFileName();
#endif
            SqliteSession.Trace = true;

            using (var db = new SqliteSession("Data Source=" + tempFileName + ";DefaultTimeout=100", false))
            {
                db.Connection.Open();
                db.CreateTable <TestObj>();
                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj {
                        Text = "My Text"
                    });
                }

                Assert.AreEqual(0, db.Table <TestObj>().Count());

                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj {
                        Text = "My Text"
                    });
                    trans.Complete();
                }

                Assert.AreEqual(1, db.Table <TestObj>().Count());
            }
        }
示例#14
0
    public Session Select(string myUniqueID)
    {
        if (type == DatabaseType.DEFAULT)
        {
            return(SqliteSession.Select(myUniqueID));
        }
        else
        {
            // This code could be refactored from existing code in SqliteSession::Select()

            SqliteGeneral sqliteGeneral = new SqliteGeneral(databasePath);
            SqliteCommand dbcommand     = sqliteGeneral.command();

            dbcommand.CommandText = "SELECT * FROM Session WHERE uniqueID == @myUniqueID";
            dbcommand.Parameters.Add(new SqliteParameter("@myUniqueID", myUniqueID));

            SqliteDataReader reader = dbcommand.ExecuteReader();

            // Copied from a non-callable (yet) static method: SqliteSession::Select()
            string [] values = new string[9];

            while (reader.Read())
            {
                values[0] = reader[0].ToString();
                values[1] = reader[1].ToString();
                values[2] = reader[2].ToString();
                values[3] = reader[3].ToString();
                values[4] = reader[4].ToString();
                values[5] = reader[5].ToString();
                values[6] = reader[6].ToString();
                values[7] = reader[7].ToString();
                values[8] = reader[8].ToString();
            }

            Session mySession = new Session(values[0],
                                            values[1], values[2], UtilDate.FromSql(values[3]),
                                            Convert.ToInt32(values[4]), Convert.ToInt32(values[5]), Convert.ToInt32(values[6]),
                                            values[7], Convert.ToInt32(values[8]));

            return(mySession);
        }
    }
示例#15
0
    //---- end of spin_exhibition_group stuff
    private void on_button_exhibition_select_clicked(object o, EventArgs args)
    {
        //select session
        string newSessionName = string.Format("{0}-{1}", spin_exhibition_school.Value, spin_exhibition_group.Value);

        if (currentSession == null || currentSession.Name != newSessionName)
        {
            currentSession = SqliteSession.SelectByName(newSessionName);
            on_load_session_accepted();
            sensitiveGuiYesSession();
        }

        //select person
        int rowToSelect = myTreeViewPersons.FindRow(Convert.ToInt32(spin_exhibition_id.Value));

        if (rowToSelect != -1)
        {
            selectRowTreeView_persons(treeview_persons, rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
示例#16
0
    public PrepareEventGraphJumpSimple(double tv, double tc, int sessionID, int personID, string table, string type)
    {
        Sqlite.Open();

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

        string sqlSelect = "";

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

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

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

        //end of select data from SQL to update graph

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

        Sqlite.Close();
    }
示例#17
0
        public void InsertUsingSystemTransactions()
        {
            var options = new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            };

            SqliteSession.Trace = true;

            using (var db = new SqliteSession("Data Source=TempDb" + DateTime.Now.Ticks + ".db;DefaultTimeout=100", false))
            {
                db.Connection.Open();
                db.CreateTable <TestObj>();
                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj {
                        Text = "My Text"
                    });
                }

                Assert.AreEqual(0, db.Table <TestObj>().Count());

                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj {
                        Text = "My Text"
                    });
                    trans.Complete();
                }

                Assert.AreEqual(1, db.Table <TestObj>().Count());
            }
        }
示例#18
0
    private void configInit()
    {
        //trying new Config class
        Config config = new Config();

        config.Read();
        LogB.Information("Config:\n" + config.ToString());

        /*
         * TODO: do an else to any option
         * is good to do the else here because user can import a configuration at any time
         * and things need to be restored to default position in glade
         *
         * But note this has to be executed only if it has changed!!
         */

        if (config.Maximized)
        {
            app1.Maximize();
        }
        if (config.CustomButtons)
        {
            //---- capture tab ----

            hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
            hbox_encoder_capture_extra_mass_raspberry.Visible    = true;

            button_encoder_select.HeightRequest = 40;
            //this will make all encoder capture controls taller
            //88 then buttons will be the same height than button_encoder_select. The 8 extra is for the vertical space
            button_encoder_capture.SetSizeRequest(125, 88);
            //button_encoder_capture.HeightRequest = 88;

            spin_encoder_im_weights_n.Visible = false;
            hbox_encoder_im_weights_n.Visible = true;

            //---- analyze tab ----

            hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
            button_encoder_analyze.SetSizeRequest(120, 40);
        }
        if (!config.UseVideo)
        {
            useVideo = false;
            alignment_video_encoder.Visible = false;
        }

        //Auto-detect stuff
        configAutodetectPort = config.AutodetectPort;

        autodetectSignalEnabled = false;         //do not raise signals that could rewrite the config file (loop)

        if (configAutodetectPort == Config.AutodetectPortEnum.ACTIVE)
        {
            radio_autodetect_active.Active = true;
        }
        else if (configAutodetectPort == Config.AutodetectPortEnum.INACTIVE)
        {
            radio_autodetect_inactive.Active = true;
        }
        else         // (configAutodetectPort == Config.AutodetectPortEnum.DISCARDFIRST)
        {
            radio_autodetect_discard_first.Active = true;
        }

        autodetectSignalEnabled = true;         //activate signals again


        //show only power
        if (config.OnlyEncoderGravitatory)
        {
            select_menuitem_mode_toggled(menuitem_modes.POWERGRAVITATORY);
        }
        else if (config.OnlyEncoderInertial)
        {
            select_menuitem_mode_toggled(menuitem_modes.POWERINERTIAL);
        }

        if (config.EncoderCaptureShowOnlyBars)
        {
            vpaned_encoder_capture_video_and_set_graph.Visible = false;

            vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
            vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
            notebook_encoder_capture_main.ShowTabs = true;
        }
        else
        {
            /*
             * is good to do the else here because user can import a configuration at any time
             * and things need to be restored to default position in glade
             *
             * But note this has to be executed only if it has changed!!
             */
            /*
             * notebook_encoder_capture_main.ShowTabs = false;
             * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
             * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
             */
        }

        encoderUpdateTreeViewWhileCapturing = config.EncoderUpdateTreeViewWhileCapturing;

        if (config.PersonWinHide)
        {
            //vbox_persons.Visible = false;
            notebook_session_person.Visible = false;
            hbox_encoder_person.Visible     = true;
        }

        if (config.EncoderAnalyzeHide)
        {
            hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
        }

        if (config.Econf != null)
        {
            encoderConfigurationDefinedFromFile = true;
            encoderConfigurationCurrent         = config.Econf;
            encoderConfigurationGUIUpdate();
            //TODO: allow to see full data, but don't allow to change it (Open window content as unsensitive)
        }

        if (config.SessionMode == Config.SessionModeEnum.UNIQUE)
        {
            main_menu.Visible = false;
            button_preferences_not_menu.Visible = true;

            if (!Sqlite.Exists(false, Constants.SessionTable, "session"))
            {
                //this creates the session and inserts at DB
                currentSession = new Session(
                    "session", "", DateTime.Today,                              //name, place, dateTime
                    Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                    "", Constants.ServerUndefinedID);                           //comments, serverID
            }
            else
            {
                currentSession = SqliteSession.SelectByName("session");
            }

            on_load_session_accepted();
        }

        //TODO
        //RunScriptOnExit

        /*
         * if(linuxType == linuxTypeEnum.NETWORKS) {
         *      //mostrar directament el power
         *      select_menuitem_mode_toggled(menuitem_modes.POWER);
         *
         *      //no mostrar menu
         *      main_menu.Visible = false;
         *
         *      //no mostrar persones
         *      //vbox_persons.Visible = false;
         *      //TODO: rfid can be here, also machine, maybe weight, other features
         *      //time, gym, ...
         *
         *      //show rfid
         *      hbox_rfid.Visible = true;
         *
         *      //to test display, just make sensitive the top controls, but beware there's no session yet and no person
         *      notebook_sup.Sensitive = true;
         *      hbox_encoder_sup_capture_analyze.Sensitive = true;
         *      notebook_encoder_sup.Sensitive = false;
         * }
         */
    }
示例#19
0
 /// <summary>
 /// Connect to database
 /// </summary>
 public bool connect()
 {
     try
     {
         session = new SqliteSession(CONNECTION_STRING);
         setup();
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         return false;
     }
 }
示例#20
0
    private static void on_server_upload_session_started()
    {
        int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            LogB.Information(myServer.DisConnectDatabase());
        } catch {
            //other thread updates the gui:
            serverSessionError = true;
        }
    }
示例#21
0
文件: main.cs 项目: GNOME/chronojump
    public static void CreateTables(bool server)
    {
        Sqlite.Open();

        creationTotal = 14;
        creationRate = 1;

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

        if(server) {
            sqliteServerObject.CreatePingTable();

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

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

            SqlitePersonSessionNotUpload.CreateTable();
            creationRate ++;
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        SqliteChronopicRegister.createTableChronopicRegister();

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

        Sqlite.Close();
        creationRate ++;
    }
示例#22
0
    private void configInit()
    {
        //trying new Config class
        configChronojump = new Config();
        configChronojump.Read();
        LogB.Information("Config:\n" + configChronojump.ToString());

        /*
         * TODO: do an else to any option
         * is good to do the else here because user can import a configuration at any time
         * and things need to be restored to default position in glade
         *
         * But note this has to be executed only if it has changed!!
         */

        if (configChronojump.Maximized)
        {
            app1.Maximize();
        }
        if (configChronojump.CustomButtons)
        {
            //---- capture tab ----

            hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
            hbox_encoder_capture_extra_mass_raspberry.Visible    = true;

            button_encoder_select.HeightRequest = 40;
            //this will make all encoder capture controls taller
            button_encoder_capture.SetSizeRequest(125, 60);

            spin_encoder_im_weights_n.Visible = false;
            hbox_encoder_im_weights_n.Visible = true;

            //---- analyze tab ----

            hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
            button_encoder_analyze.SetSizeRequest(120, 40);
        }
        if (!configChronojump.UseVideo)
        {
            alignment_video_encoder.Visible = false;
        }

        //show only power
        if (configChronojump.OnlyEncoderGravitatory)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
        }
        else if (configChronojump.OnlyEncoderInertial)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
        }

        if (configChronojump.EncoderCaptureShowOnlyBars)
        {
            //attention: this makes encoder_capture_signal_drawingarea == null
            vpaned_encoder_capture_video_and_set_graph.Visible = false;

            vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
            vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
            notebook_encoder_capture_main.ShowTabs = true;
        }
        else
        {
            /*
             * is good to do the else here because user can import a configuration at any time
             * and things need to be restored to default position in glade
             *
             * But note this has to be executed only if it has changed!!
             */
            /*
             * notebook_encoder_capture_main.ShowTabs = false;
             * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
             * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
             */
        }

        encoderUpdateTreeViewWhileCapturing = configChronojump.EncoderUpdateTreeViewWhileCapturing;

        if (configChronojump.PersonWinHide)
        {
            //vbox_persons.Visible = false;
            notebook_session_person.Visible = false;
            hbox_encoder_person.Visible     = true;
        }

        if (configChronojump.EncoderAnalyzeHide)
        {
            hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
        }

        if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE || configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY)
        {
            main_menu.Visible = false;
            app1.Decorated    = false;
            hbox_menu_and_preferences_outside_menu.Visible = true;

            if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE)
            {
                if (!Sqlite.Exists(false, Constants.SessionTable, "session"))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        "session", "", DateTime.Today,                                  //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                               //comments, serverID
                }
                else
                {
                    currentSession = SqliteSession.SelectByName("session");
                }
            }
            else
            {
                //configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY

                string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
                LogB.Information("yearMonthStr: " + yearMonthStr);
                if (!Sqlite.Exists(false, Constants.SessionTable, yearMonthStr))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        yearMonthStr, "", DateTime.Today,                                 //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                                 //comments, serverID

                    //insert personSessions from last month
                    string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr();
                    if (Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr))
                    {
                        Session s = SqliteSession.SelectByName(yearLastMonthStr);

                        //import all persons from last session
                        List <PersonSession> personSessions = SqlitePersonSession.SelectPersonSessionList(s.UniqueID);

                        //convert all personSessions to currentSession
                        //and nullify UniqueID in order to be inserted incrementally by SQL
                        foreach (PersonSession ps in personSessions)
                        {
                            ps.UniqueID  = -1;
                            ps.SessionID = currentSession.UniqueID;
                        }


                        //insert personSessions using a transaction
                        new SqlitePersonSessionTransaction(personSessions);
                    }
                }
                else
                {
                    currentSession = SqliteSession.SelectByName(yearMonthStr);
                }
            }

            on_load_session_accepted();
        }

        //TODO
        //RunScriptOnExit

        /*
         * if(linuxType == linuxTypeEnum.NETWORKS) {
         *      //mostrar directament el power
         *      select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER);
         *
         *      //no mostrar menu
         *      main_menu.Visible = false;
         *
         *      //no mostrar persones
         *      //vbox_persons.Visible = false;
         *      //TODO: rfid can be here, also machine, maybe weight, other features
         *      //time, gym, ...
         *
         *      //show rfid
         *      hbox_rfid.Visible = true;
         *
         *      //to test display, just make sensitive the top controls, but beware there's no session yet and no person
         *      notebook_sup.Sensitive = true;
         *      hbox_encoder_sup_capture_analyze.Sensitive = true;
         *      notebook_encoder_sup.Sensitive = false;
         * }
         */

        hbox_rfid.Visible = (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX);
    }
示例#23
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 ++;
    }
        public void InsertUsingSystemTransactions()
        {
            var options = new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted};
#if NETFX_CORE
            var tempFileName = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path + "\\TempDb" + DateTime.Now.Ticks + ".db";
#else            
            var tempFileName = Path.GetTempFileName();

#endif
            SqliteSession.Trace = true;

            using (var db = new SqliteSession("Data Source=" + tempFileName + ";DefaultTimeout=100", false))
            {
                db.Connection.Open();
                db.CreateTable<TestObj>();
                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj { Text = "My Text" });
                }
            
                Assert.AreEqual(0, db.Table<TestObj>().Count());

                db.Connection.Close();

                using (var trans = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    db.Connection.Open();
                    db.Insert(new TestObj { Text = "My Text" });
                    trans.Complete();
                }

                Assert.AreEqual(1, db.Table<TestObj>().Count());
            }
        }