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 RuleControl ruleControl;
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 dbConnected;
ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
private Dictionary<Guid, ClosableTabItem> openTabs = new Dictionary<Guid, ClosableTabItem>();
private Dictionary<ClosableTabItem, Guid> lockedCores = new Dictionary<ClosableTabItem, Guid>();
private int failedLogonCount = 0;
private ReportingParty userEntity = null;
private ILog _log = LogManager.GetLogger(typeof(MainWindow));
private DatabaseEntityWatchdog _dbWatchDog;
private readonly ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
private readonly Dictionary<Guid, ClosableTabItem> openTabs = new Dictionary<Guid, ClosableTabItem>();
private readonly Dictionary<ClosableTabItem, Guid> lockedCores = new Dictionary<ClosableTabItem, Guid>();
private int failedLogonCount;
private ReportingParty userEntity;
private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
private readonly DatabaseEntityWatchdog _dbWatchDog;
#endregion
@ -125,10 +125,7 @@ namespace ENI2
this._dbWatchDog.Register(aMessageCore);
drc.HighlightReset += Drc_HighlightReset;
drc.OpenNewCoreRequested += (core) =>
{
this.AnmeldungenControl_MessageCoreSelected(core);
};
drc.OpenNewCoreRequested += (core) => this.AnmeldungenControl_MessageCoreSelected(core);
}
else
@ -140,8 +137,7 @@ namespace ENI2
private void Drc_HighlightReset(DatabaseEntity entity)
{
MessageCore resetCore = entity as MessageCore;
if (resetCore != null)
if (entity is MessageCore resetCore)
{
if (openTabs.ContainsKey(resetCore.Id.Value))
{
@ -152,13 +148,12 @@ namespace ENI2
private void SearchResultItem_TabClosing(object sender, CancelEventArgs e)
{
ClosableTabItem tabItem = sender as ClosableTabItem;
if(tabItem != null)
if (sender is ClosableTabItem tabItem)
{
DetailRootControl drc = tabItem.Content as DetailRootControl;
// 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)
e.Cancel = true;
@ -298,23 +293,21 @@ namespace ENI2
private void ExecutedClearCommand(object sender, ExecutedRoutedEventArgs e)
{
Xceed.Wpf.Toolkit.DateTimePicker dtPicker = e.OriginalSource as Xceed.Wpf.Toolkit.DateTimePicker;
if (dtPicker == null)
if (!(e.OriginalSource is Xceed.Wpf.Toolkit.DateTimePicker dtPicker))
dtPicker = CustomCommands.FindParent<Xceed.Wpf.Toolkit.DateTimePicker>(e.OriginalSource as DependencyObject);
if(dtPicker != null)
if (dtPicker != null)
{
dtPicker.Value = null;
}
// das funktioniert auch für Comboboxen :P
ComboBox cb = e.OriginalSource as ComboBox;
if(cb == null)
if (!(e.OriginalSource is ComboBox cb))
{
cb = CustomCommands.FindParent<ComboBox>(e.OriginalSource as DependencyObject);
}
if(cb != null)
if (cb != null)
{
cb.SelectedIndex = -1;
@ -435,8 +428,7 @@ namespace ENI2
private void closeButton_Click(object sender, RoutedEventArgs e)
{
// close particular tab
TabItem tabitem = e.Source as TabItem;
if(tabitem != null)
if (e.Source is TabItem tabitem)
{
this.mainFrame.Items.Remove(tabitem);
}
@ -444,17 +436,16 @@ namespace ENI2
private void _dbWatchDog_DatabaseEntityChanged(DatabaseEntity entity)
{
MessageCore changedCore = entity as MessageCore;
if(changedCore != null)
if (entity is MessageCore changedCore)
{
// tab färben
if(this.openTabs.ContainsKey(changedCore.Id.Value))
if (this.openTabs.ContainsKey(changedCore.Id.Value))
{
TabItem tabitem = this.openTabs[changedCore.Id.Value];
this.Dispatcher.BeginInvoke(new Action(() =>
{
if (tabitem is ClosableTabItem)
((ClosableTabItem)tabitem).IsHighlighted = true;
((ClosableTabItem)tabitem).IsHighlighted = true;
}));
}
}
@ -462,17 +453,13 @@ namespace ENI2
private void _dbWatchDog_VisitTransitIdUpdated(DatabaseEntity entity)
{
MessageCore changedCore = entity as MessageCore;
if (changedCore != null)
if (entity is MessageCore changedCore)
{
TabItem tabitem = this.openTabs[changedCore.Id.Value];
this.Dispatcher.BeginInvoke(new Action(() =>
{
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)]
public class LockingService : IService
{
private static ILog _log = LogManager.GetLogger(typeof(LockingService));
private static Dictionary<Guid, LockEntry> lockDict = new Dictionary<Guid, LockEntry>();
private static Timer staleTimer = new Timer(5000); // alle 5 Sekunden prüfen
private static readonly ILog _log = LogManager.GetLogger(typeof(LockingService));
private static readonly Dictionary<Guid, LockEntry> lockDict = new Dictionary<Guid, LockEntry>();
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
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

View File

@ -306,6 +306,13 @@ namespace bsmd.database
{
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));
// 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

View File

@ -100,5 +100,15 @@ namespace bsmd.database
#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
#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
}
}