3.9.5: Kleine Verbesserungen (TRUNCATE Validierung, Copy ID) und Korrekturen

This commit is contained in:
Daniel Schick 2017-12-10 11:47:42 +00:00
parent 7f659144b7
commit 2ee4059926
24 changed files with 171 additions and 36 deletions

View File

@ -175,7 +175,14 @@ namespace ENI2
protected void RegisterTextboxChange(TextBox textBox, Message.NotificationClass notificationClass)
{
this._dpTextBox.AddValueChanged(textBox, this.controlContentChanged);
this._controlClassDict[textBox] = notificationClass;
this._controlClassDict[textBox] = notificationClass;
}
protected void UnregisterTextboxChange(TextBox textBox)
{
this._dpTextBox.RemoveValueChanged(textBox, this.controlContentChanged);
if (this._controlClassDict.ContainsKey(textBox))
this._controlClassDict.Remove(textBox);
}
protected void RegisterDateTimePickerChange(Xceed.Wpf.Toolkit.DateTimePicker dateTimePicker, Message.NotificationClass notificationClass)

View File

@ -377,15 +377,22 @@ namespace ENI2.DetailViewControls
public void UpdateCore()
{
this.UnregisterTextboxChange(this.textBoxDisplayId);
this.textBoxDisplayId.DataContext = null;
this.textBoxDisplayId.DataContext = this.Core;
this.textBoxDisplayId.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
this.RegisterTextboxChange(this.textBoxDisplayId, Message.NotificationClass.ATA);
this.labelBSMDStatusInternal.DataContext = null;
this.labelBSMDStatusInternal.DataContext = this.Core;
this.labelBSMDStatusInternal.GetBindingExpression(Label.ContentProperty)?.UpdateTarget();
MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId));
this.labelBSMDStatusInternal.GetBindingExpression(Label.ContentProperty)?.UpdateTarget();
//MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId));
ShowIdDialog sid = new ShowIdDialog();
sid.DisplayId = this.Core.DisplayId;
sid.Show();
this.Core.IsDirty = false; // ist ja schon gespeichert..
}
#endregion

View File

@ -35,8 +35,8 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>3.9.3.%2a</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.9.5.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@ -308,6 +308,9 @@
<Compile Include="EditControls\NewWithIdDialog.xaml.cs">
<DependentUpon>NewWithIdDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\ShowIdDialog.xaml.cs">
<DependentUpon>ShowIdDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\SimplePropertyViewDialog.xaml.cs">
<DependentUpon>SimplePropertyViewDialog.xaml</DependentUpon>
</Compile>
@ -537,6 +540,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\ShowIdDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\SimplePropertyViewDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -43,9 +43,9 @@ namespace ENI2.EditControls
public string VisitTransitId { get { return this.textBoxVisitTransitId.Text; } }
public string IMO { get { if (this.doubleUpDownIMO.Value.HasValue) return this.doubleUpDownIMO.Value.ToString(); else return null; } }
public string IMO { get { if (this.doubleUpDownIMO.Value.HasValue) return this.doubleUpDownIMO.Value.Value.ToString("0000000"); else return null; } }
public string ENI { get { if (this.doubleUpDownENI.Value.HasValue) return this.doubleUpDownENI.Value.ToString(); else return null; } }
public string ENI { get { if (this.doubleUpDownENI.Value.HasValue) return this.doubleUpDownENI.Value.Value.ToString("00000000"); else return null; } }
public DateTime? ETA { get { return this.datePickerETA.SelectedDate; } }

View File

@ -0,0 +1,22 @@
<Window x:Class="ENI2.EditControls.ShowIdDialog"
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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ENI2.EditControls"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textVisitTransitId}" Height="152" Width="300" WindowStyle="SingleBorderWindow">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Label Content="Id updated:" Grid.Row="0" />
<TextBox IsReadOnly="True" Name="textBoxId" MouseDown="textBoxId_MouseDown" FontWeight="Bold" HorizontalAlignment="Center" VerticalContentAlignment="Center" Margin="2" Grid.Row="1"/>
<Label Content=" -> click to copy" HorizontalAlignment="Center" Grid.Row="2" MouseDown="textBoxId_MouseDown"/>
<Button Grid.Row="3" HorizontalAlignment="Right" Content="OK" Margin="2" Width="100" Click="Button_Click" />
</Grid>
</Window>

View File

@ -0,0 +1,48 @@
// Copyright (c) 2017 schick Informatik
// Description: Info-Dialog wenn eine Id erhalten wird
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for ShowIdDialog.xaml
/// </summary>
public partial class ShowIdDialog : Window
{
public ShowIdDialog()
{
InitializeComponent();
}
public string DisplayId
{
set { this.textBoxId.Text = value; }
get { return this.textBoxId.Text; }
}
private void textBoxId_MouseDown(object sender, MouseButtonEventArgs e)
{
Clipboard.SetText(this.textBoxId.Text);
this.textBoxId.Background = Brushes.LightGreen;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@ -57,10 +57,10 @@ namespace ENI2.EditControls
}
if (this.doubleUpDownIMO.Value.HasValue)
this.Core.IMO = this.doubleUpDownIMO.Value.ToString();
this.Core.IMO = this.doubleUpDownIMO.Value.Value.ToString("0000000");
if (this.doubleUpDownENI.Value.HasValue)
this.Core.ENI = this.doubleUpDownENI.Value.ToString();
this.Core.ENI = this.doubleUpDownENI.Value.Value.ToString("00000000");
this.Core.PoC = this.locodePoC.LocodeValue;
this.Core.Portname = LocodeDB.PortNameFromLocode(this.Core.PoC);

Binary file not shown.

View File

@ -165,7 +165,7 @@ namespace bsmd.database
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
{
foreach (PortOfItinerary poi in this.PortOfItineraries)
RuleEngine.ValidateProperties(poi, errors);
RuleEngine.ValidateProperties(poi, errors, violations);
}
#endregion

View File

@ -330,7 +330,9 @@ namespace bsmd.database
{
result = (Message) messages[0]; // es kann nur eine sein
result.MessageCore = core;
// TODO: abhängige Listen laden?
List<Message> lm = new List<Message>();
lm.Add(result);
this.LoadMessageDependencies(lm);
}
if (this._closeConnectionAfterUse) this.Disconnect();

View File

@ -434,30 +434,30 @@ namespace bsmd.database
foreach (IMDGPosition imdg in this.IMDGPositions)
{
RuleEngine.ValidateProperties(imdg, errors);
RuleEngine.ValidateProperties(imdg, errors, violations);
imdg.Validate(errors, violations);
}
foreach(IBCPosition ibc in this.IBCPositions)
{
RuleEngine.ValidateProperties(ibc, errors);
RuleEngine.ValidateProperties(ibc, errors, violations);
ibc.Validate(errors, violations);
}
foreach(IGCPosition igc in this.IGCPositions)
{
RuleEngine.ValidateProperties(igc, errors);
RuleEngine.ValidateProperties(igc, errors, violations);
}
foreach(IMSBCPosition imsbc in this.IMSBCPositions)
{
RuleEngine.ValidateProperties(imsbc, errors);
RuleEngine.ValidateProperties(imsbc, errors, violations);
imsbc.Validate(errors, violations);
}
foreach(MARPOL_Annex_I_Position marpol in this.MARPOLPositions)
{
RuleEngine.ValidateProperties(marpol, errors);
RuleEngine.ValidateProperties(marpol, errors, violations);
marpol.Validate(errors, violations);
}
}

View File

@ -447,7 +447,7 @@ namespace bsmd.database
violations.Add(RuleEngine.CreateViolation(ValidationCode.V809, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
RuleEngine.ValidateProperties(sr, errors);
RuleEngine.ValidateProperties(sr, errors, violations);
}
#endregion

View File

@ -555,7 +555,7 @@ namespace bsmd.database
foreach (PortOfCallLast30Days poc30d in this.portOfCallLast30Days)
{
RuleEngine.ValidateProperties(poc30d, errors);
RuleEngine.ValidateProperties(poc30d, errors, violations);
poc30d.Validate(errors, violations);
}
}

View File

@ -258,7 +258,7 @@ namespace bsmd.database
{
foreach (PortOfCallLast30DaysCrewJoinedShip poc30Crew in this.CrewJoinedShip)
{
RuleEngine.ValidateProperties(poc30Crew, errors);
RuleEngine.ValidateProperties(poc30Crew, errors, violations);
}
}
}

View File

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

View File

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

View File

@ -134,7 +134,7 @@ namespace bsmd.database
/// </summary>
/// <param name="entity"></param>
/// <param name="errors"></param>
public static void ValidateProperties(DatabaseEntity entity, List<MessageError> errors)
public static void ValidateProperties(DatabaseEntity entity, List<MessageError> errors, List<MessageViolation> violations)
{
string identifier = null;
if (entity is ISublistElement)
@ -186,6 +186,17 @@ namespace bsmd.database
}
}
/// check for truncation warnings
if (Attribute.IsDefined(property, typeof(MaxLengthAttribute)))
{
MaxLengthAttribute mla = Attribute.GetCustomAttribute(property, typeof(MaxLengthAttribute)) as MaxLengthAttribute;
if((value.Length >= 50) && (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));
}
}
// check properties
switch (validationCode)
@ -195,16 +206,21 @@ namespace bsmd.database
break;
case ValidationCode.LOCODE:
{
Regex rgx = new Regex("[A-Z]{2}[A-Z0-9]{3}");
if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
if (_locodeChecker != null)
Regex rgx = new Regex("^[A-Z]{2}[A-Z0-9]{3}$");
if (!rgx.IsMatch(value))
{
errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
}
else if (_locodeChecker != null)
{
if (!_locodeChecker(value, LocodeMode.STANDARD))
errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
}
}
break;
case ValidationCode.LOCODE_NOPORT:
{
Regex rgx = new Regex("[A-Z]{2}[A-Z0-9]{3}");
Regex rgx = new Regex("^[A-Z]{2}[A-Z0-9]{3}$");
if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
if (_locodeChecker != null)
if (!_locodeChecker(value, LocodeMode.NO_PORT_FLAG))
@ -213,7 +229,7 @@ namespace bsmd.database
break;
case ValidationCode.LOCODE_SSN:
{
Regex rgx = new Regex("[A-Z]{2}[A-Z0-9]{3}");
Regex rgx = new Regex("^[A-Z]{2}[A-Z0-9]{3}$");
if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
if (_locodeChecker != null)
if (!_locodeChecker(value, LocodeMode.SSN))
@ -326,6 +342,13 @@ namespace bsmd.database
if ((value.Length > maxlen) || (value.Length == 0))
errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
break;
case ValidationCode.FRZ:
{
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;
}
default:
break;
}
@ -348,7 +371,7 @@ namespace bsmd.database
// individuelle Fehler nach Nachrichtenklasse prüfen
derivedEntity.MessageCore = aMessage.MessageCore; // some instance we need info from core (NOA / Transit)
if ((derivedEntity is LADG) && aMessage.MessageCore.IsTransit) continue; // kein error reporting für LADG bei Transit (CH, 1.2.16)
RuleEngine.ValidateProperties(derivedEntity, errors);
RuleEngine.ValidateProperties(derivedEntity, errors, violations);
derivedEntity.Validate(errors, violations);
}
@ -373,7 +396,7 @@ namespace bsmd.database
// individuelle Fehler nach Nachrichtenklasse prüfen
derivedEntity.MessageCore = entity.MessageCore; // some instance we need info from core (NOA / Transit)
if ((derivedEntity is LADG) && entity.MessageCore.IsTransit) continue; // kein error reporting für LADG bei Transit (CH, 1.2.16)
RuleEngine.ValidateProperties(derivedEntity, errors);
RuleEngine.ValidateProperties(derivedEntity, errors, violations);
derivedEntity.Validate(errors, violations);
}

View File

@ -371,13 +371,13 @@ namespace bsmd.database
foreach (LastTenPortFacilitiesCalled L10Called in this.LastTenPortFacilitesCalled)
{
RuleEngine.ValidateProperties(L10Called, errors);
RuleEngine.ValidateProperties(L10Called, errors, violations);
L10Called.Validate(errors, violations);
}
foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s in this.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
{
RuleEngine.ValidateProperties(s2s, errors);
RuleEngine.ValidateProperties(s2s, errors, violations);
s2s.Validate(errors, violations);
}
}

View File

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

View File

@ -11,6 +11,7 @@ using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using log4net;
namespace bsmd.database
{
@ -18,6 +19,7 @@ namespace bsmd.database
{
private static Regex regexVisit = new Regex("(DE)([A-Z]{3})-([0-9]{4})-([A-Z]{6})", RegexOptions.IgnoreCase);
private static Regex regexTransit = new Regex("(ZZNOK)-([0-9]{4})-([A-Z]{6})", RegexOptions.IgnoreCase);
private static ILog _log = LogManager.GetLogger(typeof(Util));
/// <summary>
/// Extension helper to add values that can be null:
@ -127,7 +129,13 @@ namespace bsmd.database
if(!existingMessages.IsNullOrEmpty())
{
foreach (Message aMessage in existingMessages)
messageDict.Add(aMessage.MessageNotificationClass, aMessage);
{
if(messageDict.ContainsKey(aMessage.MessageNotificationClass))
{
_log.WarnFormat("Core {0} [{1}] has more than one message class for {2}", core.Id, core.DisplayId, aMessage.MessageNotificationClassDisplay);
}
messageDict[aMessage.MessageNotificationClass] = aMessage;
}
}
bool isDE, isDK;

View File

@ -37,12 +37,14 @@ namespace bsmd.database
DOT_NO_COMMA,
VESSEL_TYPE,
NOT_NULL_MAX_LEN,
FRZ,
POSITION_COUNT = 22,
STRING_UNNUMBER = 23,
STRING_IMOCLASS = 24,
DRAUGHT_IMPLAUSIBLE = 25,
TIME_IMPLAUSIBLE = 26,
PORTAREA,
TRUNCATE = 28,
E121 = 121,
E122 = 122,
E123 = 123,

View File

@ -312,10 +312,16 @@ namespace bsmd.database
{
foreach (Waste waste in this.Waste)
{
RuleEngine.ValidateProperties(waste, errors);
RuleEngine.ValidateProperties(waste, errors, violations);
waste.Validate(errors, violations);
}
foreach(WasteDisposalServiceProvider wdsp in this.WasteDisposalServiceProvider)
{
RuleEngine.ValidateProperties(wdsp, errors, violations);
wdsp.Validate(errors, violations);
}
bool entryMissing = false;
int missingType = 0;

View File

@ -108,10 +108,12 @@ namespace bsmd.database
[ShowReport]
[MaxLength(5)]
[ENI2Validation]
[Validation(ValidationCode.LOCODE)]
public string WasteDisposalPort { get; set; }
[ShowReport]
[ENI2Validation]
[Validation(ValidationCode.NOT_NULL)]
public double? WasteAmountGeneratedTillNextPort_MTQ { get; set; }
[ENI2Validation]

View File

@ -27,8 +27,9 @@ namespace bsmd.database
public WAS WAS { get; set; }
[ShowReport]
[MaxLength(100)]
[MaxLength(99)]
[ENI2Validation]
[Validation(ValidationCode.STRING_MAXLEN, 99)]
public string WasteDisposalServiceProviderName { get; set; }
[ShowReport]