Zwischenstand

This commit is contained in:
Daniel Schick 2019-04-04 04:59:14 +00:00
parent afedf644db
commit 5f7453fae5
6 changed files with 55 additions and 41 deletions

View File

@ -36,18 +36,18 @@ namespace ENI2
private ReportingPartyControl rpControl; private ReportingPartyControl rpControl;
private RuleControl ruleControl; private RuleControl ruleControl;
private ServerStatusControl statusControl; private ServerStatusControl statusControl;
private SucheControl sucheControl; private readonly SucheControl sucheControl;
private List<MessageCore> anmeldungen = new List<MessageCore>(); private readonly List<MessageCore> anmeldungen = new List<MessageCore>();
private bool efMode = false; private bool efMode = false;
private bool dbConnected; private bool dbConnected;
ScaleTransform _transform = new ScaleTransform(1.0, 1.0); private readonly ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
private Dictionary<Guid, ClosableTabItem> openTabs = new Dictionary<Guid, ClosableTabItem>(); private readonly Dictionary<Guid, ClosableTabItem> openTabs = new Dictionary<Guid, ClosableTabItem>();
private Dictionary<ClosableTabItem, Guid> lockedCores = new Dictionary<ClosableTabItem, Guid>(); private readonly Dictionary<ClosableTabItem, Guid> lockedCores = new Dictionary<ClosableTabItem, Guid>();
private int failedLogonCount = 0; private int failedLogonCount;
private ReportingParty userEntity = null; private ReportingParty userEntity;
private ILog _log = LogManager.GetLogger(typeof(MainWindow)); private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
private DatabaseEntityWatchdog _dbWatchDog; private readonly DatabaseEntityWatchdog _dbWatchDog;
#endregion #endregion
@ -125,10 +125,7 @@ namespace ENI2
this._dbWatchDog.Register(aMessageCore); this._dbWatchDog.Register(aMessageCore);
drc.HighlightReset += Drc_HighlightReset; drc.HighlightReset += Drc_HighlightReset;
drc.OpenNewCoreRequested += (core) => drc.OpenNewCoreRequested += (core) => this.AnmeldungenControl_MessageCoreSelected(core);
{
this.AnmeldungenControl_MessageCoreSelected(core);
};
} }
else else
@ -140,8 +137,7 @@ namespace ENI2
private void Drc_HighlightReset(DatabaseEntity entity) private void Drc_HighlightReset(DatabaseEntity entity)
{ {
MessageCore resetCore = entity as MessageCore; if (entity is MessageCore resetCore)
if (resetCore != null)
{ {
if (openTabs.ContainsKey(resetCore.Id.Value)) if (openTabs.ContainsKey(resetCore.Id.Value))
{ {
@ -152,13 +148,12 @@ namespace ENI2
private void SearchResultItem_TabClosing(object sender, CancelEventArgs e) private void SearchResultItem_TabClosing(object sender, CancelEventArgs e)
{ {
ClosableTabItem tabItem = sender as ClosableTabItem; if (sender is ClosableTabItem tabItem)
if(tabItem != null)
{ {
DetailRootControl drc = tabItem.Content as DetailRootControl; DetailRootControl drc = tabItem.Content as DetailRootControl;
// Test for unsaved changes // Test for unsaved changes
if(drc.HasUnsavedChanges) if (drc.HasUnsavedChanges)
{ {
if (MessageBox.Show(Properties.Resources.textConfirmWithoutSaving, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) if (MessageBox.Show(Properties.Resources.textConfirmWithoutSaving, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true; e.Cancel = true;
@ -298,23 +293,21 @@ namespace ENI2
private void ExecutedClearCommand(object sender, ExecutedRoutedEventArgs e) private void ExecutedClearCommand(object sender, ExecutedRoutedEventArgs e)
{ {
Xceed.Wpf.Toolkit.DateTimePicker dtPicker = e.OriginalSource as Xceed.Wpf.Toolkit.DateTimePicker; if (!(e.OriginalSource is Xceed.Wpf.Toolkit.DateTimePicker dtPicker))
if (dtPicker == null)
dtPicker = CustomCommands.FindParent<Xceed.Wpf.Toolkit.DateTimePicker>(e.OriginalSource as DependencyObject); dtPicker = CustomCommands.FindParent<Xceed.Wpf.Toolkit.DateTimePicker>(e.OriginalSource as DependencyObject);
if(dtPicker != null) if (dtPicker != null)
{ {
dtPicker.Value = null; dtPicker.Value = null;
} }
// das funktioniert auch für Comboboxen :P // das funktioniert auch für Comboboxen :P
ComboBox cb = e.OriginalSource as ComboBox; if (!(e.OriginalSource is ComboBox cb))
if(cb == null)
{ {
cb = CustomCommands.FindParent<ComboBox>(e.OriginalSource as DependencyObject); cb = CustomCommands.FindParent<ComboBox>(e.OriginalSource as DependencyObject);
} }
if(cb != null) if (cb != null)
{ {
cb.SelectedIndex = -1; cb.SelectedIndex = -1;
@ -435,8 +428,7 @@ namespace ENI2
private void closeButton_Click(object sender, RoutedEventArgs e) private void closeButton_Click(object sender, RoutedEventArgs e)
{ {
// close particular tab // close particular tab
TabItem tabitem = e.Source as TabItem; if (e.Source is TabItem tabitem)
if(tabitem != null)
{ {
this.mainFrame.Items.Remove(tabitem); this.mainFrame.Items.Remove(tabitem);
} }
@ -444,17 +436,16 @@ namespace ENI2
private void _dbWatchDog_DatabaseEntityChanged(DatabaseEntity entity) private void _dbWatchDog_DatabaseEntityChanged(DatabaseEntity entity)
{ {
MessageCore changedCore = entity as MessageCore; if (entity is MessageCore changedCore)
if(changedCore != null)
{ {
// tab färben // tab färben
if(this.openTabs.ContainsKey(changedCore.Id.Value)) if (this.openTabs.ContainsKey(changedCore.Id.Value))
{ {
TabItem tabitem = this.openTabs[changedCore.Id.Value]; TabItem tabitem = this.openTabs[changedCore.Id.Value];
this.Dispatcher.BeginInvoke(new Action(() => this.Dispatcher.BeginInvoke(new Action(() =>
{ {
if (tabitem is ClosableTabItem) if (tabitem is ClosableTabItem)
((ClosableTabItem)tabitem).IsHighlighted = true; ((ClosableTabItem)tabitem).IsHighlighted = true;
})); }));
} }
} }
@ -462,17 +453,13 @@ namespace ENI2
private void _dbWatchDog_VisitTransitIdUpdated(DatabaseEntity entity) private void _dbWatchDog_VisitTransitIdUpdated(DatabaseEntity entity)
{ {
MessageCore changedCore = entity as MessageCore; if (entity is MessageCore changedCore)
if (changedCore != null)
{ {
TabItem tabitem = this.openTabs[changedCore.Id.Value]; TabItem tabitem = this.openTabs[changedCore.Id.Value];
this.Dispatcher.BeginInvoke(new Action(() => this.Dispatcher.BeginInvoke(new Action(() =>
{ {
DetailRootControl drc = tabitem.Content as DetailRootControl; DetailRootControl drc = tabitem.Content as DetailRootControl;
if (drc != null) drc?.CoreChanged(changedCore);
{
drc.CoreChanged(changedCore);
}
})); }));
} }
} }

Binary file not shown.

View File

@ -16,9 +16,9 @@ namespace bsmd.LockingService
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class LockingService : IService public class LockingService : IService
{ {
private static ILog _log = LogManager.GetLogger(typeof(LockingService)); private static readonly ILog _log = LogManager.GetLogger(typeof(LockingService));
private static Dictionary<Guid, LockEntry> lockDict = new Dictionary<Guid, LockEntry>(); private static readonly Dictionary<Guid, LockEntry> lockDict = new Dictionary<Guid, LockEntry>();
private static Timer staleTimer = new Timer(5000); // alle 5 Sekunden prüfen private static readonly Timer staleTimer = new Timer(5000); // alle 5 Sekunden prüfen
private const int staleTimeoutSeconds = 120; // wenn sie eine Anwendung 2 Minuten nicht meldet, werden die Locks freigegeben private const int staleTimeoutSeconds = 120; // wenn sie eine Anwendung 2 Minuten nicht meldet, werden die Locks freigegeben
static LockingService() static LockingService()
@ -42,7 +42,7 @@ namespace bsmd.LockingService
} }
} }
private ILog log = LogManager.GetLogger(typeof(LockingService)); private readonly ILog log = LogManager.GetLogger(typeof(LockingService));
#region Implementation IService #region Implementation IService

View File

@ -306,6 +306,13 @@ namespace bsmd.database
{ {
if (this.GrossTonnage.HasValue && (this.GrossTonnage.Value >= 500) && (this.ISMCompanyName.IsNullOrEmpty() || this.ISMCompanyId.IsNullOrEmpty())) if (this.GrossTonnage.HasValue && (this.GrossTonnage.Value >= 500) && (this.ISMCompanyName.IsNullOrEmpty() || this.ISMCompanyId.IsNullOrEmpty()))
violations.Add(RuleEngine.CreateViolation(ValidationCode.V821, "ISMCompanyId/Name must be provided", null, this.Title, null, this.Tablename)); violations.Add(RuleEngine.CreateViolation(ValidationCode.V821, "ISMCompanyId/Name must be provided", null, this.Title, null, this.Tablename));
// Neue Regeln vom 1.4.2019
if (this.LengthOverall_MTR.HasValue && ((this.LengthOverall_MTR.Value < 10) || (this.LengthOverall_MTR.Value > 500)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Length valid?", null, this.Title, null, this.Tablename));
if (this.Beam_MTR.HasValue && ((this.Beam_MTR.Value < 5) || (this.Beam_MTR.Value > 50)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Beam valid?", null, this.Title, null, this.Tablename));
if (this.GrossTonnage.HasValue && ((this.GrossTonnage.Value < 50) || (this.GrossTonnage > 500000)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Gross tonnage valid?", null, this.Title, null, this.Tablename));
} }
#endregion #endregion

View File

@ -100,5 +100,15 @@ namespace bsmd.database
#endregion #endregion
#region Validation
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
{
if(this.DraughtUponArrival_DMT.HasValue && ((this.DraughtUponArrival_DMT.Value < 10) || (this.DraughtUponArrival_DMT.Value > 200)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Check draught on arrival", null, this.Title, null, this.Tablename));
}
#endregion
} }
} }

View File

@ -101,5 +101,15 @@ namespace bsmd.database
#endregion #endregion
#region Validation
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
{
if (this.DraughtUponDeparture_DMT.HasValue && ((this.DraughtUponDeparture_DMT.Value < 10) || (this.DraughtUponDeparture_DMT.Value > 200)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Check draught on departure", null, this.Title, null, this.Tablename));
}
#endregion
} }
} }