SQL() публичный статический Метод

public static SQL ( string message ) : void
message string
Результат void
Пример #1
0
    //tableName is jumpType or jumpRjType
    public static bool HasWeight(string tableName, string typeName)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT weight " +
                            " FROM " + tableName +
                            " WHERE name == \"" + typeName + "\"";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        bool hasWeight = false;

        while (reader.Read())
        {
            if (reader[0].ToString() == "1")
            {
                hasWeight = true;
                LogB.SQL("found type: hasWeight");
            }
            else
            {
                LogB.SQL("found type: NO hasWeight");
            }
        }
        reader.Close();
        Sqlite.Close();
        return(hasWeight);
    }
Пример #2
0
    /*
     * DB 1.20 -> 1.21
     * "Fixing loosing of encoder videoURL after recalculate"
     * each encoder signal can have saved some encoder curves
     * both are records on encoder table
     * connection between them is found in encoderSignalCurve table.
     * Problem since chronojump 1.4.9 and maybe earlier is on recalculate: videoURL is deleted on signal
     * but hopefully not in curve
     * Now this problem has been fixed in new code and it does not get deleted.
     *
     * Following  method: is to restore signals that lost their videoURL value
     */

    public static void FixLostVideoURLAfterEncoderRecalculate()
    {
        dbcmd.CommandText = "SELECT eSignal.uniqueID, eCurve.videoURL " +
                            "FROM encoder AS eSignal, encoder AS eCurve, encoderSignalCurve " +
                            "WHERE eSignal.signalOrCurve = \"signal\" AND eCurve.signalOrCurve = \"curve\" " +
                            "AND eSignal.videoURL = \"\" AND eCurve.videoURL != \"\" " +
                            "AND encoderSignalCurve.signalID = eSignal.uniqueID " +
                            "AND encoderSignalCurve.curveID = eCurve.uniqueID";

        LogB.SQL(dbcmd.CommandText.ToString());
        SqliteDataReader reader = dbcmd.ExecuteReader();

        IDNameList idnamelist = new IDNameList();

        while (reader.Read())
        {
            idnamelist.Add(new IDName(
                               Convert.ToInt32(reader[0].ToString()),   //encoder signal uniqueID (this signal has lost his videoURL)
                               reader[1].ToString()                     //videoURL of encoder curve
                               ));
        }
        reader.Close();

        foreach (IDName idname in idnamelist.l)
        {
            dbcmd.CommandText = "UPDATE encoder SET videoURL = \"" + idname.Name + "\" " +
                                "WHERE uniqueID = " + idname.UniqueID.ToString();
            LogB.SQL(dbcmd.CommandText.ToString());
            dbcmd.ExecuteNonQuery();
        }
    }
Пример #3
0
    //useful to convert DB from 0.57 to 0.58 (strip republic and kingdom stuff)
    public static bool TableHasOldRepublicStuff()
    {
        dbcmd.CommandText = "SELECT name FROM " + Constants.CountryTable + " WHERE code == \"DZA\"";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        bool hasRepublicStuff;

        if (reader[0].ToString() == "Algeria")
        {
            hasRepublicStuff = false;
        }
        else
        {
            hasRepublicStuff = true;
        }

        LogB.SQL(reader[0].ToString() + " " + hasRepublicStuff);

        reader.Close();
        return(hasRepublicStuff);
    }
Пример #4
0
    /*
     * ReactionTime class methods
     */

    public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, double time, string description, int simulated)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        dbcmd.CommandText = "INSERT INTO " + tableName +
                            " (uniqueID, personID, sessionID, type, time, description, simulated)" +
                            " VALUES (" + uniqueID + ", "
                            + personID + ", " + sessionID + ", \"" + type + "\", "
                            + Util.ConvertToPoint(time) + ", \"" + description + "\", " + simulated + ")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

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

        return(myLast);
    }
Пример #5
0
    //convert slCMJ to slCMJleft, slCMJright
    //DB 1.13 -> DB 1.14
    public static void slCMJDivide()
    {
        //it's a conversion, dbcon is opened

        //changes on jumpType table
        SqliteJumpType.Delete(Constants.JumpTypeTable, "slCMJ", true);
        SqliteJumpType.JumpTypeInsert("slCMJleft:1:0:Single-leg CMJ jump", true);
        SqliteJumpType.JumpTypeInsert("slCMJright:1:0:Single-leg CMJ jump", true);


        //changes on jump table
        dbcmd.CommandText = "UPDATE " + Constants.JumpTable + " SET type = \"slCMJleft\" WHERE description LIKE \"%Left%\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        dbcmd.CommandText = "UPDATE " + Constants.JumpTable + " SET type = \"slCMJright\" WHERE description LIKE \"%Right%\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        dbcmd.CommandText = "UPDATE " + Constants.JumpTable + " SET description=replace(description, \" Left\", \"\")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        dbcmd.CommandText = "UPDATE " + Constants.JumpTable + " SET description=replace(description, \" Right\", \"\")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
    }
Пример #6
0
    //Called from new methods were dbcon is opened
    public static string Select(string myName, bool dbconOpened)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        dbcmd.CommandText = "SELECT value FROM " + Constants.PreferencesTable +
                            " WHERE name == \"" + myName + "\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //SqliteDataReader reader;
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        string myReturn = "0";

        if (reader.Read())
        {
            myReturn = reader[0].ToString();
        }
        reader.Close();

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

        return(myReturn);
    }
Пример #7
0
    public static int Insert1RM(bool dbconOpened, int personID, int sessionID, int exerciseID, double load1RM)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        dbcmd.CommandText = "INSERT INTO " + Constants.Encoder1RMTable +
                            " (uniqueID, personID, sessionID, exerciseID, load1RM, future1, future2, future3)" +
                            " VALUES (NULL, " + personID + ", " + sessionID + ", " +
                            exerciseID + ", " + Util.ConvertToPoint(load1RM) + ", \"\",\"\",\"\")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

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

        return(myLast);
    }
Пример #8
0
    //called on load signal
    //if does not found any encoderConfiguration then return one with -1 as uniqueID
    public static EncoderConfigurationSQLObject SelectByEconf(bool dbconOpened, Constants.EncoderGI encoderGI, EncoderConfiguration econf)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable +
                            " WHERE encoderGI = \"" + encoderGI.ToString() + "\"" +
                            " AND encoderConfiguration LIKE \"" + econf.ToStringOutput(EncoderConfiguration.Outputs.SQLECWINCOMPARE) + "\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject();

        if (reader.Read())
        {
            econfSO = new EncoderConfigurationSQLObject(
                Convert.ToInt32(reader[0].ToString()),                          //uniqueID
                encoderGI,                                                      //encoderGI
                true,                                                           //active
                reader[3].ToString(),                                           //name
                econf,                                                          //encoderConfiguration
                reader[5].ToString()                                            //description
                );
        }
        reader.Close();
        Sqlite.Close();

        return(econfSO);
    }
Пример #9
0
    public static JumpRj SelectJumpData(string tableName, int uniqueID, bool dbconOpened)
    {
        //tableName is jumpRj or tempJumpRj

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

        dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID;

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        JumpRj myJump = new JumpRj(DataReaderToStringArray(reader, 18));

        reader.Close();
        if (!dbconOpened)
        {
            Sqlite.Close();
        }
        return(myJump);
    }
Пример #10
0
    //use this in the future:
    public static List <PersonSession> SelectPersonSessionList(int sessionID)
    {
        string tps = Constants.PersonSessionTable;

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

        reader = dbcmd.ExecuteReader();

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

        while (reader.Read())
        {
            PersonSession ps = new PersonSession(
                Convert.ToInt32(reader[0].ToString()),                               //uniqueID
                Convert.ToInt32(reader[1].ToString()),                               //personID
                Convert.ToInt32(reader[2].ToString()),                               //sessionID
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), //height
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //weight
                Convert.ToInt32(reader[5].ToString()),                               //sportID
                Convert.ToInt32(reader[6].ToString()),                               //speciallityID
                Convert.ToInt32(reader[7].ToString()),                               //practice
                reader[8].ToString()                                                 //comments
                );
            list.Add(ps);
        }
        reader.Close();
        Sqlite.Close();
        return(list);
    }
Пример #11
0
    public static bool ExistsAndItsNotMe(int uniqueID, string personName)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT uniqueID FROM " + Constants.PersonTable +
                            " WHERE LOWER(" + Constants.PersonTable + ".name) == LOWER(\"" + personName + "\")" +
                            " AND uniqueID != " + uniqueID;
        LogB.SQL(dbcmd.CommandText.ToString());

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        bool exists = new bool();

        exists = false;

        if (reader.Read())
        {
            exists = true;
            //LogB.SQL("valor {0}", reader[0].ToString());
        }
        //LogB.SQL("exists = {0}", exists.ToString());

        reader.Close();
        Sqlite.Close();
        return(exists);
    }
Пример #12
0
    public static bool PersonSelectExistsInSession(int myPersonID, int mySessionID)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT * FROM " + Constants.PersonSessionTable +
                            " WHERE personID == " + myPersonID +
                            " AND sessionID == " + mySessionID;
        LogB.SQL(dbcmd.CommandText.ToString());

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        bool exists = new bool();

        exists = false;

        while (reader.Read())
        {
            exists = true;
        }

        reader.Close();
        Sqlite.Close();
        return(exists);
    }
Пример #13
0
    //when a session is NOT KNOWN, then select atrribute of last session
    //select doubles
    public static double SelectAttribute(int personID, string attribute)
    {
        Sqlite.Open();

        dbcmd.CommandText = "SELECT " + attribute + ", sessionID FROM " + Constants.PersonSessionTable +
                            " WHERE personID == " + personID +
                            "ORDER BY sessionID DESC LIMIT 1";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        double myReturn = 0;

        if (reader.Read())
        {
            myReturn = Convert.ToDouble(Util.ChangeDecimalSeparator(reader[0].ToString()));
        }
        reader.Close();
        Sqlite.Close();
        return(myReturn);
    }
Пример #14
0
    //we know if it has fall if it starts in
    public static bool HasFall(string tableName, string typeName)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT startIn " +
                            " FROM " + tableName +
                            " WHERE name == \"" + typeName + "\"";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        bool hasFall = true;

        while (reader.Read())
        {
            if (reader[0].ToString() == "1")
            {
                hasFall = false;
            }
        }
        reader.Close();
        Sqlite.Close();
        return(hasFall);
    }
Пример #15
0
    public static void Update(bool dbconOpened, ForceSensorExercise ex)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        /*
         * string uniqueIDStr = "NULL";
         * if(ex.UniqueID != -1)
         *         uniqueIDStr = ex.UniqueID.ToString();
         */

        dbcmd.CommandText = "UPDATE " + table + " SET " +
                            " name = \"" + ex.Name +
                            "\", percentBodyWeight = " + ex.PercentBodyWeight +
                            ", resistance = \"" + ex.Resistance +
                            "\", angleDefault = " + ex.AngleDefault +
                            ", description = \"" + ex.Description +
                            "\" WHERE uniqueID = " + ex.UniqueID;

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

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Пример #16
0
    //checks if there are Rjs with different number of TCs than TFs
    //then repair database manually, and look if the jump is jumpLimited, and how many jumps there are defined
    public static void FindBadRjs()
    {
        Sqlite.Open();

        dbcmd.CommandText = "SELECT uniqueID, tcstring, tvstring, jumps, limited FROM jumpRj";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        while (reader.Read())
        {
            if (Util.GetNumberOfJumps(reader[1].ToString(), true) != Util.GetNumberOfJumps(reader[2].ToString(), true))
            {
                LogB.Error(string.Format("Problem with jumpRj: {0}, tcstring{1}, tvstring{2}, jumps{3}, limited{4}",
                                         reader[0].ToString(),
                                         Util.GetNumberOfJumps(reader[1].ToString(), true).ToString(),
                                         Util.GetNumberOfJumps(reader[2].ToString(), true).ToString(),
                                         reader[3].ToString(), reader[4].ToString()));
            }
        }
        reader.Close();
        Sqlite.Close();
    }
Пример #17
0
    public static RunInterval SelectRunData(string tableName, int uniqueID, bool dbconOpened)
    {
        //tableName can be runInterval or tempRunInterval

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

        dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID;

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        RunInterval myRun = new RunInterval(DataReaderToStringArray(reader, 13));

        reader.Close();
        if (!dbconOpened)
        {
            Sqlite.Close();
        }
        return(myRun);
    }
Пример #18
0
 /*
  * from SqlitePersonSessionWeight.DeletePersonFromSessionAndTests()
  * if person is not in other sessions, delete it from DB
  */
 public static void Delete(int uniqueID)
 {
     dbcmd.CommandText = "Delete FROM " + Constants.PersonOldTable +
                         " WHERE uniqueID == " + uniqueID.ToString();
     LogB.SQL(dbcmd.CommandText.ToString());
     dbcmd.ExecuteNonQuery();
 }
Пример #19
0
    public static PulseType SelectAndReturnPulseType(string typeName)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT * " +
                            " FROM " + Constants.PulseTypeTable +
                            " WHERE name  = \"" + typeName +
                            "\" ORDER BY uniqueID";

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        PulseType myPulseType = new PulseType();

        while (reader.Read())
        {
            myPulseType.Name           = reader[1].ToString();
            myPulseType.FixedPulse     = Convert.ToDouble(reader[2].ToString());
            myPulseType.TotalPulsesNum = Convert.ToInt32(reader[3]);
        }

        reader.Close();
        Sqlite.Close();

        return(myPulseType);
    }
Пример #20
0
    //can be "Constants.PersonOldTable" or "Constants.ConvertTempTable"
    //temp is used to modify table between different database versions if needed
    public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string sex, DateTime dateBorn, double height, double weight, int sportID, int speciallityID, int practice, string description, int race, int countryID, int serverUniqueID)
    {
        if (!dbconOpened)
        {
            dbcon.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        string myString = "INSERT INTO " + tableName +
                          " (uniqueID, name, sex, dateBorn, height, weight,  sportID, speciallityID, practice, description, race, countryID, serverUniqueID) VALUES (" + uniqueID + ", '" +
                          name + "', '" + sex + "', '" + UtilDate.ToSql(dateBorn) + "', " +
                          Util.ConvertToPoint(height) + ", " + "-1" + ", " + //"-1" is weight because it's defined in personSesionWeight for allow change between sessions
                          sportID + ", " + speciallityID + ", " + practice + ", '" + description + "', " +
                          race + ", " + countryID + ", " + serverUniqueID + ")";

        dbcmd.CommandText = myString;
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();
        int myReturn = -10000;         //dbcon.LastInsertRowId;

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

        return(myReturn);
    }
Пример #21
0
    public static ReactionTime SelectReactionTimeData(int uniqueID, bool dbconOpened)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        dbcmd.CommandText = "SELECT * FROM " + Constants.ReactionTimeTable + " WHERE uniqueID == " + uniqueID;

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

        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        ReactionTime myRT = new ReactionTime(DataReaderToStringArray(reader, 7));

        reader.Close();
        if (!dbconOpened)
        {
            Sqlite.Close();
        }
        return(myRT);
    }
Пример #22
0
    //used on Sqlite main convertPersonAndPersonSessionTo77()
    public ArrayList SelectAllPersons()
    {
        dbcmd.CommandText = "SELECT * FROM " + Constants.PersonOldTable + " ORDER BY uniqueID";
        LogB.SQL(dbcmd.CommandText.ToString());
        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();

        ArrayList myArray = new ArrayList(1);

        while (reader.Read())
        {
            PersonOld p = new PersonOld(
                Convert.ToInt32(reader[0].ToString()),                               //uniqueID
                reader[1].ToString(),                                                //name
                reader[2].ToString(),                                                //sex
                UtilDate.FromSql(reader[3].ToString()),                              //dateBorn
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //height
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())), //weight

                Convert.ToInt32(reader[6].ToString()),                               //sportID
                Convert.ToInt32(reader[7].ToString()),                               //speciallityID
                Convert.ToInt32(reader[8].ToString()),                               //practice
                reader[9].ToString(),                                                //description
                Convert.ToInt32(reader[10].ToString()),                              //race
                Convert.ToInt32(reader[11].ToString()),                              //countryID
                Convert.ToInt32(reader[12].ToString())                               //serverUniqueID
                );
            myArray.Add(p);
        }
        reader.Close();
        return(myArray);
    }
Пример #23
0
    public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        if (uniqueID == "-1")
        {
            uniqueID = "NULL";
        }

        dbcmd.CommandText = "INSERT INTO " + tableName + " (uniqueID, name, place, date, personsSportID, personsSpeciallityID, personsPractice, comments, serverUniqueID)" +
                            " VALUES (" + uniqueID + ", \""
                            + name + "\", \"" + place + "\", \"" + UtilDate.ToSql(date) + "\", " +
                            personsSportID + ", " + personsSpeciallityID + ", " +
                            personsPractice + ", \"" + comments + "\", " +
                            serverUniqueID + ")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        //int myLast = dbcon.LastInsertRowId;
        //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
        string myString = @"select last_insert_rowid()";

        dbcmd.CommandText = myString;
        int myLast = Convert.ToInt32(dbcmd.ExecuteScalar());         // Need to type-cast since `ExecuteScalar` returns an object.

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

        return(myLast);
    }
Пример #24
0
    public static List <ForceSensorRFD> SelectAll(bool dbconOpened)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "SELECT * FROM " + table + " WHERE code != \"I\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader = dbcmd.ExecuteReader();

        List <ForceSensorRFD> l = new List <ForceSensorRFD>();

        while (reader.Read())
        {
            ForceSensorRFD rfd = new ForceSensorRFD(
                reader[0].ToString(),                                                   //code
                Util.IntToBool(Convert.ToInt32(reader[1])),                             //active
                (ForceSensorRFD.Functions)Enum.Parse(
                    typeof(ForceSensorRFD.Functions), reader[2].ToString()),            //function
                (ForceSensorRFD.Types)Enum.Parse(
                    typeof(ForceSensorRFD.Types), reader[3].ToString()),                //type
                Convert.ToInt32(reader[4]),                                             //num1
                Convert.ToInt32(reader[5])                                              //num2
                );
            l.Add(rfd);
        }

        reader.Close();
        closeIfNeeded(dbconOpened);

        return(l);
    }
Пример #25
0
 //DB 1.17 -> 1.18
 protected internal static void deleteNegativeRuns()
 {
     dbcmd.CommandText = "Delete FROM " + Constants.RunIntervalTable +
                         " WHERE timeTotal < 0";
     LogB.SQL(dbcmd.CommandText.ToString());
     dbcmd.ExecuteNonQuery();
 }
Пример #26
0
    public static ForceSensorImpulse SelectImpulse(bool dbconOpened)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "SELECT * FROM " + table + " WHERE code == \"I\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader = dbcmd.ExecuteReader();

        ForceSensorImpulse impulse = null;

        while (reader.Read())
        {
            impulse = new ForceSensorImpulse(
                Util.IntToBool(Convert.ToInt32(reader[1])),                             //active
                (ForceSensorImpulse.Functions)Enum.Parse(
                    typeof(ForceSensorImpulse.Functions), reader[2].ToString()),        //function
                (ForceSensorImpulse.Types)Enum.Parse(
                    typeof(ForceSensorImpulse.Types), reader[3].ToString()),            //type
                Convert.ToInt32(reader[4]),                                             //num1
                Convert.ToInt32(reader[5])                                              //num2
                );
        }

        reader.Close();
        closeIfNeeded(dbconOpened);

        return(impulse);
    }
Пример #27
0
    /*
     * class methods
     */

    public static void Insert(bool dbconOpened, ExecuteAutoSQL eaSQL)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        dbcmd.CommandText = "INSERT INTO " + Constants.ExecuteAutoTable +
                            " (uniqueID, name, mode, description, " +
                            " serie1IDs, serie2IDs, serie3IDs, " +
                            " future1, future2, future3)" +
                            " VALUES ( NULL, \"" +
                            eaSQL.name + "\", \"" + eaSQL.Mode.ToString() + "\", \"" + eaSQL.Description + "\", \"" +
                            eaSQL.SerieIDsToStr(eaSQL.Serie1IDs) + "\", \"" +
                            eaSQL.SerieIDsToStr(eaSQL.Serie2IDs) + "\", \"" +
                            eaSQL.SerieIDsToStr(eaSQL.Serie3IDs) + "\", " +
                            "\"\", \"\", \"\")"; //future1, future2, future3
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Пример #28
0
    //undefined defaultAngle will be 1000
    //note execution can have a different angle than the default angle
    public static void Insert(bool dbconOpened, int uniqueID, string name, int percentBodyWeight,
                              string resistance, int angleDefault, string description)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        string uniqueIDStr = "NULL";

        if (uniqueID != -1)
        {
            uniqueIDStr = uniqueID.ToString();
        }

        dbcmd.CommandText = "INSERT INTO " + table +
                            " (uniqueID, name, percentBodyWeight, resistance, angleDefault, description)" +
                            " VALUES (" + uniqueIDStr + ", \"" + name + "\", " + percentBodyWeight + ", \"" +
                            resistance + "\", " + angleDefault + ", \"" + description + "\")";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Пример #29
0
    public static void Insert(bool dbconOpened, SqliteCommand mycmd, string code, string nameEnglish, string continent)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

        string myString = "INSERT INTO " + Constants.CountryTable +
                          //" (uniqueID, code, name, continent) VALUES (NULL, '" + code + "', '" +
                          //nameEnglish + "', '" + continent + "')";
                          //fix bad chars (') :
                          " (uniqueID, code, name, continent) VALUES (NULL, \"" + code + "\", \"" +
                          nameEnglish + "\", \"" + continent + "\")";

        mycmd.CommandText = myString;
        LogB.SQL(mycmd.CommandText.ToString());
        mycmd.ExecuteNonQuery();

        /*
         * //int myLast = dbcon.LastInsertRowId;
         * //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
         * myString = @"select last_insert_rowid()";
         * mycmd.CommandText = myString;
         * int myLast = Convert.ToInt32(dbcmd.ExecuteScalar()); // Need to type-cast since `ExecuteScalar` returns an object.
         */

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Пример #30
0
    public static string Select(bool dbconOpened, int uniqueID)
    {
        if (uniqueID == -1)
        {
            return("");
        }

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

        dbcmd.CommandText = "SELECT name FROM " + Constants.SpeciallityTable + " WHERE uniqueID == " + uniqueID;

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

        SqliteDataReader reader;

        reader = dbcmd.ExecuteReader();
        reader.Read();

        string speciallityName = reader[0].ToString();         //name

        reader.Close();

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

        return(Catalog.GetString(speciallityName));
    }