Die Termine werden jetzt wieder korrekt gedruckt.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using BeWo.Data.Entities;
|
||||
|
||||
using BS.Shared.Extensions;
|
||||
@@ -1170,7 +1170,8 @@ namespace BeWo.Data.Access
|
||||
return c.List<ApplicationUser>().Count > 0;
|
||||
}
|
||||
|
||||
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)
|
||||
//TODO: Hier vielleicht die neue CreateRecurrenceCriteria-Methode benutzen?
|
||||
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))
|
||||
@@ -1275,8 +1276,7 @@ namespace BeWo.Data.Access
|
||||
|
||||
var recId = GetSpecificValueFromRecurrenceInfo(a.RecurrenceInfo, a.RecurrenceInfo.IndexOf("Id=\"") + 4);
|
||||
var index = GetSpecificValueFromRecurrenceInfo(a.RecurrenceInfo, a.RecurrenceInfo.IndexOf("Index=\"") + 7);
|
||||
int intIndex;
|
||||
Int32.TryParse(index, out intIndex);
|
||||
int.TryParse(index, out var intIndex);
|
||||
|
||||
return !(recurrenceId.Equals(recId) && occurrenceIndex == intIndex);
|
||||
});
|
||||
@@ -1286,65 +1286,33 @@ namespace BeWo.Data.Access
|
||||
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));
|
||||
oidList.AddRange(appointment.EmployeeList.Select(rel => rel.ParticipationAnswer != ParticipationAnswer.Absage && rel.Employee.Oid != null ? rel.Employee.Oid.Value : 0));
|
||||
}
|
||||
|
||||
var emp = oidList.Intersect(employees).Any();
|
||||
var cus = schedulerAppointments.Any(app => app.CustomerList.Select(c => c.Oid != null ? c.Oid.Value : 0).Intersect(customers).Any());
|
||||
var res = schedulerAppointments.Any(app => app.ResourceList.Select(r => r.Oid != null ? r.Oid.Value : 0).Intersect(resources).Any());
|
||||
var cus = schedulerAppointments.Any(app => app.CustomerList.Select(c => c.Oid ?? 0).Intersect(customers).Any());
|
||||
var res = schedulerAppointments.Any(app => app.ResourceList.Select(r => r.Oid ?? 0).Intersect(resources).Any());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public IEnumerable<SchedulerAppointment> GetAllActiveAppointmentsForEmployeeInInterval(DateTime start, DateTime end, long pEmployeeOid)
|
||||
public IEnumerable<SchedulerAppointment> GetAllActiveAppointmentsForEmployeeInInterval(DateTime start, DateTime end, long pEmployeeOid)
|
||||
{
|
||||
var detachedCriteria = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.Add(Restrictions.And(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_Employee + ".Oid", pEmployeeOid),
|
||||
Restrictions.Not(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_ParticipationAnswer, ParticipationAnswer.Absage))));
|
||||
detachedCriteria.SetProjection(Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
var recurrenceBetween = string.Format("'{0:yyyy-MM-dd} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')", start, SchedulerAppointment.PropertyName_RecurrenceInfo);
|
||||
|
||||
var hasResources = $"{BeWoEntityBase.PropertyName_Oid} IN (SELECT newschappoid FROM resource2newschapp)";
|
||||
|
||||
var criteria = CreateCriteria<SchedulerAppointment>()
|
||||
.Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
|
||||
.Add(Restrictions.Or(
|
||||
Restrictions.And(
|
||||
Restrictions.Not(Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "Range", MatchMode.Anywhere)),
|
||||
Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "OccurrenceCount=\"10\"", MatchMode.Anywhere)),
|
||||
Restrictions.Or(
|
||||
Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Lt(SchedulerAppointment.PropertyName_StartDate, end), Restrictions.Ge(SchedulerAppointment.PropertyName_EndDate, start)),
|
||||
Restrictions.And(Restrictions.IsNotNull(SchedulerAppointment.PropertyName_RecurrenceInfo), Expression.Sql(new SqlString(recurrenceBetween)))),
|
||||
Restrictions.And(Restrictions.Eq(SchedulerAppointment.PropertyName_Type, 3), Expression.Sql(new SqlString(recurrenceBetween))))))
|
||||
var criteria = CreateRecurrenceCriteria(start, end)
|
||||
.Add(Restrictions.Or(
|
||||
Expression.Sql(new SqlString(hasResources)),
|
||||
Restrictions.Or(
|
||||
Restrictions.Eq(SchedulerAppointment.PropertyName_Originator + ".Oid", pEmployeeOid),
|
||||
Subqueries.PropertyIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria))));
|
||||
CreateOwnAppointmentsCriteria(pEmployeeOid)));
|
||||
|
||||
return criteria.List<SchedulerAppointment>();
|
||||
}
|
||||
|
||||
public IEnumerable<SchedulerAppointment> GetAllActiveAppointmentsInInterval(DateTime start, DateTime end)
|
||||
{
|
||||
var recurrenceBetween = string.Format("'{0} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')", start.ToString("yyyy-MM-dd"), SchedulerAppointment.PropertyName_RecurrenceInfo);
|
||||
|
||||
var criteria = CreateCriteria<SchedulerAppointment>()
|
||||
.Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
|
||||
.Add(Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Not(Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "Range", MatchMode.Anywhere)),
|
||||
Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "OccurrenceCount=\"10\"", MatchMode.Anywhere)),
|
||||
Restrictions.Or(
|
||||
Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Lt(SchedulerAppointment.PropertyName_StartDate, end), Restrictions.Ge(SchedulerAppointment.PropertyName_EndDate, start)),
|
||||
Restrictions.And(Restrictions.IsNotNull(SchedulerAppointment.PropertyName_RecurrenceInfo), Expression.Sql(new SqlString(recurrenceBetween)))),
|
||||
Restrictions.And(Restrictions.Eq(SchedulerAppointment.PropertyName_Type, 3), Expression.Sql(new SqlString(recurrenceBetween))))));
|
||||
|
||||
return criteria.List<SchedulerAppointment>();
|
||||
return CreateRecurrenceCriteria(start, end).List<SchedulerAppointment>();
|
||||
}
|
||||
|
||||
private static string GetSpecificValueFromRecurrenceInfo(string str, int startIndex)
|
||||
@@ -1431,14 +1399,15 @@ namespace BeWo.Data.Access
|
||||
return c.List<ServiceRecord>();
|
||||
}
|
||||
|
||||
// Veraltet
|
||||
// Veraltet. Wird nicht mehr benutzt
|
||||
public IEnumerable<SchedulerAppointment> FindAppointmentsForPrintingForEmployee(long employeeOid, List<DateTime> selectedDates, List<UserRightType> userRights)
|
||||
{
|
||||
var abfrage = string.Format("SELECT Oid FROM newschedulerappointment WHERE IsActive = 1 AND ");
|
||||
var abfrage = "SELECT Oid FROM newschedulerappointment WHERE IsActive = 1 AND ";
|
||||
var or = string.Empty;
|
||||
|
||||
foreach (var d in selectedDates)
|
||||
{
|
||||
// TODO: RecurrenceInfo hat nicht immer ein Enddatum
|
||||
or += string.Format("StartDate LIKE '{0}%' OR RecurrenceInfo IS NOT NULL AND '{0} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')", d.ToString("yyyy-MM-dd"), SchedulerAppointment.PropertyName_RecurrenceInfo);
|
||||
if (selectedDates.IndexOf(d) < selectedDates.Count - 1)
|
||||
{
|
||||
@@ -1487,30 +1456,21 @@ namespace BeWo.Data.Access
|
||||
Restrictions.Not(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_ParticipationAnswer, ParticipationAnswer.Absage))));
|
||||
detachedCriteria.SetProjection(Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
var recurrenceBetween = String.Format("'{0} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')",
|
||||
start.ToString("yyyy-MM-dd"),
|
||||
SchedulerAppointment.PropertyName_RecurrenceInfo);
|
||||
var hasResources = $"{BeWoEntityBase.PropertyName_Oid} IN (SELECT newschappoid FROM resource2newschapp)";
|
||||
|
||||
var hasResources = String.Format("{0} IN (SELECT newschappoid FROM resource2newschapp)", BeWoEntityBase.PropertyName_Oid);
|
||||
var detachedCriteria2 = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.SetProjection(Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
var criteria = CreateCriteria<SchedulerAppointment>()
|
||||
.Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
|
||||
.Add(Restrictions.Or(
|
||||
Restrictions.And(
|
||||
Restrictions.Not(Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "Range", MatchMode.Anywhere)),
|
||||
Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, "OccurrenceCount=\"10\"", MatchMode.Anywhere)),
|
||||
Restrictions.Or(
|
||||
Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Lt(SchedulerAppointment.PropertyName_StartDate, end), Restrictions.Ge(SchedulerAppointment.PropertyName_EndDate, start)),
|
||||
Restrictions.And(Restrictions.IsNotNull(SchedulerAppointment.PropertyName_RecurrenceInfo), Expression.Sql(new SqlString(recurrenceBetween)))),
|
||||
Restrictions.And(Restrictions.Eq(SchedulerAppointment.PropertyName_Type, 3), Expression.Sql(new SqlString(recurrenceBetween))))))
|
||||
.Add(Restrictions.Or(
|
||||
var ownAppointmentCriterion = Restrictions.Or(
|
||||
Restrictions.And(Restrictions.In(Employee2SchedulerAppointment.PropertyName_Employee + ".Oid", pEmployeeOids), Subqueries.PropertyNotIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria2)),
|
||||
Subqueries.PropertyIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria));
|
||||
|
||||
var criteria = CreateRecurrenceCriteria(start, end)
|
||||
.Add(Restrictions.Or(
|
||||
Expression.Sql(new SqlString(hasResources)),
|
||||
Restrictions.Or(
|
||||
Restrictions.In(SchedulerAppointment.PropertyName_Originator + ".Oid", pEmployeeOids),
|
||||
Subqueries.PropertyIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria))));
|
||||
ownAppointmentCriterion));
|
||||
|
||||
return criteria.List<SchedulerAppointment>();
|
||||
return criteria.List<SchedulerAppointment>();
|
||||
}
|
||||
|
||||
public IEnumerable<long> FilterEmployeesWithAppointments(List<long> pEmployeeOids, DateTime pStartTime, DateTime pEndTime)
|
||||
@@ -2329,25 +2289,10 @@ namespace BeWo.Data.Access
|
||||
|
||||
if (pEmployeeOid.HasValue)
|
||||
{
|
||||
var detachedCriteria = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.Add(Restrictions.And(
|
||||
Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_Employee + ".Oid", pEmployeeOid),
|
||||
Restrictions.Not(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_ParticipationAnswer,
|
||||
ParticipationAnswer.Absage))));
|
||||
detachedCriteria.SetProjection(
|
||||
Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
var detachedCriteria2 = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.SetProjection(
|
||||
Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
ownAppointmentCriterion = Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Eq(SchedulerAppointment.PropertyName_Originator + ".Oid", pEmployeeOid), Subqueries.PropertyNotIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria2)),
|
||||
Subqueries.PropertyIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria));
|
||||
|
||||
ownAppointmentCriterion = CreateOwnAppointmentsCriteria(pEmployeeOid.Value);
|
||||
}
|
||||
|
||||
if (pPrivateAppointmentsOnly)
|
||||
if(pPrivateAppointmentsOnly)
|
||||
{
|
||||
mainCriteria.Add(Restrictions.Eq(SchedulerAppointment.PropertyName_IsPrivate, true));
|
||||
}
|
||||
@@ -2393,7 +2338,6 @@ namespace BeWo.Data.Access
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var blah = $"{BeWoEntityBase.PropertyName_Oid} IN (SELECT newschappoid FROM customer2newschapp WHERE customeroid IN ({list}))";
|
||||
customerCriterion = Expression.Sql(blah);
|
||||
}
|
||||
@@ -2416,16 +2360,15 @@ namespace BeWo.Data.Access
|
||||
var blah = $"{BeWoEntityBase.PropertyName_Oid} IN (SELECT newschappoid FROM resource2newschapp WHERE resourceoid IN ({list}))";
|
||||
resourceCriterion = Expression.Sql(blah);
|
||||
}
|
||||
|
||||
var listOfCriterias = new List<ICriterion>()
|
||||
// AND {SchedulerAppointment.PropertyName_RecurrenceInfo} IS NOT NULL AND {SchedulerAppointment.PropertyName_RecurrenceInfo} NOT LIKE '%Index%'
|
||||
var listOfCriterias = new List<ICriterion>
|
||||
{
|
||||
employeeCriterion,
|
||||
customerCriterion,
|
||||
resourceCriterion
|
||||
};
|
||||
|
||||
|
||||
if (!pHasRightToSeeAllEmployeeAppointments)
|
||||
if (!pHasRightToSeeAllEmployeeAppointments && pSelectedEmployees.Count == 0)
|
||||
{
|
||||
mainCriteria.Add(ownAppointmentCriterion);
|
||||
}
|
||||
@@ -2440,7 +2383,55 @@ namespace BeWo.Data.Access
|
||||
{
|
||||
mainCriteria.Add(orCriteria);
|
||||
}
|
||||
return mainCriteria.List<SchedulerAppointment>();
|
||||
|
||||
var appointments = mainCriteria.List<SchedulerAppointment>();
|
||||
|
||||
var exceptionalRecurrenceInfos = appointments.Where(w => w.RecurrenceInfo != null && w.Type == 3).ToList();
|
||||
|
||||
var exceptionIds = new List<long>();
|
||||
var regex = new Regex("(Id=\\\"[a-z0-9-]+\\\")");
|
||||
foreach(var appointment in exceptionalRecurrenceInfos)
|
||||
{
|
||||
var match = regex.Match(appointment.RecurrenceInfo);
|
||||
if(match.Success)
|
||||
{
|
||||
var value = match.Value;
|
||||
var actualId = value.Split("\"");
|
||||
if(actualId.Count > 1)
|
||||
{
|
||||
var id = actualId[1];
|
||||
|
||||
if(!appointments.Any(w => w.RecurrenceInfo != null && w.RecurrenceInfo.Contains(id) && w.Type == 1))
|
||||
{
|
||||
exceptionIds.Add(appointment.Oid.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var exceptionsToModify = appointments.Where(w => w.Oid.HasValue && exceptionIds.Contains(w.Oid.Value)).ToList();
|
||||
|
||||
foreach(var exception in exceptionsToModify)
|
||||
{
|
||||
var replacingAppointment = new SchedulerAppointment
|
||||
{
|
||||
Oid = exception.Oid.Value * -1,
|
||||
Version = 1,
|
||||
Type = 4,
|
||||
RecurrenceInfo = exception.RecurrenceInfo,
|
||||
Originator = exception.Originator,
|
||||
EmployeeList = exception.EmployeeList,
|
||||
CustomerList = exception.CustomerList,
|
||||
ResourceList = exception.ResourceList
|
||||
};
|
||||
|
||||
exception.RecurrenceInfo = null;
|
||||
exception.Type = 0;
|
||||
|
||||
appointments.Add(replacingAppointment);
|
||||
}
|
||||
|
||||
return appointments;
|
||||
}
|
||||
|
||||
private static ICriterion CreateOrCriteria(IReadOnlyCollection<ICriterion> criterionList)
|
||||
@@ -2453,14 +2444,7 @@ namespace BeWo.Data.Access
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
if (orCriterion == null)
|
||||
{
|
||||
orCriterion = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
orCriterion = Restrictions.Or(orCriterion, c);
|
||||
}
|
||||
orCriterion = orCriterion == null ? c : Restrictions.Or(orCriterion, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2468,6 +2452,25 @@ namespace BeWo.Data.Access
|
||||
return orCriterion;
|
||||
}
|
||||
|
||||
private static ICriterion CreateOwnAppointmentsCriteria(long pEmployeeOid)
|
||||
{
|
||||
var detachedCriteria = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.Add(Restrictions.And(
|
||||
Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_Employee + ".Oid", pEmployeeOid),
|
||||
Restrictions.Not(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_ParticipationAnswer,
|
||||
ParticipationAnswer.Absage))));
|
||||
detachedCriteria.SetProjection(Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
var detachedCriteria2 = DetachedCriteria.For<Employee2SchedulerAppointment>()
|
||||
.SetProjection(Projections.Property(Employee2SchedulerAppointment.PropertyName_SchedulerAppointment));
|
||||
|
||||
ICriterion ownAppointmentCriterion = Restrictions.Or(
|
||||
Restrictions.And(Restrictions.Eq(SchedulerAppointment.PropertyName_Originator + ".Oid", pEmployeeOid), Subqueries.PropertyNotIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria2)),
|
||||
Subqueries.PropertyIn(BeWoEntityBase.PropertyName_Oid, detachedCriteria));
|
||||
|
||||
return ownAppointmentCriterion;
|
||||
}
|
||||
|
||||
private ICriteria CreateRecurrenceCriteria(DateTime start, DateTime end)
|
||||
{
|
||||
var recurrenceBetween = string.Format("'{0:yyyy-MM-dd} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')", start, SchedulerAppointment.PropertyName_RecurrenceInfo);
|
||||
@@ -2495,5 +2498,14 @@ namespace BeWo.Data.Access
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public IList<SchedulerAppointment> FindDeletedRecurrencesByRecurrenceId(string pRecurrenceId)
|
||||
{
|
||||
var c = CreateCriteria<SchedulerAppointment>()
|
||||
.Add(Restrictions.Like(SchedulerAppointment.PropertyName_RecurrenceInfo, pRecurrenceId, MatchMode.Anywhere))
|
||||
.Add(Restrictions.Eq(SchedulerAppointment.PropertyName_Type, 4));
|
||||
|
||||
return c.List<SchedulerAppointment>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.Core;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
@@ -16,22 +19,57 @@ namespace BeWo.Report.ReportObjects
|
||||
public List<SchedulerAppointment> Appointments { get; set; }
|
||||
public List<KalenderTag> KalenderTageSortiert { get; set; }
|
||||
public Dictionary<int, KalenderWoche> Wochen { get; set; }
|
||||
public String PrintingDate { get { return DateTime.Now.ToShortDateString(); } }
|
||||
public string PrintingDate => DateTime.Now.ToShortDateString();
|
||||
|
||||
public static KalenderRO Create(IEnumerable<long> appointmentOids, long? employeeOid, IEnumerable<SchedulerAppointmentDC> serientermine, IEnumerable<DateTime> selectedDates, IEnumerable<SchedulerAppointmentDC> mehrtaegigeTermine)
|
||||
public static KalenderRO Create(IEnumerable<long> appointmentOids, long? employeeOid, IEnumerable<SchedulerAppointmentDC> serientermine, IEnumerable<DateTime> selectedDates, IEnumerable<SchedulerAppointmentDC> mehrtaegigeTermine)
|
||||
{
|
||||
var appointments = DAOFactory.GenericDAO.LoadByIDs<SchedulerAppointment>(appointmentOids);
|
||||
var employeeName = DAOFactory.GenericDAO.GetByID<Employee>(employeeOid.Value).Person.FirstNameLastName;
|
||||
var kalenderTage = new HashSet<KalenderTag>();
|
||||
var wochen = new Dictionary<int, KalenderWoche>();
|
||||
var recurringAppointments = serientermine.ToList();
|
||||
|
||||
var recurrenceIds2Appointments = new Dictionary<string, List<SchedulerAppointment>>();
|
||||
var test = recurringAppointments.Where(w => w.RecurrenceInfo != null).Select(s => s.RecurrenceInfo).ToList();
|
||||
|
||||
foreach(var recurrenceInfo in test)
|
||||
{
|
||||
var id = Utils.GetRecurrenceIdFromRecurrenceInfo(recurrenceInfo);
|
||||
|
||||
if(!recurrenceIds2Appointments.ContainsKey(id))
|
||||
{
|
||||
recurrenceIds2Appointments.Add(id, new List<SchedulerAppointment>());
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var kvp in recurrenceIds2Appointments)
|
||||
{
|
||||
kvp.Value.AddRange(DAOFactory.SearchDAO.FindDeletedRecurrencesByRecurrenceId(kvp.Key).ToList());
|
||||
}
|
||||
|
||||
foreach(var kvp in recurrenceIds2Appointments)
|
||||
{
|
||||
foreach(var appointment in kvp.Value)
|
||||
{
|
||||
var start = appointment.StartDate;
|
||||
var end = appointment.EndDate;
|
||||
|
||||
var theOneToDelete = recurringAppointments.FirstOrDefault(w => w.RecurrenceInfo.Contains(kvp.Key) && w.StartDate == start && w.EndDate == end);
|
||||
|
||||
if(theOneToDelete != null)
|
||||
{
|
||||
recurringAppointments.Remove(theOneToDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var mapper = new SchedulerAppointmentDC_SchedulerAppointment();
|
||||
var objekte = mapper.MapToNewEntities(serientermine);
|
||||
var objekte = mapper.MapToNewEntities(recurringAppointments);
|
||||
var objekte2 = mapper.MapToNewEntities(mehrtaegigeTermine);
|
||||
|
||||
appointments.AddRange(objekte2);
|
||||
appointments.AddRange(objekte);
|
||||
appointments = appointments.Where(w => (w.StartDate != null && selectedDates.Any(a => a.CompareShortDates(w.StartDate.Value)))).OrderBy(o => o.StartDate).ToList();
|
||||
appointments = appointments.Where(w => w.StartDate != null && selectedDates.Any(a => a.CompareShortDates(w.StartDate.Value))).OrderBy(o => o.StartDate).ToList();
|
||||
|
||||
// ganztägige Termine beachten
|
||||
foreach (var app in appointments)
|
||||
@@ -54,6 +92,7 @@ namespace BeWo.Report.ReportObjects
|
||||
foreach (var kTag in kalenderTage)
|
||||
{
|
||||
var wt = c.GetWeekOfYear(kTag.Date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
|
||||
|
||||
if (wochen.ContainsKey(wt))
|
||||
{
|
||||
wochen[wt].AddDayToWeek(kTag);
|
||||
@@ -154,7 +193,7 @@ namespace BeWo.Report.ReportObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = String.Empty;
|
||||
var result = string.Empty;
|
||||
|
||||
if (Appointment.AllDay)
|
||||
{
|
||||
@@ -162,23 +201,16 @@ namespace BeWo.Report.ReportObjects
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Appointment.StartDate.HasValue ? String.Format("{0} - {1}", Appointment.StartDate.Value.ToShortTimeString(), Appointment.EndDate.Value.ToShortTimeString()) : string.Empty;
|
||||
result = Appointment.StartDate.HasValue ? $"{Appointment.StartDate.Value.ToShortTimeString()} - {Appointment.EndDate.Value.ToShortTimeString()}"
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public string SubjectLocationString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Appointment.Location))
|
||||
return String.Format("{0} ({1})", Appointment.Subject, Appointment.Location);
|
||||
return Appointment.Subject;
|
||||
}
|
||||
}
|
||||
public string SubjectLocationString => !string.IsNullOrEmpty(Appointment.Location) ? $"{Appointment.Subject} ({Appointment.Location})" : Appointment.Subject;
|
||||
|
||||
public SchedulerAppointment Appointment { get; set; }
|
||||
public SchedulerAppointment Appointment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using BeWo.Data.Entities;
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BeWo.Data;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.Service.Core
|
||||
{
|
||||
@@ -225,5 +226,47 @@ namespace BeWo.Service.Core
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetRecurrenceIdFromRecurrenceInfo(string pRecurrenceInfo)
|
||||
{
|
||||
var regex = new Regex("(Id=\\\"[a-z0-9-]+\\\")");
|
||||
|
||||
var match = regex.Match(pRecurrenceInfo);
|
||||
if(match.Success)
|
||||
{
|
||||
var value = match.Value;
|
||||
var actualId = value.Split("\"");
|
||||
if(actualId.Count > 1)
|
||||
{
|
||||
return actualId[1];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetRecurrenceIndexFromRecurrenceInfo(string pRecurrenceInfo)
|
||||
{
|
||||
if(!pRecurrenceInfo.Contains("Index"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var regex = new Regex("(Index=\\\"\\d+\\\")");
|
||||
|
||||
var match = regex.Match(pRecurrenceInfo);
|
||||
if(match.Success)
|
||||
{
|
||||
var value = match.Value;
|
||||
var actualIndex = value.Split("\"");
|
||||
|
||||
if(actualIndex.Count > 1)
|
||||
{
|
||||
return actualIndex[1];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,9 @@
|
||||
<HintPath>..\Lib\Castle.DynamicProxy2.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevExpress.Data.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Mvvm.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DevExpress.Pdf.v17.1.Core, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Printing.v17.1.Core, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Charts.v17.1.Core, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
|
||||
@@ -696,6 +696,34 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<SchedulerAppointment>(pSchedulerAppointments.Select(b => b.SchedulerAppointmentOid.Value));
|
||||
var allegleich = true;
|
||||
|
||||
var test = pSchedulerAppointments.Where(w => w.SchedulerAppointmentOid.HasValue && lOriginals.Any(a => a.Oid.HasValue &&
|
||||
a.Oid.Value == w.SchedulerAppointmentOid.Value && a.RecurrenceInfo != null &&
|
||||
w.RecurrenceInfo == null))
|
||||
.ToList();
|
||||
|
||||
if(test.Count > 0)
|
||||
{
|
||||
var originalAppointments = lOriginals.Where(w => w.Oid.HasValue && test.Select(s => s.SchedulerAppointmentOid.Value).Contains(w.Oid.Value)).ToList();
|
||||
|
||||
foreach(var modifiedException in test)
|
||||
{
|
||||
var original = originalAppointments.FirstOrDefault(f => f.Oid.Value == modifiedException.SchedulerAppointmentOid.Value);
|
||||
|
||||
if(original == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(modifiedException.Type != 4)
|
||||
{
|
||||
modifiedException.Type = original.Type;
|
||||
}
|
||||
|
||||
modifiedException.RecurrenceInfo = original.RecurrenceInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Die geänderten Anwesenheiten updaten und die entfernten löschen
|
||||
foreach (var item in pSchedulerAppointments)
|
||||
{
|
||||
@@ -808,8 +836,33 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<SchedulerAppointment>(pOid2Version.Keys);
|
||||
|
||||
if(lOriginals.Count > 0 && lOriginals.Any(a => a.Type == 3 && a.Oid.HasValue && pOid2Version.Keys.Contains(a.Oid.Value)))
|
||||
{
|
||||
var originalsToUpdate = lOriginals.Where(w => w.Type == 3 && w.Oid.HasValue && pOid2Version.Keys.Contains(w.Oid.Value)).ToList();
|
||||
foreach(var original in originalsToUpdate)
|
||||
{
|
||||
original.Type = 4;
|
||||
}
|
||||
|
||||
DAOFactory.GenericDAO.Update(originalsToUpdate);
|
||||
|
||||
var updatedAppointments = DAOFactory.GenericDAO.LoadByIDs<SchedulerAppointment>(originalsToUpdate.Select(s => s.Oid.Value));
|
||||
|
||||
foreach(var appointment in updatedAppointments)
|
||||
{
|
||||
if(appointment.Oid.HasValue && appointment.Version.HasValue && pOid2Version.ContainsKey(appointment.Oid.Value))
|
||||
{
|
||||
pOid2Version.Remove(appointment.Oid.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kvp in pOid2Version)
|
||||
ServiceLogic.SetActivationType<SchedulerAppointment>(new Dictionary<long, long> { { kvp.Key, kvp.Value } }, ActivationTypeId.Deleted);
|
||||
{
|
||||
ServiceLogic.SetActivationType<SchedulerAppointment>(new Dictionary<long, long> { { kvp.Key, kvp.Value } }, ActivationTypeId.Deleted);
|
||||
}
|
||||
|
||||
return GetSchedulerAppointmentsById(pOid2Version.Keys);
|
||||
}
|
||||
@@ -985,8 +1038,8 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
//Man hat nur Customer und/oder Resourcen ausgewählt, dann dürfen die eigenen nicht angezeigt werden
|
||||
if ((pSelectedEmployees == null || pSelectedEmployees.Count == 0) &&
|
||||
((pSelectedCustomer != null && pSelectedCustomer.Count > 0) ||
|
||||
(pSelectedResources != null && pSelectedResources.Count > 0)))
|
||||
(pSelectedCustomer != null && pSelectedCustomer.Count > 0 ||
|
||||
pSelectedResources != null && pSelectedResources.Count > 0))
|
||||
{
|
||||
ownerOid = null;
|
||||
}
|
||||
@@ -996,8 +1049,13 @@ namespace BeWo.Service.ServiceImplementations
|
||||
ownerOid = pEmployeeOid;
|
||||
}
|
||||
|
||||
//rausnehmen, sonst werden termine nicht gezeigt, bei denen man owner und kein Employee ausgewählt wurde
|
||||
pSelectedEmployees?.Remove(pEmployeeOid);
|
||||
if(!(!pHasRightToSeeAllEmployeeAppointments && pSelectedEmployees != null && pSelectedEmployees.Count == 1 && pSelectedEmployees.Contains(pEmployeeOid)))
|
||||
{
|
||||
//rausnehmen, sonst werden termine nicht gezeigt, bei denen man owner und kein Employee ausgewählt wurde.
|
||||
//wird nicht rausgenommen, wenn man die termine anderer mitarbeiter nicht sehen darf und "nur meine termine" ausgewählt hat.
|
||||
//sonst werden die filter mit and und nicht mit or verknüpft.
|
||||
pSelectedEmployees?.Remove(pEmployeeOid);
|
||||
}
|
||||
|
||||
if(pPrivateAppointmentsOnly && (pSelectedEmployees == null || pSelectedEmployees.Count == 0) && (pSelectedCustomer == null || pSelectedCustomer.Count == 0) && (pSelectedResources == null || pSelectedResources.Count == 0) && !(pSelectedEmployees == null || pSelectedEmployees.Count == 0) &&
|
||||
(pSelectedCustomer != null && pSelectedCustomer.Count > 0 ||
|
||||
|
||||
Reference in New Issue
Block a user