public WeekOverview Get([FromQuery] int employeeId, [FromQuery] int?workWeek = -1, [FromQuery] int?year = -1)
        {
            var weekoverview = new WeekOverview();

            try
            {
                _logger.LogInformation($"Get WeekOverview for EmployeeId '{employeeId}', Workweek '{workWeek}', Year '{year}'");
                var workweek = DateTimeExtensions.GetDateTimesOfWorkWeek(workWeek.Value, year.Value);


                foreach (var workday in workweek)
                {
                    var wordayOverview = _prikkingenService.GetDayOverview(employeeId, workday);
                    weekoverview.DayOverviewCollection.Add(wordayOverview);

                    try
                    {
                        //try to get userinfo
                        weekoverview.UserOverview = _prikkingenService.GetUserOverview(employeeId, workday);
                    }
                    catch (Exception)
                    {
                        //Ignore UserNotFoundException
                    }
                }

                weekoverview.CalculateTotal();
                weekoverview.CalculateEnd();
            }
            catch (Exception e)
            {
                _logger.LogError("Error on Get WeekOverview", e);
                weekoverview.Error = e.Message;
            }

            return(weekoverview);
        }
Example #2
0
        /// <summary>
        /// Gets the week overview for a date
        /// </summary>
        /// <param name="date">The date that will be used to calculate the week starting date from</param>
        /// <returns>Dashbaord/WeekInformation</returns>
        public ActionResult WeekInformation(DateTime date)
        {
            //Finds the week start date
            date = FindStartDate(date);

            //Generates utilisation chart for the week
            var chart = GenerateWeekChart(date, "WeekChart");

            //Calculates the frequency, occupancy and utilisation rates for the company for the week
            var model = new WeekOverview
            {
                Chart           = chart,
                Frequency       = (service.CalculateFrequencyRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                Occupancy       = (service.CalculateOccupancyRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                Utilisation     = (service.CalculateUtilisationRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                DateInformation = new DateInformation
                {
                    StartDate = date,
                    EndDate   = date.AddDays(4),
                },
            };

            //Calculates the frequency, occupancy and utilisation rates for every resource for the week
            var resources = converter.ConvertResourceListFromWrapper(resourceService.GetResources());

            foreach (Resource resource in resources)
            {
                model.Resources.Add(new ResourceOverview
                {
                    Resource    = resource,
                    Utilisation = (service.CalculateResourceUtilisationRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                    Frequency   = (service.CalculateResourceFrequencyRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                    Occupancy   = (service.CalculateResourceOccupancyRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                });
            }
            return(View(model));
        }
Example #3
0
 public void SetCurrentWeek(TimesheetsOverviewWeekViewModel timesheetsWeek)
 {
     CurrentDate = timesheetsWeek.DateStart;
     CurrentWeek = new WeekOverview(this, timesheetsWeek);
 }