public static Exists ( bool dbconOpened, string tableName, string findName ) : bool | ||
dbconOpened | bool | |
tableName | string | |
findName | string | |
return | bool |
protected internal static void insertSimulatedSession() { if (!Sqlite.Exists(true, Constants.SessionTable, Constants.SessionSimulatedName)) { Insert(true, Constants.SessionTable, "-1", Constants.SessionSimulatedName, "", DateTime.Today, Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID, Catalog.GetString("Use this session to simulate tests."), Constants.ServerUndefinedID); } }
protected internal static void addEncoderJumpExercise() { bool exists = Sqlite.Exists(true, Constants.EncoderExerciseTable, "Jump"); if (!exists) { InsertExercise(true, "Jump", 100, "", "", ""); } }
public bool SaveToSQL() { if (Sqlite.Exists(false, Constants.ExecuteAutoTable, name)) { return(false); //not saved because name exists } SqliteExecuteAuto.Insert(false, this); return(true); //saved }
public static string IfNameExistsAddSuffix(string name, string suffix) { if (Sqlite.Exists(false, Constants.EncoderConfigurationTable, name)) { do { name += "_" + suffix; } while (Sqlite.Exists(false, Constants.EncoderConfigurationTable, name)); } return(name); }
public int UploadSport(Sport mySport) { int id = -1; //upload if doesn't exists (uploaded before by this or other evaluator) if (!Sqlite.Exists(false, Constants.SportTable, mySport.Name)) { id = mySport.InsertAtDB(false); } return(id); //uniqueID of sport at server }
/* * IfNameExistsAddSuffix starts ---------------------> */ /* * this method check if a name exists. * if exists, add a suffix, like _copy * but if the string already ends with _copy add a number: _copy2 * but if the number already exists, like _copy21, convert into _copy22 * always check that the new string exists. * * The main reason of this method is not to have a: * unnamed_copy_copy_copy_copy (that's very ugly and breaks the interface), and have instead: * unnamed_copy4 */ public static string IfNameExistsAddSuffix(string name, string suffix) { Sqlite.Open(); if (Sqlite.Exists(true, Constants.EncoderConfigurationTable, name)) { do { name = ifNameExistsAddSuffixDo(name, suffix); } while (Sqlite.Exists(true, Constants.EncoderConfigurationTable, name)); } Sqlite.Close(); return(name); }
public string UploadRunIntervalType(RunType type, int evalSID) { string typeServer = type.Name + "-" + evalSID.ToString(); Console.WriteLine("RUN_I" + typeServer + ":" + type.Distance + ":" + type.Description); if (!Sqlite.Exists(false, Constants.RunIntervalTypeTable, typeServer)) { type.Name = typeServer; SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, false); return(typeServer); } return("-1"); }
public string UploadJumpType(JumpType type, int evalSID) { string typeServer = type.Name + "-" + evalSID.ToString(); Console.WriteLine("JUMP" + typeServer + ":" + type.StartIn + ":" + type.HasWeight + ":" + type.Description); if (!Sqlite.Exists(false, Constants.JumpTypeTable, typeServer)) { SqliteJumpType.JumpTypeInsert( typeServer + ":" + Util.BoolToInt(type.StartIn).ToString() + ":" + Util.BoolToInt(type.HasWeight).ToString() + ":" + type.Description, false); return(typeServer); } return("-1"); }
void on_button_accept_clicked(object o, EventArgs args) { //check if this jump type exists, and check it's name is not AllJumpsName bool jumpTypeExists = Sqlite.Exists(false, Constants.JumpTypeTable, Util.RemoveTildeAndColonAndDot(entry_name.Text)); if (Util.RemoveTildeAndColonAndDot(entry_name.Text) == Constants.AllJumpsName) { jumpTypeExists = true; } if (jumpTypeExists) { //string myString = Catalog.GetString ("Jump type: '") + // Util.RemoveTildeAndColonAndDot(entry_name.Text) + // Catalog.GetString ("' exists. Please, use another name"); string myString = string.Format(Catalog.GetString("Jump type: '{0}' exists. Please, use another name"), Util.RemoveTildeAndColonAndDot(entry_name.Text)); LogB.Information(myString); ErrorWindow.Show(myString); } else { string myJump = ""; myJump = Util.RemoveTildeAndColonAndDot(entry_name.Text); if (radiobutton_startIn_yes.Active) { myJump = myJump + ":1"; } else { myJump = myJump + ":0"; } if (radiobutton_extra_weight_yes.Active) { myJump = myJump + ":1"; } else { myJump = myJump + ":0"; } if (radiobutton_simple.Active) { myJump = myJump + ":" + Util.RemoveTildeAndColon(textview_description.Buffer.Text); SqliteJumpType.JumpTypeInsert(myJump, false); //false, because dbcon is not opened InsertedSimple = true; } else { if (radiobutton_unlimited.Active) { //unlimited (but in jumps do like if it's limited by jumps //(explanation in sqlite/jumpType.cs) myJump = myJump + ":1:-1"; } else { if (radiobutton_limited_jumps.Active) { myJump = myJump + ":1"; } else { myJump = myJump + ":0"; } if (checkbutton_limited_fixed.Active) { myJump = myJump + ":" + spin_fixed_num.Value; } else { myJump = myJump + ":0"; } } myJump = myJump + ":" + Util.RemoveTildeAndColon(textview_description.Buffer.Text); SqliteJumpType.JumpRjTypeInsert(myJump, false); //false, because dbcon is not opened InsertedSimple = false; } LogB.Information(string.Format("Inserted: {0}", myJump)); fakeButtonAccept.Click(); JumpTypeAddWindowBox.jump_type_add.Hide(); JumpTypeAddWindowBox = null; } }
private void configInit() { //trying new Config class Config config = new Config(); config.Read(); LogB.Information("Config:\n" + config.ToString()); /* * TODO: do an else to any option * is good to do the else here because user can import a configuration at any time * and things need to be restored to default position in glade * * But note this has to be executed only if it has changed!! */ if (config.Maximized) { app1.Maximize(); } if (config.CustomButtons) { //---- capture tab ---- hbox_encoder_capture_extra_mass_no_raspberry.Visible = false; hbox_encoder_capture_extra_mass_raspberry.Visible = true; button_encoder_select.HeightRequest = 40; //this will make all encoder capture controls taller //88 then buttons will be the same height than button_encoder_select. The 8 extra is for the vertical space button_encoder_capture.SetSizeRequest(125, 88); //button_encoder_capture.HeightRequest = 88; spin_encoder_im_weights_n.Visible = false; hbox_encoder_im_weights_n.Visible = true; //---- analyze tab ---- hbox_encoder_analyze_signal_or_curves.HeightRequest = 40; button_encoder_analyze.SetSizeRequest(120, 40); } if (!config.UseVideo) { useVideo = false; alignment_video_encoder.Visible = false; } //Auto-detect stuff configAutodetectPort = config.AutodetectPort; autodetectSignalEnabled = false; //do not raise signals that could rewrite the config file (loop) if (configAutodetectPort == Config.AutodetectPortEnum.ACTIVE) { radio_autodetect_active.Active = true; } else if (configAutodetectPort == Config.AutodetectPortEnum.INACTIVE) { radio_autodetect_inactive.Active = true; } else // (configAutodetectPort == Config.AutodetectPortEnum.DISCARDFIRST) { radio_autodetect_discard_first.Active = true; } autodetectSignalEnabled = true; //activate signals again //show only power if (config.OnlyEncoderGravitatory) { select_menuitem_mode_toggled(menuitem_modes.POWERGRAVITATORY); } else if (config.OnlyEncoderInertial) { select_menuitem_mode_toggled(menuitem_modes.POWERINERTIAL); } if (config.EncoderCaptureShowOnlyBars) { vpaned_encoder_capture_video_and_set_graph.Visible = false; vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves); vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves); notebook_encoder_capture_main.ShowTabs = true; } else { /* * is good to do the else here because user can import a configuration at any time * and things need to be restored to default position in glade * * But note this has to be executed only if it has changed!! */ /* * notebook_encoder_capture_main.ShowTabs = false; * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves); * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves); */ } encoderUpdateTreeViewWhileCapturing = config.EncoderUpdateTreeViewWhileCapturing; if (config.PersonWinHide) { //vbox_persons.Visible = false; notebook_session_person.Visible = false; hbox_encoder_person.Visible = true; } if (config.EncoderAnalyzeHide) { hbox_encoder_sup_capture_analyze_two_buttons.Visible = false; } if (config.Econf != null) { encoderConfigurationDefinedFromFile = true; encoderConfigurationCurrent = config.Econf; encoderConfigurationGUIUpdate(); //TODO: allow to see full data, but don't allow to change it (Open window content as unsensitive) } if (config.SessionMode == Config.SessionModeEnum.UNIQUE) { main_menu.Visible = false; button_preferences_not_menu.Visible = true; if (!Sqlite.Exists(false, Constants.SessionTable, "session")) { //this creates the session and inserts at DB currentSession = new Session( "session", "", DateTime.Today, //name, place, dateTime Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID, "", Constants.ServerUndefinedID); //comments, serverID } else { currentSession = SqliteSession.SelectByName("session"); } on_load_session_accepted(); } //TODO //RunScriptOnExit /* * if(linuxType == linuxTypeEnum.NETWORKS) { * //mostrar directament el power * select_menuitem_mode_toggled(menuitem_modes.POWER); * * //no mostrar menu * main_menu.Visible = false; * * //no mostrar persones * //vbox_persons.Visible = false; * //TODO: rfid can be here, also machine, maybe weight, other features * //time, gym, ... * * //show rfid * hbox_rfid.Visible = true; * * //to test display, just make sensitive the top controls, but beware there's no session yet and no person * notebook_sup.Sensitive = true; * hbox_encoder_sup_capture_analyze.Sensitive = true; * notebook_encoder_sup.Sensitive = false; * } */ }
void on_button_accept_clicked(object o, EventArgs args) { //ConsoleB.Information(getEntriesString()); string name = Util.RemoveTildeAndColonAndDot(entry_name.Text); //check if this run type exists, and check it's name is not AllRunsName bool runTypeExists = Sqlite.Exists(false, Constants.RunTypeTable, name); if (name == Constants.AllRunsName) { runTypeExists = true; } if (runTypeExists) { string myString = string.Format(Catalog.GetString("Race type: '{0}' exists. Please, use another name"), name); LogB.Information(myString); ErrorWindow.Show(myString); } else { RunType type = new RunType(); type.Name = name; type.Description = Util.RemoveTildeAndColon(textview_description.Buffer.Text); if (radiobutton_dist_variable.Active) { type.Distance = 0; } else if (radiobutton_dist_fixed.Active) { type.Distance = spin_distance_fixed.Value; } else { //dist_different (only on intervallic) type.Distance = -1; type.DistancesString = getEntriesString(); } if (radiobutton_simple.Active) { SqliteRunType.Insert(type, Constants.RunTypeTable, false); //false, because dbcon is not opened InsertedSimple = true; } else { if (radiobutton_unlimited.Active) { //unlimited (but in runs do like if it's limited by seconds: TracksLimited = false //(explanation in sqlite/jumpType.cs) type.TracksLimited = false; type.FixedValue = 0; type.Unlimited = true; } else { type.TracksLimited = radiobutton_limited_tracks.Active; if (checkbutton_limited_fixed.Active) { type.FixedValue = Convert.ToInt32(spin_fixed_tracks_or_time.Value); } else { type.FixedValue = 0; } type.Unlimited = false; } SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, false); //false, because dbcon is not opened InsertedSimple = false; } //LogB.Information(string.Format("Inserted: {0}", type)); fakeButtonAccept.Click(); RunTypeAddWindowBox.run_type_add.Hide(); RunTypeAddWindowBox = null; } }
private void configInit() { //trying new Config class configChronojump = new Config(); configChronojump.Read(); LogB.Information("Config:\n" + configChronojump.ToString()); /* * TODO: do an else to any option * is good to do the else here because user can import a configuration at any time * and things need to be restored to default position in glade * * But note this has to be executed only if it has changed!! */ if (configChronojump.Maximized) { app1.Maximize(); } if (configChronojump.CustomButtons) { //---- capture tab ---- hbox_encoder_capture_extra_mass_no_raspberry.Visible = false; hbox_encoder_capture_extra_mass_raspberry.Visible = true; button_encoder_select.HeightRequest = 40; //this will make all encoder capture controls taller button_encoder_capture.SetSizeRequest(125, 60); spin_encoder_im_weights_n.Visible = false; hbox_encoder_im_weights_n.Visible = true; //---- analyze tab ---- hbox_encoder_analyze_signal_or_curves.HeightRequest = 40; button_encoder_analyze.SetSizeRequest(120, 40); } if (!configChronojump.UseVideo) { alignment_video_encoder.Visible = false; } //show only power if (configChronojump.OnlyEncoderGravitatory) { select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY); } else if (configChronojump.OnlyEncoderInertial) { select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL); } if (configChronojump.EncoderCaptureShowOnlyBars) { //attention: this makes encoder_capture_signal_drawingarea == null vpaned_encoder_capture_video_and_set_graph.Visible = false; vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves); vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves); notebook_encoder_capture_main.ShowTabs = true; } else { /* * is good to do the else here because user can import a configuration at any time * and things need to be restored to default position in glade * * But note this has to be executed only if it has changed!! */ /* * notebook_encoder_capture_main.ShowTabs = false; * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves); * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves); */ } encoderUpdateTreeViewWhileCapturing = configChronojump.EncoderUpdateTreeViewWhileCapturing; if (configChronojump.PersonWinHide) { //vbox_persons.Visible = false; notebook_session_person.Visible = false; hbox_encoder_person.Visible = true; } if (configChronojump.EncoderAnalyzeHide) { hbox_encoder_sup_capture_analyze_two_buttons.Visible = false; } if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE || configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY) { main_menu.Visible = false; app1.Decorated = false; hbox_menu_and_preferences_outside_menu.Visible = true; if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE) { if (!Sqlite.Exists(false, Constants.SessionTable, "session")) { //this creates the session and inserts at DB currentSession = new Session( "session", "", DateTime.Today, //name, place, dateTime Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID, "", Constants.ServerUndefinedID); //comments, serverID } else { currentSession = SqliteSession.SelectByName("session"); } } else { //configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY string yearMonthStr = UtilDate.GetCurrentYearMonthStr(); LogB.Information("yearMonthStr: " + yearMonthStr); if (!Sqlite.Exists(false, Constants.SessionTable, yearMonthStr)) { //this creates the session and inserts at DB currentSession = new Session( yearMonthStr, "", DateTime.Today, //name, place, dateTime Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID, "", Constants.ServerUndefinedID); //comments, serverID //insert personSessions from last month string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr(); if (Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr)) { Session s = SqliteSession.SelectByName(yearLastMonthStr); //import all persons from last session List <PersonSession> personSessions = SqlitePersonSession.SelectPersonSessionList(s.UniqueID); //convert all personSessions to currentSession //and nullify UniqueID in order to be inserted incrementally by SQL foreach (PersonSession ps in personSessions) { ps.UniqueID = -1; ps.SessionID = currentSession.UniqueID; } //insert personSessions using a transaction new SqlitePersonSessionTransaction(personSessions); } } else { currentSession = SqliteSession.SelectByName(yearMonthStr); } } on_load_session_accepted(); } //TODO //RunScriptOnExit /* * if(linuxType == linuxTypeEnum.NETWORKS) { * //mostrar directament el power * select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER); * * //no mostrar menu * main_menu.Visible = false; * * //no mostrar persones * //vbox_persons.Visible = false; * //TODO: rfid can be here, also machine, maybe weight, other features * //time, gym, ... * * //show rfid * hbox_rfid.Visible = true; * * //to test display, just make sensitive the top controls, but beware there's no session yet and no person * notebook_sup.Sensitive = true; * hbox_encoder_sup_capture_analyze.Sensitive = true; * notebook_encoder_sup.Sensitive = false; * } */ hbox_rfid.Visible = (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX); }