diff --git a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml
index 758fa4250..5bf0e037b 100644
--- a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml
+++ b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml
@@ -294,9 +294,9 @@
Height="23" MinWidth="80" Margin="3" EditValue="{Binding Controller.DisplayStartDate}" x:Name="StartDateDateEdit"
EditValueChanged="StartDate_OnChange" />
-
+
@@ -304,7 +304,9 @@
-
+
diff --git a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs
index 7e02b8c4c..9d5a1d2e4 100644
--- a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs
+++ b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs
@@ -9,7 +9,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
-
+using System.Windows.Media;
using BeWo.Annotations;
using BeWo.Core;
using BeWo.Scheduler.Utils;
@@ -463,7 +463,7 @@ namespace BeWo.Scheduler.View
ViewModel.NewVM.Start = start;
ViewModel.NewVM.End = end;
- if(isTask && dueDate.HasValue)
+ if (isTask && dueDate.HasValue)
{
ViewModel.NewVM.End = dueDate.Value.GetShortDateTime().AddDays(1);
}
@@ -485,22 +485,6 @@ namespace BeWo.Scheduler.View
var item = (SchedulerAppointmentVM) Appointment.GetSourceObject(Control.GetCoreStorage());
- //var overlaps = false;
- //if(!IsInTaskViewMode){
- // ServiceFacade.DoResourceServiceSync(definedBelow => overlaps = definedBelow.OverlappingAppointmentsExist(Appointment.Start, Appointment.End, employeeOids, customerOids, resources.Select(res => res.ResourceOid.Value).ToList(), ViewModel.NewVM.Originator.EmployeeOid, item?.CommitToDataContract().SchedulerAppointmentOid, string.Empty, Appointment.RecurrenceIndex));
-
- // if (overlaps)
- // {
- // var erg = MessageBox.Show("Dieser Termin überschneidet sich mit einem anderen bereits existierenden Termin.\n Möchten Sie ihn wirklich speichern?", "Überschneidung", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
-
- // if (erg.Equals(MessageBoxResult.No))
- // {
- // Controller.Storage.EndUpdate();
- // return;
- // }
- // }
- //}
-
ViewModel.ShouldLockOverlappingAppointmentCheck = Appointment.Type == AppointmentType.ChangedOccurrence;
if (Appointment.RecurrenceInfo != null)
@@ -508,18 +492,6 @@ namespace BeWo.Scheduler.View
ViewModel.ApplyChangesToChangedOccurencyCustomFields(employees, customers, resources, originator, isPrivate, Appointment.RecurrenceIndex.ToString(), new Guid(Appointment.RecurrenceInfo.Id.ToString()), isTask, taskDescription, completedDate, dueDate, completedNotice, supportConceptList, Appointment.Subject, Appointment.AllDay);
}
- //if(Appointment.IsOccurrence && item == null)
- //{
- // Appointment.GetCustomFieldStorage().EmployeeList.ForEach(each =>
- // {
- // each.Employee2SchedulerAppointmentOid = null;
- // each.Employee2SchedulerAppointmentVersion = null;
- // each.SchedulerAppointmentOid = null;
- // each.IsPChanged = false;
- // each.IsPC_CheckedTs = null;
- // });
- //}
-
ApplyChanges();
}
catch (Exception exception)
@@ -674,49 +646,15 @@ namespace BeWo.Scheduler.View
}
}
- private bool _HasBeenUnchecked;
-
private void AllDay_OnCheckedChange(object sender, RoutedEventArgs e)
{
- //var source = (CheckEdit)e.Source;
- //var value = source.IsChecked ?? false;
-
- //if(value == false && _HasBeenUnchecked == false)
- //{
- // var displayStart = NewSchedulerAppointmentFormController.DisplayStart;
- // var start = NewSchedulerAppointmentFormController.Start;
- // var end = NewSchedulerAppointmentFormController.End;
-
- // if(!end.Equals(start))
- // {
- // _HasBeenUnchecked = true;
-
- // var day = displayStart.Day;
- // var month = displayStart.Month;
- // var year = displayStart.Year;
-
- // var newEndDay = (end.AddDays(-1) >= start ? end.AddDays(-1) : start).Day;
-
- // var newStart = new DateTime(year, month, day, 0, 0, 0);
- // var newEnd = new DateTime(year, month, newEndDay, 1, 0, 0);
-
- // NewSchedulerAppointmentFormController.Start = newStart;
- // NewSchedulerAppointmentFormController.End = newEnd;
-
- // NewSchedulerAppointmentFormController.DisplayStart = newStart;
- // NewSchedulerAppointmentFormController.DisplayEnd = newEnd;
-
- // NewSchedulerAppointmentFormController.DisplayStartTime = new TimeSpan(0, 0, 0, 0);
- // NewSchedulerAppointmentFormController.DisplayEndTime = new TimeSpan(0, 1, 0, 0);
-
- // _HasBeenUnchecked = true;
- // }
- //}
+ var source = (CheckEdit)e.Source;
+ var value = source.IsChecked ?? false;
}
private void DueDate_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
{
- if(e.NewValue != null && e.NewValue is DateTime dueDate)
+ if(e.NewValue != null && e.NewValue is DateTime dueDate)
{
var newEnd = dueDate.GetShortDateTime().AddDays(1);
@@ -736,24 +674,47 @@ namespace BeWo.Scheduler.View
* If the new Appointment. End property's value is less than the Appointment.
* Start property's value, an exception is raised.
*
+ * Endzeit = Startzeit + Vorherige Dauer
*/
+ private DateTime? _PreviousEndDate;
+
+ private bool _HasBeenChangedByStartTime;
+
+ // TOOD: KGW?
private void StartDate_OnChange(object sender, EditValueChangedEventArgs e)
{
- var newStartDate = (DateTime?) e.NewValue;
- var oldStartDate = (DateTime?) e.OldValue;
-
- //BeWoApp.LogMessage($"EndDates: {newStartDate:dd.MM.yyyy HH:mm} vs. {oldStartDate:dd.MM.yyyy HH:mm}", DebugWindowMessageColor.Red);
- }
+ //_HasBeenChangedByStartTime = false;
+ }
+ // TOOD: KGW?
private void EndDate_OnChange(object sender, EditValueChangedEventArgs e)
{
- var newEndDate = (DateTime?) e.NewValue;
- var oldEndDate = (DateTime?) e.OldValue;
-
- //BeWoApp.LogMessage($"EndDates: {newEndDate:dd.MM.yyyy HH:mm} vs. {oldEndDate:dd.MM.yyyy HH:mm}", DebugWindowMessageColor.Red);
+ //_HasBeenChangedByStartTime = false;
}
- }
+
+ private void StartTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
+ {
+ _PreviousEndDate = NewSchedulerAppointmentFormController.End;
+
+ _HasBeenChangedByStartTime = true;
+ }
+
+ private void EndTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
+ {
+ //if(_HasBeenChangedByStartTime && _PreviousEndDate.HasValue)
+ // {
+ // var start = NewSchedulerAppointmentFormController.Start;
+
+ // if(_PreviousEndDate > start)
+ // {
+ // NewSchedulerAppointmentFormController.End = NewSchedulerAppointmentFormController.End.MergeDatesByDate(_PreviousEndDate.Value);
+ // }
+ // }
+
+ // _HasBeenChangedByStartTime = false;
+ }
+ }
public class NewSchedulerAppointmentFormController : AppointmentFormController
{
diff --git a/BeWo/Security/EncryptionUtils.cs b/BeWo/Security/EncryptionUtils.cs
new file mode 100644
index 000000000..f993936ad
--- /dev/null
+++ b/BeWo/Security/EncryptionUtils.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace BeWo.Security
+{
+ public class EncryptionUtils
+ {
+ private static readonly byte[] _Rc2Iv = { 50, 241, 173, 46, 224, 103, 137, 72 };
+ private static readonly byte[] _Rc2Key = { 140, 81, 67, 90, 70, 222, 51, 20, 154, 60, 68, 87, 112, 169, 38, 234 };
+
+ public static string EncryptString(string stringToEncrypt)
+ {
+ var rc2Csp = new RC2CryptoServiceProvider();
+ var encryptor = rc2Csp.CreateEncryptor(_Rc2Key, _Rc2Iv);
+
+ using(var memoryStream = new MemoryStream())
+ {
+ using(var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
+ {
+ var toEncrypt = Encoding.UTF8.GetBytes(stringToEncrypt);
+
+ cryptoStream.Write(toEncrypt, 0, toEncrypt.Length);
+ cryptoStream.FlushFinalBlock();
+
+ var encrypted = memoryStream.ToArray();
+
+ return Convert.ToBase64String(encrypted);
+ }
+ }
+ }
+
+ public static string DecryptString(string stringToDecrypt)
+ {
+ var rc2Csp = new RC2CryptoServiceProvider();
+ var decryptor = rc2Csp.CreateDecryptor(_Rc2Key, _Rc2Iv);
+
+ stringToDecrypt = stringToDecrypt.Replace(' ', '+');
+ stringToDecrypt = stringToDecrypt.Trim(',');
+
+ try
+ {
+ using (var memoryStream = new MemoryStream(Convert.FromBase64String(stringToDecrypt)))
+ {
+ using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
+ {
+ var bytes = new List();
+ int b;
+
+ do
+ {
+ b = cryptoStream.ReadByte();
+
+ if(b != -1)
+ {
+ bytes.Add(Convert.ToByte(b));
+ }
+ } while(b != -1);
+
+ return Encoding.UTF8.GetString(bytes.ToArray());
+ }
+ }
+ }
+ catch(CryptographicException)
+ {
+ // Es wird davon ausgegangen, dass der String nicht verschlüsselt ist.
+ return Encoding.UTF8.GetString(Convert.FromBase64String(stringToDecrypt));
+ }
+ }
+ }
+}
diff --git a/BeWo/View/Detail/DebugMessageLogView.xaml b/BeWo/View/Detail/DebugMessageLogView.xaml
index c83ce0e80..6c40b8621 100644
--- a/BeWo/View/Detail/DebugMessageLogView.xaml
+++ b/BeWo/View/Detail/DebugMessageLogView.xaml
@@ -5,10 +5,17 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BeWo.View.Detail"
Title="Debug Log" mc:Ignorable="d"
- d:DesignHeight="500" d:DesignWidth="1000">
+ Height="900" Width="700">
-
+
+
+
+
+
+
+
+
diff --git a/BeWo/View/Detail/DebugMessageLogView.xaml.cs b/BeWo/View/Detail/DebugMessageLogView.xaml.cs
index 8fde6bd34..3b7fc7a6d 100644
--- a/BeWo/View/Detail/DebugMessageLogView.xaml.cs
+++ b/BeWo/View/Detail/DebugMessageLogView.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
+using System.Windows;
using System.Windows.Media;
using BeWo.Annotations;
@@ -39,11 +40,6 @@ namespace BeWo.View.Detail
DebugMessageList.Add(new DebugWindowMessage(message));
}
- public void LogMessage(string message, DebugWindowMessageColor debugWindowMessageColor)
- {
- DebugMessageList.Add(new DebugWindowMessage(message, debugWindowMessageColor));
- }
-
public void LogMessage(string message, Color color)
{
DebugMessageList.Add(new DebugWindowMessage(message, color));
@@ -51,81 +47,37 @@ namespace BeWo.View.Detail
public event PropertyChangedEventHandler PropertyChanged;
+
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
+
+ private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+ {
+ DebugMessageList.Clear();
+ }
}
public class DebugWindowMessage
{
public string MessageText { get; }
- public DebugWindowMessageColor DebugWindowMessageColor { get; }
-
public Color CustomColor { get; }
- public SolidColorBrush TextColor
- {
- get
- {
- switch(DebugWindowMessageColor)
- {
- case DebugWindowMessageColor.Blue:
- return new SolidColorBrush(Colors.DodgerBlue);
- case DebugWindowMessageColor.Black:
- return new SolidColorBrush(Colors.Black);
- case DebugWindowMessageColor.Green:
- return new SolidColorBrush(Colors.MediumSeaGreen);
- case DebugWindowMessageColor.Orange:
- return new SolidColorBrush(Color.FromRgb(255, 90, 0));
- case DebugWindowMessageColor.Red:
- return new SolidColorBrush(Colors.Red);
- case DebugWindowMessageColor.Yellow:
- return new SolidColorBrush(Colors.Yellow);
- case DebugWindowMessageColor.Purple:
- return new SolidColorBrush(Colors.Purple);
- case DebugWindowMessageColor.Custom:
- return new SolidColorBrush(CustomColor);
- default:
- return new SolidColorBrush(Colors.Black);
-
- }
- }
- }
+ public SolidColorBrush TextColor => new SolidColorBrush(CustomColor);
public DebugWindowMessage(string messageText)
{
MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}";
- DebugWindowMessageColor = DebugWindowMessageColor.Black;
- CustomColor = Colors.Black;
- }
-
- public DebugWindowMessage(string messageText, DebugWindowMessageColor debugWindowMessageColor)
- {
- MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}";
- DebugWindowMessageColor = debugWindowMessageColor;
CustomColor = Colors.Black;
}
public DebugWindowMessage(string messageText, Color customColor)
{
MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}";
- DebugWindowMessageColor = DebugWindowMessageColor.Custom;
CustomColor = customColor;
}
}
-
- public enum DebugWindowMessageColor
- {
- Black,
- Green,
- Yellow,
- Red,
- Orange,
- Blue,
- Custom,
- Purple
- }
}