Insert() public static method

public static Insert ( bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, double distanceTotal, double timeTotal, double distanceInterval, string intervalTimesString, double tracks, string description, string limited, int simulated, bool initialSpeed ) : int
dbconOpened bool
tableName string
uniqueID string
personID int
sessionID int
type string
distanceTotal double
timeTotal double
distanceInterval double
intervalTimesString string
tracks double
description string
limited string
simulated int
initialSpeed bool
return int
Esempio n. 1
0
 public override int InsertAtDB(bool dbconOpened, string tableName)
 {
     return(SqliteRunInterval.Insert(dbconOpened, tableName,
                                     uniqueID.ToString(),
                                     personID, sessionID,
                                     type, distanceTotal, timeTotal,
                                     distanceInterval, intervalTimesString,
                                     tracks, description,
                                     limited, simulated, initialSpeed));
 }
Esempio n. 2
0
    protected void writeRunInterval(bool tempTable)
    {
        int    tracksHere  = 0;     //different than globakl tracks variable
        string limitString = "";

        //if user clicked in finish earlier
        if (finish)
        {
            if (tracksLimited)
            {
                tracksHere  = Util.GetNumberOfJumps(intervalTimesString, false);
                limitString = tracksHere.ToString() + "R";
            }
            else
            {
                //when we mark that run should finish by time, chronopic thread is probably capturing data
                //check if it captured more than date limit, and if it has done, delete last(s) run(s)
                if (limitAsDouble != -1)
                {
                    bool eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble);
                    while (eventPassed)
                    {
                        intervalTimesString = Util.DeleteLastSubEvent(intervalTimesString);

                        //run limited by time that first subRun has arrived later than maximum for the whole run,
                        //and DeleteLastSubEvent returns "-" as a mark
                        if (intervalTimesString[0] == '-')
                        {
                            //this dialog can make crash the software because the non-gui part calls it
                            //new DialogMessage(Constants.MessageTypes.WARNING,
                            //		Catalog.GetString("Run will not be recorded, 1st track is out of time"));

                            feedbackMessage         = Catalog.GetString("Run will not be recorded. Out of time.");
                            needShowFeedbackMessage = true;
                            LogB.Information("Run will not be recorded, 1st track is out of time");

                            //mark for not having problems with cancelled
                            cancel = true;
                            //event will be raised, and managed in chronojump.cs
                            fakeButtonFinished.Click();

                            //end this piece of code
                            return;
                        }
                        else
                        {
                            LogB.Information("Deleted one event out of time");
                            eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble);
                        }
                    }
                }
                //tracksHere are defined here (and not before) because can change on "while(eventPassed)" before
                tracksHere  = Util.GetNumberOfJumps(intervalTimesString, false);
                limitString = Util.GetTotalTime(intervalTimesString) + "T";
            }
        }
        else
        {
            if (tracksLimited)
            {
                limitString = limitAsDouble.ToString() + "R";
                tracksHere  = (int)limitAsDouble;
            }
            else
            {
                limitString = limitAsDouble.ToString() + "T";
                string [] myStringFull = intervalTimesString.Split(new char[] { '=' });
                tracksHere = myStringFull.Length;
            }
        }

        distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracksHere);
        timeTotal     = Util.GetTotalTime(intervalTimesString);


        string description = "";

        if (type == "MTGUG")
        {
            description = "u u u u u u";             //undefined 6 items of questionnaire
        }
        if (tempTable)
        {
            SqliteRunInterval.Insert(false, Constants.TempRunIntervalTable, "NULL", personID, sessionID, type,
                                     distanceTotal, timeTotal,
                                     distanceInterval, intervalTimesString, tracksHere,
                                     description,
                                     limitString,
                                     Util.BoolToNegativeInt(simulated),
                                     !startIn           //initialSpeed true if not startIn
                                     );
        }
        else
        {
            uniqueID = SqliteRunInterval.Insert(false, Constants.RunIntervalTable, "NULL", personID, sessionID, type,
                                                distanceTotal, timeTotal,
                                                distanceInterval, intervalTimesString, tracksHere,
                                                description,
                                                limitString,
                                                Util.BoolToNegativeInt(simulated),
                                                !startIn
                                                );

            //define the created object
            eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn);


            string tempValuesString = "";
            if (tracksLimited)
            {
                tempValuesString = " (" + distanceIntervalFixed + "x" + tracksHere + "R), " + Catalog.GetString("Time") + ": " + Util.TrimDecimals(timeTotal.ToString(), pDN);
            }
            else
            {
                tempValuesString = " (" + distanceIntervalFixed + "x" + Util.TrimDecimals(timeTotal.ToString(), pDN) + "T), " + Catalog.GetString("Tracks") + ": " + tracksHere;
            }

            /*
             * string myStringPush =   Catalog.GetString("Last run") + ": " + RunnerName + ", " +
             *      type + tempValuesString + ", " +
             *      Catalog.GetString("AVG Speed") + ": " + Util.TrimDecimals(
             *                      Util.GetSpeed(distanceTotal.ToString(),
             *                              timeTotal.ToString(), metersSecondsPreferred )
             *                      , pDN ) ;
             */
            if (simulated)
            {
                feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
            }
            else
            {
                feedbackMessage = "";
            }
            needShowFeedbackMessage = true;


            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
                distanceIntervalFixed, Util.GetLast(intervalTimesString), intervalTimesString, distanceTotal, distancesString);
            needUpdateGraphType = eventType.RUNINTERVAL;
            needUpdateGraph     = true;

            needEndEvent = true;             //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here
        }
    }