protected override void write() { /* * string myStringPush = * personName + " " + * type + " " + Catalog.GetString("Time") + ": " + Util.TrimDecimals( time.ToString(), pDN ) ; */ if (simulated) { feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); } else { feedbackMessage = ""; } needShowFeedbackMessage = true; string table = Constants.ReactionTimeTable; uniqueID = SqliteReactionTime.Insert( false, table, "NULL", personID, sessionID, type, time, description, Util.BoolToNegativeInt(simulated)); //define the created object eventDone = new ReactionTime(uniqueID, personID, sessionID, type, time, description, Util.BoolToNegativeInt(simulated)); //app1.PrepareJumpSimpleGraph(tv, tc); PrepareEventGraphReactionTimeObject = new PrepareEventGraphReactionTime(time, sessionID, personID, table, type); needUpdateGraphType = eventType.REACTIONTIME; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow }
//reactionTime execution public ReactionTimeExecute(int personID, string personName, int sessionID, Chronopic cp, Gtk.TextView event_execute_textview_message, Gtk.Window app, int pDN, bool volumeOn, double progressbarLimit, ExecutingGraphData egd ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.cp = cp; this.event_execute_textview_message = event_execute_textview_message; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; this.progressbarLimit = progressbarLimit; this.egd = egd; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonEventEnded = new Gtk.Button(); fakeButtonFinished = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a ReactionTime eventDone = new ReactionTime(); //updateProgressBar = new UpdateProgressBar(); }
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); }
public int UploadRT(ReactionTime myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.ReactionTimeTable); myTest.UniqueID = temp; return(id); //uniqueID of person at server }
protected override System.Object getObjectFromString(string [] myStringOfData) { ReactionTime myReactionTime = new ReactionTime(); myReactionTime.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); myReactionTime.Time = Convert.ToDouble(myStringOfData[5].ToString()); myReactionTime.Description = myStringOfData[6].ToString(); myReactionTime.Simulated = Convert.ToInt32(myStringOfData[7].ToString()); return(myReactionTime); }
protected override void fillTime(Event myEvent) { ReactionTime myRT = (ReactionTime)myEvent; entryTime = myRT.Time.ToString(); //show all the decimals for not triming there in edit window using //(and having different values in formulae like GetHeightInCm ...) //entry_time_value.Text = Util.TrimDecimals(entryTime, pDN); entry_time_value.Text = entryTime; }
protected override string [] getLineToStore(System.Object myObject) { ReactionTime newReactionTime = (ReactionTime)myObject; string title = ""; if (newReactionTime.Simulated == Constants.Simulated) { title += Constants.SimulatedTreeview + " "; } string [] myData = new String [getColsNum()]; int count = 0; //myData[count++] = newReactionTime.Type; myData[count++] = title; myData[count++] = Util.TrimDecimals(newReactionTime.Time.ToString(), pDN); myData[count++] = newReactionTime.Description; myData[count++] = newReactionTime.UniqueID.ToString(); return(myData); }
//reactionTime execution public ReactionTimeExecute(int personID, string personName, int sessionID, string type, Chronopic cp, Gtk.Window app, int pDN, bool volumeOn, Preferences.GstreamerTypes gstreamer, double progressbarLimit, ExecutingGraphData egd, string description ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.type = type; this.cp = cp; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; this.gstreamer = gstreamer; this.progressbarLimit = progressbarLimit; this.egd = egd; this.description = description; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonThreadDyed = new Gtk.Button(); FakeButtonReactionTimeStart = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a ReactionTime eventDone = new ReactionTime(); //updateProgressBar = new UpdateProgressBar(); }
//reactionTime execution public ReactionTimeExecute(int personID, string personName, int sessionID, Chronopic cp, Gtk.Label event_execute_label_message, Gtk.Window app, int pDN, bool volumeOn, double progressbarLimit, ExecutingGraphData egd, string description ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.cp = cp; this.event_execute_label_message = event_execute_label_message; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; this.progressbarLimit = progressbarLimit; this.egd = egd; this.description = description; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonEventEnded = new Gtk.Button(); fakeButtonFinished = new Gtk.Button(); fakeButtonThreadDyed = new Gtk.Button(); FakeButtonReactionTimeStart = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a ReactionTime eventDone = new ReactionTime(); //updateProgressBar = new UpdateProgressBar(); }
//reactionTime execution public ReactionTimeExecute(int personID, string personName, int sessionID, string type, Chronopic cp, Gtk.Label event_execute_label_message, Gtk.Window app, int pDN, bool volumeOn, double progressbarLimit, ExecutingGraphData egd, string description ) { this.personID = personID; this.personName = personName; this.sessionID = sessionID; this.type = type; this.cp = cp; this.event_execute_label_message = event_execute_label_message; this.app = app; this.pDN = pDN; this.volumeOn = volumeOn; this.progressbarLimit = progressbarLimit; this.egd = egd; this.description = description; fakeButtonUpdateGraph = new Gtk.Button(); fakeButtonEventEnded = new Gtk.Button(); fakeButtonFinished = new Gtk.Button(); fakeButtonThreadDyed = new Gtk.Button(); FakeButtonReactionTimeStart = new Gtk.Button(); simulated = false; needUpdateEventProgressBar = false; needUpdateGraph = false; //initialize eventDone as a ReactionTime eventDone = new ReactionTime(); //updateProgressBar = new UpdateProgressBar(); }
public void TestCalculationTimeToEvent() { var reactionTime1 = new ReactionTime { hour = 5, minute = 25, second = 0 }; var reactionTime2 = new ReactionTime { hour = 15, minute = -1, second = -1 }; var leftToEvent1 = reactionTime1.TimeLeftBeforeEvent(new DateTime(2016, 1, 1, 6, 30, 0)); Assert.AreEqual(leftToEvent1, new TimeSpan(22, 55, 0)); var leftToEvent2 = reactionTime1.TimeLeftBeforeEvent(new DateTime(2016, 1, 1, 5, 0, 0)); Assert.AreEqual(leftToEvent2, new TimeSpan(0, 25, 0)); var leftToEvent3 = reactionTime1.TimeLeftBeforeEvent(new DateTime(2016, 1, 1, 5, 24, 5)); Assert.AreEqual(leftToEvent3, new TimeSpan(0, 0, 55)); var leftToEvent4 = reactionTime2.TimeLeftBeforeEvent(new DateTime(2016, 1, 1, 4, 25, 0)); Assert.AreEqual(leftToEvent4, new TimeSpan(11, 0, 0)); var leftToEvent5 = reactionTime2.TimeLeftBeforeEvent(new DateTime(2016, 1, 1, 16, 25, 0)); Assert.AreEqual(leftToEvent5, new TimeSpan(23, 0, 0)); }
public void UploadRTAsync(ReactionTime myTest) { this.UploadRTAsync(myTest, null); }
public int UploadRT(ReactionTime myTest) { object[] results = this.Invoke("UploadRT", new object[] { myTest}); return ((int)(results[0])); }
//upload a test private static Constants.UploadCodes serverUploadTest(ChronojumpServer myServer, Constants.TestTypes type, string tableName, Event myTest) { Constants.UploadCodes uCode; if (myTest.Simulated == Constants.Simulated) { //Test is simulated, don't upload uCode = Constants.UploadCodes.SIMULATED; } else if (myTest.Simulated > 0) { //Test is already uploaded, don't upload uCode = Constants.UploadCodes.EXISTS; } else { int idAtServer = -1; switch (type) { case Constants.TestTypes.JUMP: Jump jump = (Jump)myTest; idAtServer = myServer.UploadJump(jump); break; case Constants.TestTypes.JUMP_RJ: JumpRj jumpRj = (JumpRj)myTest; idAtServer = myServer.UploadJumpRj(jumpRj); break; case Constants.TestTypes.RUN: Run run = (Run)myTest; idAtServer = myServer.UploadRun(run); break; case Constants.TestTypes.RUN_I: RunInterval runI = (RunInterval)myTest; idAtServer = myServer.UploadRunI(runI); break; case Constants.TestTypes.RT: ReactionTime rt = (ReactionTime)myTest; idAtServer = myServer.UploadRT(rt); break; case Constants.TestTypes.PULSE: Pulse pulse = (Pulse)myTest; idAtServer = myServer.UploadPulse(pulse); break; case Constants.TestTypes.MULTICHRONOPIC: MultiChronopic mc = (MultiChronopic)myTest; idAtServer = myServer.UploadMultiChronopic(mc); break; } //update test (simulated) on client database myTest.Simulated = idAtServer; SqliteEvent.UpdateSimulated(true, tableName, myTest.UniqueID, idAtServer); uCode = Constants.UploadCodes.OK; } return(uCode); }
private void treeviewReactionTimesContextMenu(ReactionTime myRt) { Menu myMenu = new Menu (); Gtk.MenuItem myItem; /* myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + myRt.Type + " (" + myRt.PersonName + ")"); if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, Constants.TestTypes.RT, myTreeViewReactionTimes.EventSelectedID))) { myItem.Activated += on_video_play_selected_reaction_time_clicked; myItem.Sensitive = true; } else myItem.Sensitive = false; myMenu.Attach( myItem, 0, 1, 0, 1 ); */ myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRt.Type + " (" + myRt.PersonName + ")"); myItem.Activated += on_edit_selected_reaction_time_clicked; myMenu.Attach( myItem, 0, 1, 0, 1 ); Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem(); myMenu.Attach( mySep, 0, 1, 1, 2 ); myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRt.Type + " (" + myRt.PersonName + ")"); myItem.Activated += on_delete_selected_reaction_time_clicked; myMenu.Attach( myItem, 0, 1, 2, 3 ); myMenu.Popup(); myMenu.ShowAll(); }
private void on_reaction_time_finished(object o, EventArgs args) { currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_reaction_time_finished); if ( ! currentEventExecute.Cancel ) { currentReactionTime = (ReactionTime) currentEventExecute.EventDone; //move video file if exists Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, currentReactionTime.UniqueID); myTreeViewReactionTimes.Add(currentPerson.Name, currentReactionTime); //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown showHideActionEventButtons(true, "ReactionTime"); //show if(createdStatsWin) { showUpdateStatsAndHideData(true); } //unhide buttons for delete last reaction time sensitiveGuiYesEvent(); } else if( currentEventExecute.ChronopicDisconnected ) { Log.WriteLine("DISCONNECTED gui/cj"); createChronopicWindow(true); } //unhide buttons that allow jumping sensitiveGuiEventDone(); }
/* * useful to do a conversion from an int to a double * used on jump.angle * we done on sqlite/jump.cs: * on createTable change "angle INT" to "angle FLOAT" * then call this alterTableColumn * * but CAUTION: doing this, all the float data is converted to .0 * eg: 27.35 will be 27.0 * -1 will be -1.0 * * if we don't use this, and we have created a column as int, and introduce floats or doubles, * we can insert ok the float or doubles, but on select we will have ints */ protected internal static void alterTableColumn(Sqlite sqliteObject, string tableName, int columns) { conversionSubRate = 1; conversionSubRateTotal = -1; //unknown yet //2st create convert temp table sqliteObject.createTable(Constants.ConvertTempTable); //2nd copy all data from desired table to temp table adding the simulated column ArrayList myArray = new ArrayList(2); dbcmd.CommandText = "SELECT * " + "FROM " + tableName + " ORDER BY uniqueID"; SqliteDataReader reader; reader = dbcmd.ExecuteReader(); LogB.SQL(dbcmd.CommandText.ToString()); while(reader.Read()) { string [] myReaderStr = new String[columns]; for (int i=0; i < columns; i ++) myReaderStr[i] = reader[i].ToString(); Event myEvent = new Event(); switch (tableName) { case Constants.JumpTable: myEvent = new Jump(myReaderStr); break; case Constants.JumpRjTable: myEvent = new JumpRj(myReaderStr); break; case Constants.RunTable: myEvent = new Run(myReaderStr); break; case Constants.RunIntervalTable: myEvent = new RunInterval(myReaderStr); break; case Constants.ReactionTimeTable: myEvent = new ReactionTime(myReaderStr); break; case Constants.PulseTable: myEvent = new Pulse(myReaderStr); break; } myArray.Add(myEvent); } reader.Close(); conversionSubRateTotal = myArray.Count * 2; foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } //3rd drop desired table Sqlite.dropTable(tableName); //4d create desired table (now with new columns) sqliteObject.createTable(tableName); //5th insert data in desired table foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, tableName); conversionSubRate ++; } //6th drop temp table Sqlite.dropTable(Constants.ConvertTempTable); }
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 override System.Object getObjectFromString(string [] myStringOfData) { ReactionTime myReactionTime = new ReactionTime(); myReactionTime.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); myReactionTime.Type = myStringOfData[4].ToString(); myReactionTime.Time = Convert.ToDouble(myStringOfData[5].ToString()); myReactionTime.Description = myStringOfData[6].ToString(); myReactionTime.Simulated = Convert.ToInt32(myStringOfData[7].ToString()); return myReactionTime; }
public void UploadRTAsync(ReactionTime myTest, object userState) { if ((this.UploadRTOperationCompleted == null)) { this.UploadRTOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadRTCompleted); } this.InvokeAsync("UploadRT", new object[] { myTest}, this.UploadRTOperationCompleted, userState); }
private void on_reaction_time_finished(object o, EventArgs args) { currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_reaction_time_finished); //test can be deleted if not cancelled button_delete_last_test.Sensitive = ! currentEventExecute.Cancel; if ( ! currentEventExecute.Cancel ) { currentReactionTime = (ReactionTime) currentEventExecute.EventDone; //move video file if exists if(preferences.videoOn) if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, currentReactionTime.UniqueID)) new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored.")); myTreeViewReactionTimes.Add(currentPerson.Name, currentReactionTime); //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown showHideActionEventButtons(true, "ReactionTime"); //show if(createdStatsWin) { showUpdateStatsAndHideData(true); } //unhide buttons for delete last reaction time sensitiveGuiYesEvent(); } else if( currentEventExecute.ChronopicDisconnected ) chronopicDisconnectedWhileExecuting(); }
/* * The problem of this method is that uses class constructors: person, jump, ... * and if the sqlite version is updated from a really old version * maybe the object has to be converted from really older class to old, and then to new class (two conversions) * and this can have problems in the class construction * The best seem to have a boolean that indicates if certain conversion has done before * (see bool runAndRunIntervalInitialSpeedAdded) */ protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle) { conversionSubRate = 1; conversionSubRateTotal = -1; //unknown yet //2st create convert temp table sqliteObject.createTable(Constants.ConvertTempTable); //2nd copy all data from desired table to temp table (in event tables, adding the simulated column) ArrayList myArray = new ArrayList(2); dbcmd.CommandText = "SELECT * " + "FROM " + tableName + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); while(reader.Read()) { string [] myReaderStr = new String[columnsBefore + columnsToAdd.Count]; int i; for (i=0; i < columnsBefore; i ++) myReaderStr[i] = reader[i].ToString(); foreach (string myStr in columnsToAdd) myReaderStr[i++] = myStr; if (putDescriptionInMiddle) { //string [] strFull = changePos.Split(new char[] {':'}); //int row1 = Convert.ToInt32(strFull[0]); //int row2 = Convert.ToInt32(strFull[1]); string desc = myReaderStr[6]; myReaderStr[6] = myReaderStr[7]; myReaderStr[7] = myReaderStr[8]; myReaderStr[8] = myReaderStr[9]; myReaderStr[9] = desc; } if(tableName == Constants.PersonOldTable) { PersonOld myPerson = new PersonOld(myReaderStr); myArray.Add(myPerson); } else if(tableName == Constants.SessionTable) { Session mySession = new Session(myReaderStr); myArray.Add(mySession); } else if(tableName == Constants.RunIntervalTypeTable) { RunType myType = new RunType(myReaderStr, true); //interval myArray.Add(myType); } else if(tableName == Constants.PersonSessionOldWeightTable) { PersonSessionOld myPS = new PersonSessionOld(myReaderStr); myArray.Add(myPS); } else { Event myEvent = new Event(); switch (tableName) { case Constants.JumpTable: myEvent = new Jump(myReaderStr); break; case Constants.JumpRjTable: myEvent = new JumpRj(myReaderStr); break; case Constants.RunTable: myEvent = new Run(myReaderStr); break; case Constants.RunIntervalTable: myEvent = new RunInterval(myReaderStr); break; case Constants.ReactionTimeTable: myEvent = new ReactionTime(myReaderStr); break; case Constants.PulseTable: myEvent = new Pulse(myReaderStr); break; } myArray.Add(myEvent); } } reader.Close(); LogB.SQL("1" + tableName); conversionSubRateTotal = myArray.Count * 2; if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, Constants.ConvertTempTable, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } LogB.SQL("2" + tableName); //3rd drop desired table Sqlite.dropTable(tableName); LogB.SQL("3" + tableName); //4d create desired table (now with new columns) sqliteObject.createTable(tableName); LogB.SQL("4" + tableName); //5th insert data in desired table if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, tableName, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, tableName); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, tableName); conversionSubRate ++; } } LogB.SQL("5" + tableName); //6th drop temp table Sqlite.dropTable(Constants.ConvertTempTable); }
public System.IAsyncResult BeginUploadRT(ReactionTime myTest, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UploadRT", new object[] { myTest}, callback, asyncState); }
public int UploadRT(ReactionTime myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.ReactionTimeTable); myTest.UniqueID = temp; return id; //uniqueID of person at server }
public static ReactionTime SelectReactionTimeData(int uniqueID, bool dbconOpened) { if(!dbconOpened) dbcon.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.ReactionTimeTable + " WHERE uniqueID == " + uniqueID; Log.WriteLine(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); reader.Read(); ReactionTime myRT = new ReactionTime(DataReaderToStringArray(reader, 7)); reader.Close(); if(!dbconOpened) dbcon.Close(); return myRT; }
protected override void write() { /* string myStringPush = personName + " " + type + " " + Catalog.GetString("Time") + ": " + Util.TrimDecimals( time.ToString(), pDN ) ; */ if(simulated) feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); else feedbackMessage = ""; needShowFeedbackMessage = true; uniqueID = SqliteReactionTime.Insert( false, Constants.ReactionTimeTable, "NULL", personID, sessionID, "", //type time, "", Util.BoolToNegativeInt(simulated)); //time, description, simulated //define the created object eventDone = new ReactionTime(uniqueID, personID, sessionID, time, "", Util.BoolToNegativeInt(simulated)); //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); //app1.PrepareJumpSimpleGraph(tv, tc); PrepareEventGraphReactionTimeObject = new PrepareEventGraphReactionTime(time); needUpdateGraphType = eventType.REACTIONTIME; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow }