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); }
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; } }); }
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); }
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"); } }); }
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; })); }
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); }
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; })); }
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")} %"; } })); }
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); }