Beispiel #1
0
        public LabReport CreateLabReport(DateTime startDate, DateTime endDate, DateTime startHour, DateTime endHour, Lab lab, bool weekends)
        {
            LabReport          labReport = new LabReport(lab);
            List <Task>        tasks     = new List <Task>();
            List <ComputerLab> cL        = getComputerInLab(lab, startDate, endDate);

            foreach (var item in cL)
            {
                //  Task t = Task.Factory.StartNew(() =>
                //  {
                ComputerReport cR = CreateComputerInLabReport(startDate, endDate, startHour, endHour, item, weekends);

                //add data to labreport
                lock (reportLock)
                {
                    labReport.ComputersReport.Add(cR);
                    labReport.AddToLabTotalActivityTime(cR.GetComputerTotalActiveTime());
                    labReport.AddToLabTotalActivityTimeWithClasses(cR.GetComputerTotalActiveTimeWithClasses());
                    labReport.AddToLabTotalHours(cR.GetComputerTotalTime());
                }
                //  });
                //  tasks.Add(t);
            }
            Task.WaitAll(tasks.ToArray());

            return(labReport);
        }
Beispiel #2
0
        public List <LabReport> CreateLabReport(DateTime startDate, DateTime endDate, DateTime startHour, DateTime endHour, List <int> labsIds, bool weekends)
        {
            List <LabReport> reports = new List <LabReport>();
            List <Task>      tasks   = new List <Task>();

            endDate = endDate.AddDays(1);
            foreach (var id in labsIds)
            {
                Task t = Task.Factory.StartNew(() =>
                {
                    LabReport labReport = CreateLabReport(startDate, endDate, startHour, endHour, id, weekends);
                    reports.Add(labReport);
                });
                tasks.Add(t);
            }
            Task.WaitAll(tasks.ToArray());
            return(reports);
        }