[chronojump] Done restTimes list for last 20' on top of contacts and encoder



commit 3466e27d33a9cceadd3784a9c838efa60cd134d3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 19 11:13:02 2017 +0200

    Done restTimes list for last 20' on top of contacts and encoder

 glade/app1.glade      |  292 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/gui/chronojump.cs |  118 +++++++++++++++++++-
 src/gui/encoder.cs    |    2 +-
 src/restTime.cs       |   67 +++++++++---
 4 files changed, 456 insertions(+), 23 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 9d3f02c..6bb4710 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1372,6 +1372,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -3286,10 +3289,151 @@ EncoderInertialCapture</property>
                                                     <property name="position">2</property>
                                                   </packing>
                                                 </child>
+                                                <child>
+                                                  <widget class="GtkTable" id="table13">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="n_rows">2</property>
+                                                    <property name="n_columns">5</property>
+                                                    <property name="column_spacing">8</property>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_1_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_2_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">1</property>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_3_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">2</property>
+                                                        <property name="right_attach">3</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_4_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">3</property>
+                                                        <property name="right_attach">4</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_5_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">4</property>
+                                                        <property name="right_attach">5</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_1_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_2_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">1</property>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_3_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">2</property>
+                                                        <property name="right_attach">3</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_4_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">3</property>
+                                                        <property name="right_attach">4</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_contacts_rest_time_5_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">4</property>
+                                                        <property name="right_attach">5</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">3</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
-                                                <property name="expand">True</property>
+                                                <property name="expand">False</property>
                                                 <property name="fill">False</property>
+                                                <property name="padding">30</property>
                                                 <property name="position">2</property>
                                               </packing>
                                             </child>
@@ -14848,10 +14992,151 @@ Concentric</property>
                                                     <property name="position">2</property>
                                                   </packing>
                                                 </child>
+                                                <child>
+                                                  <widget class="GtkTable" id="table14">
+                                                    <property name="visible">True</property>
+                                                    <property name="can_focus">False</property>
+                                                    <property name="n_rows">2</property>
+                                                    <property name="n_columns">5</property>
+                                                    <property name="column_spacing">8</property>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_1_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_2_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">1</property>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_3_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">2</property>
+                                                        <property name="right_attach">3</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_4_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">3</property>
+                                                        <property name="right_attach">4</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_5_name">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">4</property>
+                                                        <property name="right_attach">5</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_1_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_2_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">1</property>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_3_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">2</property>
+                                                        <property name="right_attach">3</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_4_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">3</property>
+                                                        <property name="right_attach">4</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                    <child>
+                                                      <widget class="GtkLabel" 
id="label_encoder_rest_time_5_time">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">False</property>
+                                                      </widget>
+                                                      <packing>
+                                                        <property name="left_attach">4</property>
+                                                        <property name="right_attach">5</property>
+                                                        <property name="top_attach">1</property>
+                                                        <property name="bottom_attach">2</property>
+                                                        <property name="x_options">GTK_FILL</property>
+                                                        <property name="y_options"/>
+                                                      </packing>
+                                                    </child>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">True</property>
+                                                    <property name="fill">True</property>
+                                                    <property name="position">3</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
-                                                <property name="expand">True</property>
+                                                <property name="expand">False</property>
                                                 <property name="fill">False</property>
+                                                <property name="padding">30</property>
                                                 <property name="position">1</property>
                                               </packing>
                                             </child>
@@ -21212,6 +21497,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 15ff060..7d1b47a 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -305,6 +305,30 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_person_add_single;
        [Widget] Gtk.Button button_person_add_multiple;
 
+       [Widget] Gtk.Label label_contacts_rest_time_1_name;
+       [Widget] Gtk.Label label_contacts_rest_time_2_name;
+       [Widget] Gtk.Label label_contacts_rest_time_3_name;
+       [Widget] Gtk.Label label_contacts_rest_time_4_name;
+       [Widget] Gtk.Label label_contacts_rest_time_5_name;
+
+       [Widget] Gtk.Label label_contacts_rest_time_1_time;
+       [Widget] Gtk.Label label_contacts_rest_time_2_time;
+       [Widget] Gtk.Label label_contacts_rest_time_3_time;
+       [Widget] Gtk.Label label_contacts_rest_time_4_time;
+       [Widget] Gtk.Label label_contacts_rest_time_5_time;
+
+       [Widget] Gtk.Label label_encoder_rest_time_1_name;
+       [Widget] Gtk.Label label_encoder_rest_time_2_name;
+       [Widget] Gtk.Label label_encoder_rest_time_3_name;
+       [Widget] Gtk.Label label_encoder_rest_time_4_name;
+       [Widget] Gtk.Label label_encoder_rest_time_5_name;
+
+       [Widget] Gtk.Label label_encoder_rest_time_1_time;
+       [Widget] Gtk.Label label_encoder_rest_time_2_time;
+       [Widget] Gtk.Label label_encoder_rest_time_3_time;
+       [Widget] Gtk.Label label_encoder_rest_time_4_time;
+       [Widget] Gtk.Label label_encoder_rest_time_5_time;
+
        [Widget] Gtk.Notebook notebook_execute;
        [Widget] Gtk.Notebook notebook_results;
        [Widget] Gtk.Notebook notebook_options_top;
@@ -470,6 +494,10 @@ public partial class ChronoJumpWindow
        //to control method that is updating restTimes on treeview_persons
        bool updatingRestTimes = false;
 
+       List<Gtk.Label> labels_rest_time_contacts_names;
+       List<Gtk.Label> labels_rest_time_contacts_times;
+       List<Gtk.Label> labels_rest_time_encoder_names;
+       List<Gtk.Label> labels_rest_time_encoder_times;
 
        //only called the first time the software runs
        //and only on windows
@@ -657,6 +685,7 @@ public partial class ChronoJumpWindow
                label_version_hidden.Text = buildVersion;
                LogB.Information("Build version:" + buildVersion);
 
+               initializeRestTimeLabels();
                restTime = new RestTime();
                updatingRestTimes = true;
                GLib.Timeout.Add(1000, new GLib.TimeoutHandler(updateRestTimes)); //each s, better than 5s 
for don't have problems sorting data on treeview
@@ -4094,21 +4123,67 @@ public partial class ChronoJumpWindow
                } else {
                        event_execute_progressbar_time.Fraction = 1;
 
-                       restTime.AddOrModify(currentPerson.UniqueID, true);
+                       restTime.AddOrModify(currentPerson.UniqueID, currentPerson.Name, true);
                        updateRestTimes();
                }
 
                chronojumpWindowTestsNext();
        }
 
+       private void initializeRestTimeLabels()
+       {
+               labels_rest_time_contacts_names = new List<Gtk.Label>();
+               labels_rest_time_contacts_times = new List<Gtk.Label>();
+               labels_rest_time_encoder_names = new List<Gtk.Label>();
+               labels_rest_time_encoder_times = new List<Gtk.Label>();
+
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_1_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_2_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_3_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_4_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_5_name);
+
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_1_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_2_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_3_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_4_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_5_time);
+
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_1_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_2_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_3_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_4_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_5_name);
+
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_1_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_2_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_3_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_4_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_5_time);
+       }
+
+       private void labels_rest_time_contacts_clean()
+       {
+               for(int i=0; i < 5; i ++) {
+                       ((Gtk.Label) labels_rest_time_contacts_names[i]).Text = "";
+                       ((Gtk.Label) labels_rest_time_contacts_times[i]).Text = "";
+               }
+       }
+
+       private void labels_rest_time_encoder_clean()
+       {
+               for(int i=0; i < 5; i ++) {
+                       ((Gtk.Label) labels_rest_time_encoder_names[i]).Text = "";
+                       ((Gtk.Label) labels_rest_time_encoder_times[i]).Text = "";
+               }
+       }
+
        //called each second and after a test
        bool updateRestTimes()
        {
                if(! updatingRestTimes)
                        return false;
 
-               myTreeViewPersons.UpdateRestTimes(restTime);
-
                if( configChronojump.Compujump && currentPerson != null &&
                                DateTime.Now.Subtract(currentPersonCompujumpLoginTime).TotalMinutes >= 3 && 
//login time minimum 3'
                                restTime.CompujumpPersonNeedLogout(currentPerson.UniqueID) )                 
//3' since last executed test
@@ -4116,6 +4191,43 @@ public partial class ChronoJumpWindow
                        compujumpPersonLogoutDo();
                }
 
+               if( ! configChronojump.PersonWinHide)
+               {
+                       myTreeViewPersons.UpdateRestTimes(restTime);
+                       return true;
+               }
+
+
+               if(current_menuitem_mode == Constants.Menuitem_modes.POWERGRAVITATORY ||
+                              current_menuitem_mode == Constants.Menuitem_modes.POWERINERTIAL)
+               {
+                       labels_rest_time_encoder_clean();
+                       List<LastTestTime> listLastMin = restTime.LastMinList();
+                       int count = 0;
+                       foreach(LastTestTime ltt in listLastMin)
+                       {
+                               if(count < 5) //only 5 values
+                               {
+                                       ((Gtk.Label) labels_rest_time_encoder_names[count]).Text = 
ltt.PersonName;
+                                       ((Gtk.Label) labels_rest_time_encoder_times[count]).Text = 
ltt.RestedTime;
+                                       count ++;
+                               }
+                       }
+               } else {
+                       labels_rest_time_contacts_clean();
+                       List<LastTestTime> listLastMin = restTime.LastMinList();
+                       int count = 0;
+                       foreach(LastTestTime ltt in listLastMin)
+                       {
+                               if(count < 5) //only 5 values
+                               {
+                                       ((Gtk.Label) labels_rest_time_contacts_names[count]).Text = 
ltt.PersonName;
+                                       ((Gtk.Label) labels_rest_time_contacts_times[count]).Text = 
ltt.RestedTime;
+                                       count ++;
+                               }
+                       }
+               }
+
                return true;
        }
 
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 83cd23f..4e89c67 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -6271,7 +6271,7 @@ public partial class ChronoJumpWindow
 
                        if(action == encoderActions.CURVES_AC)
                        {
-                               restTime.AddOrModify(currentPerson.UniqueID, true);
+                               restTime.AddOrModify(currentPerson.UniqueID, currentPerson.Name, true);
                                updateRestTimes();
                        }
 
diff --git a/src/restTime.cs b/src/restTime.cs
index a53a1a1..a0502f8 100644
--- a/src/restTime.cs
+++ b/src/restTime.cs
@@ -24,12 +24,14 @@ using System.Collections.Generic; //List<T>
 public class LastTestTime
 {
        private int personID;
+       private string personName;
        private DateTime time;
 
        //constructor
-       public LastTestTime(int pID)
+       public LastTestTime(int pID, string pName)
        {
                this.personID = pID;
+               this.personName = pName;
                this.time = DateTime.Now;
        }
        
@@ -50,7 +52,7 @@ public class LastTestTime
                get {
                        TimeSpan ts = DateTime.Now.Subtract(time);
                        if(ts.TotalMinutes >= 60)
-                               return maxTimeString; //TODO: check if this is correctly sorted on treeview 
persons
+                               return maxTimeString;
 
                        //add a 0 if values are <10 to order them correctly on treeview persons
                        int m = ts.Minutes;
@@ -66,6 +68,12 @@ public class LastTestTime
                }
        }
 
+       public int GetTotalMinutes()
+       {
+               TimeSpan ts = DateTime.Now.Subtract(time);
+               return Convert.ToInt32(ts.TotalMinutes);
+       }
+
        public static int GetSeconds(string restedTime)
        {
                if(restedTime == null || restedTime == "")
@@ -87,21 +95,28 @@ public class LastTestTime
        {
                get { return personID; } 
        }
+
+       public string PersonName
+       {
+               get { return personName; }
+       }
 }
 
 public class RestTime
 {
-       private List<LastTestTime> list;
+       private List<LastTestTime> listAll;
+       private List<LastTestTime> listLastMin; //for Compujump, list of last 20' on the top
 
        public RestTime()
        {
                //initialize list when Chronojump starts
-               list = new List<LastTestTime>();
+               listAll = new List<LastTestTime>();
+               listLastMin = new List<LastTestTime>();
        }
        
        public string RestedTime(int personID)
        {
-               foreach(LastTestTime ltt in list)
+               foreach(LastTestTime ltt in listAll)
                        if(ltt.PersonID == personID)
                                return ltt.RestedTime;
                
@@ -110,7 +125,7 @@ public class RestTime
 
        public bool CompujumpPersonNeedLogout(int personID)
        {
-               foreach(LastTestTime ltt in list)
+               foreach(LastTestTime ltt in listAll)
                        if(ltt.PersonID == personID)
                        {
                                if(LastTestTime.GetSeconds(ltt.RestedTime) > 180) //3 min
@@ -123,36 +138,54 @@ public class RestTime
                return true;
        }
 
-       public void AddOrModify(int personID, bool print)
+       public void AddOrModify(int personID, string personName, bool print)
        {
-               if(exists(personID))
-                       modifyRestTime(personID);
+               //listAll
+               if(exists(listAll, personID))
+                       modifyRestTime(listAll, personID);
                else
-                       addRestTime(personID);
+                       addRestTime(listAll, personID, personName);
 
                if(print)
-                       foreach(LastTestTime ltt in list)
+                       foreach(LastTestTime ltt in listAll)
                                LogB.Information(ltt.ToString());
+
+               //listLastMin
+               if(exists(listLastMin, personID))
+                       modifyRestTime(listLastMin, personID);
+               else
+                       addRestTime(listLastMin, personID, personName);
        }
 
-       private bool exists(int personID)
+       private bool exists(List<LastTestTime> l, int personID)
        {
-               foreach(LastTestTime ltt in list)
+               foreach(LastTestTime ltt in l)
                        if(ltt.PersonID == personID)
                                return true;
                
                return false;
        }
        
-       private void addRestTime(int personID)
+       private void addRestTime(List<LastTestTime> l, int personID, string personName)
        {
-               list.Add(new LastTestTime(personID));
+               l.Add(new LastTestTime(personID, personName));
        }
        
-       private void modifyRestTime(int personID)
+       private void modifyRestTime(List<LastTestTime> l, int personID)
        {
-               foreach(LastTestTime ltt in list)
+               foreach(LastTestTime ltt in l)
                        if(ltt.PersonID == personID)
                                ltt.Update();
        }
+
+       public List<LastTestTime> LastMinList()
+       {
+               foreach(LastTestTime ltt in listLastMin)
+               {
+                       if(ltt.GetTotalMinutes() > 20) //20 minutes
+                               listLastMin.Remove(ltt);
+               }
+
+               return listLastMin;
+       }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]