public static SelectAndReturnRunIntervalType ( string typeName, bool dbconOpened ) : RunType, | ||
typeName | string | |
dbconOpened | bool | |
return | RunType, |
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); }
protected override System.Object getObjectFromString(string [] myStringOfData) { RunInterval myRunI = new RunInterval(); myRunI.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); myRunI.Type = myStringOfData[4].ToString(); myRunI.DistanceTotal = Convert.ToDouble(myStringOfData[5].ToString()); myRunI.TimeTotal = Convert.ToDouble(myStringOfData[6].ToString()); myRunI.DistanceInterval = Convert.ToDouble(myStringOfData[7].ToString()); myRunI.IntervalTimesString = myStringOfData[8].ToString(); myRunI.Limited = myStringOfData[11].ToString(); myRunI.Description = myStringOfData[10].ToString(); myRunI.Simulated = Convert.ToInt32(myStringOfData[12].ToString()); //speed is not needed to define runType = SqliteRunIntervalType.SelectAndReturnRunIntervalType(myRunI.Type, Sqlite.IsOpened); return(myRunI); }
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; } }
protected void printRunsInterval(bool showSubruns, string title) { int dec = preferences.digitsNumber; //decimals ArrayList myData = new ArrayList(1); bool isFirstHeader = true; if (myRunsInterval.Length > 0) { printTitles(title); } Sqlite.Open(); foreach (string runString in myRunsInterval) { if (showSubruns) { myData = new ArrayList(1); } //if show subruns show this every time, else show only one if (isFirstHeader || showSubruns) { myData.Add("\n" + Catalog.GetString("Person ID") + ":" + Catalog.GetString("Person name") + ":" + Catalog.GetString("run ID") + ":" + Catalog.GetString("Type") + ":" + Catalog.GetString("Distance total") + ":" + Catalog.GetString("Time total") + ":" + Catalog.GetString("Average speed") + ":" + Catalog.GetString("Distance interval") + ":" + Catalog.GetString("Laps") + ":" + Catalog.GetString("Limited") + ":" + Catalog.GetString("Description") + ":" + Catalog.GetString("Simulated") + ":" + Catalog.GetString("Initial Speed")); isFirstHeader = false; } string [] myStr = runString.Split(new char[] { ':' }); RunType myRunType = new RunType(); string myRunTypeString = myStr[4]; string myRunDistanceInterval = myStr[7]; if (myRunDistanceInterval == "-1" || myRunDistanceInterval == "-1.0") { myRunType = SqliteRunIntervalType.SelectAndReturnRunIntervalType( myRunTypeString, true); } myData.Add( myStr[2] + ":" + //personID myStr[0] + ":" + myStr[1] + ":" + //person.name, run.uniqueID myRunTypeString + ":" + Util.TrimDecimals(myStr[5], dec) + ":" + //run.type, run.distancetotal Util.TrimDecimals(myStr[6], dec) + ":" + //run.timetotal Util.TrimDecimals(Util.GetSpeed(myStr[5], myStr[6], true), dec) + ":" + //speed AVG in m/s(true) myStr[7] + ":" + //run.distanceInterval myStr[9] + ":" + Util.GetLimitedRounded(myStr[11], dec) + ":" + //tracks, limited Util.RemoveNewLine(myStr[10], true) + ":" + //description Util.SimulatedTestNoYes(Convert.ToInt32(myStr[12])) + ":" + //simulated Util.NoYes(Util.StringToBool(myStr[13])) //initialSpeed ); if (showSubruns) { writeData(myData); myData = new ArrayList(1); //print intervalTimesString string [] timeString = myStr[8].Split(new char[] { '=' }); myData.Add(" " + ":" + Catalog.GetString("Interval speed") + ":" + Catalog.GetString("interval times")); //print Total, AVG, SD myData.Add(Catalog.GetString("Total") + ":" + " " + ":" + Util.TrimDecimals(Util.GetTotalTime(myStr[8]).ToString(), dec)); myData.Add(Catalog.GetString("AVG") + ":" + Util.TrimDecimals(Util.GetSpeed( myStr[5], myStr[6], true), dec) + ":" + Util.TrimDecimals(Util.GetAverage(myStr[8]).ToString(), dec)); myData.Add(Catalog.GetString("SD") + ":" + " " + ":" + Util.TrimDecimals(Util.CalculateSD( Util.ChangeEqualForColon(myStr[8]), Util.GetTotalTime(myStr[8]), Util.GetNumberOfJumps(myStr[8], false)).ToString(), dec)); int count = 1; foreach (string myTime in timeString) { string myDistance = myStr[7]; string myShowDistance = ""; if (myRunDistanceInterval == "-1" || myRunDistanceInterval == "-1.0") { myDistance = Util.GetRunIVariableDistancesStringRow( myRunType.DistancesString, count - 1).ToString(); myShowDistance = " (" + myDistance.ToString() + "m)"; } myData.Add((count++).ToString() + myShowDistance + ":" + Util.TrimDecimals(Util.GetSpeed(myDistance, myTime, true), dec) + ":" + //true for: m/s Util.TrimDecimals(myTime, dec) ); } writeData(myData); writeData("VERTICAL-SPACE"); } } Sqlite.Close(); //if not showSubruns write data at last for not having every row as TH if (!showSubruns) { writeData(myData); } }
//run execution public RunIntervalExecute(int personID, int sessionID, string type, double distanceInterval, double limitAsDouble, bool tracksLimited, Chronopic cp, Gtk.Label event_execute_label_message, Gtk.Window app, int pDN, bool metersSecondsPreferred, bool volumeOn, RepetitiveConditionsWindow repetitiveConditionsWin, double progressbarLimit, ExecutingGraphData egd, Constants.DoubleContact checkDoubleContactMode, int checkDoubleContactTime, bool speedStartArrival ) { this.personID = personID; this.sessionID = sessionID; this.type = type; this.distanceInterval = distanceInterval; this.limitAsDouble = limitAsDouble; this.tracksLimited = tracksLimited; //if distances are variable distancesString = ""; if (distanceInterval == -1) { RunType runType = SqliteRunIntervalType.SelectAndReturnRunIntervalType(type, false); distancesString = runType.DistancesString; } if (tracksLimited) { this.limited = limitAsDouble.ToString() + "R"; //'R'uns (don't put 'T'racks for not confusing with 'T'ime) } else { this.limited = limitAsDouble.ToString() + "T"; timeTotal = limitAsDouble; } this.cp = cp; this.event_execute_label_message = event_execute_label_message; this.app = app; this.metersSecondsPreferred = metersSecondsPreferred; this.pDN = pDN; this.volumeOn = volumeOn; this.repetitiveConditionsWin = repetitiveConditionsWin; this.progressbarLimit = progressbarLimit; this.egd = egd; this.checkDoubleContactMode = checkDoubleContactMode; this.checkDoubleContactTime = checkDoubleContactTime; this.speedStartArrival = speedStartArrival; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonEventEnded = new Gtk.Button(); fakeButtonFinished = new Gtk.Button(); fakeButtonThreadDyed = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; timesForSavingRepetitive = 1; //number of times that this repetive event needs for being recorded in temporal table //initialize eventDone as a RunInterval eventDone = new RunInterval(); }