234 lines
9.7 KiB
C#
234 lines
9.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWo.Scheduler.ViewModel
|
|
{
|
|
public class CustomFieldStorage
|
|
{
|
|
public string ToolTip
|
|
{
|
|
get
|
|
{
|
|
var result = Subject;
|
|
|
|
if(IsTask)
|
|
{
|
|
result = result ?? string.Empty;
|
|
|
|
if(CompletedDate.HasValue)
|
|
{
|
|
result += " erledigt am " + CompletedDate.Value.ToShortDateString();
|
|
}
|
|
else if(DueDate.HasValue)
|
|
{
|
|
result += $" bis {DueDate.Value:dd.MM.yyyy HH:mm}";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Man darf den Betreff nicht sehen, wenn man der Originator ist und nicht in der nicht leeren EmployeeList ist oder man weder Originator noch in der EmployeeList ist
|
|
|
|
var isInEmployeeList = EmployeeList.Any(e2A => e2A.Employee.Equals(BeWoApp.CompactLoggedOnEmployee));
|
|
var isOriginator = Originator.Equals(BeWoApp.CompactLoggedOnEmployee);
|
|
|
|
if(IsPrivate && (!isOriginator && !isInEmployeeList || !isInEmployeeList))
|
|
{
|
|
result = "Privat";
|
|
}
|
|
}
|
|
|
|
if(!IsAbsenceTime || !_AbsenceTimeStart.HasValue)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
var absenceTimeEnd = _AbsenceTimeEnd;
|
|
|
|
if(!absenceTimeEnd.HasValue)
|
|
{
|
|
return $"{result}{_AbsenceTimeStart.Value.GetIntervalDescription(absenceTimeEnd)}";
|
|
}
|
|
|
|
var absenceTimeStart = _AbsenceTimeStart.Value;
|
|
|
|
if(absenceTimeStart.IsTimeZero() && absenceTimeEnd.Value.IsTimeZero() && absenceTimeEnd.Value.AddDays(-1) > absenceTimeStart)
|
|
{
|
|
absenceTimeEnd = absenceTimeEnd.Value.AddDays(-1);
|
|
}
|
|
|
|
return $"{result}{_AbsenceTimeStart.Value.GetIntervalDescription(absenceTimeEnd)}";
|
|
}
|
|
}
|
|
|
|
public string Subject { get; set; }
|
|
|
|
public bool IsTask { get; set; }
|
|
public bool IsAbsenceTime { get; set; }
|
|
public bool IsPrivate { get; set; }
|
|
public bool IsAllDay { get; set; }
|
|
|
|
public LinearGradientBrush BackgroundColor => new LinearGradientBrush(new GradientStopCollection { new GradientStop(IsTask ? Color.FromRgb(153, 59, 59) : Color.FromRgb(192, 255, 208), 1) }, new Point(.5, 0), new Point(.5, 1));
|
|
public LinearGradientBrush ForegroundColor => new LinearGradientBrush(new GradientStopCollection { new GradientStop(IsTask ? Color.FromRgb(224, 224, 224) : Color.FromRgb(0, 0, 0), 1) }, new Point(.5, 0), new Point(.5, 1));
|
|
|
|
public ObservableCollection<Employee2SchedulerAppointmentDC> EmployeeList { get; set; } = new ObservableCollection<Employee2SchedulerAppointmentDC>();
|
|
public List<CompactCustomerDC> CustomerList { get; set; } = new List<CompactCustomerDC>();
|
|
public List<ResourceDC> ResourceList { get; set; } = new List<ResourceDC>();
|
|
public List<CompactSupportConceptDC> SupportConceptList { get; set; } = new List<CompactSupportConceptDC>();
|
|
|
|
public DateTime? DueDate { get; set; }
|
|
public DateTime? CompletedDate { get; set; }
|
|
public string CompletedNotice { get; set; }
|
|
public string CompletedUser { get; set; }
|
|
public string TaskDescription { get; set; }
|
|
|
|
public long? SchedulerAppointmentOid { get; set; }
|
|
|
|
public string RecurrenceId { get; set; }
|
|
public int RecurrenceIndex { get; set; }
|
|
|
|
public CompactEmployeeDC Originator { get; set; }
|
|
|
|
private DateTime? _AbsenceTimeStart;
|
|
|
|
private DateTime? _AbsenceTimeEnd;
|
|
|
|
public InternalInfo InternalInfo { get; set; }
|
|
|
|
public bool CanBeEdited { get; set; }
|
|
|
|
public long? AbsenceTimeOid { get; set; }
|
|
|
|
public bool IsCustomerAbsenceTime { get; set; }
|
|
|
|
public CustomFieldStorage()
|
|
{
|
|
|
|
}
|
|
|
|
public CustomFieldStorage(SchedulerAppointmentVM pAppointment)
|
|
{
|
|
IsTask = pAppointment.IsTask;
|
|
IsAbsenceTime = pAppointment.IsAbsenceTime;
|
|
IsPrivate = pAppointment.IsPrivate;
|
|
IsAllDay = pAppointment.AllDay;
|
|
|
|
EmployeeList = pAppointment.EmployeeList;
|
|
CustomerList = pAppointment.CustomerList;
|
|
ResourceList = pAppointment.ResourceList;
|
|
SupportConceptList = pAppointment.SupportConceptList;
|
|
|
|
DueDate = pAppointment.DueDate;
|
|
CompletedDate = pAppointment.CompletedDate;
|
|
CompletedNotice = pAppointment.CompletedNotice;
|
|
TaskDescription = pAppointment.TaskDescription;
|
|
|
|
Originator = pAppointment.Originator;
|
|
Subject = pAppointment.Subject;
|
|
|
|
SchedulerAppointmentOid = pAppointment.DataContract?.SchedulerAppointmentOid;
|
|
|
|
RecurrenceId = pAppointment.DataContract?.RecurrenceIdReference;
|
|
RecurrenceIndex = pAppointment.DataContract?.RecurrenceIndexReference ?? 0;
|
|
|
|
_AbsenceTimeStart = pAppointment.AbsenceTimeStart;
|
|
_AbsenceTimeEnd = pAppointment.AbsenceTimeEnd;
|
|
|
|
HasServiceRecordEntry = pAppointment.HasServiceRecordEntry;
|
|
if (Subject.Contains("Flingern"))
|
|
{
|
|
int test = 0;
|
|
}
|
|
CanBeEdited = pAppointment.CanBeEdited;
|
|
|
|
AbsenceTimeOid = pAppointment.AbsenceTimeOid;
|
|
IsCustomerAbsenceTime = pAppointment.IsCustomerAbsenceTime;
|
|
ServiceRecordList = pAppointment.ServiceRecordList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Erzeugt ein CustomFieldStorage-Objekt aus einem SchedulerAppointmentDC. Wird nur für veränderte Serientermine benutzt.
|
|
/// </summary>
|
|
/// <param name="pAppointment">Der veränderte Serientermin als SchedulerAppointmentDC</param>
|
|
public CustomFieldStorage(SchedulerAppointmentDC pAppointment)
|
|
{
|
|
IsTask = pAppointment.IsTask;
|
|
IsAbsenceTime = false;
|
|
IsPrivate = pAppointment.IsPrivate;
|
|
IsAllDay = pAppointment.AllDay;
|
|
|
|
EmployeeList = new ObservableCollection<Employee2SchedulerAppointmentDC>(pAppointment.EmployeeList);
|
|
CustomerList = pAppointment.CustomerList;
|
|
ResourceList = pAppointment.ResourceList;
|
|
SupportConceptList = pAppointment.SupportConceptList;
|
|
ServiceRecordList = pAppointment.ServiceRecordList;
|
|
|
|
DueDate = pAppointment.DueDate;
|
|
CompletedDate = pAppointment.CompletedDate;
|
|
CompletedNotice = pAppointment.CompletedNotice;
|
|
TaskDescription = pAppointment.TaskDescription;
|
|
|
|
Originator = pAppointment.Originator;
|
|
Subject = pAppointment.Subject;
|
|
|
|
SchedulerAppointmentOid = pAppointment.SchedulerAppointmentOid;
|
|
|
|
RecurrenceId = pAppointment.RecurrenceIdReference;
|
|
RecurrenceIndex = pAppointment.RecurrenceIndexReference ?? 0;
|
|
|
|
HasServiceRecordEntry = pAppointment.HasServiceRecordEntry;
|
|
|
|
CanBeEdited = pAppointment.CanBeEdited;
|
|
}
|
|
|
|
public CustomFieldStorage(ObservableCollection<Employee2SchedulerAppointmentDC> pEmployees, List<CompactCustomerDC> pCustomers, List<ResourceDC> pResources, CompactEmployeeDC pOriginator, bool pIsPrivate, bool pIsTask, string pTaskDescription, DateTime? pDueDate, DateTime? pCompletedDate, string pCompletedNotice, List<CompactSupportConceptDC> pSupportConcepts, string pSubject, bool pIsAllDay, List<ServiceRecordDC> serviceRecords)
|
|
{
|
|
IsTask = pIsTask;
|
|
IsPrivate = pIsPrivate;
|
|
IsAllDay = pIsAllDay;
|
|
|
|
EmployeeList = pEmployees;
|
|
CustomerList = pCustomers;
|
|
ResourceList = pResources;
|
|
|
|
SupportConceptList = pSupportConcepts;
|
|
ServiceRecordList = serviceRecords;
|
|
|
|
DueDate = pDueDate;
|
|
CompletedDate = pCompletedDate;
|
|
CompletedNotice = pCompletedNotice;
|
|
TaskDescription = pTaskDescription;
|
|
|
|
Originator = pOriginator;
|
|
Subject = pSubject;
|
|
}
|
|
|
|
public Visibility ToolTipTimeVisibility => IsTask || IsAbsenceTime ? Visibility.Collapsed : Visibility.Visible;
|
|
|
|
public Visibility ToolTipResourcesVisibility => ResourceList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
public Visibility ToolTipEmployeesVisibility => EmployeeList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
public Visibility ToolTipCustomersVisibility => CustomerList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
public Visibility ToolTipTrennstrichVisibility => EmployeeList?.Count > 0 || CustomerList?.Count > 0 || ResourceList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
public Visibility ToolTipZusageVisibility => IsTask ? Visibility.Collapsed : Visibility.Visible;
|
|
|
|
public bool HasServiceRecordEntry { get; set; }
|
|
|
|
public List<ServiceRecordDC> ServiceRecordList { get; set; } = new List<ServiceRecordDC>();
|
|
}
|
|
|
|
public class InternalInfo
|
|
{
|
|
public bool IsTimeChangedRecurringAppointment { get; set; }
|
|
}
|
|
}
|