//if uniqueID != -1, returns an especific EncoderExercise that can be read like this //EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID)[0]; public static ArrayList SelectEncoderExercises(bool dbconOpened, int uniqueID, bool onlyNames) { if (!dbconOpened) { Sqlite.Open(); } string uniqueIDStr = ""; if (uniqueID != -1) { uniqueIDStr = " WHERE " + Constants.EncoderExerciseTable + ".uniqueID = " + uniqueID; } if (onlyNames) { dbcmd.CommandText = "SELECT name FROM " + Constants.EncoderExerciseTable + uniqueIDStr; } else { dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderExerciseTable + uniqueIDStr; } LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); EncoderExercise ex = new EncoderExercise(); if (onlyNames) { while (reader.Read()) { ex = new EncoderExercise(reader[0].ToString()); array.Add(ex); } } else { while (reader.Read()) { double speed1RM = 0; if (reader[5].ToString() != "") { speed1RM = Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())); } ex = new EncoderExercise( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name Convert.ToInt32(reader[2].ToString()), //percentBodyWeight reader[3].ToString(), //ressistance reader[4].ToString(), //description speed1RM ); array.Add(ex); } } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }
//this is called by non gtk thread. Don't do gtk stuff here //I suppose reading gtk is ok, changing will be the problem private void encoderDoAnalyze() { EncoderParams ep = new EncoderParams(); string dataFileName = ""; string analysisOptions = getEncoderAnalysisOptions(); //use this send because we change it to send it to R //but we don't want to change encoderAnalysis because we want to know again if == "cross" (or "1RM") //encoderAnalysis can be "cross" and sendAnalysis be "Speed / Load" //encoderAnalysis can be "1RM" and sendAnalysis be "1RMBadilloBench, ... string sendAnalysis = encoderAnalysis; //see doProcess at encoder/graph.R string analysisVariables = "none"; //cannot be blank string crossName = ""; if(sendAnalysis == "cross") { crossName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_cross), encoderAnalyzeCrossTranslation); if( crossName == "Power / Load" || crossName == "Speed / Load" || crossName == "Force / Load" || crossName == "Speed,Power / Load" || crossName == "Force / Speed"|| crossName == "Power / Speed" ) { //convert: "Force / Speed" in: "Force;Speed;mean" string [] crossNameFull = crossName.Split(new char[] {' '}); analysisVariables = crossNameFull[0] + ";" + crossNameFull[2]; //[1]=="/" if(check_encoder_analyze_mean_or_max.Active) analysisVariables += ";mean"; else analysisVariables += ";max"; } else if (crossName == "Power / Date" || crossName == "Speed / Date" || crossName == "Force / Date" ) { /* * In order to recycle paintCrossVariables in encoder/graph.R, * we send "Force / Date" as "Force;Load;(mean or max);Date" and there variables will be swapped */ //convert: "Force / Date" in: "Force;Load;mean;Date" string [] crossNameFull = crossName.Split(new char[] {' '}); analysisVariables = crossNameFull[0] + ";Load"; if(check_encoder_analyze_mean_or_max.Active) analysisVariables += ";mean;Date"; else analysisVariables += ";max;Date"; } } string my1RMName = ""; if(sendAnalysis == "1RM") { my1RMName = Util.FindOnArray(':',1,0,UtilGtk.ComboGetActive(combo_encoder_analyze_1RM), encoderAnalyze1RMTranslation); //(my1RMName == "1RM Any exercise") done below different for curve and signal if(my1RMName == "1RM Bench Press") { sendAnalysis = "1RMBadilloBench"; analysisOptions = "p"; } else if(my1RMName == "1RM Squat") { sendAnalysis = "1RMBadilloSquat"; analysisOptions = "p"; } } if(sendAnalysis == "powerBars" || sendAnalysis == "single" || sendAnalysis == "side") analysisVariables = getAnalysisVariables(sendAnalysis); if( ! radio_encoder_analyze_individual_current_set.Active) //not current set { string myEccon = "ec"; if(! check_encoder_analyze_eccon_together.Active) myEccon = "ecS"; int myCurveNum = -1; if(sendAnalysis == "single") myCurveNum = Convert.ToInt32(UtilGtk.ComboGetActive( combo_encoder_analyze_curve_num_combo)); dataFileName = UtilEncoder.GetEncoderGraphInputMulti(); //neuromuscularProfile works only with ec, do not use c curves EncoderSQL.Eccons ecconSelect = EncoderSQL.Eccons.ALL; if(encoderAnalysis == "neuromuscularProfile") { ecconSelect = EncoderSQL.Eccons.ecS; } //double bodyMass = Convert.ToDouble(currentPersonSession.Weight); //select curves for this person ArrayList data = new ArrayList(); if(radio_encoder_analyze_individual_current_session.Active) { //select currentPerson, currentSession curves //onlyActive is false to have all the curves //this is a need for "single" to select on display correct curve data = SqliteEncoder.Select( false, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(), getExerciseIDFromCombo(exerciseCombos.ANALYZE), "curve", ecconSelect, false, true); } else if(radio_encoder_analyze_groupal_current_session.Active) { for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) { ArrayList dataPre = SqliteEncoder.Select( false, -1, Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()), currentSession.UniqueID, getEncoderGI(), getExerciseIDFromCombo(exerciseCombos.ANALYZE), "curve", EncoderSQL.Eccons.ALL, false, //onlyActive=false. Means: all saved repetitions true); foreach(EncoderSQL eSQL in dataPre) { eSQL.status = "active"; //force all to be active on interperson data.Add(eSQL); } } LogB.Information("ENCODERCOMPAREINTER GROUP"); foreach (string str in encSelReps.EncoderCompareInter) LogB.Information(str); } else if(radio_encoder_analyze_individual_all_sessions.Active) { for (int i=0 ; i < encSelReps.EncoderCompareInter.Count ; i ++) { ArrayList dataPre = SqliteEncoder.Select( false, -1, currentPerson.UniqueID, Util.FetchID(encSelReps.EncoderCompareInter[i].ToString()), getEncoderGI(), getExerciseIDFromCombo(exerciseCombos.ANALYZE), "curve", EncoderSQL.Eccons.ALL, false, //onlyActive=false. Means: all saved repetitions true); foreach(EncoderSQL eSQL in dataPre) { string comboWeightsValue = UtilGtk.ComboGetActive(combo_encoder_analyze_weights); if(check_encoder_intersession_x_is_date.Active && comboWeightsValue != Catalog.GetString("All weights") && comboWeightsValue != Util.ChangeDecimalSeparator(eSQL.extraWeight)) continue; eSQL.status = "active"; //force all to be active on intersession data.Add(eSQL); } } LogB.Information("ENCODERCOMPAREINTER INTERSESSION"); foreach (string str in encSelReps.EncoderCompareInter) LogB.Information(str); } //1RM is calculated using curves //cannot be curves of different exercises //because is 1RM of a person on an exercise //this is checked at: "on_button_encoder_analyze_clicked()" if(encoderAnalysis == "1RM" && (my1RMName == "1RM Bench Press" || my1RMName == "1RM Squat" || my1RMName == "1RM Any exercise") ) { //get exercise ID int exID = -1; foreach(EncoderSQL eSQL in data) { if(eSQL.status == "active") { exID = eSQL.exerciseID; break; } } if(my1RMName == "1RM Any exercise") { //get speed1RM (from exercise of curve on SQL, not from combo) EncoderExercise exTemp = (EncoderExercise) SqliteEncoder.SelectEncoderExercises( false , exID, false)[0]; sendAnalysis = "1RMAnyExercise"; analysisVariables = Util.ConvertToPoint(exTemp.speed1RM) + ";" + SqlitePreferences.Select("encoder1RMMethod"); analysisOptions = "p"; } } //-1 because data will be different on any curve ep = new EncoderParams( -1, -1, //exercisePercentBodyWeight "-1", //massBody "-1", //massExtra myEccon, //this decides if analysis will be together or separated sendAnalysis, analysisVariables, analysisOptions, preferences.encoderCaptureCheckFullyExtended, preferences.encoderCaptureCheckFullyExtendedValue, new EncoderConfiguration(), Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.' myCurveNum, image_encoder_width, image_encoder_height, preferences.CSVExportDecimalSeparator ); //create dataFileName TextWriter writer = File.CreateText(dataFileName); writer.WriteLine("status,seriesName,exerciseName,massBody,massExtra,dateTime,fullURL,eccon,percentBodyWeight," + "econfName, econfd, econfD, econfAnglePush, econfAngleWeight, econfInertia, econfGearedDown, laterality"); ArrayList eeArray = SqliteEncoder.SelectEncoderExercises(false, -1, false); EncoderExercise ex = new EncoderExercise(); LogB.Information("AT ANALYZE"); int iteratingPerson = -1; int iteratingSession = -1; double iteratingMassBody = -1; int countSeries = 1; Sqlite.Open(); foreach(EncoderSQL eSQL in data) { foreach(EncoderExercise eeSearch in eeArray) if(eSQL.exerciseID == eeSearch.uniqueID) ex = eeSearch; LogB.Debug(" AT ANALYZE 1.1 "); //massBody change if we are comparing different persons or sessions if(eSQL.personID != iteratingPerson || eSQL.sessionID != iteratingSession) { iteratingMassBody = SqlitePersonSession.SelectAttribute( true, eSQL.personID, eSQL.sessionID, Constants.Weight); } LogB.Debug(" AT ANALYZE 1.2 "); //seriesName string seriesName = ""; if(radio_encoder_analyze_groupal_current_session.Active) { foreach(string str in encSelReps.EncoderCompareInter) if(Util.FetchID(str) == eSQL.personID) seriesName = Util.FetchName(str); } else if(radio_encoder_analyze_individual_all_sessions.Active) { foreach(string str in encSelReps.EncoderCompareInter) { LogB.Information(str); if(Util.FetchID(str) == eSQL.sessionID) seriesName = Util.FetchName(str); } if(seriesName == "") seriesName = currentSession.DateShortAsSQL; } if(seriesName == "") seriesName = currentPerson.Name; /* * to avoid problems on reading files from R and strange character encoding * (this problem happens in Parallels (MacOSX) * copy to temp * and tell the csv file that it's in temp */ string safeFullURL = Path.Combine(Path.GetTempPath(), "chronojump_enc_curve_" + countSeries.ToString() + ".txt"); string fullURL = safeFullURL; try { File.Copy(eSQL.GetFullURL(false), safeFullURL, true); fullURL = fullURL.Replace("\\","/"); //R needs this separator path: "/" in all systems } catch { fullURL = eSQL.GetFullURL(true); //convertPathToR } writer.WriteLine(eSQL.status + "," + Util.ChangeChars(seriesName,","," ") + "," + //person name cannot have commas ex.name + "," + Util.ConvertToPoint(iteratingMassBody).ToString() + "," + Util.ConvertToPoint(Convert.ToDouble(eSQL.extraWeight)) + "," + eSQL.GetDate(true) + "," + fullURL + "," + eSQL.eccon + "," + //this is the eccon of every curve ex.percentBodyWeight.ToString() + "," + eSQL.encoderConfiguration.ToStringOutput(EncoderConfiguration.Outputs.RCSV) + "," + eSQL.LateralityToEnglish() ); countSeries ++; } writer.Flush(); LogB.Debug(" closing writer "); writer.Close(); LogB.Debug(" disposing writer "); ((IDisposable)writer).Dispose(); LogB.Debug(" AT ANALYZE 2 "); Sqlite.Close(); } else { //current set if(encoderAnalysis == "1RM") { if(my1RMName == "1RM Any exercise") { //get speed1RM (from combo) EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises( false, getExerciseIDFromCombo(exerciseCombos.CAPTURE), false)[0]; sendAnalysis = "1RMAnyExercise"; analysisVariables = Util.ConvertToPoint(ex.speed1RM) + ";" + SqlitePreferences.Select("encoder1RMMethod"); analysisOptions = "p"; } else if(my1RMName == "1RM Indirect") { sendAnalysis = "1RMIndirect"; } } //if combo_encoder_analyze_curve_num_combo "All" is selected, then use a 0, else get the number int curveNum = 0; //all if(Util.IsNumber(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo), false)) curveNum = Convert.ToInt32(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo)); ep = new EncoderParams( preferences.EncoderCaptureMinHeight(encoderConfigurationCurrent.has_inertia), getExercisePercentBodyWeightFromComboCapture (), Util.ConvertToPoint(findMass(Constants.MassType.BODY)), Util.ConvertToPoint(findMass(Constants.MassType.EXTRA)), findEccon(false), //do not force ecS (ecc-conc separated) sendAnalysis, analysisVariables, analysisOptions, preferences.encoderCaptureCheckFullyExtended, preferences.encoderCaptureCheckFullyExtendedValue, encoderConfigurationCurrent, Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.' curveNum, image_encoder_width, image_encoder_height, preferences.CSVExportDecimalSeparator ); dataFileName = UtilEncoder.GetEncoderDataTempFileName(); } EncoderStruct encoderStruct = new EncoderStruct( dataFileName, UtilEncoder.GetEncoderGraphTempFileName(), UtilEncoder.GetEncoderAnalyzeTableTempFileName(), UtilEncoder.GetEncoderScriptsPathWithoutLastSep(), UtilEncoder.GetEncoderTempPathWithoutLastSep(), ep); string titleStr = Util.ChangeSpaceAndMinusForUnderscore(currentPerson.Name); if(encoderAnalysis == "neuromuscularProfile") titleStr = "Neuromuscular Profile" + "-" + titleStr; else { //on signal show encoder exercise, but not in curves because every curve can be of a different exercise if(radio_encoder_analyze_individual_current_set.Active) //current set titleStr += "-" + Util.ChangeSpaceAndMinusForUnderscore(UtilGtk.ComboGetActive(combo_encoder_exercise_capture)); } encoderRProcAnalyze.SendData( titleStr, encoderAnalysis == "neuromuscularProfile", preferences.RGraphsTranslate); encoderRProcAnalyze.StartOrContinue(encoderStruct); }
//if uniqueID != -1, returns an especific EncoderExercise that can be read like this //EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID)[0]; public static ArrayList SelectEncoderExercises(bool dbconOpened, int uniqueID, bool onlyNames) { if(! dbconOpened) Sqlite.Open(); string uniqueIDStr = ""; if(uniqueID != -1) uniqueIDStr = " WHERE " + Constants.EncoderExerciseTable + ".uniqueID = " + uniqueID; if(onlyNames) dbcmd.CommandText = "SELECT name FROM " + Constants.EncoderExerciseTable + uniqueIDStr; else dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderExerciseTable + uniqueIDStr; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); EncoderExercise ex = new EncoderExercise(); if(onlyNames) { while(reader.Read()) { ex = new EncoderExercise (reader[0].ToString()); array.Add(ex); } } else { while(reader.Read()) { double speed1RM = 0; if(reader[5].ToString() != "") speed1RM = Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())); ex = new EncoderExercise ( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name Convert.ToInt32(reader[2].ToString()), //percentBodyWeight reader[3].ToString(), //ressistance reader[4].ToString(), //description speed1RM ); array.Add(ex); } } reader.Close(); if(! dbconOpened) Sqlite.Close(); return array; }
protected internal static void initializeTable(string databaseVersion, bool creatingBlankDatabase) { using (SqliteTransaction tr = dbcon.BeginTransaction()) { using (SqliteCommand dbcmdTr = dbcon.CreateCommand()) { dbcmdTr.Transaction = tr; Insert("databaseVersion", databaseVersion, dbcmdTr); if (UtilAll.IsWindows() || creatingBlankDatabase) { Insert("chronopicPort", Constants.ChronopicDefaultPortWindows, dbcmdTr); } else { Insert("chronopicPort", Constants.ChronopicDefaultPortLinux, dbcmdTr); } //appearance Insert("maximized", Preferences.MaximizedTypes.NO.ToString(), dbcmdTr); Insert("personWinHide", "False", dbcmdTr); Insert("personPhoto", "True", dbcmdTr); Insert("encoderCaptureShowOnlyBars", "False", dbcmdTr); Insert("encoderCaptureShowNRepetitions", "-1", dbcmdTr); Insert("digitsNumber", "3", dbcmdTr); Insert("showPower", "True", dbcmdTr); Insert("showStiffness", "True", dbcmdTr); Insert("showInitialSpeed", "True", dbcmdTr); Insert("showAngle", "False", dbcmdTr); //for treeviewjumps Insert("showQIndex", "False", dbcmdTr); //for treeviewJumps Insert("showDjIndex", "False", dbcmdTr); //for treeviewJumps Insert("simulated", "True", dbcmdTr); Insert("weightStatsPercent", "False", dbcmdTr); Insert("askDeletion", "True", dbcmdTr); Insert("heightPreferred", "False", dbcmdTr); Insert("metersSecondsPreferred", "True", dbcmdTr); Insert("language", "", dbcmdTr); Insert("crashLogLanguage", "", dbcmdTr); Insert("allowFinishRjAfterTime", "True", dbcmdTr); Insert("volumeOn", "True", dbcmdTr); Insert(Preferences.GstreamerStr, Preferences.GstreamerTypes.GST_0_1.ToString(), dbcmdTr); Insert("videoOn", "True", dbcmdTr); Insert("evaluatorServerID", "-1", dbcmdTr); Insert("versionAvailable", "", dbcmdTr); Insert("runSpeedStartArrival", "True", dbcmdTr); Insert("runDoubleContactsMode", Constants.DoubleContact.LAST.ToString(), dbcmdTr); Insert("runDoubleContactsMS", "300", dbcmdTr); Insert("runIDoubleContactsMode", Constants.DoubleContact.AVERAGE.ToString(), dbcmdTr); Insert("runIDoubleContactsMS", "300", dbcmdTr); Insert("thresholdJumps", "50", dbcmdTr); Insert("thresholdRuns", "10", dbcmdTr); Insert("thresholdOther", "50", dbcmdTr); Random rnd = new Random(); string machineID = rnd.Next().ToString(); Insert("machineID", machineID, dbcmdTr); Insert("multimediaStorage", Constants.MultimediaStorage.BYSESSION.ToString(), dbcmdTr); //encoder Insert("encoderCaptureTime", "60", dbcmdTr); Insert("encoderCaptureInactivityEndTime", "3", dbcmdTr); Insert("encoderCaptureMainVariable", Constants.EncoderVariablesCapture.MeanPower.ToString(), dbcmdTr); Insert("encoderCaptureMinHeightGravitatory", "20", dbcmdTr); Insert("encoderCaptureMinHeightInertial", "5", dbcmdTr); Insert("encoderCaptureInertialDiscardFirstN", "3", dbcmdTr); Insert("encoderCaptureCheckFullyExtended", "True", dbcmdTr); Insert("encoderCaptureCheckFullyExtendedValue", "4", dbcmdTr); Insert("encoderCaptureBarplotFontSize", "14", dbcmdTr); Insert("encoderShowStartAndDuration", "False", dbcmdTr); Insert("encoderCaptureCutByTriggers", Preferences.TriggerTypes.NO_TRIGGERS.ToString(), dbcmdTr); Insert("encoderPropulsive", "True", dbcmdTr); Insert("encoderSmoothEccCon", "0.6", dbcmdTr); Insert("encoderSmoothCon", "0.7", dbcmdTr); Insert("encoder1RMMethod", Constants.Encoder1RMMethod.WEIGHTED2.ToString(), dbcmdTr); ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(true, -1, true); if (encoderExercises.Count > 0) { EncoderExercise ex = (EncoderExercise)encoderExercises[0]; Insert(EncoderExerciseIDGravitatory, ex.uniqueID.ToString(), dbcmdTr); Insert(EncoderExerciseIDInertial, ex.uniqueID.ToString(), dbcmdTr); } else { Insert(EncoderExerciseIDGravitatory, "1", dbcmdTr); Insert(EncoderExerciseIDInertial, "1", dbcmdTr); } Insert(EncoderContractionGravitatory, Constants.Concentric, dbcmdTr); Insert(EncoderContractionInertial, Constants.EccentricConcentric, dbcmdTr); Insert(EncoderLateralityGravitatory, "RL", dbcmdTr); Insert(EncoderLateralityInertial, "RL", dbcmdTr); Insert(EncoderMassGravitatory, "10", dbcmdTr); Insert(EncoderWeightsInertial, "0", dbcmdTr); //encoderRhythm EncoderRhythm er = new EncoderRhythm(); Insert(EncoderRhythmActiveStr, er.Active.ToString(), dbcmdTr); Insert(EncoderRhythmRepsOrPhasesStr, er.RepsOrPhases.ToString(), dbcmdTr); Insert(EncoderRhythmRepSecondsStr, Util.ConvertToPoint(er.RepSeconds), dbcmdTr); Insert(EncoderRhythmEccSecondsStr, Util.ConvertToPoint(er.EccSeconds), dbcmdTr); Insert(EncoderRhythmConSecondsStr, Util.ConvertToPoint(er.ConSeconds), dbcmdTr); Insert(EncoderRhythmRestRepsSecondsStr, Util.ConvertToPoint(er.RestRepsSeconds), dbcmdTr); Insert(EncoderRhythmRestAfterEccStr, er.RestAfterEcc.ToString(), dbcmdTr); Insert(EncoderRhythmRepsClusterStr, Util.ConvertToPoint(er.RepsCluster), dbcmdTr); Insert(EncoderRhythmRestClustersSecondsStr, Util.ConvertToPoint(er.RestClustersSeconds), dbcmdTr); Insert("videoDevice", "", dbcmdTr); //first Insert("videoDeviceResolution", "", dbcmdTr); Insert("videoDeviceFramerate", "", dbcmdTr); Insert("videoStopAfter", "2", dbcmdTr); Insert("inertialmomentum", "0.01", dbcmdTr); Insert("CSVExportDecimalSeparator", Util.GetDecimalSeparatorFromLocale(), dbcmdTr); Insert("RGraphsTranslate", "True", dbcmdTr); Insert("useHeightsOnJumpIndexes", "True", dbcmdTr); Insert("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.BEST.ToString(), dbcmdTr); Insert("email", "", dbcmdTr); Insert("muteLogs", "False", dbcmdTr); Insert(ForceSensorTareDateTimeStr, "", dbcmdTr); Insert(ForceSensorTareStr, "-1", dbcmdTr); //result value from sensor. Decimal is point!! Insert(ForceSensorCalibrationDateTimeStr, "", dbcmdTr); Insert(ForceSensorCalibrationWeightStr, "-1", dbcmdTr); Insert(ForceSensorCalibrationFactorStr, "-1", dbcmdTr); //result value from sensor. Decimal is point!! //removed on 1.37 //Insert ("encoderConfiguration", new EncoderConfiguration().ToStringOutput(EncoderConfiguration.Outputs.SQL), dbcmdTr); } tr.Commit(); } }
//if submited a -1, returns an especific EncoderExercise that can be read like this //EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID)[0]; public static ArrayList SelectEncoderExercises(int uniqueID, bool onlyNames) { dbcon.Open(); string uniqueIDStr = ""; if(uniqueID != -1) uniqueIDStr = " WHERE " + Constants.EncoderExerciseTable + ".uniqueID = " + uniqueID; if(onlyNames) dbcmd.CommandText = "SELECT name FROM " + Constants.EncoderExerciseTable + uniqueIDStr; else dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderExerciseTable + uniqueIDStr; Log.WriteLine(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); EncoderExercise ex = new EncoderExercise(); if(onlyNames) { while(reader.Read()) { ex = new EncoderExercise (reader[0].ToString()); array.Add(ex); } } else { while(reader.Read()) { ex = new EncoderExercise ( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name Convert.ToInt32(reader[2].ToString()), //percentBodyWeight reader[3].ToString(), //ressistance reader[4].ToString() //description ); array.Add(ex); } } reader.Close(); dbcon.Close(); return array; }