SqliteRunIntervalType.SelectAndReturnRunIntervalType C# (CSharp) Method

SelectAndReturnRunIntervalType() public static method

public static SelectAndReturnRunIntervalType ( string typeName, bool dbconOpened ) : RunType,
typeName string
dbconOpened bool
return RunType,
    public static RunType SelectAndReturnRunIntervalType(string typeName, bool dbconOpened)
    {
        if(!dbconOpened)
            Sqlite.Open();
        dbcmd.CommandText = "SELECT * " +
            " FROM " + Constants.RunIntervalTypeTable +
            " WHERE name  = \"" + typeName +
            "\" ORDER BY uniqueID";

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

        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        RunType myRunType = new RunType();

        while(reader.Read()) {
            myRunType.Name = reader[1].ToString();
            myRunType.Distance = Convert.ToDouble( reader[2].ToString() );
            myRunType.HasIntervals = true;
            myRunType.TracksLimited = Util.IntToBool(Convert.ToInt32(reader[3].ToString()));
            myRunType.FixedValue = Convert.ToInt32( reader[4].ToString() );
            myRunType.Unlimited = Util.IntToBool(Convert.ToInt32(reader[5].ToString()));
            myRunType.Description = reader[6].ToString();

            myRunType.DistancesString = Util.ChangeDecimalSeparator(reader[7].ToString());
            //if it has no value sqlite reads it as 0, but should be ""
            if(myRunType.DistancesString == "0")
                myRunType.DistancesString = "";
        }

        myRunType.IsPredefined = myRunType.FindIfIsPredefined();

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

        return myRunType;
    }

Usage Example

コード例 #1
0
    protected override string [] getSubLineToStore(System.Object myObject, int lineCount)
    {
        RunInterval newRunI = (RunInterval)myObject;

        //check the time
        string [] myStringFull = newRunI.IntervalTimesString.Split(new char[] { '=' });
        string    timeInterval = myStringFull[lineCount];


        //write line for treeview
        string [] myData = new String [getColsNum()];
        int       count  = 0;

        if (newRunI.DistanceInterval == -1)
        {
            runType         = SqliteRunIntervalType.SelectAndReturnRunIntervalType(newRunI.Type, Sqlite.IsOpened);
            myData[count++] = (lineCount + 1).ToString() +
                              " (" + Util.GetRunIVariableDistancesStringRow(runType.DistancesString, lineCount).ToString() + "m)";

            myData[count++] = Util.TrimDecimals(
                Util.GetSpeed(
                    Util.GetRunIVariableDistancesStringRow(runType.DistancesString, lineCount).ToString(),                             //distancesString (variable)
                    timeInterval,
                    metersSecondsPreferred)
                , pDN);
        }
        else
        {
            myData[count++] = (lineCount + 1).ToString();

            myData[count++] = Util.TrimDecimals(
                Util.GetSpeed(
                    newRunI.DistanceInterval.ToString(),                             //distanceInterval (same for all subevents)
                    timeInterval,
                    metersSecondsPreferred)
                , pDN);
        }

        myData[count++] = Util.TrimDecimals(timeInterval, pDN);                                         //lapTime

        myData[count++] = Util.TrimDecimals(getSplitTime(newRunI.IntervalTimesString, lineCount), pDN); //splitTime
        myData[count++] = "";

        myData[count++] = "-1";         //mark to non select here, select first line

        return(myData);
    }
All Usage Examples Of SqliteRunIntervalType::SelectAndReturnRunIntervalType