1002 lines
38 KiB
C#
1002 lines
38 KiB
C#
using System;
|
|
using System.Activities.Expressions;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls.Primitives;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Threading;
|
|
using BeWo.Core;
|
|
using BeWo.Core.Service;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.ClientPartials;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Data.Helpers;
|
|
using DevExpress.Xpf.Charts;
|
|
using DevExpress.Xpf.Editors;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class SupportConceptGoalRatingView : BeWoView
|
|
{
|
|
public static readonly DependencyProperty RatingListProperty = DependencyProperty.Register(
|
|
"RatingList",
|
|
typeof(RatingListVM),
|
|
typeof(SupportConceptGoalRatingView),
|
|
new UIPropertyMetadata(
|
|
(s, e) =>
|
|
{
|
|
//var c = s as SupportConceptGoalRatingView;
|
|
//var d = e.NewValue as RatingListVM;
|
|
|
|
//if (c != null && d != null)
|
|
//{
|
|
// c.InitListView();
|
|
//}
|
|
}));
|
|
|
|
public static readonly DependencyProperty SupportConceptProperty = DependencyProperty.Register(
|
|
"SupportConcept",
|
|
typeof(SupportConceptVM),
|
|
typeof(SupportConceptGoalRatingView),
|
|
new UIPropertyMetadata(
|
|
(s, e) =>
|
|
{
|
|
var c = s as SupportConceptGoalRatingView;
|
|
c.ResetControl();
|
|
|
|
//var d = e.NewValue as RatingListVM;
|
|
|
|
//if (c != null && d != null)
|
|
//{
|
|
// c.InitListView();
|
|
//}
|
|
}));
|
|
|
|
private SupportConceptVM _ViewModel;
|
|
private IList<GoalRatingDC> serviceRecordRatings = null;
|
|
private ObservableCollection<SupportConceptGoalTreeItem> _SelectedGoals;
|
|
|
|
public SupportConceptGoalRatingView()
|
|
{
|
|
this.InitializeComponent();
|
|
ChartRatings.CrosshairOptions = new CrosshairOptions();
|
|
ChartRatings.CrosshairOptions.ShowValueLabels = false;
|
|
ChartRatings.CrosshairOptions.ShowArgumentLabels = false;
|
|
ChartRatings.CrosshairOptions.ShowArgumentLine = true;
|
|
ChartRatings.CrosshairOptions.ShowGroupHeaders = false;
|
|
//ChartRatings.CrosshairOptions.ShowValueLabels
|
|
//XYDiagram2D diag = ChartRatings.Diagram as XYDiagram2D;
|
|
|
|
//var a = diag.AxisX;
|
|
//var o = a.DateTimeScaleOptions;
|
|
//var co = a.DateTimeScaleOptions as ContinuousDateTimeScaleOptions;
|
|
//co.GridAlignment = DateTimeGridAlignment.Day;
|
|
//co.AutoGrid = true;
|
|
}
|
|
|
|
public DateTime? StartDate { get; set; }
|
|
public DateTime? EndDate { get; set; }
|
|
|
|
public void ResetControl()
|
|
{
|
|
serviceRecordRatings = null;
|
|
}
|
|
|
|
public void UpdateControl()
|
|
{
|
|
//if (chkShowServiceRecordRatings.IsChecked.HasValue && chkShowServiceRecordRatings.IsChecked.Value)
|
|
//{
|
|
FetchServiceRecords();
|
|
//}
|
|
FetchStatistics();
|
|
|
|
ListBoxGoals.ItemsSource = null;
|
|
|
|
var listBoxGoals = new List<ListBoxGoalItem>();
|
|
var oid2EntryDict = new Dictionary<long, bool>();
|
|
|
|
foreach (var goal in SupportConcept.GetSelectedGoals())
|
|
{
|
|
var g = goal;
|
|
|
|
|
|
|
|
if (goal.Type == ValueListEntryType.SupportConceptGoalType ||
|
|
goal.Type == ValueListEntryType.SupportConceptIndividualGoalType)
|
|
{
|
|
if (goal.ParentOid.HasValue)
|
|
{
|
|
g = Cache.GetInstance().GetGoalEntry(goal.ParentOid.Value);
|
|
}
|
|
}
|
|
|
|
if (goal.Type == ValueListEntryType.SupportConceptGoalCategoryType ||
|
|
goal.Type == ValueListEntryType.SupportConceptIndividualGoalCategoryType)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
if (g != null && g.ValueListEntryOid.HasValue && !oid2EntryDict.ContainsKey(g.ValueListEntryOid.Value))
|
|
{
|
|
oid2EntryDict.Add(g.ValueListEntryOid.Value, true);
|
|
|
|
var item = new ListBoxGoalItem();
|
|
item.GoalEntry = g;
|
|
listBoxGoals.Add(item);
|
|
SetzeGeleisteteStunden(item);
|
|
}
|
|
|
|
|
|
}
|
|
decimal stdGesamt = 0;
|
|
foreach (var g in listBoxGoals)
|
|
{
|
|
stdGesamt += g.GeleisteteMinuten;
|
|
}
|
|
|
|
if (stdGesamt > 0)
|
|
{
|
|
foreach (var g in listBoxGoals)
|
|
{
|
|
g.GeleistetProzentual = (g.GeleisteteMinuten / stdGesamt) * 100;
|
|
|
|
}
|
|
}
|
|
|
|
ListBoxGoals.ItemsSource = listBoxGoals.OrderBy(g => g.GoalEntry.TypeDescription);
|
|
ListBoxGoals.SelectAll();
|
|
//if (RatingList != null && RatingList.VMList.Count > 0)
|
|
//{
|
|
// var goals = new List<ListBoxGoalItem>();
|
|
// foreach (var gr in RatingList.VMList[0].GoalRatingList.VMList)
|
|
// {
|
|
// var item = new ListBoxGoalItem();
|
|
// item.GoalEntry = gr.GoalEntry;
|
|
|
|
// SetzeGeleisteteStunden(item);
|
|
|
|
// goals.Add(item);
|
|
// }
|
|
|
|
// decimal stdGesamt = 0;
|
|
// foreach (var g in goals)
|
|
// {
|
|
// stdGesamt += g.GeleisteteMinuten;
|
|
// }
|
|
|
|
// if (stdGesamt > 0)
|
|
// {
|
|
// foreach (var g in goals)
|
|
// {
|
|
// g.GeleistetProzentual = (g.GeleisteteMinuten / stdGesamt) * 100;
|
|
|
|
// }
|
|
// }
|
|
|
|
// ListBoxGoals.ItemsSource = goals;
|
|
// ListBoxGoals.SelectAll();
|
|
//}
|
|
|
|
|
|
|
|
UpdateChart();
|
|
//ListBoxGoals.ItemsSource = ViewModel.Goals;
|
|
}
|
|
|
|
private void SetzeGeleisteteStunden(ListBoxGoalItem item)
|
|
{
|
|
if (serviceRecordRatings != null)
|
|
{
|
|
foreach (var srr in serviceRecordRatings)
|
|
{
|
|
if (srr.ServiceRecord != null && srr.GoalEntry.ValueListEntryOid == item.GoalEntry.ValueListEntryOid)
|
|
{
|
|
item.GeleisteteMinuten += srr.ServiceRecord.RoundedDuration;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UpdateChart()
|
|
{
|
|
ChartRatings.DataSource = CreateChartData();
|
|
SetSeriesVisibility();
|
|
}
|
|
|
|
private IList<ChartData> CreateChartData()
|
|
{
|
|
var dataList = new List<ChartData>();
|
|
|
|
foreach (var rating in RatingList.VMList)
|
|
{
|
|
if (rating.StartDate.HasValue && (!StartDate.HasValue || rating.StartDate >= StartDate.Value) && (!EndDate.HasValue || rating.StartDate <= EndDate.Value))
|
|
{
|
|
foreach (var goalrating in rating.GoalRatingList.VMList)
|
|
{
|
|
if (goalrating.GoalEntry != null && goalrating.RatingType != null)
|
|
{
|
|
var cdata = new ChartData
|
|
{
|
|
Date = rating.StartDate.Value.Date,
|
|
Goal = goalrating.GoalEntry.DisplayName,
|
|
Rating = goalrating.RatingType.RatingId ?? 0,
|
|
RatingType = goalrating.RatingType,
|
|
GoalEntry = goalrating.GoalEntry
|
|
|
|
|
|
};
|
|
dataList.Add(cdata);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (chkShowServiceRecordRatings.IsChecked.HasValue && chkShowServiceRecordRatings.IsChecked.Value && serviceRecordRatings != null)
|
|
{
|
|
foreach (var goalrating in serviceRecordRatings)
|
|
{
|
|
if (goalrating.GoalEntry != null && goalrating.RatingType != null && goalrating.ServiceRecord != null && (!StartDate.HasValue || goalrating.ServiceRecord.Start >= StartDate.Value) && (!EndDate.HasValue || goalrating.ServiceRecord.Start <= EndDate.Value))
|
|
{
|
|
var cdata = new ChartData
|
|
{
|
|
Date = goalrating.ServiceRecord.Start.Value,
|
|
Goal = goalrating.GoalEntry.DisplayName,
|
|
Rating = goalrating.RatingType.RatingId ?? 0,
|
|
RatingType = goalrating.RatingType,
|
|
GoalEntry = goalrating.GoalEntry,
|
|
ServiceRecord = goalrating.ServiceRecord
|
|
};
|
|
dataList.Add(cdata);
|
|
}
|
|
}
|
|
}
|
|
return dataList;
|
|
}
|
|
|
|
public RatingListVM RatingList
|
|
{
|
|
get
|
|
{
|
|
return (RatingListVM)this.GetValue(RatingListProperty);
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(RatingListProperty, value);
|
|
}
|
|
}
|
|
|
|
public SupportConceptVM SupportConcept
|
|
{
|
|
get
|
|
{
|
|
return (SupportConceptVM)this.GetValue(SupportConceptProperty);
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(SupportConceptProperty, value);
|
|
}
|
|
}
|
|
|
|
private void button_checkAllGoals_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ListBoxGoals.SelectAll();
|
|
}
|
|
|
|
private void button_uncheckAllGoals_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
ListBoxGoals.UnSelectAll();
|
|
}
|
|
|
|
|
|
private bool IsSeriesSelected(Series serie)
|
|
{
|
|
var selected = ListBoxGoals.SelectedItems;
|
|
foreach (var item in selected)
|
|
{
|
|
var goal = item as ListBoxGoalItem;
|
|
|
|
if (goal != null && goal.GoalEntry != null && goal.GoalEntry.DisplayName == serie.DisplayName)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool CheckIfAllGoalsAreSelected()
|
|
{
|
|
bool b = true;
|
|
var selectedInView = ListBoxGoals.SelectedItems;
|
|
foreach (var item in selectedInView)
|
|
{
|
|
var goal = item as ListBoxGoalItem;
|
|
|
|
if (goal == null && goal.GoalEntry == null)
|
|
{
|
|
b = false;
|
|
}
|
|
}
|
|
|
|
return b;
|
|
}
|
|
|
|
public List<ListBoxGoalItem> GetSelectedGoals()
|
|
{
|
|
var selectedInView = ListBoxGoals.SelectedItems;
|
|
List<ListBoxGoalItem> selected = new List<ListBoxGoalItem>();
|
|
foreach (var item in selectedInView)
|
|
{
|
|
var goal = item as ListBoxGoalItem;
|
|
|
|
if (goal != null && goal.GoalEntry != null)
|
|
{
|
|
selected.Add(goal);
|
|
}
|
|
}
|
|
|
|
return selected;
|
|
}
|
|
|
|
private void ListBoxGoals_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
|
{
|
|
SetSeriesVisibility();
|
|
}
|
|
|
|
private void SetSeriesVisibility()
|
|
{
|
|
foreach (var serie in ChartRatings.Diagram.Series)
|
|
{
|
|
serie.Visible = IsSeriesSelected(serie);
|
|
}
|
|
}
|
|
|
|
|
|
private void ChkShowServiceRecordRatings_OnChecked(object sender, RoutedEventArgs e)
|
|
{
|
|
FetchServiceRecords();
|
|
|
|
UpdateChart();
|
|
}
|
|
|
|
private void FetchServiceRecords()
|
|
{
|
|
if (serviceRecordRatings == null)
|
|
{
|
|
serviceRecordRatings = ServiceFacade.DoOperationsServiceSync(s => s.FetchServiceRecordRatings(SupportConcept.DataContract.SupportConceptOid.Value, null, null, null, null, null));
|
|
}
|
|
}
|
|
|
|
private void ChkShowServiceRecordRatings_OnUnchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
UpdateChart();
|
|
}
|
|
|
|
private void chartControl1_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
TooltipPanel.Children.Clear();
|
|
|
|
ChartHitInfo hitInfo = ChartRatings.CalcHitInfo(e.GetPosition(ChartRatings));
|
|
|
|
if (hitInfo != null && hitInfo.SeriesPoint != null)
|
|
{
|
|
SeriesPoint point = hitInfo.SeriesPoint;
|
|
|
|
var cdList = point.Tag as List<Object>;
|
|
if (cdList != null)
|
|
{
|
|
bool first = true;
|
|
foreach (var o in cdList)
|
|
{
|
|
var cd = o as ChartData;
|
|
if (cd != null)
|
|
{
|
|
var ttt = CreateTooltipElement(cd, first);
|
|
|
|
TooltipPanel.Children.Add(ttt);
|
|
|
|
first = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var cd = point.Tag as ChartData;
|
|
|
|
if (cd != null)
|
|
{
|
|
var ttt = CreateTooltipElement(cd, true);
|
|
|
|
TooltipPanel.Children.Add(ttt);
|
|
}
|
|
}
|
|
|
|
var test = e.GetPosition(ChartRatings);
|
|
tooltip1.PlacementTarget = ChartRatings;
|
|
tooltip1.Placement = PlacementMode.Left;
|
|
tooltip1.HorizontalOffset = test.X + 10;
|
|
tooltip1.VerticalOffset = test.Y - 10;
|
|
|
|
|
|
tooltip1.PopupAnimation = PopupAnimation.Fade;
|
|
|
|
//tooltip1.HorizontalOffset = 10;
|
|
//tooltip1.VerticalOffset = -30;
|
|
tooltip1.IsOpen = true;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//tooltip1.IsOpen = false;
|
|
|
|
}
|
|
}
|
|
|
|
private Grid CreateTooltipElement(ChartData cd, bool createDateBlock)
|
|
{
|
|
Grid g = new Grid();
|
|
g.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto});
|
|
g.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto});
|
|
g.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
g.RowDefinitions.Add(new RowDefinition {Height = GridLength.Auto});
|
|
|
|
|
|
if (createDateBlock)
|
|
{
|
|
g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
|
|
TextBlock dateBlock = CreateTextBlock(true);
|
|
dateBlock.Foreground = Brushes.SteelBlue;
|
|
dateBlock.Text = string.Format("{0:dd.MM.yyyy}", cd.Date);
|
|
dateBlock.SetValue(Grid.ColumnProperty, 0);
|
|
dateBlock.SetValue(Grid.RowProperty, 0);
|
|
dateBlock.SetValue(Grid.ColumnSpanProperty, 3);
|
|
g.Children.Add(dateBlock);
|
|
}
|
|
else
|
|
{
|
|
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
}
|
|
|
|
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
TextBlock zielLabel = CreateTextBlock(true);
|
|
zielLabel.Text = "Ziel:";
|
|
zielLabel.SetValue(Grid.ColumnProperty, 0);
|
|
zielLabel.SetValue(Grid.RowProperty, 2);
|
|
g.Children.Add(zielLabel);
|
|
|
|
TextBlock zielText = CreateTextBlock(false);
|
|
zielText.Text = cd.Goal;
|
|
zielText.SetValue(Grid.ColumnProperty, 1);
|
|
zielText.SetValue(Grid.RowProperty, 2);
|
|
zielText.SetValue(Grid.ColumnSpanProperty, 2);
|
|
g.Children.Add(zielText);
|
|
|
|
TextBlock ratingLabel = CreateTextBlock(true);
|
|
ratingLabel.Text = "Bewertung:";
|
|
ratingLabel.SetValue(Grid.ColumnProperty, 0);
|
|
ratingLabel.SetValue(Grid.RowProperty, 3);
|
|
g.Children.Add(ratingLabel);
|
|
|
|
TextBlock ratingText = CreateTextBlock(false);
|
|
ratingText.Text = cd.RatingType != null ? cd.RatingType.DisplayName : "";
|
|
ratingText.SetValue(Grid.ColumnProperty, 1);
|
|
ratingText.SetValue(Grid.ColumnSpanProperty, 2);
|
|
ratingText.SetValue(Grid.RowProperty, 3);
|
|
g.Children.Add(ratingText);
|
|
|
|
if (cd.ServiceRecord != null)
|
|
{
|
|
g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
|
|
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
|
|
TextBlock recordLabel = CreateTextBlock(false);
|
|
|
|
if (cd.ServiceRecord.Start.Value.Second == 0)
|
|
{
|
|
recordLabel.Text +=
|
|
string.Format("Uhrzeit: {0:HH:mm} bis {1:HH:mm}\nDauer: {2:0.##} Minuten",
|
|
cd.ServiceRecord.Start, cd.ServiceRecord.End, cd.ServiceRecord.RoundedDuration);
|
|
}
|
|
else
|
|
{
|
|
recordLabel.Text +=
|
|
string.Format("Dauer: {0:0.##} Minuten", cd.ServiceRecord.RoundedDuration);
|
|
}
|
|
|
|
recordLabel.SetValue(Grid.ColumnProperty, 0);
|
|
recordLabel.SetValue(Grid.RowProperty, 5);
|
|
recordLabel.SetValue(Grid.ColumnSpanProperty, 2);
|
|
|
|
var btn = new Button();
|
|
btn.ToolTip = Translator.Translate("In Zeiterfassung öffnen");
|
|
|
|
btn.SetValue(Grid.ColumnProperty, 2);
|
|
btn.SetValue(Grid.RowProperty, 5);
|
|
|
|
btn.Height = 23;
|
|
btn.Width = 23;
|
|
btn.Tag = cd.ServiceRecord;
|
|
btn.HorizontalAlignment = HorizontalAlignment.Right;
|
|
btn.Margin = new Thickness(0,0,0,0);
|
|
|
|
var img = new System.Windows.Controls.Image
|
|
{
|
|
Source = new BitmapImage(
|
|
new Uri(
|
|
"pack://application:,,,/Ressources/Icons/HistoryDisabled.png"))
|
|
};
|
|
btn.Content = img;
|
|
|
|
btn.Click += Btn_Click;
|
|
//< Button Grid.Column = "1" Width = "23" Height = "23" Style = "{DynamicResource TransparentButtonStyle}" ToolTip = "{markup:Translate In Zeiterfassung öffnen}" Tag = "{Binding}" Click = "ButtonOpenServiceRecordView_Click" Margin = "0,0,0,0" >
|
|
|
|
//< Image Source = "..\..\..\Ressources\Icons\HistoryDisabled.png" />
|
|
|
|
//</ Button >
|
|
|
|
g.Children.Add(recordLabel);
|
|
g.Children.Add(btn);
|
|
|
|
}
|
|
|
|
return g;
|
|
}
|
|
|
|
private void Btn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var btn = sender as Button;
|
|
|
|
var dc = btn.Tag as ServiceRecordDC;
|
|
if (dc == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
BeWoUtils.EditServiceRecord(dc, this);
|
|
|
|
}
|
|
|
|
|
|
private TextBlock CreateTextBlock(bool bold)
|
|
{
|
|
var tb = new TextBlock();
|
|
tb.Foreground = Brushes.Black;
|
|
tb.FontSize = 12;
|
|
tb.Margin = new Thickness(3);
|
|
if (bold)
|
|
{
|
|
tb.FontWeight = FontWeights.Bold;
|
|
|
|
}
|
|
|
|
return tb;
|
|
}
|
|
|
|
private void chartControl1_MouseLeave(object sender, MouseEventArgs e)
|
|
{
|
|
//tooltip1.IsOpen = false;
|
|
}
|
|
|
|
private void FetchStatistics()
|
|
{
|
|
|
|
long c2sOid = 0;
|
|
if (SupportConcept != null && SupportConcept.CostBearerRelations != null && SupportConcept.CostBearerRelations.VMList.Count > 0)
|
|
{
|
|
c2sOid = SupportConcept.CostBearerRelations.VMList[0].DataContract.CostBearer2SupportConceptOid.Value;
|
|
}
|
|
|
|
if (c2sOid == 0)
|
|
{
|
|
CreateStatisticInfos(null);
|
|
return;
|
|
}
|
|
|
|
ServiceFacade.DoOperationsServiceAsync(
|
|
s1 => s1.GetServiceRecordStatisticInfo(c2sOid, DateTime.Now),
|
|
stinf => ServiceFacade.DoOperationsServiceAsync(
|
|
s => s.CreateSupportConceptStatistics(c2sOid, DateTime.Now),
|
|
r => this.Dispatch(delegate
|
|
{
|
|
if (stinf != null)
|
|
{
|
|
VariableStatisticsGrid.Visibility = Visibility.Visible;
|
|
FixedStatisticsGrid.Visibility = Visibility.Collapsed;
|
|
|
|
CreateStatisticInfos(stinf);
|
|
}
|
|
else
|
|
{
|
|
VariableStatisticsGrid.Visibility = Visibility.Collapsed;
|
|
FixedStatisticsGrid.Visibility = Visibility.Visible;
|
|
|
|
StatisticsListBox.ItemsSource = CreateStatisticVMList(r);
|
|
}
|
|
|
|
}), false));
|
|
}
|
|
|
|
|
|
private static List<SupportConceptPeriodStatisticsVM> CreateStatisticVMList(SupportConceptStatisticsDC statisticsDc)
|
|
{
|
|
var stats = new List<SupportConceptPeriodStatisticsVM>();
|
|
if (statisticsDc != null)
|
|
{
|
|
if (statisticsDc.PeriodStatistics.Count > 1 && !TimeSpanIsEqual(statisticsDc))
|
|
stats.Add(CreateTotalStatisticsVM(statisticsDc));
|
|
|
|
foreach (SupportConceptPeriodStatisticsDC dc in statisticsDc.PeriodStatistics)
|
|
{
|
|
bool showOutOfPeriod = statisticsDc.PeriodStatistics.Count == 1;
|
|
stats.Add(CreateStatisticsVM(statisticsDc, dc, showOutOfPeriod));
|
|
}
|
|
}
|
|
return stats;
|
|
}
|
|
|
|
private static bool TimeSpanIsEqual(SupportConceptStatisticsDC r)
|
|
{
|
|
if (r.PeriodStatistics != null && r.PeriodStatistics.Count > 1)
|
|
{
|
|
for (int i = 0; i < r.PeriodStatistics.Count - 1; i++)
|
|
{
|
|
SupportConceptPeriodStatisticsDC p1 = r.PeriodStatistics[i];
|
|
|
|
if (p1.SupportConceptApprovalPeriod.StartDate.HasValue && p1.SupportConceptApprovalPeriod.EndDate.HasValue)
|
|
{
|
|
for (int j = i + 1; j < r.PeriodStatistics.Count; j++)
|
|
{
|
|
SupportConceptPeriodStatisticsDC p2 = r.PeriodStatistics[j];
|
|
if (p2.SupportConceptApprovalPeriod.StartDate.HasValue && p2.SupportConceptApprovalPeriod.EndDate.HasValue)
|
|
{
|
|
if ((p1.SupportConceptApprovalPeriod.StartDate.Value.Date != p2.SupportConceptApprovalPeriod.StartDate.Value.Date) ||
|
|
(p1.SupportConceptApprovalPeriod.EndDate.Value.Date != p2.SupportConceptApprovalPeriod.EndDate.Value.Date))
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static SupportConceptPeriodStatisticsVM CreateTotalStatisticsVM(SupportConceptStatisticsDC dc)
|
|
{
|
|
int unitDividend = 60;
|
|
|
|
var vm = new SupportConceptPeriodStatisticsVM();
|
|
vm.Header = "Gesamt";
|
|
|
|
|
|
vm.StatisticInfo1Left = String.Format("{0:0.00}", dc.MinutesProvidedThisWeek / unitDividend);
|
|
vm.StatisticInfo1Right = String.Format("{0:0.00}", dc.MinutesProvidedTotalRounded / unitDividend);
|
|
|
|
vm.StatisticInfo2Left = String.Format("{0:0.00}", dc.MinutesApprovedPerWeek / unitDividend);
|
|
vm.StatisticInfo2Right = String.Format("{0:0.00}", dc.MinutesApprovedTotal / unitDividend);
|
|
|
|
vm.StatisticInfo3Left = String.Format("{0:0.00}", dc.MinutesFreePerWeekAverage / unitDividend);
|
|
|
|
vm.StatisticInfo3Right = String.Format("{0:0.00}", (dc.MinutesApprovedTotal - dc.MinutesProvidedTotalRounded) / unitDividend);
|
|
|
|
|
|
decimal schwellwert = dc.MinutesApprovedTotal * (BeWoApp.AppSettings.ZeiterfassungsSchwellwert / 100m);
|
|
decimal free = dc.MinutesApprovedTotal - dc.MinutesProvidedTotalRounded;
|
|
|
|
decimal prozent = 0;
|
|
if (dc.MinutesApprovedTotal != 0)
|
|
{
|
|
prozent = (free / dc.MinutesApprovedTotal) * 100;
|
|
}
|
|
if (dc.MinutesProvidedTotalRounded > schwellwert)
|
|
{
|
|
vm.StatisticInfo3ForegroundColor = Brushes.Red;
|
|
|
|
if (free >= 0)
|
|
{
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Es stehen nur noch {0:0.##} % der bewilligten Gesamtstunden zur Verfügung.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent);
|
|
}
|
|
else
|
|
{
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Die bewilligten Gesamtstunden wurden um {0:0.##} % überschritten.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent * -1m);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
vm.StatisticInfo3ForegroundColor = Brushes.Green;
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Es stehen noch {0:0.##} % der bewilligten Gesamtstunden zur Verfügung.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent);
|
|
}
|
|
|
|
|
|
|
|
vm.MinutesProvidedTotalRounded = dc.MinutesProvidedTotalRounded;
|
|
return vm;
|
|
}
|
|
|
|
public static SupportConceptPeriodStatisticsVM CreateStatisticsVM(SupportConceptStatisticsDC stats, SupportConceptPeriodStatisticsDC periodStats, bool showOutOfPeriod)
|
|
{
|
|
int unitDividend = 60;
|
|
|
|
var vm = new SupportConceptPeriodStatisticsVM();
|
|
if (periodStats.SupportConceptApprovalPeriod != null)
|
|
{
|
|
if (periodStats.SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
{
|
|
if (periodStats.SupportConceptApprovalPeriod.StartDate.HasValue && periodStats.SupportConceptApprovalPeriod.EndDate.HasValue &&
|
|
periodStats.SupportConceptApprovalPeriod.StartDate.Value.Date == stats.StatisticsStartDate.Date &&
|
|
periodStats.SupportConceptApprovalPeriod.EndDate.Value.Date == stats.StatisticsEndDate.Date && !showOutOfPeriod)
|
|
{
|
|
vm.Header = periodStats.SupportConceptApprovalPeriod.ServiceCategory.Name;
|
|
}
|
|
else
|
|
{
|
|
vm.Header = String.Format("{0}: {1:dd.MM.yy} - {2:dd.MM.yy}",
|
|
periodStats.SupportConceptApprovalPeriod.ServiceCategory.Name,
|
|
periodStats.SupportConceptApprovalPeriod.StartDate,
|
|
periodStats.SupportConceptApprovalPeriod.EndDate);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
vm.Header = String.Format("{0:dd.MM.yy} - {1:dd.MM.yy}",
|
|
periodStats.SupportConceptApprovalPeriod.StartDate,
|
|
periodStats.SupportConceptApprovalPeriod.EndDate);
|
|
}
|
|
}
|
|
|
|
|
|
vm.StatisticInfo1Left = String.Format("{0:0.00}", periodStats.MinutesProvidedThisWeek / unitDividend);
|
|
vm.StatisticInfo1Right = String.Format("{0:0.00}", periodStats.MinutesProvidedTotalRounded / unitDividend);
|
|
|
|
vm.StatisticInfo2Left = String.Format("{0:0.00}", periodStats.MinutesApprovedPerWeek / unitDividend);
|
|
vm.StatisticInfo2Right = String.Format("{0:0.00}", periodStats.MinutesApprovedTotal / unitDividend);
|
|
|
|
vm.StatisticInfo3Left = String.Format("{0:0.00}", periodStats.MinutesFreePerWeek / unitDividend);
|
|
vm.StatisticInfo3Right = String.Format("{0:0.00}",
|
|
(periodStats.MinutesApprovedTotal - periodStats.MinutesProvidedTotalRounded) /
|
|
unitDividend);
|
|
|
|
decimal schwellwert = periodStats.MinutesApprovedTotal * (BeWoApp.AppSettings.ZeiterfassungsSchwellwert / 100m);
|
|
decimal free = periodStats.MinutesApprovedTotal - periodStats.MinutesProvidedTotalRounded;
|
|
|
|
decimal prozent = 0;
|
|
if (periodStats.MinutesApprovedTotal != 0)
|
|
{
|
|
prozent = (free / periodStats.MinutesApprovedTotal) * 100;
|
|
}
|
|
if (periodStats.MinutesProvidedTotalRounded > schwellwert)
|
|
{
|
|
vm.StatisticInfo3ForegroundColor = Brushes.Red;
|
|
|
|
if (free >= 0)
|
|
{
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Es stehen nur noch {0:0.##} % der bewilligten Gesamtstunden zur Verfügung.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent);
|
|
}
|
|
else
|
|
{
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Die bewilligten Gesamtstunden wurden um {0:0.##} % überschritten.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent * -1m);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
vm.StatisticInfo3ForegroundColor = Brushes.Green;
|
|
vm.StatisticInfo3Tooltip =
|
|
String.Format(
|
|
"Es stehen noch {0:0.##} % der bewilligten Gesamtstunden zur Verfügung.\nSie können den Schwellwert für diese Anzeige in der Verwaltung ändern.",
|
|
prozent);
|
|
}
|
|
|
|
|
|
if (showOutOfPeriod && stats.MinutesOutOfApprovedPeriod > 0)
|
|
vm.StatisticInfo1Error = String.Format(" {0:0.00}", stats.MinutesOutOfApprovedPeriod / 60);
|
|
|
|
vm.MinutesProvidedTotalRounded = periodStats.MinutesProvidedTotalRounded;
|
|
|
|
return vm;
|
|
}
|
|
|
|
private void CreateStatisticInfos(ServiceRecordStatisticsInfoDC info)
|
|
{
|
|
StatisticInfoGrid.Children.Clear();
|
|
StatisticInfoGrid.ColumnDefinitions.Clear();
|
|
StatisticInfoGrid.RowDefinitions.Clear();
|
|
|
|
if (info != null)
|
|
{
|
|
|
|
if (info.Header != null)
|
|
{
|
|
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
|
|
{
|
|
Width = new GridLength(1, GridUnitType.Auto)
|
|
});
|
|
|
|
foreach (var header in info.Header)
|
|
{
|
|
StatisticInfoGrid.RowDefinitions.Add(new RowDefinition());
|
|
}
|
|
|
|
int rowIndex = 0;
|
|
foreach (var header in info.Header)
|
|
{
|
|
var txt = new TextBlock();
|
|
txt.SetValue(Grid.ColumnProperty, 0);
|
|
txt.SetValue(Grid.RowProperty, rowIndex);
|
|
txt.Foreground =
|
|
new SolidColorBrush(
|
|
(Color)ColorConverter.ConvertFromString(info.ForegroundColor[rowIndex]));
|
|
txt.Height = 14;
|
|
txt.Text = header;
|
|
|
|
StatisticInfoGrid.Children.Add(txt);
|
|
|
|
rowIndex++;
|
|
}
|
|
|
|
if (info.PeriodStatisticInfos != null)
|
|
{
|
|
foreach (var periodInfo in info.PeriodStatisticInfos)
|
|
{
|
|
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
|
|
{
|
|
Width = new GridLength(1, GridUnitType.Auto)
|
|
});
|
|
StatisticInfoGrid.ColumnDefinitions.Add(new ColumnDefinition
|
|
{
|
|
Width = new GridLength(1, GridUnitType.Auto)
|
|
});
|
|
}
|
|
|
|
int colIndex = 1;
|
|
foreach (var periodInfo in info.PeriodStatisticInfos)
|
|
{
|
|
rowIndex = 0;
|
|
foreach (var lv in periodInfo.LeftValues)
|
|
{
|
|
if (!String.IsNullOrEmpty(lv))
|
|
{
|
|
var txt = new TextBlock();
|
|
txt.SetValue(Grid.ColumnProperty, colIndex);
|
|
txt.SetValue(Grid.RowProperty, rowIndex);
|
|
txt.Foreground = new SolidColorBrush(
|
|
(Color)ColorConverter.ConvertFromString(periodInfo.LeftValueColors[rowIndex]));
|
|
txt.Height = 12;
|
|
txt.FontWeight = FontWeights.Bold;
|
|
txt.Text = lv;
|
|
txt.HorizontalAlignment = HorizontalAlignment.Right;
|
|
txt.Margin = new Thickness(10, 0, 0, 0);
|
|
txt.Padding = new Thickness(1, 0, 1, 0);
|
|
if (String.IsNullOrEmpty(periodInfo.RightValues[rowIndex]))
|
|
{
|
|
txt.SetValue(Grid.ColumnSpanProperty, 2);
|
|
}
|
|
|
|
StatisticInfoGrid.Children.Add(txt);
|
|
|
|
|
|
//<TextBlock x:Name="txtStatisticInfoHeader" Grid.Column="0" Grid.Row="0"
|
|
// Text="{Binding Path=Header}" Grid.ColumnSpan="4"
|
|
// FontWeight="Bold" FontSize="12" Foreground="{DynamicResource BigInfoTextBrush}" Height="14"/>
|
|
}
|
|
if (!String.IsNullOrEmpty(periodInfo.RightValues[rowIndex]))
|
|
{
|
|
var txt = new TextBlock();
|
|
txt.SetValue(Grid.ColumnProperty, colIndex + 1);
|
|
txt.SetValue(Grid.RowProperty, rowIndex);
|
|
txt.Foreground =
|
|
new SolidColorBrush(
|
|
(Color)ColorConverter.ConvertFromString(
|
|
periodInfo.RightValueColors[rowIndex]));
|
|
txt.Height = 12;
|
|
txt.FontWeight = FontWeights.Bold;
|
|
txt.Text = periodInfo.RightValues[rowIndex];
|
|
txt.HorizontalAlignment = HorizontalAlignment.Right;
|
|
txt.Margin = new Thickness(10, 0, 0, 0);
|
|
txt.Padding = new Thickness(1, 0, 1, 0);
|
|
StatisticInfoGrid.Children.Add(txt);
|
|
|
|
|
|
//<TextBlock x:Name="txtStatisticInfoHeader" Grid.Column="0" Grid.Row="0"
|
|
// Text="{Binding Path=Header}" Grid.ColumnSpan="4"
|
|
// FontWeight="Bold" FontSize="12" Foreground="{DynamicResource BigInfoTextBrush}" Height="14"/>
|
|
}
|
|
|
|
|
|
rowIndex++;
|
|
}
|
|
|
|
colIndex += 2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void UIElement_OnMouseLeave(object sender, MouseEventArgs e)
|
|
{
|
|
tooltip1.IsOpen = false;
|
|
}
|
|
}
|
|
|
|
public class ListBoxGoalItem
|
|
{
|
|
public ValueListEntryDC GoalEntry { get; set; }
|
|
public decimal GeleisteteMinuten { get; set; }
|
|
public decimal GeleistetProzentual { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
String name = "";
|
|
|
|
if (GoalEntry != null)
|
|
{
|
|
name = GoalEntry.TypeDescription;
|
|
}
|
|
|
|
//name += String.Format("\t(bisher geleistet: {0:0.00} Std. entspricht {1:0.00}%)", GeleistetStunden, GeleistetProzentual);
|
|
name += String.Format(" ({0:0.##} Minuten = {1:0.00} Std.)", GeleisteteMinuten, GeleisteteMinuten / 60);
|
|
return name;
|
|
}
|
|
}
|
|
|
|
public class ChartData
|
|
{
|
|
public String Goal { get; set; }
|
|
public DateTime Date { get; set; }
|
|
public int Rating { get; set; }
|
|
public RatingTypeDC RatingType { get; set; }
|
|
public ValueListEntryDC GoalEntry { get; set; }
|
|
public ServiceRecordDC ServiceRecord { get; set; }
|
|
}
|
|
|
|
public class MarkerDataTemplateSelector : DataTemplateSelector
|
|
{
|
|
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
|
{
|
|
if (container is FrameworkElement element && item is SeriesPoint seriesPoint)
|
|
{
|
|
var cd = seriesPoint.Tag as ChartData;
|
|
if (cd != null && cd.ServiceRecord != null)
|
|
{
|
|
return element.FindResource("circleModel") as DataTemplate;
|
|
}
|
|
return element.FindResource("squareModel") as DataTemplate;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
} |