public static RunInterval SelectRunData(string tableName, int uniqueID, bool dbconOpened) { //tableName can be runInterval or tempRunInterval if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); reader.Read(); RunInterval myRun = new RunInterval(DataReaderToStringArray(reader, 13)); reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(myRun); }
//recuperate temp jumpRj or RunI if chronojump hangs private string recuperateBrokenEvents() { string returnString = ""; string tableName = "tempJumpRj"; int existsTempData = Sqlite.TempDataExists(tableName); if (existsTempData > 0) { JumpRj myJumpRj = SqliteJumpRj.SelectJumpData("tempJumpRj", existsTempData, false); try { myJumpRj.InsertAtDB(true, Constants.JumpRjTable); } catch {} //pitty, cannot insert Sqlite.DeleteTempEvents(tableName); returnString = "Recuperated last Reactive Jump"; } tableName = "tempRunInterval"; existsTempData = Sqlite.TempDataExists(tableName); if (existsTempData > 0) { RunInterval myRun = SqliteRunInterval.SelectRunData("tempRunInterval", existsTempData, false); try { myRun.InsertAtDB(true, Constants.RunIntervalTable); } catch {} //pitty, cannot insert Sqlite.DeleteTempEvents(tableName); returnString = "Recuperated last Intervallic Run"; } return(returnString); }
private TimeSpan GetTimeSpanForRunInterval(RunInterval interval) { switch (interval) { case RunInterval.Custom: return(CustomFrequency); case RunInterval.QuarterHourly: return(new TimeSpan(0, 15, 0)); case RunInterval.HalfHourly: return(new TimeSpan(0, 30, 0)); case RunInterval.Hourly: return(new TimeSpan(1, 0, 0)); case RunInterval.Daily: return(new TimeSpan(1, 0, 0, 0)); case RunInterval.Weekly: return(new TimeSpan(7, 0, 0, 0)); case RunInterval.Monthly: return(DateTime.Now - DateTime.Now.AddMonths(-1)); } return(new TimeSpan()); }
protected override int getNumOfSubEvents(System.Object myObject) { RunInterval newRunI = (RunInterval)myObject; string [] myStringFull = newRunI.IntervalTimesString.Split(new char[] { '=' }); return(myStringFull.Length); }
public int UploadRunI(RunInterval myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.RunIntervalTable); myTest.UniqueID = temp; return(id); //uniqueID of person at server }
/// <summary> /// /// </summary> public IntegrityConfig() { InitializeComponent(); InitializeDatabaseComboBox(databaseComboBox); InitializeTimeoutComboBox(timeoutComboBox); LogDirectory = AppDomain.CurrentDomain.BaseDirectory; fileLabel.Text = LogDirectory; SystemConfig systemConfig = SystemConfig.GetInstance(); if (systemConfig.AutomaticScheduling) { scheduleButton.Visible = true; } IntegrityCheckConfig config = IntegrityCheckConfig.GetInstance(); if (!String.IsNullOrEmpty(config.DatabaseName)) { int index = databaseComboBox.FindString(config.DatabaseName); if (index != -1) { databaseComboBox.SelectedIndex = index; } } physicalCheckBox.Checked = config.PhysicalOnly.Equals("Y") ? true : false; GetCheckBoxText(physicalCheckBox); indexesCheckBox.Checked = config.ExcludeIndexes.Equals("Y") ? true : false; GetCheckBoxText(indexesCheckBox); extendedChecksCheckBox.Checked = config.ExtendedLogicalChecks.Equals("Y") ? true : false; GetCheckBoxText(extendedChecksCheckBox); interval = config.RunInterval; additionalInfo = config.AdditionalInfo; if (!String.IsNullOrEmpty(config.CheckCommand)) { int index = commandComboBox.FindString(GetMappedCommand(config.CheckCommand)); if (index != -1) { commandComboBox.SelectedIndex = index; } } commandComboBox.SelectedIndex = commandComboBox.FindString(GetMappedCommand(config.CheckCommand)); }
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 string [] printTotal(System.Object myObject, int cols) { RunInterval newRunI = (RunInterval)myObject; string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = Catalog.GetString("Total"); myData[count++] = ""; myData[count++] = Util.TrimDecimals(newRunI.TimeTotal.ToString(), pDN); //lapTime myData[count++] = ""; //splitTime myData[count++] = ""; //description 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); }
/// <summary> /// /// </summary> /// <param name="interval"></param> /// <param name="additionalInfo"></param> /// <returns></returns> protected string GetDisplaySchedule(RunInterval interval, string additionalInfo) { string text = ""; switch (interval) { case RunInterval.Hourly: DateTime t = DateTime.ParseExact(additionalInfo, "mm:ss", CultureInfo.InvariantCulture); text = "Scheduled to run every hour at " + t.Minute + " mins " + t.Second + " secs."; break; case RunInterval.Daily: t = DateTime.ParseExact(additionalInfo, "HH:mm", CultureInfo.InvariantCulture); text = "Scheduled to run every Day at " + t.Hour + " hrs " + t.Minute + " mins."; break; case RunInterval.Weekly: text = "Scheduled to run every week on " + additionalInfo; break; case RunInterval.Fortnightly: text = "Scheduled to run every alternate week on " + additionalInfo; break; case RunInterval.Monthly: string temp = additionalInfo.Substring(additionalInfo.IndexOf(" @ ")); string day = additionalInfo.Substring(0, additionalInfo.IndexOf(temp)); temp = temp.Trim(); text = "Scheduled to run every " + day + " day of the month " + temp; break; case RunInterval.Yearly: text = "Scheduled to run every year on " + additionalInfo; break; case RunInterval.None: default: // do nothing. break; } return(text); }
public void addTreeView_runs_interval_sprint(RunInterval runI, RunType runIType) { LogB.Information("SPRINT add START"); if (storeSprint == null) { createTreeView_runs_interval_sprint(treeview_runs_interval_sprint); return; } string positions = getSprintPositions( runI.DistanceInterval, //distanceInterval. == -1 means variable distances runI.IntervalTimesString, runIType.DistancesString //distancesString ); if (positions == "") { return; } TreeIter iter = new TreeIter(); bool iterOk = storeSprint.GetIterFirst(out iter); if (!iterOk) { iter = new TreeIter(); } iter = storeSprint.AppendValues( runI.Type, runI.UniqueID.ToString(), positions, getSplitTimes(runI.IntervalTimesString), Util.TrimDecimals(runI.TimeTotal, preferences.digitsNumber) ); //scroll treeview if needed TreePath path = storeSprint.GetPath(iter); treeview_runs_interval_sprint.ScrollToCell(path, null, true, 0, 0); LogB.Information("SPRINT add END"); }
protected override string [] printSD(System.Object myObject, int cols) { RunInterval newRunI = (RunInterval)myObject; string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = Catalog.GetString("SD"); myData[count++] = ""; myData[count++] = Util.TrimDecimals(Util.CalculateSD( Util.ChangeEqualForColon(newRunI.IntervalTimesString), Util.GetTotalTime(newRunI.IntervalTimesString), Util.GetNumberOfJumps(newRunI.IntervalTimesString, false)).ToString(), pDN); myData[count++] = ""; //splitTime myData[count++] = ""; //description myData[count++] = "-1"; //mark to non select here, select first line return(myData); }
protected override string [] printAVG(System.Object myObject, int cols) { RunInterval newRunI = (RunInterval)myObject; string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = Catalog.GetString("AVG"); myData[count++] = Util.TrimDecimals(Util.GetSpeed( newRunI.DistanceTotal.ToString(), newRunI.TimeTotal.ToString(), metersSecondsPreferred), pDN); myData[count++] = Util.TrimDecimals( Util.GetAverage(newRunI.IntervalTimesString).ToString() //AVG of intervalTimesString , pDN); myData[count++] = ""; //splitTime myData[count++] = ""; //description myData[count++] = "-1"; //mark to non select here, select first line return(myData); }
protected override string [] getLineToStore(System.Object myObject) { RunInterval newRunI = (RunInterval)myObject; string title = newRunI.Type; if (newRunI.Simulated == Constants.Simulated) { title += Constants.SimulatedTreeview + " "; } string myTypeComplet = title + "(" + newRunI.DistanceInterval + "x" + Util.GetLimitedRounded(newRunI.Limited, pDN) + ")"; string [] myData = new String [getColsNum()]; int count = 0; myData[count++] = myTypeComplet; myData[count++] = ""; //speed myData[count++] = ""; //lapTime myData[count++] = ""; //splitTime myData[count++] = newRunI.Description; myData[count++] = newRunI.UniqueID.ToString(); return(myData); }
private void on_run_interval_finished(object o, EventArgs args) { currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_interval_finished); if ( ! currentEventExecute.Cancel ) { currentRunInterval = (RunInterval) currentEventExecute.EventDone; //move video file if exists Util.MoveTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, currentRunInterval.UniqueID); currentRunInterval.MetersSecondsPreferred = metersSecondsPreferred; //if user clicked in finish earlier if(currentEventExecute.Finish) { currentRunInterval.Tracks = Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false); if(currentRunInterval.TracksLimited) { currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + "R"; } else { currentRunInterval.Limited = Util.GetTotalTime( currentRunInterval.IntervalTimesString) + "T"; } } myTreeViewRunsInterval.Add(currentPerson.Name, currentRunInterval); //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown showHideActionEventButtons(true, "RunInterval"); //show if(createdStatsWin) { showUpdateStatsAndHideData(true); } lastRunIsSimple = false; //unhide buttons for delete last jump sensitiveGuiYesEvent(); //put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer) event_execute_LabelTimeValue = currentRunInterval.TimeTotal; //possible deletion of last run can make the runs on event window be false event_execute_LabelEventValue = currentRunInterval.Tracks; } else if( currentEventExecute.ChronopicDisconnected ) { Log.WriteLine("DISCONNECTED gui/cj"); createChronopicWindow(true); } //delete the temp tables if exists Sqlite.DeleteTempEvents("tempRunInterval"); //unhide buttons that allow jumping, running sensitiveGuiEventDone(); }
protected void writeRunInterval(bool tempTable) { int tracksHere = 0; //different than globakl tracks variable string limitString = ""; //if user clicked in finish earlier if(finish) { if(tracksLimited) { tracksHere = Util.GetNumberOfJumps(intervalTimesString, false); limitString = tracksHere.ToString() + "R"; } else { //when we mark that run should finish by time, chronopic thread is probably capturing data //check if it captured more than date limit, and if it has done, delete last(s) run(s) if(limitAsDouble != -1) { bool eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble); while(eventPassed) { intervalTimesString = Util.DeleteLastSubEvent(intervalTimesString); //run limited by time that first subRun has arrived later than maximum for the whole run, //and DeleteLastSubEvent returns "-" as a mark if(intervalTimesString[0] == '-') { //this dialog can make crash the software because the non-gui part calls it //new DialogMessage(Constants.MessageTypes.WARNING, // Catalog.GetString("Race will not be recorded, 1st lap is out of time")); feedbackMessage = Catalog.GetString("Race will not be recorded. Out of time."); needShowFeedbackMessage = true; LogB.Information("Race will not be recorded, 1st lap is out of time"); //mark for not having problems with cancelled cancel = true; //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); //end this piece of code return; } else { LogB.Information("Deleted one event out of time"); eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble); } } } //tracksHere are defined here (and not before) because can change on "while(eventPassed)" before tracksHere = Util.GetNumberOfJumps(intervalTimesString, false); limitString = Util.GetTotalTime(intervalTimesString) + "T"; } } else { if(tracksLimited) { limitString = limitAsDouble.ToString() + "R"; tracksHere = (int) limitAsDouble; } else { limitString = limitAsDouble.ToString() + "T"; string [] myStringFull = intervalTimesString.Split(new char[] {'='}); tracksHere = myStringFull.Length; } } distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracksHere); timeTotal = Util.GetTotalTime(intervalTimesString); string description = ""; if(type == "MTGUG") description = "u u u u u u"; //undefined 6 items of questionnaire if(tempTable) SqliteRunInterval.Insert(false, Constants.TempRunIntervalTable, "NULL", personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn //initialSpeed true if not startIn ); else { uniqueID = SqliteRunInterval.Insert(false, Constants.RunIntervalTable, "NULL", personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn ); //define the created object eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn); /* string tempValuesString; if(tracksLimited) tempValuesString = " (" + distanceIntervalFixed + "x" + tracksHere + "R), " + Catalog.GetString("Time") + ": " + Util.TrimDecimals( timeTotal.ToString(), pDN); else tempValuesString = " (" + distanceIntervalFixed + "x" + Util.TrimDecimals( timeTotal.ToString(), pDN) + "T), " + Catalog.GetString("Tracks") + ": " + tracksHere; string myStringPush = Catalog.GetString("Last run") + ": " + RunnerName + ", " + type + tempValuesString + ", " + Catalog.GetString("AVG Speed") + ": " + Util.TrimDecimals( Util.GetSpeed(distanceTotal.ToString(), timeTotal.ToString(), metersSecondsPreferred ) , pDN ) ; */ if(simulated) feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); else feedbackMessage = ""; needShowFeedbackMessage = true; //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval( distanceIntervalFixed, Util.GetLast(intervalTimesString), intervalTimesString, distanceTotal, distancesString, startIn); needUpdateGraphType = eventType.RUNINTERVAL; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here } }
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, false); return myRunI; }
public int UploadRunI(RunInterval myTest) { object[] results = this.Invoke("UploadRunI", new object[] { myTest}); return ((int)(results[0])); }
RepairRunIntervalWindow(Gtk.Window parent, RunInterval myRun, int pDN) { Glade.XML gladeXML; gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "repair_sub_event.glade", "repair_sub_event", null); gladeXML.Autoconnect(this); repair_sub_event.Parent = parent; //put an icon to window UtilGtk.IconWindow(repair_sub_event); this.runInterval = myRun; repair_sub_event.Title = Catalog.GetString("Repair intervallic race"); System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; label_header.Text = string.Format(Catalog.GetString("Use this window to repair this test.\nDouble clic any cell to edit it (decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator); type = SqliteRunIntervalType.SelectAndReturnRunIntervalType(myRun.Type, false); TextBuffer tb = new TextBuffer (new TextTagTable()); tb.Text = createTextForTextView(type); textview1.Buffer = tb; createTreeView(treeview_subevents); //count, time store = new TreeStore(typeof (string), typeof (string)); treeview_subevents.Model = store; fillTreeView (treeview_subevents, store, myRun, pDN); button_add_before.Sensitive = false; button_add_after.Sensitive = false; button_delete.Sensitive = false; label_totaltime_value.Text = getTotalTime().ToString() + " " + Catalog.GetString("seconds"); treeview_subevents.Selection.Changed += onSelectionEntry; }
private void intervalComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (intervalComboBox.SelectedIndex >= 0) { object value = intervalComboBox.Items[intervalComboBox.SelectedIndex]; RunInterval interval = (RunInterval)Enum.Parse(typeof(RunInterval), value.ToString()); switch (interval) { case RunInterval.Hourly: addInfoComboBox.Visible = false; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.CustomFormat = "mm:ss"; addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.ShowUpDown = true; addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1); addInfoLabel.Text = "Execution Time (mm:ss) : "; addInfoLabel.Visible = true; return; case RunInterval.Daily: addInfoLabel.Text = "Execution Time (hh:mm): "; addInfoComboBox.Visible = false; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.CustomFormat = "HH:mm"; addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.ShowUpDown = true; addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1); addInfoLabel.Visible = true; break; case RunInterval.Weekly: // show day of the week drop down list addInfoLabel.Text = "Execution Time"; addInfoLabel.Visible = true; addInfoComboBox.Items.Clear(); foreach (object obj in Enum.GetValues(typeof(DayOfWeek))) { addInfoComboBox.Items.Add("Every " + obj); } addInfoComboBox.Visible = true; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.CustomFormat = "HH:mm"; addInfoDateTimePicker1.ShowUpDown = true; addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1); break; case RunInterval.Fortnightly: // show day of the week drop down list addInfoLabel.Text = "Select Day of the Week "; addInfoLabel.Visible = true; addInfoComboBox.Items.Clear(); foreach (object obj in Enum.GetValues(typeof(DayOfWeek))) { addInfoComboBox.Items.Add("Alternate " + obj); } addInfoComboBox.Visible = true; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.CustomFormat = "HH:mm"; addInfoDateTimePicker1.ShowUpDown = true; addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1); break; case RunInterval.Monthly: // show day of the month drop down list addInfoLabel.Text = "Day of Month "; addInfoLabel.Visible = true; addInfoComboBox.Items.Clear(); addInfoComboBox.Visible = false; // for (int i = 0; i < 28; i++) addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.CustomFormat = @"On dd @ hh:mm"; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.ShowUpDown = true; break; case RunInterval.Yearly: addInfoComboBox.Visible = false; addInfoLabel.Visible = true; addInfoLabel.Text = "Date of the year"; addInfoDateTimePicker1.Visible = true; addInfoDateTimePicker1.Format = DateTimePickerFormat.Custom; addInfoDateTimePicker1.CustomFormat = @"dd-MMM @ hh:mm"; break; } } }
/// public static DialogResult ShowDialog(string caption, ref RunInterval interval, ref string additionalInfo) { ScheduleDialog dialog = new ScheduleDialog(); // interval = RunInterval.None; // additionalInfo = ""; if (interval != RunInterval.None && !String.IsNullOrEmpty(additionalInfo)) { int index = dialog.intervalComboBox.FindString(interval.ToString()); if (index != -1) { dialog.intervalComboBox.SelectedIndex = index; } switch (interval) { case RunInterval.Hourly: dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(additionalInfo, "mm:ss", CultureInfo.InvariantCulture); break; case RunInterval.Daily: dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(additionalInfo, "HH:mm", CultureInfo.InvariantCulture); // dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString(additionalInfo); break; case RunInterval.Weekly: string day = additionalInfo.Substring(0, additionalInfo.IndexOf(" at ")); dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString("Every " + day.Trim()); string time = additionalInfo.Substring(additionalInfo.IndexOf(" at ") + " at ".Length - 1); dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(time.Trim(), "HH:mm", CultureInfo.InvariantCulture); break; case RunInterval.Fortnightly: day = additionalInfo.Substring(0, additionalInfo.IndexOf(" at ")); dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString("Alternate " + day.Trim()); time = additionalInfo.Substring(additionalInfo.IndexOf(" at ") + " at ".Length - 1); dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(time.Trim(), "HH:mm", CultureInfo.InvariantCulture); break; case RunInterval.Monthly: // dialog.addInfoComboBox.SelectedIndex = dialog.addInfoComboBox.FindString(additionalInfo); day = additionalInfo.Substring(additionalInfo.IndexOf("On ") + "On ".Length, additionalInfo.IndexOf(" @ ") - " @ ".Length); time = additionalInfo.Substring(additionalInfo.IndexOf(" @ ") + " @ ".Length); DateTime t = Convert.ToDateTime( new DateTime(DateTime.Today.Year, DateTime.Today.Month, Convert.ToInt32(day)).ToShortDateString() + " " + time); dialog.addInfoDateTimePicker1.MinDate = DateTime.Now.AddDays(-1); dialog.addInfoDateTimePicker1.Value = t; dialog.addInfoDateTimePicker1.MaxDate = DateTime.Now.AddDays(1); break; case RunInterval.Yearly: dialog.addInfoDateTimePicker1.MinDate = DateTime.Now.AddYears(-1); dialog.addInfoDateTimePicker1.Value = DateTime.ParseExact(additionalInfo, "dd-MMM @ hh:mm", CultureInfo.InvariantCulture); dialog.addInfoDateTimePicker1.MaxDate = DateTime.Now.AddYears(1); break; default: // do nothing break; } } // Set the members of the new instance // according to the value of the parameters if (string.IsNullOrEmpty(caption)) { dialog.Text = Application.ProductName; } else { dialog.Text = caption; } // Declare a variable to hold the result to be // returned on exitting the method DialogResult result = DialogResult.None; // Loop round until the user enters // some valid data, or cancels. while (result == DialogResult.None) { result = dialog.ShowDialog(); if (result == DialogResult.OK) { bool success = dialog.Validate(out interval, out additionalInfo); if (success) { result = DialogResult.OK; } else { result = DialogResult.None; } } else { result = DialogResult.Cancel; } } // Trash the dialog if it is hanging around. dialog.Dispose(); // Send back the result. return(result); }
protected Nullable <DateTime> GetNextExecutionDate(RunInterval interval, string additionalInfo) { Nullable <DateTime> retValue = null; switch (interval) { case RunInterval.None: retValue = null; break; case RunInterval.Hourly: retValue = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " " + DateTime.Now.Hour + ":" + additionalInfo); if (retValue.Value.CompareTo(DateTime.Now) < 0) // execution time is passed. { retValue = retValue.Value.AddHours(1); } break; case RunInterval.Daily: retValue = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " " + additionalInfo + ":00"); if (retValue.Value.CompareTo(DateTime.Now) < 0) { retValue = retValue.Value.AddDays(1); } break; case RunInterval.Weekly: case RunInterval.Fortnightly: string temp = additionalInfo.Substring(additionalInfo.IndexOf(" at ") + " at ".Length); temp = temp.Trim(); retValue = Convert.ToDateTime(GetNextWeekDay(additionalInfo).ToShortDateString() + " " + temp + ":00"); if (interval == RunInterval.Fortnightly) { // add week time in Weekly schedule. int count = Enum.GetValues(typeof(DayOfWeek)).Length; retValue = retValue.Value.AddDays(count); } break; case RunInterval.Monthly: string day = additionalInfo.Substring(additionalInfo.IndexOf("On ") + "On ".Length, additionalInfo.IndexOf(" @ ") - " @ ".Length); DateTime today = DateTime.Today; if (today.Month == 12) // December { retValue = new DateTime(today.Year + 1, 1, Convert.ToInt32(day.Trim())); } else { // month is less than December retValue = new DateTime(today.Year, today.Month + 1, Convert.ToInt32(day.Trim())); } string time = additionalInfo.Substring(additionalInfo.IndexOf(" @ ") + " @ ".Length); retValue = Convert.ToDateTime(retValue.Value.ToShortDateString() + " " + time); break; case RunInterval.Yearly: // 28-Feb @ 02:01 retValue = DateTime.ParseExact(additionalInfo, "dd-MMM @ hh:mm", CultureInfo.InvariantCulture); // retValue = DateTime.Parse(additionalInfo.Trim()); retValue = retValue.Value.AddYears(1); break; default: throw new ArgumentException("Invalid interval Value Passed"); } return(retValue); }
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; } }
private void on_run_interval_finished(object o, EventArgs args) { currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_interval_finished); //test can be deleted if not cancelled button_delete_last_test.Sensitive = ! currentEventExecute.Cancel; if ( ! currentEventExecute.Cancel ) { currentRunInterval = (RunInterval) currentEventExecute.EventDone; //move video file if exists if(preferences.videoOn) if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, currentRunInterval.UniqueID)) new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, video cannot be stored.")); currentRunInterval.MetersSecondsPreferred = preferences.metersSecondsPreferred; //if user clicked in finish earlier if(currentEventExecute.Finish) { currentRunInterval.Tracks = Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false); if(currentRunInterval.TracksLimited) { currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + "R"; } else { currentRunInterval.Limited = Util.GetTotalTime( currentRunInterval.IntervalTimesString) + "T"; } } myTreeViewRunsInterval.Add(currentPerson.Name, currentRunInterval); //since 0.7.4.1 when test is done, treeview select it. action event button have to be shown showHideActionEventButtons(true, "RunInterval"); //show if(createdStatsWin) { showUpdateStatsAndHideData(true); } lastRunIsSimple = false; //unhide buttons for delete last jump sensitiveGuiYesEvent(); //put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer) event_execute_LabelTimeValue = currentRunInterval.TimeTotal; //possible deletion of last run can make the runs on event window be false event_execute_LabelEventValue = currentRunInterval.Tracks; } else if( currentEventExecute.ChronopicDisconnected ) chronopicDisconnectedWhileExecuting(); //delete the temp tables if exists Sqlite.DeleteTempEvents("tempRunInterval"); }
public static RunInterval SelectRunData(string tableName, int uniqueID, bool dbconOpened) { //tableName can be runInterval or tempRunInterval if(!dbconOpened) Sqlite.Open(); dbcmd.CommandText = "SELECT * FROM " + tableName + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); reader.Read(); RunInterval myRun = new RunInterval(DataReaderToStringArray(reader, 13)); reader.Close(); if(!dbconOpened) Sqlite.Close(); return myRun; }
/// <summary> /// /// </summary> public RunConfig() { InitializeComponent(); InitializeDatabaseComboBox(databaseComboBox); InitializeTimeoutComboBox(timeoutComboBox); logDirectoryLabel.Text = AppDomain.CurrentDomain.BaseDirectory; LogDirectory = logDirectoryLabel.Text; SystemConfig systemConfig = SystemConfig.GetInstance(); if (systemConfig.AutomaticScheduling) { scheduleButton.Visible = true; } IndexConfig config = IndexConfig.GetInstance(); if (!String.IsNullOrEmpty(config.DatabaseName)) { int index = databaseComboBox.FindString(config.DatabaseName); if (index != -1) { databaseComboBox.SelectedIndex = index; } } frag1TextBox.Text = config.FragmentationLevel1.ToString(); frag2TextBox.Text = config.FragmentationLevel2.ToString(); if (config.OperationSequence != null) { string[] parts = config.OperationSequence.Split(','); if (parts.Length > 0) { lowCombobox.SelectedIndex = lowCombobox.FindString(parts[0]); } if (parts.Length > 1) { mediumComboBox.SelectedIndex = mediumComboBox.FindString(parts[1]); } if (parts.Length > 2) { highComboBox.SelectedIndex = highComboBox.FindString(parts[2]); } } minPageCntTextBox.Text = config.MinimumPageCountLevel.ToString(); int i = timeoutComboBox.FindString((config.QueryExecutionTimeout / 60).ToString() + " minute"); if (i != -1) { timeoutComboBox.SelectedIndex = i; } fillFactorTextBox.Text = config.FillFactor.ToString(); updateStatsComboBox.Text = GetMappedCommand(config.UpdateStatistics); interval = config.RunInterval; additionalInfo = config.AdditionalInfo; if (config.NextExecution != null) { scheduleLabel.Text = GetDisplaySchedule(interval, additionalInfo) + ". Next Execution @ " + config.NextExecution; scheduleLabel.Visible = true; } }
private void treeviewRunsIntervalContextMenu(RunInterval myRun) { Menu myMenu = new Menu (); Gtk.MenuItem myItem; /* myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + myRun.Type + " (" + myRun.PersonName + ")"); if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, Constants.TestTypes.RUN_I, myTreeViewRunsInterval.EventSelectedID))) { myItem.Activated += on_video_play_selected_run_interval_clicked; myItem.Sensitive = true; } else myItem.Sensitive = false; myMenu.Attach( myItem, 0, 1, 0, 1 ); */ myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRun.Type + " (" + myRun.PersonName + ")"); myItem.Activated += on_edit_selected_run_interval_clicked; myMenu.Attach( myItem, 0, 1, 0, 1 ); myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myRun.Type + " (" + myRun.PersonName + ")"); myItem.Activated += on_repair_selected_run_interval_clicked; myMenu.Attach( myItem, 0, 1, 1, 2 ); Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem(); myMenu.Attach( mySep, 0, 1, 2, 3 ); myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRun.Type + " (" + myRun.PersonName + ")"); myItem.Activated += on_delete_selected_run_interval_clicked; myMenu.Attach( myItem, 0, 1, 3, 4 ); myMenu.Popup(); myMenu.ShowAll(); }
//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(); }
protected void writeRunInterval(bool tempTable) { int tracksHere = 0; //different than globakl tracks variable string limitString = ""; //if user clicked in finish earlier if (finish) { if (tracksLimited) { tracksHere = Util.GetNumberOfJumps(intervalTimesString, false); limitString = tracksHere.ToString() + "R"; } else { //when we mark that run should finish by time, chronopic thread is probably capturing data //check if it captured more than date limit, and if it has done, delete last(s) run(s) if (limitAsDouble != -1) { bool eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble); while (eventPassed) { intervalTimesString = Util.DeleteLastSubEvent(intervalTimesString); //run limited by time that first subRun has arrived later than maximum for the whole run, //and DeleteLastSubEvent returns "-" as a mark if (intervalTimesString[0] == '-') { //this dialog can make crash the software because the non-gui part calls it //new DialogMessage(Constants.MessageTypes.WARNING, // Catalog.GetString("Run will not be recorded, 1st track is out of time")); feedbackMessage = Catalog.GetString("Run will not be recorded. Out of time."); needShowFeedbackMessage = true; LogB.Information("Run will not be recorded, 1st track is out of time"); //mark for not having problems with cancelled cancel = true; //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); //end this piece of code return; } else { LogB.Information("Deleted one event out of time"); eventPassed = Util.EventPassedFromMaxTime(intervalTimesString, limitAsDouble); } } } //tracksHere are defined here (and not before) because can change on "while(eventPassed)" before tracksHere = Util.GetNumberOfJumps(intervalTimesString, false); limitString = Util.GetTotalTime(intervalTimesString) + "T"; } } else { if (tracksLimited) { limitString = limitAsDouble.ToString() + "R"; tracksHere = (int)limitAsDouble; } else { limitString = limitAsDouble.ToString() + "T"; string [] myStringFull = intervalTimesString.Split(new char[] { '=' }); tracksHere = myStringFull.Length; } } distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracksHere); timeTotal = Util.GetTotalTime(intervalTimesString); string description = ""; if (type == "MTGUG") { description = "u u u u u u"; //undefined 6 items of questionnaire } if (tempTable) { SqliteRunInterval.Insert(false, Constants.TempRunIntervalTable, "NULL", personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn //initialSpeed true if not startIn ); } else { uniqueID = SqliteRunInterval.Insert(false, Constants.RunIntervalTable, "NULL", personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn ); //define the created object eventDone = new RunInterval(uniqueID, personID, sessionID, type, distanceTotal, timeTotal, distanceInterval, intervalTimesString, tracksHere, description, limitString, Util.BoolToNegativeInt(simulated), !startIn); string tempValuesString = ""; if (tracksLimited) { tempValuesString = " (" + distanceIntervalFixed + "x" + tracksHere + "R), " + Catalog.GetString("Time") + ": " + Util.TrimDecimals(timeTotal.ToString(), pDN); } else { tempValuesString = " (" + distanceIntervalFixed + "x" + Util.TrimDecimals(timeTotal.ToString(), pDN) + "T), " + Catalog.GetString("Tracks") + ": " + tracksHere; } /* * string myStringPush = Catalog.GetString("Last run") + ": " + RunnerName + ", " + * type + tempValuesString + ", " + * Catalog.GetString("AVG Speed") + ": " + Util.TrimDecimals( * Util.GetSpeed(distanceTotal.ToString(), * timeTotal.ToString(), metersSecondsPreferred ) * , pDN ) ; */ if (simulated) { feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); } else { feedbackMessage = ""; } needShowFeedbackMessage = true; //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval( distanceIntervalFixed, Util.GetLast(intervalTimesString), intervalTimesString, distanceTotal, distancesString); needUpdateGraphType = eventType.RUNINTERVAL; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here } }
private bool Validate(out RunInterval interval, out string additionalInfo) { bool success = false; if (intervalComboBox.SelectedIndex < 0) { MessageBox.Show("ERR: Run interval is mandatory.", "Validation Errors", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); interval = RunInterval.None; additionalInfo = ""; return(success); } object obj = intervalComboBox.Items[intervalComboBox.SelectedIndex]; interval = (RunInterval)Enum.Parse(typeof(RunInterval), obj.ToString()); obj = null; switch (interval) { case RunInterval.Hourly: obj = addInfoDateTimePicker1.Value.ToString("mm:ss"); // default value break; case RunInterval.Daily: obj = addInfoDateTimePicker1.Value.ToString("HH:mm"); /*if (addInfoComboBox.SelectedIndex < 0) * { * MessageBox.Show("ERR: Please select an appropriate hour", "Validation Errors", * MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); * } * else * { * obj = addInfoComboBox.Items[addInfoComboBox.SelectedIndex].ToString(); * }*/ break; case RunInterval.Weekly: if (addInfoComboBox.SelectedIndex < 0) { MessageBox.Show("ERR: Please select a Day of the week", "Validation Errors", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { obj = addInfoComboBox.Items[addInfoComboBox.SelectedIndex].ToString(); obj = obj.ToString().Substring("Every ".Length - 1); } obj += " at " + addInfoDateTimePicker1.Value.ToString("HH:mm"); break; case RunInterval.Fortnightly: if (addInfoComboBox.SelectedIndex < 0) { MessageBox.Show("ERR: Please select an appropriate hour", "Validation Errors", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { obj = addInfoComboBox.Items[addInfoComboBox.SelectedIndex].ToString(); obj = obj.ToString().Substring("Alternate ".Length - 1); } obj += " at " + addInfoDateTimePicker1.Value.ToString("HH:mm"); break; case RunInterval.Monthly: /*if (addInfoComboBox.SelectedIndex < 0) * { * MessageBox.Show("ERR: Please select a Date of the month", "Validation Errors", MessageBoxButtons.OK, * MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); * } * else * { * obj = addInfoComboBox.Items[addInfoComboBox.SelectedIndex].ToString(); * obj = obj.ToString(); * }*/ obj = addInfoDateTimePicker1.Value.ToString(@"On dd @ hh:mm"); break; case RunInterval.Yearly: obj = addInfoDateTimePicker1.Value.ToString(@"dd-MMM @ hh:mm"); break; default: obj = null; break; } if (obj != null) { success = true; additionalInfo = obj.ToString(); } else { additionalInfo = ""; } return(success); }
public void UploadRunIAsync(RunInterval myTest, object userState) { if ((this.UploadRunIOperationCompleted == null)) { this.UploadRunIOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadRunICompleted); } this.InvokeAsync("UploadRunI", new object[] { myTest}, this.UploadRunIOperationCompleted, userState); }
private void fillTreeView(Gtk.TreeView tv, TreeStore store, RunInterval myRun, int pDN) { if(myRun.IntervalTimesString.Length > 0) { string [] timeArray = myRun.IntervalTimesString.Split(new char[] {'='}); int count = 0; foreach (string myTime in timeArray) { store.AppendValues ( (count+1).ToString(), Util.TrimDecimals(myTime, pDN) ); count ++; } } }
/// <summary> /// /// </summary> /// <param name="backupType"></param> public BackupConfig(string backupType) { this._backupType = backupType; InitializeComponent(); folderBrowserDialog1.Description = "Select a Backup Directory"; folderBrowserDialog1.RootFolder = Environment.SpecialFolder.DesktopDirectory; folderBrowserDialog1.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; InitializeDatabaseComboBox(databaseComboBox); InitializeTimeoutComboBox(timeoutComboBox); GetCheckBoxText(verifyCheckBox); GetCheckBoxText(checksumCheckBox); LogDirectory = AppDomain.CurrentDomain.BaseDirectory; logFileLabel.Text = LogDirectory; SystemConfig systenConfig = SystemConfig.GetInstance(); if (systenConfig.AutomaticScheduling) { scheduleButton.Visible = true; } DoBackupConfig config = DoBackupConfig.GetInstance(_backupType); if (!String.IsNullOrEmpty(config.DatabaseName)) { int index = databaseComboBox.FindString(config.DatabaseName); if (index != -1) { databaseComboBox.SelectedIndex = index; } } checksumCheckBox.Checked = config.ChecksumCheck == "Y"; verifyCheckBox.Checked = config.VerifyBackup == "Y"; folderBrowserDialog1.SelectedPath = config.DatabaseDirectory; backupPathLabel.Text = config.DatabaseDirectory; int i = timeoutComboBox.FindString((config.QueryExecutionTimeout / 60).ToString() + " minute"); if (i != -1) { timeoutComboBox.SelectedIndex = i; } backupTypeComboBox.Text = GetMappedCommand(_backupType); interval = config.RunInterval; additionalInfo = config.AdditionalInfo; if (config.NextExecution != null) { scheduleLabel.Text = "Scheduled to Run " + interval + " at " + additionalInfo + " i.e. " + config.NextExecution; scheduleLabel.Visible = true; } else { scheduleLabel.Visible = false; } }
public static RepairRunIntervalWindow Show(Gtk.Window parent, RunInterval myRun, int pDN) { //LogB.Information(myRun); if (RepairRunIntervalWindowBox == null) { RepairRunIntervalWindowBox = new RepairRunIntervalWindow (parent, myRun, pDN); } RepairRunIntervalWindowBox.repair_sub_event.Show (); return RepairRunIntervalWindowBox; }
/* * 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 void UploadRunIAsync(RunInterval myTest) { this.UploadRunIAsync(myTest, null); }
//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); }
public System.IAsyncResult BeginUploadRunI(RunInterval myTest, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UploadRunI", new object[] { myTest}, callback, asyncState); }
public int UploadRunI(RunInterval myTest) { int temp = myTest.UniqueID; myTest.UniqueID = -1; int id = myTest.InsertAtDB(false, Constants.RunIntervalTable); myTest.UniqueID = temp; return id; //uniqueID of person at server }
//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(); }
/* * 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); }