Exemplo n.º 1
0
        public List <Entry> GenerateChartImputationMonthVsHourMonthExpected(Models.Timesheet timesheet)
        {
            var entries         = new List <Microcharts.Entry>();
            var totalHoursMonth = (AppSettings.HoursDay * timesheet.Days.Where(x => x.IsClosed == false && x.IsWeekend == false && (x.Holiday == null || x.Holiday?.IsHolyday == false)).Count()) * 60;

            var consumed = timesheet.Activities.Sum(x => x.Value.Imputed);
            var pending  = totalHoursMonth - consumed;

            pending = pending < 0 ? pending = 0 : pending;

            entries.Add(new Entry(float.Parse(consumed.ToString()))
            {
                Color      = GenerateColors.GetColor(2),
                TextColor  = GenerateColors.GetColor(2),
                Label      = "Consumed",
                ValueLabel = TimeFormat.Format(consumed)
            });


            entries.Add(new Entry(float.Parse(pending.ToString()))
            {
                Color      = GenerateColors.GetColor(3),
                TextColor  = GenerateColors.GetColor(3),
                Label      = "Pending",
                ValueLabel = TimeFormat.Format(pending)
            });
            return(entries);
        }
Exemplo n.º 2
0
        protected void LoadSpecialDatesAsync(DateTime from, DateTime to)
        {
            IsBusy = true;
            Device.BeginInvokeOnMainThread(async() =>
            {
                try
                {
                    if (this.IsInternetAndCloseModal())
                    {
                        _currentTimesheet = await _timesheetModule.TimesheetService.GetTimesheetBeetweenDates(from, to);
                        var specialDates  = await _timesheetModule.CalendarService.GetSpecialDatesBeetweenDatesAsync(_currentTimesheet);
                        specialDates.ForEach(x => SpecialDates.Add(x));

                        var now                 = _currentDayMonthYear;
                        var minMonth            = new DateTime(now.Year, now.Month, 1);
                        var maxMonth            = minMonth.AddMonths(1).AddDays(-1);
                        var calculateActivities = _currentTimesheet.Activities.Where(x => x.Value.Date >= minMonth && x.Value.Date <= maxMonth);

                        ImputedTotal   = calculateActivities.Sum(x => x.Value.Imputed);
                        DeviationTotal = calculateActivities.Sum(x => x.Value.Deviation);
                    }
                    IsBusy = false;
                }
                catch (Exception e)
                {
                    IsBusy = false;
                    BaseModule.DialogErrorCustomService.DialogErrorCommonTryAgain();
                }finally {
                    IsLoadCalendar = true;
                }
            });
        }
Exemplo n.º 3
0
        public List <Entry> GenerateChartActivitiesImputedGroupByTaskAndProject(Models.Timesheet timesheet)
        {
            var projectsGroup = timesheet.Activities.GroupBy(x => new { x.Value.ProjectId, x.Value.TaskId });
            var entries       = new List <Microcharts.Entry>();
            var indexColor    = 0;

            foreach (var item in projectsGroup)
            {
                var tempProject = timesheet.Projects.FirstOrDefault(x => x.Value.Id.Equals(item.Key.ProjectId));
                var tempTask    = tempProject.Value?.Tasks.FirstOrDefault(x => x.Value.Id.Equals(item.Key.TaskId));

                var imputed = item.Sum(x => x.Value.Imputed);

                entries.Add(new Entry(float.Parse(imputed.ToString()))
                {
                    Color      = GenerateColors.GetColor(indexColor),
                    TextColor  = GenerateColors.GetColor(indexColor),
                    Label      = TruncateLongString(tempTask.Value.Value.DisplayName, 20),
                    ValueLabel = TimeFormat.Format(imputed)
                });
                indexColor++;
            }

            return(entries);
        }
Exemplo n.º 4
0
        protected void LoadSpecialDatesAsync(DateTime from, DateTime to)
        {
            IsBusy = true;
            Device.BeginInvokeOnMainThread(async() =>
            {
                try
                {
                    Dates.Clear();
                    _currentTimesheet = await _timesheetModule.TimesheetService.GetTimesheetBeetweenDates(from, to);
                    var specialDates  = await _timesheetModule.CalendarService.GetSpecialDatesBeetweenDatesAsync(_currentTimesheet);
                    specialDates.ForEach(x => SpecialDates.Add(x));
                    IsBusy = false;
                }
                catch (Exception ex)
                {
                    IsBusy = false;
                    Debug.WriteLine($"[Booking] Error: {ex}");

                    await BaseModule.DialogService.ShowAlertAsync(
                        "An error ocurred, try again",
                        "Error",
                        "Ok");
                }
            });
        }
Exemplo n.º 5
0
 private Task GenerateChartActivitiesImputationVsDeviation(Models.Timesheet timesheet)
 {
     return(Task.Run(() => {
         var entries = _dashBoardModule.ChartService.GenerateChartActivitiesImputationVsDeviation(timesheet);
         ChartImputedVsDeviation = new DonutChart()
         {
             LabelTextSize = Device.Idiom == TargetIdiom.Tablet? 30:25,
             Entries = entries
         };
         ChartImputedVsDeviationIsVisible = entries != null && entries.Sum(x => x.Value) > 0 ? true : false;
     }));
 }
Exemplo n.º 6
0
        protected void ChangeDateCalendar(DateTime from)
        {
            Dates             = new ObservableCollection <DateTime>();
            SpecialDates      = new ObservableCollection <SpecialDate>();
            _currentTimesheet = null;

            ReloadData();

            _currentDayMonthYear = from;
            var to = from.AddMonths(1).AddDays(10);

            LoadSpecialDatesAsync(from.AddDays(-7), to);
        }
Exemplo n.º 7
0
        private Task GenerateChartActivitiesImputedGroupByTaskAndProject(Models.Timesheet timesheet)
        {
            return(Task.Run(() => {
                var entries = _dashBoardModule.ChartService.GenerateChartActivitiesImputedGroupByTaskAndProject(timesheet);
                var chartT = new RadarChart()
                {
                    Entries = entries
                };

                chartT.LabelTextSize = Device.Idiom == TargetIdiom.Tablet ? 30 : 20;


                ChartProjectsImputed = chartT;

                ChartProjectsImputedIsVisible = entries != null && entries.Sum(x => x.Value) > 0 ? true : false;
            }));
        }
Exemplo n.º 8
0
        private Task GenerateChartImputationMonthVsHourMonthExpected(Models.Timesheet timesheet)
        {
            return(Task.Run(() => {
                var entries = _dashBoardModule.ChartService.GenerateChartImputationMonthVsHourMonthExpected(timesheet);
                ChartConsumedMonthVsHourMonthExpected = new DonutChart()
                {
                    LabelTextSize = Device.Idiom == TargetIdiom.Tablet ? 30 : 25,
                    Entries = entries,
                };

                var consumed = entries.FirstOrDefault();
                var desviation = entries.LastOrDefault();
                if (consumed != null && desviation != null)
                {
                    var total = consumed.Value + desviation.Value;
                    StatusMonth = $"{(consumed.Value * 100 / total).ToString("0.00")} %";
                }
            }));
        }
Exemplo n.º 9
0
        public List <Entry> GenerateChartActivitiesImputationVsDeviation(Models.Timesheet timesheet)
        {
            var entries    = new List <Microcharts.Entry>();
            var imputed    = timesheet.Activities.Sum(x => x.Value.Imputed);
            var desviation = timesheet.Activities.Sum(x => x.Value.Deviation);

            entries.Add(new Entry(float.Parse(imputed.ToString()))
            {
                Color      = GenerateColors.GetColor(0),
                TextColor  = GenerateColors.GetColor(0),
                Label      = "Imputed",
                ValueLabel = TimeFormat.Format(imputed)
            });

            entries.Add(new Entry(float.Parse(desviation.ToString()))
            {
                Color      = GenerateColors.GetColor(1),
                TextColor  = GenerateColors.GetColor(1),
                Label      = "Deviation",
                ValueLabel = TimeFormat.Format(desviation)
            });

            return(entries);
        }