Gelöschte Serientermine tauchen nicht mehr im Druck auf.

Verstrichene Termine werden beim Klick auf "Allen zusagen" nicht mehr als zugesagt gespeichert, sondern als verstrichen wie beim Klick auf OK.
This commit is contained in:
LynJet
2022-06-13 13:58:51 +02:00
parent c0db0f40e3
commit 0f1487ac23
3 changed files with 132 additions and 11 deletions

View File

@@ -2199,6 +2199,30 @@ namespace BeWo.Scheduler.View
var serienTermine = new List<SchedulerAppointmentDC>();
var recurringAppointments = new List<Appointment>();
var deletedOccurrences = new List<SchedulerAppointmentDC>();
var st = apps.Where(app => app.IsRecurring || app.IsOccurrence).ToList();
var recurrenceIds = st.Select(s => s.RecurrenceInfo.Id.ToString()).Distinct().ToList();
foreach(var app in ViewModel.ActiveAppointmentViewModel.Appointments)
{
if(!(app.RecurrenceInfo is null))
{
var id = Utils.Utils.ExtractIdFromRecurrenceInfo(app.RecurrenceInfo);
if(recurrenceIds.Contains(id) && app.EventType == (int) AppointmentType.DeletedOccurrence)
{
if(app is SchedulerAppointmentVM vm)
{
deletedOccurrences.AddIfNotIn(vm.CommitToDataContract());
}
}
}
}
//var deletedOccurrences = apps.Where(w => w.Type == AppointmentType.DeletedOccurrence).ToList();
foreach(var app in apps.Where(w => w.IsOccurrence || w.IsRecurring).Where(app => !recurringAppointments.Any(a => a.RecurrenceInfo.Id.Equals(app.RecurrenceInfo.Id))))
{
recurringAppointments.Add(app);
@@ -2218,15 +2242,59 @@ namespace BeWo.Scheduler.View
serienTerminOids.Remove(basistermin.DataContract.SchedulerAppointmentOid.Value);
}
if(ausnahmen.Count > 0)
var neu = new List<Appointment>();
foreach (var app in kollektionOhneAusnahmen.Where(w => !ausnahmen.Select(s => s.RecurrenceIndex).Contains(w.RecurrenceIndex)))
{
var recurrenceId = app.RecurrenceInfo.Id.ToString();//BeWo.Scheduler.Utils.Utils.ExtractIdFromRecurrenceInfo(app.RecurrenceInfo.ToString());
if (app.IsOccurrence && deletedOccurrences.Any(a => a.RecurrenceId == recurrenceId && a.RecurrenceIndex == app.RecurrenceIndex))
{
continue;
}
neu.AddIfNotIn(app);
}
if (ausnahmen.Count > 0)
{
kollektionOhneAusnahmen = kollektionOhneAusnahmen.Where(w => !ausnahmen.Select(s => s.RecurrenceIndex).Contains(w.RecurrenceIndex)).ToList();
}
// TODO: DeletedOccurrences nicht aufnahmen bzw. herausnehmen
serienTermine.AddRange(kollektionOhneAusnahmen.Select(z => new SchedulerAppointmentDC
foreach(var appointment in kollektionOhneAusnahmen)
{
AllDay = z.AllDay, CustomerList = basistermin.CustomerList, EmployeeList = basistermin.EmployeeList.ToList(), ResourceList = basistermin.ResourceList, StartDate = z.Start, EndDate = z.End, Description = z.Description, IsPrivate = basistermin.IsPrivate, Location = z.Location, Subject = z.Subject, LabelId = z.LabelId, Type = (int) z.Type, Originator = basistermin.Originator, RecurrenceInfo = z.RecurrenceInfo.ToXml()
}));
var subject = appointment.Subject;
var recurrenceId = appointment.RecurrenceInfo.Id.ToString();
var recurrenceIndex = appointment.RecurrenceIndex;
if (!(appointment.IsOccurrence && deletedOccurrences.Any(a => a.RecurrenceIdReference == recurrenceId && a.RecurrenceIndexReference == recurrenceIndex)))
{
serienTermine.AddIfNotIn(new SchedulerAppointmentDC
{
AllDay = appointment.AllDay,
CustomerList = basistermin.CustomerList,
EmployeeList = basistermin.EmployeeList.ToList(),
ResourceList = basistermin.ResourceList,
StartDate = appointment.Start,
EndDate = appointment.End,
Description = appointment.Description,
IsPrivate = basistermin.IsPrivate,
Location = appointment.Location,
Subject = appointment.Subject,
LabelId = appointment.LabelId,
Type = (int)appointment.Type,
Originator = basistermin.Originator,
RecurrenceInfo = appointment.RecurrenceInfo.ToXml()
});
}
}
//serienTermine.AddRangeIfElementsNotIn(kollektionOhneAusnahmen.Select(z => new SchedulerAppointmentDC
//{
// AllDay = z.AllDay, CustomerList = basistermin.CustomerList, EmployeeList = basistermin.EmployeeList.ToList(), ResourceList = basistermin.ResourceList, StartDate = z.Start, EndDate = z.End, Description = z.Description, IsPrivate = basistermin.IsPrivate, Location = z.Location, Subject = z.Subject, LabelId = z.LabelId, Type = (int) z.Type, Originator = basistermin.Originator, RecurrenceInfo = z.RecurrenceInfo.ToXml()
//}));
}
appointmentOidListe.AddRange(serienTerminOids.Where(w => !appointmentOidListe.Contains(w)));

View File

@@ -314,16 +314,23 @@ namespace BeWo.Scheduler.View
{
var employeeList = customFieldStorage.EmployeeList ?? new ObservableCollection<Employee2SchedulerAppointmentDC>();
//var appointmentsToAccept = employeeList.Where(e2Sa => e2Sa.Employee.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid).ToList();
foreach(var e2Sa in employeeList)
{
e2Sa.IsPC_CheckedTs = DateTime.Now;
if (e2Sa.Employee.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid)
{
e2Sa.IsPChanged = true;
e2Sa.ParticipationAnswer = ParticipationAnswer.Zusage;
if(appointment.Start < DateTime.Now && appointment.End < DateTime.Now)
{
e2Sa.ParticipationAnswer = ParticipationAnswer.Verstrichen;
e2Sa.IsPC_CheckedTs = DateTime.Now;
e2Sa.IsPChanged = false;
}
else
{
e2Sa.IsPChanged = true;
e2Sa.ParticipationAnswer = ParticipationAnswer.Zusage;
}
}
else
{

View File

@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace BS.Shared.DataContracts
{
@@ -95,7 +96,52 @@ namespace BS.Shared.DataContracts
public string RecurrenceId { get; set; }
[DataMember]
private static readonly Regex RecurrenceIdRegex = new Regex("(Id=\\\"[a-z0-9-]+\\\")");
public string RecurrenceIdReference
{
get
{
if (!(RecurrenceInfo is null))
{
var match = RecurrenceIdRegex.Match(RecurrenceInfo);
if (match.Success)
{
var matchValue = match.Value;
var idValue = matchValue.Split("\"");
return idValue[1];
}
}
return null;
}
}
private static readonly Regex RecurrenceIndexRegex = new Regex("(Index=\\\"[0-9]+\\\")");
public int? RecurrenceIndexReference
{
get
{
if (!(RecurrenceInfo is null))
{
var match = RecurrenceIndexRegex.Match(RecurrenceInfo);
if (match.Success)
{
var matchValue = match.Value;
var indexValue = matchValue.Split("\"");
return int.TryParse(indexValue[1], out var indexInt) ? (int?)indexInt : null;
}
}
return null;
}
}
[DataMember]
public long? FormerTaskOid { get; set; }
[DataMember]