GetSeconds() публичный статический Метод

public static GetSeconds ( string restedTime ) : int
restedTime string
Результат int
Пример #1
0
    private void RenderRestTime(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
    {
        string restTime = (string)model.GetValue(iter, 2);

        if (RestSecondsMark > 0 && LastTestTime.GetSeconds(restTime) >= RestSecondsMark)
        {
            Gtk.TreeModel model2;
            Gtk.TreeIter  iter2;
            bool          selected = false;
            if (treeview.Selection.GetSelected(out model2, out iter2))
            {
                if (model.GetValue(iter, 0).ToString() == model2.GetValue(iter2, 0).ToString())
                {
                    selected = true;
                }
            }

            if (selected)
            {
                //based on http://stackoverflow.com/a/9548415
                (cell as Gtk.CellRendererText).Markup = "<span foreground=\"red\" background=\"white\">" + restTime + "</span>";
            }
            else
            {
                (cell as Gtk.CellRendererText).Foreground = UtilGtk.ColorBad;
                (cell as Gtk.CellRendererText).Text       = restTime;
            }
        }
        else
        {
            (cell as Gtk.CellRendererText).Foreground = null;                   //will show default color
            (cell as Gtk.CellRendererText).Text       = restTime;
        }
    }
Пример #2
0
    public void AddOrModify(int personID, string personName, bool print)
    {
        //listAll
        if (exists(listAll, personID))
        {
            modifyRestTime(listAll, personID);
        }
        else
        {
            addRestTime(listAll, personID, personName);
        }

        if (print)
        {
            foreach (LastTestTime ltt in listAll)
            {
                LogB.Information(ltt.ToString());
            }
        }

        //listLastMin
        if (exists(listLastMin, personID))
        {
            modifyRestTime(listLastMin, personID);
        }
        else
        {
            //add but have only five values
            if (listLastMin.Count == 5)
            {
                int secondsMax = 0;
                int seconds;
                int highestTimePos = 0;
                for (int i = listLastMin.Count - 1; i >= 0; i--)
                {
                    seconds = LastTestTime.GetSeconds(listLastMin[i].RestedTime);
                    if (seconds > secondsMax)
                    {
                        secondsMax     = seconds;
                        highestTimePos = i;
                    }
                }
                listLastMin.RemoveAt(highestTimePos);
            }

            //add the new value
            addRestTime(listLastMin, personID, personName);
        }
    }
Пример #3
0
    public bool CompujumpPersonNeedLogout(int personID)
    {
        foreach (LastTestTime ltt in listAll)
        {
            if (ltt.PersonID == personID)
            {
                if (LastTestTime.GetSeconds(ltt.RestedTime) > 180)                //3 min
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }

        //person has not done any test. DateTime.Now.Subtract(currentPersonCompujumpLoginTime).TotalMinutes will decide
        return(true);
    }