Esempio n. 1
0
        private void ExecuteClicked(object sender, EventArgs e)
        {
            if (!(checkedListBox1.CheckedItems.Count > 0))
            {
                return;
            }

            var users = GetUsersWithHours(checkedListBox1.CheckedItems.OfType <string>().ToList());
            var totalTimeForAllUsers = new TimeSpan();
            var result = "";

            foreach (var user in users.Values)
            {
                var totalAllSessionsTime = new TimeSpan();
                var missingDays          = new List <DateTime>();
                result += "Id:" + user.id + "    Name:" + user.name + Environment.NewLine;
                foreach (var sessionTime in user.attendanceTimes)
                {
                    if ((sessionTime.Key != null && sessionTime.Key >= fromDatePicker.Value && sessionTime.Key <= toDatePicker.Value) ||
                        (sessionTime.Value != null && sessionTime.Value >= fromDatePicker.Value && sessionTime.Value <= toDatePicker.Value))
                    {
                        if (sessionTime.Key == null || sessionTime.Value == null)
                        {
                            missingDays.Add((DateTime)sessionTime.Key);
                            continue;
                        }
                        var endTime          = sessionTime.Value < toDatePicker.Value ? sessionTime.Value : toDatePicker.Value;
                        var totalSessionTime = (DateTime)endTime - (DateTime)sessionTime.Key;

                        result += "From:" + sessionTime.Key + "    To:" + endTime + "    Total: " +
                                  Uti.FormatTime(totalSessionTime) + Environment.NewLine;
                        totalAllSessionsTime += totalSessionTime;
                    }
                }
                result += "Total time: " + Uti.FormatTime(totalAllSessionsTime) + "    Missing days: " + missingDays.Count + Environment.NewLine;
                totalTimeForAllUsers += totalAllSessionsTime;
                if (missingDays.Count > 0)
                {
                    result += "Missing dates: " + Environment.NewLine;
                    foreach (var day in missingDays)
                    {
                        result += day + Environment.NewLine;
                    }
                }
                result += Environment.NewLine + Environment.NewLine;
            }
            result           += "Total time 4 ALL users COMBINED: " + Uti.FormatTime(totalTimeForAllUsers);
            richTextBox1.Text = result;
        }
Esempio n. 2
0
        void t_Tick(object sender, EventArgs e)
        {
            var time_span = (DateTime.Now - user.connectedTime);

            TimerLabel.Text = Uti.FormatTime(time_span);
        }