Mobil-Klient:

Leistungen und Leistungskategorien werden jetzt nach ihrer Position sortiert.

Windows-Klient + Mobil-Klient:
Beim Kalender wird jetzt auch auf das Überschneiden mit Serienterminen geprüft.
This commit is contained in:
Lyndon Jetten
2020-07-13 16:25:43 +02:00
parent 52cf8b3f30
commit 909e0bff55
10 changed files with 187 additions and 88 deletions

View File

@@ -561,7 +561,7 @@ namespace BeWoPlanerMobil.Controllers
Model.SelectedServiceCategoryOid = scm.ServiceCategoryOid;
}
return SerializeObject(scm != null ? scm.ServiceDescriptions : new List<ServiceDescriptionDC>());
return SerializeObject(scm != null ? scm.ServiceDescriptions.OrderBy(serviceDescription => serviceDescription.Position).ToList() : new List<ServiceDescriptionDC>());
}
catch(Exception exception)
{
@@ -1528,6 +1528,11 @@ namespace BeWoPlanerMobil.Controllers
Model.SelectedSupportConceptListObject = Model.SupportConceptListObjects.First(f => f.CostBearer2SupportConceptOid.Equals(cb2ScOid.ToString()));
Model.ServiceCategories.Clear();
}
if(Model.ServiceCategories != null)
{
Model.ServiceCategories = Model.ServiceCategories.OrderBy(serviceCategory => serviceCategory.Position).ToList();
}
}
[HttpPost]

View File

@@ -116,69 +116,65 @@ namespace BeWoPlanerMobil.Controllers
(date.InBetween(w.StartDate.Value, w.EndDate.Value, false) ||
date.CompareShortDates(w.StartDate.Value)))).ToList();
var deletedOccurrences = holySweetFlyingFuck.Where(w => w.Type == 4).Select(s => GetOccurrenceId(s.RecurrenceInfo)).ToList();
var changedOccurrences = holySweetFlyingFuck.Where(w => w.Type == 3).Select(s => GetOccurrenceId(s.RecurrenceInfo)).ToList();
var deletedOccurrences = holySweetFlyingFuck.Where(w => w.Type == 4).Select(s => BS.Shared.Core.Utils.GetOccurrenceId(s.RecurrenceInfo)).ToList();
var changedOccurrences = holySweetFlyingFuck.Where(w => w.Type == 3).Select(s => BS.Shared.Core.Utils.GetOccurrenceId(s.RecurrenceInfo)).ToList();
holySweetFlyingFuck = holySweetFlyingFuck.Where(w => w.Type != 4).ToList();
var numberOfPatterns = appointments.Count(appointment => appointment.RecurrenceInfo != null && appointment.Type == 1);
foreach(var appointment in appointments)
foreach(var appointment in appointments.Where(app => app.RecurrenceInfo != null && app.Type == 1))
{
if(appointment.RecurrenceInfo != null && appointment.Type == 1)
var recurrenceInfo = new RecurrenceInfo();
recurrenceInfo.FromXml(appointment.RecurrenceInfo);
var occurrenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo);
var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern);
pattern.RecurrenceInfo.FromXml(appointment.RecurrenceInfo);
pattern.Start = pattern.RecurrenceInfo.Start;
pattern.End = pattern.RecurrenceInfo.End;
var patternId = pattern.RecurrenceInfo.Id.ToString();
var interval = new TimeInterval(date, date.AddDays(1));
var occurrences = occurrenceCalculator.CalcOccurrences(interval, pattern);
if(occurrences.Count > 0)
{
var recurrenceInfo = new RecurrenceInfo();
recurrenceInfo.FromXml(appointment.RecurrenceInfo);
var occurrenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo);
var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern);
pattern.RecurrenceInfo.FromXml(appointment.RecurrenceInfo);
pattern.Start = pattern.RecurrenceInfo.Start;
pattern.End = pattern.RecurrenceInfo.End;
var patternId = pattern.RecurrenceInfo.Id.ToString();
var interval = new TimeInterval(date, date.AddDays(1));
var occurrences = occurrenceCalculator.CalcOccurrences(interval, pattern);
if(occurrences.Count > 0)
foreach(var termin in occurrences.GetAppointments(interval))
{
foreach(var termin in occurrences.GetAppointments(interval))
var index = termin.RecurrenceIndex;
var duration = (appointment.EndDate.Value - appointment.StartDate.Value).TotalMinutes;
if(!date.InBetween(termin.Start.GetShortDateTime(), termin.Start.AddMinutes(duration), true) ||
changedOccurrences.Any(a => a.PatternId.Equals(patternId) && a.Index == index) ||
deletedOccurrences.Any(a => a.PatternId.Equals(patternId) && a.Index == index))
{
var index = termin.RecurrenceIndex;
var duration = (appointment.EndDate.Value - appointment.StartDate.Value).TotalMinutes;
if(!date.InBetween(termin.Start.GetShortDateTime(), termin.Start.AddMinutes(duration),
true) || changedOccurrences.Any(a =>
a.PatternId.Equals(patternId) && a.Index == index) ||
deletedOccurrences.Any(a => a.PatternId.Equals(patternId) && a.Index == index))
{
continue;
}
var recurringAppointment = new SchedulerAppointmentDC
{
AllDay = appointment.AllDay,
CustomerList = appointment.CustomerList,
Description = appointment.Description,
EmployeeList = appointment.EmployeeList,
EndDate = termin.Start.AddMinutes(duration),
FormerBookingSequenceOid = appointment.FormerBookingSequenceOid,
IsPrivate = appointment.IsPrivate,
LabelId = appointment.LabelId,
Location = appointment.Location,
Originator = appointment.Originator,
RecurrenceInfo = termin.RecurrenceInfo.ToXml(),
ReminderInfo = appointment.ReminderInfo,
ResourceList = appointment.ResourceList,
StartDate = termin.Start,
Subject = appointment.Subject ?? "",
Type = appointment.Type
};
Model.RecurringAppointments.AddIfNotIn(recurringAppointment);
holySweetFlyingFuck.AddIfNotIn(recurringAppointment);
continue;
}
var recurringAppointment = new SchedulerAppointmentDC
{
AllDay = appointment.AllDay,
CustomerList = appointment.CustomerList,
Description = appointment.Description,
EmployeeList = appointment.EmployeeList,
EndDate = termin.Start.AddMinutes(duration),
FormerBookingSequenceOid = appointment.FormerBookingSequenceOid,
IsPrivate = appointment.IsPrivate,
LabelId = appointment.LabelId,
Location = appointment.Location,
Originator = appointment.Originator,
RecurrenceInfo = termin.RecurrenceInfo.ToXml(),
ReminderInfo = appointment.ReminderInfo,
ResourceList = appointment.ResourceList,
StartDate = termin.Start,
Subject = appointment.Subject ?? "",
Type = appointment.Type
};
Model.RecurringAppointments.AddIfNotIn(recurringAppointment);
holySweetFlyingFuck.AddIfNotIn(recurringAppointment);
}
}
}

View File

@@ -12,8 +12,6 @@ using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using DevExpress.XtraScheduler;
using Newtonsoft.Json;
using RestSharp;
using static System.Int32;
@@ -159,25 +157,6 @@ namespace BeWoPlanerMobil.Util
return null;
}
public static RecurrenceInformation GetOccurrenceId(string pRecurrenceInfoString)
{
var regex = new Regex("Index=\"[0-9]+\"");
var match = regex.Match(pRecurrenceInfoString);
var recurrenceInfo = new RecurrenceInfo();
recurrenceInfo.FromXml(pRecurrenceInfoString);
var index = 0;
if (!match.Value.IsNullOrEmpty())
{
index = Parse(match.Value.Split('"')[1]);
}
return new RecurrenceInformation(recurrenceInfo.Id.ToString(), index);
}
public static bool IsBillable(long serviceDescriptionOid, List<ServiceDescriptionDC> serviceDescriptions)
{
var description = serviceDescriptions.FirstOrDefault(f => f.ServiceDescriptionOid.Equals(serviceDescriptionOid));

View File

@@ -19,8 +19,12 @@ using NHibernate.SqlCommand;
using BS.Shared.Core;
using BS.Shared;
using BS.Shared.DataContracts;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Compatibility;
using static System.String;
using Appointment = BeWo.Data.Entities.Appointment;
using Login = BeWo.Data.Entities.Login;
using Resource = BeWo.Data.Entities.Resource;
namespace BeWo.Data.Access
{
@@ -1254,7 +1258,7 @@ namespace BeWo.Data.Access
public bool OverlappingAppointmentsExist(DateTime start, DateTime end, IEnumerable<long> employees, IEnumerable<long> customers, IEnumerable<long> resources, long originator, long? appointmentOid, string recurrenceId = "", int occurrenceIndex = 0)
{
var criteria = CreateCriteria<SchedulerAppointment>()
.Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
.Add(Restrictions.Eq(nameof(BeWoEntityBase.IsActive), ActivationTypeId.Active))
.Add(Restrictions.Eq(nameof(SchedulerAppointment.IsTask), false))
.Add(Restrictions.Or(
Restrictions.Or(
@@ -1279,8 +1283,8 @@ namespace BeWo.Data.Access
)
)
);
if (appointmentOid != null)
if (appointmentOid != null)
{
criteria.Add(Restrictions.Not(Restrictions.Eq(BeWoEntityBase.PropertyName_Oid, appointmentOid)));
}
@@ -1303,7 +1307,75 @@ namespace BeWo.Data.Access
var schedulerAppointments = appointments as IList<SchedulerAppointment> ?? appointments.ToList();
var oidList = new List<long>();
// Serientermine anhand der RecurrenceInfo erzeugen und den schedulerAppointments hinzufügen
var deletedOccurences = schedulerAppointments.Where(app => app.Type == 4).Select(app => Utils.GetOccurrenceId(app.RecurrenceInfo)).ToList();
var changedOccurences = schedulerAppointments.Where(app => app.Type == 3).Select(app => Utils.GetOccurrenceId(app.RecurrenceInfo)).ToList();
var recurringAppointmentsCriteria = CreateRecurrenceCriteria(start, end)
.Add(Restrictions.Eq(nameof(SchedulerAppointment.Type), 1));
var recurringAppointments = recurringAppointmentsCriteria.List<SchedulerAppointment>().ToList();
foreach(var appointment in recurringAppointments)
{
var recurrenceInfo = new RecurrenceInfo();
recurrenceInfo.FromXml(appointment.RecurrenceInfo);
var occurenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo);
var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern);
pattern.RecurrenceInfo.FromXml(appointment.RecurrenceInfo);
pattern.Start = pattern.RecurrenceInfo.Start;
pattern.End = pattern.RecurrenceInfo.End;
var patternId = pattern.RecurrenceInfo.Id.ToString();
var interval = new TimeInterval(start, end);
var occurences = occurenceCalculator.CalcOccurrences(interval, pattern);
foreach(var occurence in occurences.GetAppointments(interval))
{
if(appointment.EndDate == null || appointment.StartDate == null)
{
continue;
}
var index = occurence.RecurrenceIndex;
var duration = (appointment.EndDate.Value - appointment.StartDate.Value).TotalMinutes;
if(!start.InBetweenOrAround(end, occurence.Start, occurence.Start.AddMinutes(duration)) ||
changedOccurences.Any(changedOccurence => changedOccurence.PatternId.Equals(patternId) && changedOccurence.Index == index) ||
deletedOccurences.Any(deletedOccurence => deletedOccurence.PatternId.Equals(patternId) && deletedOccurence.Index == index))
{
continue;
}
var recurringAppointment = new SchedulerAppointment
{
AllDay = occurence.AllDay,
CustomerList = appointment.CustomerList,
Notice = appointment.Notice,
EmployeeList = appointment.EmployeeList,
EndDate = occurence.Start.AddMinutes(duration),
FormerBookingSequenceOid = appointment.FormerBookingSequenceOid,
IsPrivate = appointment.IsPrivate,
Location = appointment.Location,
Originator = appointment.Originator,
RecurrenceInfo = occurence.RecurrenceInfo.ToXml(),
ReminderInfo = appointment.ReminderInfo,
ResourceList = appointment.ResourceList,
StartDate = occurence.Start,
Subject = appointment.Subject ?? "",
Type = appointment.Type
};
schedulerAppointments.AddIfNotIn(recurringAppointment);
}
}
// --------------------------------------------------------------------------------------------------------------------------------------
var oidList = new List<long>();
foreach (var appointment in schedulerAppointments)
{
oidList.AddRange(appointment.EmployeeList.Select(rel => rel.ParticipationAnswer != ParticipationAnswer.Absage && rel.Employee.Oid != null ? rel.Employee.Oid.Value : 0));
@@ -1315,7 +1387,7 @@ namespace BeWo.Data.Access
var ori = schedulerAppointments.Any(app => app.Originator.Oid.HasValue && app.Originator.Oid.Value == originator && (app.EmployeeList.Count == 0 || app.EmployeeList.Any(a => a.Employee.Oid.HasValue && a.Employee.Oid.Value == originator)));
return emp || cus || res || ori;
return emp || cus || res || ori;
}
public IEnumerable<SchedulerAppointment> GetAllActiveAppointmentsForEmployeeInInterval(DateTime start, DateTime end, long pEmployeeOid)
@@ -2393,13 +2465,15 @@ namespace BeWo.Data.Access
}
}
var test = criteria.List<SchedulerAppointment>().ToList();
return criteria.List<SchedulerAppointment>();
}
public IEnumerable<SchedulerAppointment> LoadFilteredAppointmentsForEmployee(bool pHasRightToSeeAllEmployeeAppointments, long? pEmployeeOid, DateTime pIntervalStart, DateTime pIntervalEnd, List<long> pSelectedEmployees, List<long> pSelectedCustomers, List<long> pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, bool pIncludeInactiveOnes)
{
var mainCriteria = CreateRecurrenceCriteria(pIntervalStart, pIntervalEnd, pIncludeInactiveOnes);
ICriterion ownAppointmentCriterion = null;
ICriterion employeeCriterion = null;
ICriterion customerCriterion = null;
@@ -2580,7 +2654,7 @@ namespace BeWo.Data.Access
var changedOrDeletedOccurences = FindAppointmentsByRecurrenceId(ExtractRecurrenceIdFromRecurrenceInfo(allExceptionalRecurrenceInfos.Select(s => s.RecurrenceInfo).ToList()), true);
appointments.AddRangeIfElementsNotIn(changedOrDeletedOccurences);
return appointments;
}

View File

@@ -76,6 +76,14 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="DevExpress.Data.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\BeWoPlanerMobil\bin\DevExpress.Data.v17.1.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Mvvm.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="DevExpress.XtraScheduler.v17.1.Core, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>

View File

@@ -265,7 +265,7 @@ namespace BeWo.Report.DefaultReports
// xrLabel2
//
this.xrLabel2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "MonthInformation", "Zeitraum: {0:}")});
new DevExpress.XtraReports.UI.XRBinding("Text", null, "MonthInformation", "Zeitraum: {0:MMMM yyyy}")});
this.xrLabel2.Font = new System.Drawing.Font("Arial", 12F);
this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 24.99999F);
this.xrLabel2.Name = "xrLabel2";

View File

@@ -1126,6 +1126,8 @@ namespace BeWo.Service.ServiceImplementations
var appointments = DAOFactory.SearchDAO.LoadFilteredAppointmentsForEmployee(pHasRightToSeeAllEmployeeAppointments, ownerOid, pIntervalStart, pIntervalEnd, pSelectedEmployees, pSelectedCustomer, pSelectedResources, pEmployeesOnly, pCustomersOnly, pResourcesOnly, pPrivateAppointmentsOnly, pOnlyMyAppointments, false).ToList();
var serientermine = appointments.Where(app => app.RecurrenceInfo != null && app.Type == 1).ToList();
var all = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDCs(appointments).OrderBy(a => a.StartDate).ToList();
var filteredEmployeeOids = new List<long>();
@@ -1341,8 +1343,6 @@ namespace BeWo.Service.ServiceImplementations
result.Add(kosmetisch);
}
var test = result.Where(w => w.SchedulerAppointmentOid == null).ToList();
return result;
}
catch(Exception e)

View File

@@ -0,0 +1,14 @@
namespace BS.Shared.Core
{
public class RecurrenceInformation
{
public string PatternId { get; set; }
public int Index { get; set; }
public RecurrenceInformation(string pPatternId, int pIndex)
{
PatternId = pPatternId;
Index = pIndex;
}
}
}

View File

@@ -8,11 +8,13 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Compatibility;
namespace BS.Shared.Core
{
@@ -947,10 +949,30 @@ namespace BS.Shared.Core
return lowerCase ? result.ToLowerInvariant() : result;
}
public static bool ContainsKey(string[] array, string key)
{
return array.Any(keyEntry => keyEntry.Equals(key));
}
public static RecurrenceInformation GetOccurrenceId(string pRecurrenceInfoString)
{
var regex = new Regex("Index=\"[0-9]+\"");
var match = regex.Match(pRecurrenceInfoString);
var recurrenceInfo = new RecurrenceInfo();
recurrenceInfo.FromXml(pRecurrenceInfoString);
var index = 0;
if(!match.Value.IsNullOrEmpty())
{
index = int.Parse(match.Value.Split('"')[1]);
}
return new RecurrenceInformation(recurrenceInfo.Id.ToString(), index);
}
}
public struct NullCompareResult

View File

@@ -135,6 +135,7 @@
<Compile Include="Core\IDSpecificClassAttribute.cs" />
<Compile Include="Core\ObservableDictionary.cs" />
<Compile Include="Core\ProgressStream.cs" />
<Compile Include="Core\RecurrenceInformation.cs" />
<Compile Include="Core\SchedulerAppointmentRecurrenceInfoObject.cs" />
<Compile Include="Core\ShouldSerializeContractResolver.cs" />
<Compile Include="Core\SimpleWohnheimbuchungsRelationHelper.cs" />