public int UploadPulse(Pulse myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.PulseTable); myTest.UniqueID = temp; return(id); //uniqueID of person at server }
void on_button_accept_clicked(object o, EventArgs args) { //foreach all lines... extrac intervalTimesString TreeIter myIter; string timeString = ""; bool iterOk = store.GetIterFirst(out myIter); if (iterOk) { string equal = ""; //first iteration should not appear '=' do { timeString = timeString + equal + (string)treeview_subevents.Model.GetValue(myIter, 1); equal = "="; } while (store.IterNext(ref myIter)); } //calculate other variables needed for pulse creation myPulse.TotalPulsesNum = Util.GetNumberOfJumps(timeString, false); //don't need a GetNumberOfRuns, this works myPulse.TimesString = timeString; //save it deleting the old first for having the same uniqueID Sqlite.Delete(false, Constants.PulseTable, myPulse.UniqueID); myPulse.InsertAtDB(false, Constants.PulseTable); /* * SqlitePulse.Insert(myPulse.UniqueID.ToString(), * myPulse.PersonID, myPulse.SessionID, * myPulse.Type, myPulse.FixedPulse, totalPulsesNum, * timeString, myPulse.Description * ); */ //close the window RepairPulseWindowBox.repair_sub_event.Hide(); RepairPulseWindowBox = null; }
public int UploadPulse(Pulse myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.PulseTable); myTest.UniqueID = temp; return id; //uniqueID of person at server }
/* * 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); }