Beispiel #1
0
    /*
     * Encoder class methods
     */

    public static int Insert(bool dbconOpened, EncoderSQL es)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

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

        dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable +
                            " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " +
                            "signalOrCurve, filename, url, time, minHeight, description, status, " +
                            "videoURL, encoderConfiguration, future1, future2, future3)" +
                            " VALUES (" + es.uniqueID + ", " +
                            es.personID + ", " + es.sessionID + ", " +
                            es.exerciseID + ", \"" + es.eccon + "\", \"" +
                            es.LateralityToEnglish() + "\", \"" + es.extraWeight + "\", \"" +
                            es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
                            removeURLpath(es.url) + "\", " +
                            es.time + ", " + es.minHeight + ", \"" + es.description +
                            "\", \"" + es.status + "\", \"" +
                            removeURLpath(es.videoURL) + "\", \"" +
                            es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\", \"" +
                            Util.ConvertToPoint(es.future1) + "\", \"" + es.future2 + "\", \"" + es.future3 + "\")";
        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);
    }
Beispiel #2
0
    private static void update(bool dbconOpened, EncoderSQL es, SqliteCommand mycmd)
    {
        if (!dbconOpened)
        {
            Sqlite.Open();
        }

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

        mycmd.CommandText = "UPDATE " + Constants.EncoderTable + " SET " +
                            " personID = " + es.personID +
                            ", sessionID = " + es.sessionID +
                            ", exerciseID = " + es.exerciseID +
                            ", eccon = \"" + es.eccon +
                            "\", laterality = \"" + es.LateralityToEnglish() +
                            "\", extraWeight = \"" + es.extraWeight +
                            "\", signalOrCurve = \"" + es.signalOrCurve +
                            "\", filename = \"" + es.filename +
                            "\", url = \"" + removeURLpath(es.url) +
                            "\", time = " + es.time +
                            ", minHeight = " + es.minHeight +
                            ", description = \"" + es.description +
                            "\", status = \"" + es.status +
                            "\", videoURL = \"" + removeURLpath(es.videoURL) +
                            "\", encoderConfiguration = \"" + es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) +
                            "\", future1 = \"" + Util.ConvertToPoint(es.future1) +
                            "\", future2 = \"" + es.future2 +
                            "\", future3 = \"" + es.future3 +
                            "\" WHERE uniqueID == " + es.uniqueID;

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

        if (!dbconOpened)
        {
            Sqlite.Close();
        }
    }
Beispiel #3
0
    /*
     * Encoder class methods
     */
    public static int Insert(bool dbconOpened, EncoderSQL es)
    {
        if(! dbconOpened)
            Sqlite.Open();

        if(es.uniqueID == "-1")
            es.uniqueID = "NULL";

        dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable +
            " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " +
            "signalOrCurve, filename, url, time, minHeight, description, status, " +
            "videoURL, encoderConfiguration, future1, future2, future3)" +
            " VALUES (" + es.uniqueID + ", " +
            es.personID + ", " + es.sessionID + ", " +
            es.exerciseID + ", \"" + es.eccon + "\", \"" +
            es.LateralityToEnglish() + "\", \"" + es.extraWeight + "\", \"" +
            es.signalOrCurve + "\", \"" + es.filename + "\", \"" +
            removeURLpath(es.url) + "\", " +
            es.time + ", " + es.minHeight + ", \"" + es.description +
            "\", \"" + es.status + "\", \"" +
            removeURLpath(es.videoURL) + "\", \"" +
            es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\", \"" +
            Util.ConvertToPoint(es.future1) + "\", \"" + es.future2 + "\", \"" + es.future3 + "\")";
        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;
    }
Beispiel #4
0
    private static void update(bool dbconOpened, EncoderSQL es, SqliteCommand mycmd)
    {
        if(! dbconOpened)
            Sqlite.Open();

        if(es.uniqueID == "-1")
            es.uniqueID = "NULL";

        mycmd.CommandText = "UPDATE " + Constants.EncoderTable + " SET " +
                " personID = " + es.personID +
                ", sessionID = " + es.sessionID +
                ", exerciseID = " + es.exerciseID +
                ", eccon = \"" + es.eccon +
                "\", laterality = \"" + es.LateralityToEnglish() +
                "\", extraWeight = \"" + es.extraWeight +
                "\", signalOrCurve = \"" + es.signalOrCurve +
                "\", filename = \"" + es.filename +
                "\", url = \"" + removeURLpath(es.url) +
                "\", time = " + es.time +
                ", minHeight = " + es.minHeight +
                ", description = \"" + es.description +
                "\", status = \"" + es.status +
                "\", videoURL = \"" + removeURLpath(es.videoURL) +
                "\", encoderConfiguration = \"" + es.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.SQL) +
                "\", future1 = \"" + Util.ConvertToPoint(es.future1) +
                "\", future2 = \"" + es.future2 +
                "\", future3 = \"" + es.future3 +
                "\" WHERE uniqueID == " + es.uniqueID ;

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

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