Version 3.9.6: Weitere kleinere Fehlermeldungen, Refresh/Jump aus Error/Violationdialog

This commit is contained in:
Daniel Schick 2017-12-19 10:20:51 +00:00
parent 2ee4059926
commit 0530420bf4
35 changed files with 463 additions and 122 deletions

View File

@ -34,6 +34,30 @@
<DataGridTextColumn Header="{x:Static p:Resources.textVisitTransitId}" Binding="{Binding Id}" IsReadOnly="True" Width="0.2*" />
</DataGrid.Columns>
</local:ENIDataGrid>
<xctk:BusyIndicator IsBusy="True" Grid.Row="1" x:Name="busyIndicator">
<xctk:BusyIndicator.BusyContentTemplate>
<DataTemplate>
<StackPanel Margin="4">
<TextBlock Text="{x:Static p:Resources.textUpdateStatus}" FontWeight="Bold" HorizontalAlignment="Center" Width="200"/>
<StackPanel Margin="4">
<TextBlock x:Name="textUpdateProgress" Loaded="textUpdateProgress_Loaded" />
<ProgressBar Value="40" Height="15" x:Name="progressBarUpdate" Loaded="progressBarUpdate_Loaded"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</xctk:BusyIndicator.BusyContentTemplate>
<xctk:BusyIndicator.OverlayStyle>
<Style TargetType="Rectangle">
<Setter Property="Fill" Value="#C1C1C1C1" />
</Style>
</xctk:BusyIndicator.OverlayStyle>
<xctk:BusyIndicator.ProgressBarStyle>
<Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</xctk:BusyIndicator.ProgressBarStyle>
</xctk:BusyIndicator>
</Grid>
</GroupBox>

View File

@ -12,6 +12,7 @@ using System.Globalization;
using log4net;
using bsmd.database;
using System.ServiceProcess;
using System.ComponentModel;
namespace ENI2.Controls
{
@ -24,12 +25,15 @@ namespace ENI2.Controls
private ObservableCollection<StatusEntry> entries = new ObservableCollection<StatusEntry>();
private static Regex regex = new Regex(@"BSMD_(\d*)-(.*)-(\w*)");
private static ILog _log = LogManager.GetLogger("ServerStatus");
private ProgressBar _updateProgressBar;
private TextBlock _updateTextBlock;
public ServerStatusControl()
{
InitializeComponent();
this.dataGridStatus.ItemsSource = this.entries;
this.Loaded += ServerStatusControl_Loaded;
}
private void ServerStatusControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
@ -39,18 +43,64 @@ namespace ENI2.Controls
internal void Update(LockingServiceReference.ServerStatus serverStatus)
{
int totalNum = serverStatus.IMPFiles.Length + serverStatus.READYFiles.Length + serverStatus.CORRUPTFiles.Length;
entries.Clear();
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.DoWork += (o, e) =>
{
System.Windows.Application.Current.Dispatcher.Invoke(delegate {
this._updateProgressBar.Maximum = totalNum;
this._updateProgressBar.Value = 0;
});
int counter = 0;
// Die Dateien müssen in die Objekte
List<StatusEntry> tmpList = new List<StatusEntry>();
foreach (string filename in serverStatus.IMPFiles)
{
StatusEntry se = StatusEntry.Create(filename, "IMP");
tmpList.Add(se);
counter++;
System.Windows.Application.Current.Dispatcher.Invoke(delegate {
this._updateTextBlock.Text = string.Format(Properties.Resources.textUpdatingFile, counter, totalNum);
this._updateProgressBar.Value = counter;
});
}
foreach (string filename in serverStatus.READYFiles)
{
StatusEntry se = StatusEntry.Create(filename, "READY");
tmpList.Add(se);
counter++;
System.Windows.Application.Current.Dispatcher.Invoke(delegate {
this._updateTextBlock.Text = string.Format(Properties.Resources.textUpdatingFile, counter, totalNum);
this._updateProgressBar.Value = counter;
});
}
foreach (string filename in serverStatus.CORRUPTFiles)
{
StatusEntry se = StatusEntry.Create(filename, "CORRUPT");
tmpList.Add(se);
counter++;
System.Windows.Application.Current.Dispatcher.Invoke(delegate {
this._updateTextBlock.Text = string.Format(Properties.Resources.textUpdatingFile, counter, totalNum);
this._updateProgressBar.Value = counter;
});
}
tmpList.Sort();
System.Windows.Application.Current.Dispatcher.Invoke(delegate {
// Die Dateien müssen in die Objekte
entries.Clear();
foreach (StatusEntry se in StatusEntry.CreateFromList(serverStatus.IMPFiles, "IMP"))
foreach (StatusEntry se in tmpList)
entries.Add(se);
});
};
foreach (StatusEntry se in StatusEntry.CreateFromList(serverStatus.READYFiles, "READY"))
entries.Add(se);
foreach (StatusEntry se in StatusEntry.CreateFromList(serverStatus.CORRUPTFiles, "CORRUPT"))
entries.Add(se);
bgWorker.RunWorkerCompleted += (o, e) =>
{
// Enumeration parsen und text ausgeben
ServiceControllerStatus excel = (ServiceControllerStatus)serverStatus.Excel;
@ -62,10 +112,15 @@ namespace ENI2.Controls
ServiceControllerStatus transmitter = (ServiceControllerStatus)serverStatus.Transmitter;
this.labelStatusTransmitter.Content = transmitter.ToString();
entries.BubbleSort();
});
this.busyIndicator.IsBusy = false;
};
this.busyIndicator.IsBusy = true;
bgWorker.RunWorkerAsync();
}
public class StatusEntry : IComparable
{
private static Dictionary<string, string> guidIdDict = new Dictionary<string, string>();
@ -78,18 +133,16 @@ namespace ENI2.Controls
public string Status { get; set; }
public static List<StatusEntry> CreateFromList(string[] aList, string status)
public static StatusEntry Create(string filename, string status)
{
List<StatusEntry> result = new List<StatusEntry>();
StatusEntry result = null;
foreach(string listEntry in aList)
{
if (regex.IsMatch(listEntry))
if (regex.IsMatch(filename))
{
try
{
StatusEntry entry = new StatusEntry();
Match m = regex.Match(listEntry);
Match m = regex.Match(filename);
entry.Timestamp = DateTime.ParseExact(m.Groups[1].Value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
string guidString = m.Groups[2].Value;
@ -113,14 +166,13 @@ namespace ENI2.Controls
entry.Class = m.Groups[3].Value;
entry.Status = status;
result.Add(entry);
result = entry;
}
catch(Exception ex)
catch (Exception ex)
{
_log.WarnFormat("Problem reading status info: {0}", ex.Message);
}
}
}
return result;
}
@ -155,6 +207,16 @@ namespace ENI2.Controls
}
}
}
private void textUpdateProgress_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (sender != null) this._updateTextBlock = sender as TextBlock;
}
private void progressBarUpdate_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (sender != null) this._updateProgressBar = sender as ProgressBar;
}
}
}

View File

@ -0,0 +1,57 @@
// Copyright (c) 2017 schick Informatik
// Description: Dialog Basisklasse analog EditWindowBase. Hier allerdings mit optionalem "Refresh" Knopf und
// "Close" statt "OK" und "Cancel"
using System;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using ENI2.Util;
namespace ENI2.Controls
{
[TemplatePart(Name = "buttonRefresh", Type = typeof(Button))]
[TemplatePart(Name = "buttonClose", Type = typeof(Button))]
public class StatusWindowBase : Window
{
public event Action CloseClicked;
public event Action RefreshClicked;
static StatusWindowBase()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(StatusWindowBase), new FrameworkPropertyMetadata(typeof(StatusWindowBase)));
}
public StatusWindowBase()
{
Loaded += (_, __) =>
{
var closeButton = (Button)Template.FindName("buttonClose", this);
var refreshButton = (Button)Template.FindName("buttonRefresh", this);
closeButton.Click += (s, e) => { if (IsModal) DialogResult = true; CloseClicked?.Invoke(); this.Close(); };
refreshButton.Click += (s, e) => { RefreshClicked?.Invoke(); };
};
this.IsModal = true; // default
}
public bool IsModal { get; set; }
public bool RefreshVisible
{
get { var refreshButton = (Button)Template.FindName("buttonRefresh", this); return refreshButton.Visibility == Visibility.Visible; }
set { var refreshButton = (Button)Template.FindName("buttonRefresh", this); refreshButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
// this.SetPlacement(..)
}
}
}

View File

@ -34,9 +34,9 @@ namespace ENI2
private object messageListLock = new object();
private HighlightService highlightService = new HighlightService();
// Validation
protected List<MessageError> _vErrors = new List<MessageError>();
protected List<MessageViolation> _vViolations = new List<MessageViolation>();
// Referenzen für Fehler/Violation Dialoge (können, müssen aber nicht offen bleiben)
protected ErrorListDialog _errorListDialog = null;
protected ViolationListDialog _violationListDialog = null;
#endregion
@ -369,13 +369,16 @@ namespace ENI2
private void DetailControl_RequestSendValidation()
{
this.Validate(false);
List<MessageViolation> violationList = null;
List<MessageError> errorList = null;
this.Validate(false, out violationList, out errorList);
foreach(Message aMessage in this._messages)
{
if(aMessage.InternalStatus == Message.BSMDStatus.TOSEND)
{
foreach(MessageError messageError in this._vErrors)
foreach(MessageError messageError in errorList)
{
if(messageError.NotificationClass == aMessage.MessageNotificationClassDisplay)
{
@ -445,13 +448,16 @@ namespace ENI2
private void DetailControl_RequestValidate()
{
this.Validate(true);
List<MessageError> errorList = null;
List<MessageViolation> violationList = null;
this.Validate(true, out violationList, out errorList);
}
private void Validate(bool showMessages)
private void Validate(bool showMessages, out List<MessageViolation> vViolations, out List<MessageError> vErrors)
{
this._vErrors.Clear();
this._vViolations.Clear();
vViolations = new List<MessageViolation>();
vErrors = new List<MessageError>();
// TODO: clear highlighting
Util.UIHelper.SetBusyState();
@ -475,15 +481,15 @@ namespace ENI2
mv.MessageGroupName = messageGroup;
}
this._vErrors.AddRange(errors);
this._vViolations.AddRange(violations);
vErrors.AddRange(errors);
vViolations.AddRange(violations);
}
foreach (MessageError me in this._vErrors)
foreach (MessageError me in vErrors)
{
this.highlightService.HighlightError(me, this.GetContainerForMessageGroupName(me.MessageGroupName));
}
foreach (MessageViolation mv in this._vViolations)
foreach (MessageViolation mv in vViolations)
{
this.highlightService.HighlightViolation(mv, this.GetContainerForMessageGroupName(mv.MessageGroupName));
}
@ -519,23 +525,37 @@ namespace ENI2
if (showMessages)
{
// Show error and violation dialog
if (this._vErrors.Count > 0)
if (vErrors.Count > 0)
{
ErrorListDialog eld = new ErrorListDialog();
eld.IsModal = false;
eld.Errors = this._vErrors;
eld.Show();
if(this._errorListDialog == null)
{
this._errorListDialog = new ErrorListDialog();
this._errorListDialog.Closed += (o, e) => { this._errorListDialog = null; };
this._errorListDialog.Loaded += (o, e) => { this._errorListDialog.RefreshVisible = true; };
this._errorListDialog.ErrorSelected += _errorListDialog_ErrorSelected;
this._errorListDialog.RefreshClicked += _errorListDialog_RefreshClicked;
this._errorListDialog.IsModal = false;
this._errorListDialog.Show();
}
this._errorListDialog.Errors = vErrors;
}
if (this._vViolations.Count > 0)
if (vViolations.Count > 0)
{
ViolationListDialog vld = new ViolationListDialog();
vld.IsModal = false;
vld.Violations = this._vViolations;
vld.Show();
if(this._violationListDialog == null)
{
this._violationListDialog = new ViolationListDialog();
this._violationListDialog.Closed += (o, e) => { this._violationListDialog = null; };
this._violationListDialog.Loaded += (o, e) => { this._violationListDialog.RefreshVisible = true; };
this._violationListDialog.ViolationSelected += _errorListDialog_ErrorSelected;
this._violationListDialog.RefreshClicked += _errorListDialog_RefreshClicked;
this._violationListDialog.IsModal = false;
this._violationListDialog.Show();
}
_violationListDialog.Violations = vViolations;
}
if((this._vErrors.Count == 0) && (this._vViolations.Count == 0))
if((vErrors.Count == 0) && (vViolations.Count == 0))
{
MessageBox.Show(Properties.Resources.textValidationOK, Properties.Resources.textValidation, MessageBoxButton.OK, MessageBoxImage.Information);
}
@ -543,6 +563,38 @@ namespace ENI2
}
}
private void _errorListDialog_RefreshClicked()
{
DetailControl_RequestValidate();
}
private void _errorListDialog_ErrorSelected(DatabaseEntity obj)
{
string msgGroupName = null;
if(obj is MessageError)
{
MessageError me = obj as MessageError;
msgGroupName = me.MessageGroupName;
}
else if(obj is MessageViolation)
{
MessageViolation mv = obj as MessageViolation;
msgGroupName = mv.MessageGroupName;
}
if(msgGroupName != null)
{
for(int i=0;i<_listBoxList.Count;i++)
{
if(_listBoxList[i].MessageGroupName.Equals(msgGroupName))
{
this.listBoxMessages.SelectedIndex = i;
break;
}
}
}
}
#endregion
#region private / protected methods

View File

@ -60,7 +60,7 @@
<TextBox Grid.Row="2" Grid.Column="1" Name="textRequestedPostionInPortOfCall" Margin="2" Text="{Binding RequestedPositionInPortOfCall}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Name="textBowThrusterPower" Margin="2" Text="{Binding BowThrusterPower}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Name="textSternThrusterPower" Margin="2" Text="{Binding SternThrusterPower}" VerticalContentAlignment="Center"/>
<CheckBox Grid.Row="5" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" IsThreeState="True" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargo}" Margin="2"/>
<CheckBox Grid.Row="5" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargoBool, Mode=TwoWay}" Margin="2"/>
<xctk:DoubleUpDown Grid.Row="6" Grid.Column="1" Name="doubleUpDownDisplacementSummerDraught" ShowButtonSpinner="False" ParsingNumberStyle="Any" Value="{Binding DeplacementSummerDraught_TNE}" Margin="4,2,0,2" FormatString="N1" TextAlignment="Left"/>
<TextBox Grid.Row="2" Grid.Column="3" Grid.RowSpan="2" Name="textSpecialRequirements" Margin="2" Text="{Binding SpecialRequirementsOfShipAtBerth}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="3" Grid.RowSpan="2" Name="textConstructionCharacteristics" Margin="2" Text="{Binding ConstructionCharacteristicsOfShip}" VerticalContentAlignment="Center"/>

View File

@ -35,8 +35,8 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.9.5.%2a</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>3.9.6.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@ -186,6 +186,7 @@
<Compile Include="Controls\ServerStatusControl.xaml.cs">
<DependentUpon>ServerStatusControl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\StatusWindowBase.cs" />
<Compile Include="Controls\ValidationConditionControl.xaml.cs">
<DependentUpon>ValidationConditionControl.xaml</DependentUpon>
</Compile>

View File

@ -8,7 +8,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textCoreStatus}" Height="436" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" >
Title="{x:Static p:Resources.textCoreStatus}" Height="436" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" Icon="/ENI2;component/Resources/bullet_ball_grey.ico" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"/>
@ -21,7 +21,9 @@
<RowDefinition Height="80" />
<RowDefinition Height="80" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28">
</RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textCancelled}" />
<CheckBox Name="checkBoxCancelled" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center" Margin="2" />

View File

@ -35,6 +35,8 @@ namespace ENI2.EditControls
this.textBlockErrorCode.Text = this.Core.StatusCheckErrorCode;
this.textBlockErrorMessage.Text = this.Core.StatusCheckErrorMessage;
this.Title = string.Format("{0} {1} {2}", this.Title, this.Core.DisplayId, this.Core.Shipname);
}
}
}

View File

@ -56,7 +56,6 @@ namespace ENI2.EditControls
this.comboBoxHandlingType.SelectedIndex = this.LADG.CargoHandlingType.Value;
this.comboBoxLACodes.ItemsSource = LADG.LACodes;
//this.comboBoxLACodes.KeyUp += ComboBox_KeyUp;
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
this.integerUpDownNumberOfItems.Value = this.LADG.CargoNumberOfItems;
@ -66,12 +65,11 @@ namespace ENI2.EditControls
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST;
//this.comboBoxNSTCode.KeyUp += ComboBox_KeyUp;
this.comboBoxNSTCode.SelectedValue = this.LADG.CargoCodeNST;
this.comboBoxNSTCode.SelectionChanged += ComboBoxNSTCode_SelectionChanged;
this.comboBoxNST3Code.ItemsSource = LADG.CargoCodesNST3;
//this.comboBoxNST3Code.KeyUp += ComboBox_KeyUp;
this.ComboBoxNSTCode_SelectionChanged(null, null);
this.comboBoxNST3Code.SelectedValue = this.LADG.CargoCodeNST_3;
this.AddVisible = true;

View File

@ -8,7 +8,7 @@
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textPortCall}" Height="210" Width="450" WindowStyle="SingleBorderWindow" Background="AliceBlue">
Title="{x:Static p:Resources.textPortCall}" Height="220" Width="450" WindowStyle="SingleBorderWindow" Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />

View File

@ -1,4 +1,4 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.ErrorListDialog"
<enictrl:StatusWindowBase x:Class="ENI2.EditControls.ErrorListDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -29,4 +29,4 @@
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</enictrl:EditWindowBase>
</enictrl:StatusWindowBase>

View File

@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Windows;
using System;
using bsmd.database;
using ENI2.Controls;
@ -13,20 +14,32 @@ namespace ENI2.EditControls
/// <summary>
/// Interaction logic for ErrorListDialog.xaml
/// </summary>
public partial class ErrorListDialog : EditWindowBase
public partial class ErrorListDialog : StatusWindowBase
{
public event Action<DatabaseEntity> ErrorSelected;
public ErrorListDialog()
{
InitializeComponent();
Loaded += ErrorListDialog_Loaded;
}
public List<MessageError> Errors { get; set; }
public List<MessageError> Errors
{
get { return this.dataGridErrors.ItemsSource as List<MessageError>; }
set { this.dataGridErrors.ItemsSource = value; }
}
private void ErrorListDialog_Loaded(object sender, RoutedEventArgs e)
{
this.dataGridErrors.Initialize();
this.dataGridErrors.ItemsSource = this.Errors;
this.dataGridErrors.EditRequested += DataGridErrors_EditRequested;
}
private void DataGridErrors_EditRequested(DatabaseEntity obj)
{
this.ErrorSelected?.Invoke(obj);
}
}
}

View File

@ -41,7 +41,7 @@ namespace ENI2.EditControls
public bool ValidId { get; set; }
public string VisitTransitId { get { return this.textBoxVisitTransitId.Text; } }
public string VisitTransitId { get { return this.textBoxVisitTransitId.Text.Trim(); } }
public string IMO { get { if (this.doubleUpDownIMO.Value.HasValue) return this.doubleUpDownIMO.Value.Value.ToString("0000000"); else return null; } }

View File

@ -1,4 +1,4 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.ViolationListDialog"
<enictrl:StatusWindowBase x:Class="ENI2.EditControls.ViolationListDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -12,7 +12,6 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@ -34,4 +33,4 @@
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</enictrl:EditWindowBase>
</enictrl:StatusWindowBase>

View File

@ -7,26 +7,39 @@ using System.Windows;
using bsmd.database;
using ENI2.Controls;
using System;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for ErrorListDialog.xaml
/// </summary>
public partial class ViolationListDialog : EditWindowBase
public partial class ViolationListDialog : StatusWindowBase
{
public event Action<DatabaseEntity> ViolationSelected;
public ViolationListDialog()
{
InitializeComponent();
Loaded += ErrorListDialog_Loaded;
}
public List<MessageViolation> Violations { get; set; }
public List<MessageViolation> Violations
{
get { return this.dataGridViolations.ItemsSource as List<MessageViolation>; }
set { this.dataGridViolations.ItemsSource = value; }
}
private void ErrorListDialog_Loaded(object sender, RoutedEventArgs e)
{
this.dataGridViolations.Initialize();
this.dataGridViolations.ItemsSource = this.Violations;
this.dataGridViolations.EditRequested += DataGridViolations_EditRequested;
}
private void DataGridViolations_EditRequested(DatabaseEntity obj)
{
this.ViolationSelected?.Invoke(obj);
}
}
}

View File

@ -1175,6 +1175,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
public static string textClose {
get {
return ResourceManager.GetString("textClose", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Code.
/// </summary>
@ -4253,6 +4262,24 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Server status update.
/// </summary>
public static string textUpdateStatus {
get {
return ResourceManager.GetString("textUpdateStatus", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reading file {0}/{1}....
/// </summary>
public static string textUpdatingFile {
get {
return ResourceManager.GetString("textUpdatingFile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to User administration.
/// </summary>

View File

@ -1600,4 +1600,13 @@
<data name="textCopyClip" xml:space="preserve">
<value>Copy Id to clipboard</value>
</data>
<data name="textUpdateStatus" xml:space="preserve">
<value>Server status update</value>
</data>
<data name="textUpdatingFile" xml:space="preserve">
<value>Reading file {0}/{1}...</value>
</data>
<data name="textClose" xml:space="preserve">
<value>Close</value>
</data>
</root>

View File

@ -82,11 +82,11 @@ namespace ENI2
uint? from = null, to = null;
if(this.dateTimePickerETAFrom.SelectedDate.HasValue)
{
from = this.dateTimePickerETAFrom.SelectedDate.Value.ToUnixTimeStamp();
from = this.dateTimePickerETAFrom.SelectedDate.Value.ToUniversalTime().ToUnixTimeStamp();
}
if(this.dateTimePickerETATo.SelectedDate.HasValue)
{
DateTime toTime = this.dateTimePickerETATo.SelectedDate.Value.Add(new TimeSpan(23, 59, 59)); // search till the end of the "to" day (no time selection)
DateTime toTime = this.dateTimePickerETATo.SelectedDate.Value.ToUniversalTime().Add(new TimeSpan(23, 59, 59)); // search till the end of the "to" day (no time selection)
to = toTime.ToUnixTimeStamp();
}

View File

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:local="clr-namespace:ENI2">
@ -43,6 +44,27 @@
</Setter>
</Style>
<Style TargetType="{x:Type enictrl:StatusWindowBase}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type enictrl:StatusWindowBase}">
<!--Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
/-->
<DockPanel Background="{TemplateBinding Background}" Margin="2">
<!-- TODO das hier lokalisieren! -->
<DockPanel DockPanel.Dock="Bottom" Margin="5">
<Button Width="80" Content="{x:Static p:Resources.textRefresh}" Name="buttonRefresh" Margin="0,0,10,0" Visibility="Hidden" HorizontalAlignment="Left" />
<Button Width="80" Content="{x:Static p:Resources.textClose}" IsDefault="True" IsCancel="False" Name="buttonClose" Margin="0,0,10,0" HorizontalAlignment="Right" />
</DockPanel>
<!-- This ContentPresenter automatically binds to the Content of the Window -->
<ContentPresenter />
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type enictrl:ClosableTabItem}">
<Setter Property="Template">

Binary file not shown.

View File

@ -127,7 +127,10 @@ namespace bsmd.ExcelReadService
}
}
if (result != null)
{
result = result.Trim();
this.stringVals[lookup] = result;
}
return result;
}

View File

@ -1130,8 +1130,7 @@ namespace bsmd.ExcelReadService
}
}
string lastPort = reader.ReadText("NOA_NOD.LastPort");
if (!lastPort.IsNullOrEmpty()) lastPort = lastPort.Trim();
string lastPort = reader.ReadText("NOA_NOD.LastPort")?.Trim();
if (lastPort != null)
{
@ -1240,8 +1239,8 @@ namespace bsmd.ExcelReadService
wdsp.WAS = was;
was.WasteDisposalServiceProvider.Add(wdsp);
}
was.WasteDisposalServiceProvider[0].WasteDisposalServiceProviderName = wastedispServProvName;
was.WasteDisposalServiceProvider[0].WasteDisposalDelivery = was.WasteDisposalDelivery;
((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[0]).WasteDisposalServiceProviderName = wastedispServProvName;
((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[0]).WasteDisposalDelivery = was.WasteDisposalDelivery;
}
reader.Conf.ConfirmText("WAS.WasteDisposalServiceProviderName", wastedispServProvName, wastedispServProvName.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
@ -2517,7 +2516,7 @@ namespace bsmd.ExcelReadService
bool isTransit = false;
// first check with visit/transit ID
string visitTransitId = reader.ReadText("ID");
string visitTransitId = reader.ReadTextNoWhitespace("ID");
if (visitTransitId != null)
{

View File

@ -28,6 +28,7 @@ namespace bsmd.database
private static Dictionary<string, PortArea> allPortAreas;
private object _lock = new object();
private bool _closeConnectionAfterUse = false;
private List<string> truncatedFieldCollection = new List<string>();
#endregion
@ -556,14 +557,15 @@ namespace bsmd.database
public void Save(DatabaseEntity entity)
{
List<string> truncatedFields = new List<string>();
entity.TruncateFields(truncatedFields);
List<string> fieldNames = new List<string>();
entity.TruncateFields(truncatedFields, fieldNames);
foreach(string truncatedField in truncatedFields)
{
_log.WarnFormat("Entity {0} save: Field truncated: {1}", entity.GetType(), truncatedField);
}
this.truncatedFieldCollection.AddRange(fieldNames);
SqlCommand cmd = new SqlCommand();
entity.PrepareSave(cmd);

View File

@ -135,7 +135,7 @@ namespace bsmd.database
/// auftreten kann in der ein Insert/Update an fehlender Datenvalidierung kracht
/// </summary>
/// <param name="truncated"></param>
public virtual void TruncateFields(List<string> truncated)
public virtual void TruncateFields(List<string> truncated, List<string> fieldNames)
{
List<PropertyInfo> props = new List<PropertyInfo>();
@ -154,6 +154,7 @@ namespace bsmd.database
string maxLengthValue = value.Substring(0, maxLengthAttribute.MaxLength);
truncated.Add(string.Format("[{0} ({1})]: {2}", property.Name, maxLengthAttribute.MaxLength, value));
property.SetValue(this, maxLengthValue);
fieldNames.Add(string.Format("{0}.{1}", this.Tablename, property.Name));
}
}
}

View File

@ -52,6 +52,25 @@ namespace bsmd.database
[ENI2Validation]
public byte? FumigatedBulkCargo { get; set; }
/// <summary>
/// ENI-2 Edit Value für Checkbox (OMG!)
/// </summary>
public bool? FumigatedBulkCargoBool
{
get
{
if (this.FumigatedBulkCargo.HasValue) return (this.FumigatedBulkCargo.Value != 0);
return null;
}
set
{
if (value.HasValue)
this.FumigatedBulkCargo = value.Value ? (byte)1 : (byte)0;
else
this.FumigatedBulkCargo = null;
}
}
[ShowReport]
[LookupName("INFO.DeadWeightSummer_TNE")]
[ENI2Validation]

View File

@ -18,7 +18,7 @@ namespace bsmd.database
public class PortOfCallLast30Days : DatabaseEntity, ISublistElement, ISublistContainer
{
private List<PortOfCallLast30DaysCrewJoinedShip> poc30Crew = new List<PortOfCallLast30DaysCrewJoinedShip>();
private List<DatabaseEntity> poc30Crew = new List<DatabaseEntity>();
public PortOfCallLast30Days()
{
@ -29,7 +29,7 @@ namespace bsmd.database
public MDH MDH { get; set; }
public List<PortOfCallLast30DaysCrewJoinedShip> CrewJoinedShip { get { return this.poc30Crew; } }
public List<DatabaseEntity> CrewJoinedShip { get { return this.poc30Crew; } }
[ShowReport]
[Validation2(ValidationCode.LOCODE)]
[MaxLength(5)]
@ -63,7 +63,7 @@ namespace bsmd.database
{
if (i > 0)
sb.Append(", ");
sb.Append(this.CrewJoinedShip[i].PortOfCallLast30DaysCrewJoinedShipName);
sb.Append(((PortOfCallLast30DaysCrewJoinedShip) this.CrewJoinedShip[i]).PortOfCallLast30DaysCrewJoinedShipName);
}
return sb.ToString();
}
@ -115,6 +115,7 @@ namespace bsmd.database
this.CrewJoinedShip.Clear();
// add existing and new crew
this.CrewJoinedShip.AddRange(foundList);
DatabaseEntity.ResetIdentifiers(this.CrewJoinedShip);
}
}
}

View File

@ -27,7 +27,7 @@ namespace bsmd.database
public PortOfCallLast30Days PortOfCallLast30Days { get; set; }
[ShowReport]
[Validation2(ValidationCode.NOT_NULL)]
[Validation2(ValidationCode.NOT_NULL_MAX_LEN, 99)]
[MaxLength(255)]
[ENI2Validation]
public string PortOfCallLast30DaysCrewJoinedShipName { get; set; }

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.9.5")]
[assembly: AssemblyInformationalVersion("3.9.6")]
[assembly: AssemblyCopyright("Copyright © 2014-2017 schick Informatik")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.9.5.*")]
[assembly: AssemblyVersion("3.9.6.*")]

View File

@ -167,12 +167,14 @@ namespace bsmd.database
Validation1Attribute validationAttribute = Attribute.GetCustomAttribute(property, typeof(Validation1Attribute))
as Validation1Attribute;
validationCode = validationAttribute.Code;
maxlen = validationAttribute.MaxLen;
}
else
{
Validation2Attribute validationAttribute = Attribute.GetCustomAttribute(property, typeof(Validation2Attribute))
as Validation2Attribute;
validationCode = validationAttribute.Code;
maxlen = validationAttribute.MaxLen;
}
}
if (validationCode == ValidationCode.NONE)
@ -190,7 +192,7 @@ namespace bsmd.database
if (Attribute.IsDefined(property, typeof(MaxLengthAttribute)))
{
MaxLengthAttribute mla = Attribute.GetCustomAttribute(property, typeof(MaxLengthAttribute)) as MaxLengthAttribute;
if((value.Length >= 50) && (mla.MaxLength == value.Length))
if((value.Length >= 90) && (mla.MaxLength == value.Length))
{
// put out a warning this might be truncated
violations.Add(RuleEngine.CreateViolation(ValidationCode.TRUNCATE, property.Name, value, entity.Title, identifier, entity.Tablename));
@ -347,6 +349,12 @@ namespace bsmd.database
Regex rgx = new Regex(@"^[A-Z, a-z,0-9]{4,7}$");
if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
break;
}
case ValidationCode.MMSI:
{
Regex rgx = new Regex(@"^[0-9]{9}$");
if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
break;
}
default:

View File

@ -38,7 +38,7 @@ namespace bsmd.database
public string CallSign { get; set; }
[ShowReport]
[Validation(ValidationCode.NOT_NULL)]
[Validation(ValidationCode.MMSI)]
[MaxLength(50)]
[ENI2Validation]
public string MMSINumber { get; set; }

View File

@ -45,6 +45,7 @@ namespace bsmd.database
TIME_IMPLAUSIBLE = 26,
PORTAREA,
TRUNCATE = 28,
MMSI = 29,
E121 = 121,
E122 = 122,
E123 = 123,
@ -135,7 +136,7 @@ namespace bsmd.database
public class Validation1Attribute : Attribute
{
private ValidationCode validationCode;
private int maxlen;
public Validation1Attribute(ValidationCode code)
@ -143,6 +144,18 @@ namespace bsmd.database
this.validationCode = code;
}
public Validation1Attribute(ValidationCode code, int maxlen)
{
this.maxlen = maxlen;
this.validationCode = code;
}
public int MaxLen
{
get { return this.maxlen; }
set { this.maxlen = value; }
}
public ValidationCode Code
{
get { return this.validationCode; }
@ -158,12 +171,25 @@ namespace bsmd.database
public class Validation2Attribute : Attribute
{
private ValidationCode validationCode;
private int maxlen;
public Validation2Attribute(ValidationCode code)
{
this.validationCode = code;
}
public Validation2Attribute(ValidationCode code, int maxlen)
{
this.maxlen = maxlen;
this.validationCode = code;
}
public int MaxLen
{
get { return this.maxlen; }
set { this.maxlen = value; }
}
public ValidationCode Code
{
get { return this.validationCode; }

View File

@ -300,7 +300,7 @@ namespace bsmd.database
foreach (Message message in messages)
{
messageLookup.Add(message.MessageNotificationClass, message);
messageLookup[message.MessageNotificationClass] = message;
}
try

View File

@ -18,7 +18,7 @@ namespace bsmd.database
public class WAS : DatabaseEntity, ISublistContainer
{
private ObservableCollection<WasteDisposalServiceProvider> wdsp = new ObservableCollection<WasteDisposalServiceProvider>();
private ObservableCollection<DatabaseEntity> wdsp = new ObservableCollection<DatabaseEntity>();
private ObservableCollection<DatabaseEntity> waste = new ObservableCollection<DatabaseEntity>();
@ -78,7 +78,7 @@ namespace bsmd.database
public ObservableCollection<DatabaseEntity> Waste { get { return this.waste; } }
public ObservableCollection<WasteDisposalServiceProvider> WasteDisposalServiceProvider { get { return this.wdsp; } }
public ObservableCollection<DatabaseEntity> WasteDisposalServiceProvider { get { return this.wdsp; } }
/// <summary>
/// Hilfsproperty, um eine kommaseparierte Liste von WasteDisposalServiceProvider (analog ANSW) im ENI-2 anzuzeigen,
@ -93,7 +93,7 @@ namespace bsmd.database
{
if (i > 0)
sb.Append(", ");
sb.Append(this.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName);
sb.Append(((WasteDisposalServiceProvider) this.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName);
}
return sb.ToString();
}
@ -146,6 +146,7 @@ namespace bsmd.database
// add existing and new providers
foreach(WasteDisposalServiceProvider wdsp in foundList)
this.WasteDisposalServiceProvider.Add(wdsp);
DatabaseEntity.ResetIdentifiers(this.WasteDisposalServiceProvider);
}
}
}

View File

@ -14,7 +14,7 @@ using System.Collections.Generic;
namespace bsmd.database
{
public class WasteDisposalServiceProvider : DatabaseEntity
public class WasteDisposalServiceProvider : DatabaseEntity, ISublistElement
{
public WasteDisposalServiceProvider()
@ -29,16 +29,16 @@ namespace bsmd.database
[ShowReport]
[MaxLength(99)]
[ENI2Validation]
[Validation(ValidationCode.STRING_MAXLEN, 99)]
[Validation(ValidationCode.NOT_NULL_MAX_LEN, 99)]
public string WasteDisposalServiceProviderName { get; set; }
[ShowReport]
[ENI2Validation]
[Validation(ValidationCode.NOT_NULL)]
[Obsolete]
public byte? WasteDisposalDelivery { get; set; }
public string Identifier { get; set; }
public string SublistCollectionKey { get { return "wdsp"; } }
#endregion
#region DatabaseEntity implementation