Build 3.7.1:

Weiteres Vorgehen bei der Validierung (Bearbeitungsdialog angefangen (ex dashface))
Speicherung der Validierungsregeln usw.
This commit is contained in:
Daniel Schick 2017-09-19 07:52:58 +00:00
parent 707b5c9179
commit f9d5c4f6e3
37 changed files with 1241 additions and 38 deletions

View File

@ -91,6 +91,19 @@ namespace ENI2.Controls
}
}
public bool IsCancelled
{
private get { return false; }
set
{
if (value)
{
this.textBlock.Foreground = Brushes.Gray;
this.textBlock.Background = Brushes.LightGray;
}
}
}
public void SetHeaderText(string headerText, bool lockedTab)
{
// Container for header controls

View File

@ -18,7 +18,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using bsmd.database;
using System.Windows.Controls.Primitives;
namespace ENI2.Controls
{
@ -118,6 +118,48 @@ namespace ENI2.Controls
}
#region public
public DataGridRow GetRow(int index)
{
DataGridRow row = (DataGridRow)this.ItemContainerGenerator.ContainerFromIndex(index);
if(row == null)
{
this.UpdateLayout();
this.ScrollIntoView(this.Items[index]);
row = (DataGridRow)this.ItemContainerGenerator.ContainerFromIndex(index);
}
return row;
}
public DataGridCell GetCell(DataGridRow row, int column)
{
if (row != null)
{
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(row);
if (presenter == null)
{
this.ScrollIntoView(row, this.Columns[column]);
presenter = GetVisualChild<DataGridCellsPresenter>(row);
}
DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
return cell;
}
return null;
}
public DataGridCell GetCell(int rowIndex, int columnIndex)
{
DataGridRow row = this.GetRow(rowIndex);
return this.GetCell(row, columnIndex);
}
#endregion
#region protected
protected void addItem(object sender, RoutedEventArgs e)
{
if (!this.IsReadOnly)
@ -182,6 +224,10 @@ namespace ENI2.Controls
}
}
#endregion
#region private
private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender != null)
@ -197,6 +243,31 @@ namespace ENI2.Controls
}
}
#endregion
#region private static
private static T GetVisualChild<T>(Visual parent) where T : Visual
{
T child = default(T);
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
child = v as T;
if (child == null)
{
child = GetVisualChild<T>(v);
}
if (child != null)
{
break;
}
}
return child;
}
#endregion
}
}

View File

@ -0,0 +1,26 @@
<UserControl x:Class="ENI2.Controls.RuleControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.Controls"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
<GroupBox Name="groupBoxRP" Header="{x:Static p:Resources.textValidation}">
<local:ENIDataGrid Margin="2,8,2,2" x:Name="dataGridValidationRules" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textName}" Binding="{Binding Name}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textContext}" Binding="{Binding Context}" IsReadOnly="True" Width="0.2*" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textIsActive}" Binding="{Binding IsActive}" IsReadOnly="True" Width="0.05*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCreated}" Binding="{Binding Created}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCreatedBy}" Binding="{Binding CreatedBy}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textChanged}" Binding="{Binding Changed}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textChangedBy}" Binding="{Binding ChangedBy}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</local:ENIDataGrid>
</GroupBox>
</UserControl>

View File

@ -0,0 +1,95 @@
// Copyright (c) 2017 schick Informatik
// Description: Liste der Validierungsregeln
//
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using bsmd.database;
using ENI2.EditControls;
namespace ENI2.Controls
{
/// <summary>
/// Interaction logic for RuleControl.xaml
/// </summary>
public partial class RuleControl : UserControl
{
public RuleControl()
{
InitializeComponent();
Loaded += RuleControl_Loaded;
}
public List<bsmd.database.ValidationRule> ValidationRules { get; set; }
public ReportingParty UserEntity { get; set; }
private void RuleControl_Loaded(object sender, RoutedEventArgs e)
{
this.dataGridValidationRules.Initialize();
this.dataGridValidationRules.ItemsSource = this.ValidationRules;
this.dataGridValidationRules.CreateRequested += DataGridValidationRules_CreateRequested;
this.dataGridValidationRules.AddingNewItem += DataGridValidationRules_AddingNewItem;
this.dataGridValidationRules.EditRequested += DataGridValidationRules_EditRequested;
this.dataGridValidationRules.DeleteRequested += DataGridValidationRules_DeleteRequested;
}
private void DataGridValidationRules_DeleteRequested(bsmd.database.DatabaseEntity obj)
{
bsmd.database.ValidationRule vr = obj as bsmd.database.ValidationRule;
if (vr != null)
{
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(vr);
this.ValidationRules.Remove(vr);
this.dataGridValidationRules.Items.Refresh();
}
}
private void DataGridValidationRules_EditRequested(bsmd.database.DatabaseEntity obj)
{
bsmd.database.ValidationRule vr = obj as bsmd.database.ValidationRule;
if (vr != null)
{
EditRulesDialog eld = new EditRulesDialog();
eld.ValidationRule = vr;
if (eld.ShowDialog() ?? false)
{
if (!vr.IsNew)
{
vr.Changed = DateTime.Now;
vr.ChangedBy = this.UserEntity.Logon;
}
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(vr);
this.dataGridValidationRules.Items.Refresh();
}
}
}
private void DataGridValidationRules_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridValidationRules_CreateRequested();
}
private void DataGridValidationRules_CreateRequested()
{
bsmd.database.ValidationRule vr = new bsmd.database.ValidationRule();
vr.Created = DateTime.Now;
vr.CreatedBy = this.UserEntity.Logon;
EditRulesDialog erd = new EditRulesDialog();
erd.ValidationRule = vr;
if (erd.ShowDialog() ?? false)
{
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(vr);
this.ValidationRules.Add(vr);
this.dataGridValidationRules.Items.Refresh();
}
}
}
}

View File

@ -138,7 +138,7 @@ namespace ENI2
detailControl.Initialize();
detailControl.IsEnabled = !this.LockedByOtherUser;
if (!detailControl.IsEnabled && (detailControl is OverViewDetailControl))
if (!detailControl.IsEnabled && (detailControl is OverViewDetailControl) && !(_core.Cancelled ?? false))
((OverViewDetailControl)detailControl).ShowLockedBy(this.LockedBy);
controlCache.Add(mg.MessageGroupName, detailControl);

View File

@ -37,9 +37,9 @@
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPortOfItinerary" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textPortname}" Binding="{Binding PortOfItineraryName, Mode=TwoWay}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Binding="{Binding PortOfItineraryLocode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textETA}" Binding="{Binding PortOfItineraryETA, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}, StringFormat=\{0:dd.MM.yy HH:mm\}}" IsReadOnly="True" Width="0.6*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortname}" Binding="{Binding PortOfItineraryName, Mode=TwoWay}" IsReadOnly="True" Width="0.5*" />
<!--DataGridTextColumn Binding="{Binding PortOfItineraryLocode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" /-->
<DataGridTextColumn Header="{x:Static p:Resources.textETA}" Binding="{Binding PortOfItineraryETA, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}, StringFormat=\{0:dd.MM.yy HH:mm\}}" IsReadOnly="True" Width="0.5*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>

View File

@ -33,7 +33,7 @@
<CheckBox Name="checkBoxDangerousGoodsOnBoard" IsChecked="{Binding NoDPGOnBoardOnArrival, Converter={util:InverseBooleanConverter}}" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"/>
<CheckBox Name="checkBoxDGManifestOnBoard" IsChecked="{Binding DPGManifestOnBoardOnArrival}" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"/>
<CheckBox Name="checkBoxMoUBaltic" IsChecked="{Binding MOUBaltic}" Grid.Row="1" Grid.Column="3" VerticalAlignment="Center"/>
<ComboBox x:Name="comboBoxVesselClass" Grid.Row="1" Grid.Column="1" Margin="2" SelectedIndex="{Binding INFShipClass, Converter={util:ByteConverter}}" ContextMenu="{DynamicResource ClearContextMenu}"/>
<ComboBox x:Name="comboBoxVesselClass" Grid.Row="1" Grid.Column="1" Margin="2" SelectedIndex="{Binding INFShipClass, Converter={util:ByteConverter}}" ContextMenu="{DynamicResource ClearContextMenu}" IsEditable="True" />
<TabControl Name="tabControlPositions" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="5">
<TabItem Header="{x:Static p:Resources.textIMDGItems}" Name="tabIMDGItems">
<enictrl:ENIDataGrid x:Name="dataGridIMDGItems" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"

View File

@ -75,7 +75,7 @@
<CheckBox Name="checkBoxWasMedicalConsulted" IsChecked="{Binding MedicalConsulted}" Grid.Row="8" Grid.Column="3" VerticalAlignment="Center"/>
<CheckBox Name="checkBoxAwareOfConditions" IsChecked="{Binding AwareOfFurtherInfections}" Grid.Row="9" Grid.Column="1" VerticalAlignment="Center"/>
<CheckBox Name="checkBoxStowawaysOnBoard" IsChecked="{Binding StowawaysDetected}" Grid.Row="11" Grid.Column="1" VerticalAlignment="Center"/>
<TextBox Name="textBoxStowawaysJoiningLocation" Grid.Row="11" Grid.RowSpan="3" Grid.Column="3" MaxLength="100" Text="{Binding StowawaysJoiningLocationText}" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxStowawaysJoiningLocation" Grid.Row="11" Grid.RowSpan="3" Grid.Column="3" MaxLength="100" Text="{Binding StowawaysJoiningLocationText}" Margin="2" VerticalContentAlignment="Top"/>
<CheckBox Name="checkBoxSickAnimalsOrPets" IsChecked="{Binding SickAnimalOrPetOnBoard}" Grid.Row="12" Grid.Column="1" VerticalAlignment="Center"/>
<CheckBox Name="checkBoxSanitaryControlExemption" IsChecked="{Binding ValidSanitaryControlExemptionOrCertificateOnBoard}" Grid.Row="13" Grid.Column="1" VerticalAlignment="Center"/>
<TextBox Name="textBoxPlaceOfIssue" Grid.Row="14" Grid.Column="1" MaxLength="100" Text="{Binding PlaceOfIssue}" Margin="2" />

View File

@ -35,6 +35,7 @@
<RowDefinition Height="28" />
<RowDefinition Height="4" />
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="4" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@ -105,9 +106,10 @@
</Button>
-->
</StackPanel>
<Label Grid.Column="0" Grid.Row="7" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelCancelled" VerticalContentAlignment="Center" FontWeight="Bold" />
<!-- Data Grid -->
<DataGrid Grid.Row="8" Grid.ColumnSpan="6" Margin="0,8,0,0" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False"
<DataGrid Grid.Row="9" Grid.ColumnSpan="6" Margin="0,8,0,0" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False"
SelectionMode="Extended" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown">
<DataGrid.Columns>
<DataGridTemplateColumn Header=" " Width="SizeToCells" IsReadOnly="True">

View File

@ -13,6 +13,7 @@ using bsmd.database;
using ENI2.EditControls;
using System.Windows.Media.Imaging;
using System.Collections.Generic;
using System.Windows.Media;
namespace ENI2.DetailViewControls
{
@ -70,6 +71,8 @@ namespace ENI2.DetailViewControls
vtBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
BindingOperations.SetBinding(textBoxDisplayId, TextBox.TextProperty, vtBinding);
if (this.Core.Cancelled ?? false) this.ShowCancelledLabel();
#region Meldeklassen einrichten und Icons / Gruppen / Index zuordnen
foreach (Message aMessage in this.Messages)
@ -339,6 +342,12 @@ namespace ENI2.DetailViewControls
this.OnJumpToListElementRequest(message.ENINotificationDetailIndex);
}
private void ShowCancelledLabel()
{
this.labelCancelled.Content = Properties.Resources.textCancelled;
this.labelCancelled.Background = Brushes.Yellow;
}
#endregion
#region mouse event handler
@ -426,6 +435,7 @@ namespace ENI2.DetailViewControls
if (result == MessageBoxResult.Yes)
{
this.Core.Cancelled = true;
this.ShowCancelledLabel();
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core);
}
}

View File

@ -35,8 +35,8 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>3.6.15.%2a</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.7.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@ -175,6 +175,9 @@
<Compile Include="Controls\ReportingPartyControl.xaml.cs">
<DependentUpon>ReportingPartyControl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\RuleControl.xaml.cs">
<DependentUpon>RuleControl.xaml</DependentUpon>
</Compile>
<Compile Include="CustomCommands.cs" />
<Compile Include="DetailBaseControl.cs" />
<Compile Include="DetailRootControl.xaml.cs">
@ -264,6 +267,9 @@
<Compile Include="EditControls\EditReportingPartyDialog.xaml.cs">
<DependentUpon>EditReportingPartyDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\EditRulesDialog.xaml.cs">
<DependentUpon>EditRulesDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\EditSanitaryMeasureDialog.xaml.cs">
<DependentUpon>EditSanitaryMeasureDialog.xaml</DependentUpon>
</Compile>
@ -334,6 +340,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\RuleControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ControlTemplates.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -454,6 +464,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\EditRulesDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\EditSanitaryMeasureDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -596,6 +610,10 @@
<Resource Include="Resources\recycle.png" />
<Resource Include="Resources\check.png" />
<Resource Include="Resources\hand_red_card.png" />
<Resource Include="Resources\logic_and.png" />
<Resource Include="Resources\logic_not.png" />
<Resource Include="Resources\logic_or.png" />
<Resource Include="Resources\logic_xor.png" />
<Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -32,7 +32,7 @@ namespace ENI2.EditControls
this.OKClicked += EditPortOfItineraryDialog_OKClicked;
// copy into fields
this.textBoxPortName.Text = this.PortOfItinerary.PortOfItineraryLocode;
this.textBoxPortName.Text = this.PortOfItinerary.PortOfItineraryName;
this.dateTimePickerETA.Value = this.PortOfItinerary.PortOfItineraryETA.HasValue ? ((DateTime?) DateTime.SpecifyKind(this.PortOfItinerary.PortOfItineraryETA.Value, DateTimeKind.Utc).ToLocalTime()) : null;
this.AddVisible = true;
}
@ -40,8 +40,19 @@ namespace ENI2.EditControls
public void CopyValuesToEntity()
{
// copy back
string portNameFromLocode = null;
if(!this.textBoxPortName.Text.IsNullOrEmpty() && (this.textBoxPortName.Text.Length == 5))
portNameFromLocode = LocodeDB.PortNameFromLocode(this.textBoxPortName.Text.ToUpper());
if(!portNameFromLocode.IsNullOrEmpty()) // der Anwender hat einen Locode eingetragen
{
this.PortOfItinerary.PortOfItineraryLocode = this.textBoxPortName.Text;
this.PortOfItinerary.PortOfItineraryName = this.PortOfItinerary.PortOfItineraryLocode.IsNullOrEmpty() ? "" : LocodeDB.PortNameFromLocode(this.PortOfItinerary.PortOfItineraryLocode);
this.PortOfItinerary.PortOfItineraryName = portNameFromLocode;
}
else // einfach Hafen als Text direkt übernehmen
{
this.PortOfItinerary.PortOfItineraryName = this.textBoxPortName.Text;
}
this.PortOfItinerary.PortOfItineraryETA = this.dateTimePickerETA.Value.HasValue ? ((DateTime?)DateTime.SpecifyKind(this.dateTimePickerETA.Value.Value, DateTimeKind.Local).ToUniversalTime()) : null;
}

View File

@ -0,0 +1,48 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.EditRulesDialog"
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:enictrl="clr-namespace:ENI2.Controls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textEditRules}" Height="410" Width="800" WindowStyle="SingleBorderWindow" Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="32" />
<RowDefinition Height="200" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Name="labelName" Content="{x:Static p:Resources.textName}" Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Right" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxName" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center" Margin="2" />
<Label Name="labelContext" Content="{x:Static p:Resources.textContext}" Grid.Row="0" Grid.Column="2" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<TextBox Name="textBoxContext" Grid.Row="0" Grid.Column="3" VerticalContentAlignment="Center" Margin="2" />
<Label Name="labelChanged" Content="{x:Static p:Resources.textChanged}" Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<TextBlock Name="textBlockChanged" Grid.Row="1" Grid.Column="1" FontWeight="Bold" VerticalAlignment="Center" />
<Label Name="labelChangedBy" Content="{x:Static p:Resources.textChangedBy}" Grid.Row="1" Grid.Column="2" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<TextBlock Name="textBlockChangedBy" Grid.Row="1" Grid.Column="3" FontWeight="Bold" VerticalAlignment="Center" />
<Label Name="labelCreated" Content="{x:Static p:Resources.textCreated}" Grid.Row="2" Grid.Column="0" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<TextBlock Name="textBlockCreated" Grid.Row="2" Grid.Column="1" FontWeight="Bold" VerticalAlignment="Center" />
<Label Name="labelCreatedBy" Content="{x:Static p:Resources.textCreatedBy}" Grid.Row="2" Grid.Column="2" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<TextBlock Name="textBlockCreatedBy" Grid.Row="2" Grid.Column="3" FontWeight="Bold" VerticalAlignment="Center" />
<Label Name="labelIsActive" Content="{x:Static p:Resources.textIsActive}" Grid.Row="3" Grid.Column="0" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" />
<CheckBox Name="checkBoxIsActive" Grid.Row="3" Grid.Column="1" VerticalContentAlignment="Center" Margin="2" />
<TreeView Name="treeViewRules" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Margin="2"/>
<GroupBox Name="groupBoxConditionDetails" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Margin="0" Header="{x:Static p:Resources.textCondition}">
<Grid>
</Grid>
</GroupBox>
</Grid>
</enictrl:EditWindowBase>

View File

@ -0,0 +1,210 @@
// Copyright (c) 2017 schick Informatik
// Description: Bearbeitungsdialog für Validierungsregeln
//
using System.Windows;
using System.Collections.Generic;
using bsmd.database;
using ENI2.Controls;
using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for EditRulesDialog.xaml
/// </summary>
public partial class EditRulesDialog : EditWindowBase
{
public EditRulesDialog()
{
InitializeComponent();
Loaded += EditRulesDialog_Loaded;
}
#region Properties
public bsmd.database.ValidationRule ValidationRule { get; set; }
public ConditionGroup RootCondition
{
get
{
if (this.treeViewRules.Items.Count == 0)
{
return null;
}
else
{
ConditionGroup cg = new ConditionGroup();
cg.Conditions = new List<ValidationCondition>();
cg.SubGroups = new List<ConditionGroup>();
cg.GroupOperator = ((GroupNode)this.treeViewRules.Items[0]).ConditionGroup.GroupOperator;
this.BuildConditionGroups(this.treeViewRules.Items, cg);
return cg;
}
}
set
{
if (value == null) return;
GroupNode rootNode = this.CreateGroupNode(value);
this.treeViewRules.Items.Add(rootNode);
this.BuildTree(rootNode.Items, value);
}
}
private void BuildTree(ItemCollection items, ConditionGroup root)
{
if (root.Conditions == null)
root.Conditions = new List<ValidationCondition>();
foreach (ValidationCondition vc in root.Conditions)
{
ConditionNode cn = new ConditionNode();
cn.Condition = vc;
cn.Header = cn.ToString();
//cn.ImageIndex = 4; // TODO : set image
//cn.SelectedImageIndex = 4;
items.Add(cn);
}
if (root.SubGroups == null)
root.SubGroups = new List<ConditionGroup>();
foreach (ConditionGroup cg in root.SubGroups)
{
GroupNode gn = this.CreateGroupNode(cg);
items.Add(gn);
this.BuildTree(gn.Items, cg);
}
}
private GroupNode CreateGroupNode(ConditionGroup cg)
{
GroupNode gn = new GroupNode();
gn.ConditionGroup = cg;
gn.Header = gn.ToString();
// TODO: Icon setzen je nach typ
return gn;
}
private void BuildConditionGroups(ItemCollection items, ConditionGroup parent)
{
foreach(TreeViewItem node in items)
{
if(node is ConditionNode)
{
parent.Conditions.Add(((ConditionNode)node).Condition);
}
else
{
ConditionGroup cg = ((GroupNode) node).ConditionGroup;
cg.Conditions.Clear();
parent.SubGroups.Add(cg);
this.BuildConditionGroups(node.Items, cg); // recurse down
}
}
}
#endregion
private void EditRulesDialog_Loaded(object sender, RoutedEventArgs e)
{
this.textBlockChanged.Text = this.ValidationRule.Changed?.ToString();
this.textBlockChangedBy.Text = this.ValidationRule.ChangedBy;
this.textBlockCreated.Text = this.ValidationRule.Created.ToString();
this.textBlockCreatedBy.Text = this.ValidationRule.CreatedBy;
this.textBoxName.Text = this.ValidationRule.Name;
this.textBoxContext.Text = this.ValidationRule.Context;
this.checkBoxIsActive.IsChecked = this.ValidationRule.IsActive;
// TODO: init logic tree with rule
this.OKClicked += EditRulesDialog_OKClicked;
this.AddVisible = false;
// init tree context Menu
this.treeViewRules.ContextMenu = new ContextMenu();
MenuItem addItem = new MenuItem();
addItem.Header = Properties.Resources.textNewGroup;
addItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/add.png")) };
addItem.Click += this.createNewGroup;
this.treeViewRules.ContextMenu.Items.Add(addItem);
MenuItem deleteItem = new MenuItem();
deleteItem.Header = Properties.Resources.textDelete;
deleteItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/delete.png")) };
deleteItem.Click += this.deleteItem;
this.treeViewRules.ContextMenu.Items.Add(deleteItem);
}
private void deleteItem(object sender, RoutedEventArgs e)
{
}
private void createNewGroup(object sender, RoutedEventArgs e)
{
}
public void CopyValuesToEntity()
{
this.ValidationRule.Name = this.textBoxName.Text;
this.ValidationRule.Context = this.textBoxContext.Text;
this.ValidationRule.IsActive = this.checkBoxIsActive.IsChecked;
// TODO: serialize logical tree back into string
this.ValidationRule.Rule = bsmd.database.ValidationCondition.SaveToString(this.RootCondition);
}
private void EditRulesDialog_OKClicked()
{
this.CopyValuesToEntity();
}
#region class GroupNode
internal class GroupNode : TreeViewItem
{
public ConditionGroup ConditionGroup { get; set; }
public override string ToString()
{
if (this.ConditionGroup == null) return "+++";
return string.Format("{0}", Enum.GetName(typeof(ConditionGroup.GroupOperatorEnum), this.ConditionGroup.GroupOperator));
}
}
#endregion
#region class ConditionNode
internal class ConditionNode : TreeViewItem
{
public ValidationCondition Condition { get; set; }
public override string ToString()
{
if (this.Condition == null) return "---";
return string.Format("{0} {1} {2}",
this.Condition.FieldName,
Enum.GetName(typeof(ValidationCondition.ConditionOperatorEnum), this.Condition.ConditionOperator),
this.Condition.Value);
}
}
#endregion
}
}

View File

@ -65,12 +65,14 @@
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" x:Name="logoImage" HorizontalAlignment="Left" Height="75" Width="75" Source="Resources/EUREPORT.png" Stretch="Fill" MouseUp="logoImage_MouseUp" Margin="2"/>
<Button Grid.Column="1" x:Name="buttonNewId" Content="{x:Static p:Resources.textNewVisitTransitId}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="buttonNewTransitIdClick" Background="Transparent" Margin="2"/>
<Button Grid.Column="2" x:Name="buttonNewWithId" Content="{x:Static p:Resources.textNewWithId}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="buttonNewWithIdClick" Background="Transparent" Margin="2"/>
<Button Grid.Column="3" x:Name="buttonUserAdmin" Content="{x:Static p:Resources.textUserAdministration}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="auto" Click="buttonUserAdmin_Click" Background="Transparent" Visibility="Hidden" Margin="2"/>
<Button Grid.Column="4" x:Name="buttonEditRules" Content="{x:Static p:Resources.textEditRules}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="auto" Click="buttonEditRules_Click" Background="Transparent" Visibility="Hidden" Margin="2" />
</Grid>
<Grid DockPanel.Dock="Bottom" Height="22" Background="#FFE8F6FF">

View File

@ -32,7 +32,9 @@ namespace ENI2
#region Fields
private bool userAdministrationVisible;
private bool rulesVisible;
private ReportingPartyControl rpControl;
private RuleControl ruleControl;
private bool dbConnected;
private SucheControl sucheControl;
private List<MessageCore> anmeldungen = new List<MessageCore>();
@ -80,6 +82,9 @@ namespace ENI2
// try to lock the item
Guid lockedUserId = Guid.Empty;
if (!(aMessageCore.Cancelled ?? false))
{
try
{
lockedUserId = App.LockingServiceClient.Lock(aMessageCore.Id.Value, this.userEntity.Id.Value);
@ -93,16 +98,22 @@ namespace ENI2
// TODO: wenn der Locking Service nicht erreichbar ist sollte das Ganze trotzdem noch irgendwie funktionieren
_log.ErrorFormat("LockingService.Lock: {0}", ex.Message);
}
bool iDidLockIt = (lockedUserId == Guid.Empty);
}
bool iDidLockIt = (lockedUserId == Guid.Empty) && !(aMessageCore.Cancelled ?? false);
searchResultItem.TabClosing += SearchResultItem_TabClosing;
DateTime? eta = aMessageCore.IsTransit ? aMessageCore.ETAKielCanal : aMessageCore.ETA;
searchResultItem.SetHeaderText(string.Format("{0} [{1}-{2}]", aMessageCore.Shipname, aMessageCore.PoC, eta.HasValue ? eta.Value.ToShortDateString() : ""),
iDidLockIt);
searchResultItem.IsCancelled = aMessageCore.Cancelled ?? false;
DetailRootControl drc = new DetailRootControl(aMessageCore);
drc.LockedByOtherUser = !iDidLockIt;
if (!aMessageCore.Cancelled ?? false)
{
drc.LockedBy = iDidLockIt ? this.userEntity : DBManager.Instance.GetReportingPartyDict()[lockedUserId];
}
searchResultItem.Content = drc;
this.mainFrame.Items.Add(searchResultItem);
@ -194,6 +205,29 @@ namespace ENI2
this.userAdministrationVisible = !this.userAdministrationVisible; // toggle
}
private void buttonEditRules_Click(object sender, RoutedEventArgs e)
{
if(this.rulesVisible)
{
this.rootContainer.Children.Remove(ruleControl);
this.rootContainer.Children.Add(this.mainFrame);
this.buttonEditRules.Content = Properties.Resources.textEditRules;
}
else
{
this.rootContainer.Children.Remove(this.mainFrame);
if(this.ruleControl == null)
{
this.ruleControl = new RuleControl();
this.ruleControl.UserEntity = this.userEntity;
this.ruleControl.ValidationRules = DBManager.Instance.GetValidationRules();
}
this.rootContainer.Children.Add(ruleControl);
this.buttonEditRules.Content = Properties.Resources.textNotifications;
}
this.rulesVisible = !this.rulesVisible;
}
#endregion
#region window lifetime event handler
@ -275,7 +309,6 @@ namespace ENI2
}
}
}
}
private void CanExecuteClearCommand(object sender, CanExecuteRoutedEventArgs e)
@ -454,7 +487,11 @@ namespace ENI2
this.busyIndicator.IsBusy = false;
this.labelStatusBar.Text = string.Format("Rep.Party: {0} {1} [{2}]", this.userEntity.FirstName, this.userEntity.LastName, this.userEntity.Logon);
App.UserId = this.userEntity.Id;
if (this.userEntity.IsAdmin) this.buttonUserAdmin.Visibility = Visibility.Visible;
if (this.userEntity.IsAdmin)
{
this.buttonUserAdmin.Visibility = Visibility.Visible;
this.buttonEditRules.Visibility = Visibility.Visible;
}
break;
case ReportingParty.LogonResult.FAILED:
this.labelLoginResult.Content = Properties.Resources.textWrongPassword;

View File

@ -410,6 +410,46 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap logic_and {
get {
object obj = ResourceManager.GetObject("logic_and", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap logic_not {
get {
object obj = ResourceManager.GetObject("logic_not", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap logic_or {
get {
object obj = ResourceManager.GetObject("logic_or", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap logic_xor {
get {
object obj = ResourceManager.GetObject("logic_xor", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
@ -849,6 +889,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Cancelled.
/// </summary>
public static string textCancelled {
get {
return ResourceManager.GetString("textCancelled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Confirm deletion.
/// </summary>
@ -1065,6 +1114,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Condition.
/// </summary>
public static string textCondition {
get {
return ResourceManager.GetString("textCondition", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Confirmation.
/// </summary>
@ -1155,6 +1213,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Context.
/// </summary>
public static string textContext {
get {
return ResourceManager.GetString("textContext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Control temperature.
/// </summary>
@ -1209,6 +1276,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Created by.
/// </summary>
public static string textCreatedBy {
get {
return ResourceManager.GetString("textCreatedBy", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Create PDF.
/// </summary>
@ -1533,6 +1609,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Edit rules.
/// </summary>
public static string textEditRules {
get {
return ResourceManager.GetString("textEditRules", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to E-Mail.
/// </summary>
@ -2046,6 +2131,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Is active.
/// </summary>
public static string textIsActive {
get {
return ResourceManager.GetString("textIsActive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ISM company.
/// </summary>
@ -2541,6 +2635,24 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to New condition.
/// </summary>
public static string textNewCondition {
get {
return ResourceManager.GetString("textNewCondition", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New group.
/// </summary>
public static string textNewGroup {
get {
return ResourceManager.GetString("textNewGroup", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Create new id.
/// </summary>
@ -3855,6 +3967,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Validation.
/// </summary>
public static string textValidation {
get {
return ResourceManager.GetString("textValidation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Valid exemption.
/// </summary>

View File

@ -1447,4 +1447,43 @@
<data name="textSendDate" xml:space="preserve">
<value>Send date</value>
</data>
<data name="textCancelled" xml:space="preserve">
<value>Cancelled</value>
</data>
<data name="textEditRules" xml:space="preserve">
<value>Edit rules</value>
</data>
<data name="textContext" xml:space="preserve">
<value>Context</value>
</data>
<data name="textCreatedBy" xml:space="preserve">
<value>Created by</value>
</data>
<data name="textIsActive" xml:space="preserve">
<value>Is active</value>
</data>
<data name="textValidation" xml:space="preserve">
<value>Validation</value>
</data>
<data name="logic_and" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logic_and.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="logic_not" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logic_not.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="logic_or" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logic_or.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="logic_xor" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logic_xor.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textCondition" xml:space="preserve">
<value>Condition</value>
</data>
<data name="textNewCondition" xml:space="preserve">
<value>New condition</value>
</data>
<data name="textNewGroup" xml:space="preserve">
<value>New group</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -60,6 +60,16 @@
</Grid>
<DataGrid Grid.Row="1" Margin="0,8,0,0" x:Name="dataGrid" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False"
SelectionMode="Single" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown" >
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Cancelled}" Value="true">
<Setter Property="Background" Value="LightGray"></Setter>
<Setter Property="Foreground" Value="Gray"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Type" Binding="{Binding HerbergReportType}" IsReadOnly="True" />
<DataGridTextColumn Header="IMO" Binding="{Binding IMO}" IsReadOnly="True" />

View File

@ -24,6 +24,7 @@ namespace ENI2.Util
private static Brush textBoxDefaultColor;
private static Brush intUpDownDefaultColor;
private static Brush doubleUpDownDefaultColor;
private static Brush checkBoxDefaultColor;
#region Construction
@ -192,6 +193,21 @@ namespace ENI2.Util
}
}
if(control is CheckBox)
{
CheckBox cb = (CheckBox)control;
if (checkBoxDefaultColor == null)
checkBoxDefaultColor = cb.Background;
switch(highlightStyle)
{
case HighlightStyle.ERROR:
cb.Background = new SolidColorBrush(Color.FromArgb(150, 255, 0, 0));
break;
}
}

View File

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup.Primitives;
using bsmd.database;
namespace ENI2.Util
{
@ -102,6 +103,8 @@ namespace ENI2.Util
ICollection<DependencyObject> sources)
{
var dependencyProperties = new List<DependencyProperty>();
if ((dependencyObject == null) || (propertyName.IsNullOrEmpty())) return; // sanity
dependencyProperties.AddRange(MarkupWriter.GetMarkupObjectFor(dependencyObject).Properties.Where(x => x.DependencyProperty != null).Select(x => x.DependencyProperty).ToList());
dependencyProperties.AddRange(MarkupWriter.GetMarkupObjectFor(dependencyObject).Properties.Where(x => x.IsAttached && x.DependencyProperty != null).Select(x => x.DependencyProperty).ToList());

Binary file not shown.

View File

@ -0,0 +1,15 @@
CREATE TABLE [dbo].[ValidationRule] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR (100) NULL,
[Context] NVARCHAR (255) NULL,
[Rule] NVARCHAR (MAX) NULL,
[Changed] DATETIME NULL,
[ChangedBy] NVARCHAR (100) NULL,
[Created] DATETIME NULL,
[CreatedBy] NVARCHAR (100) NULL,
[IsActive] BIT NULL,
CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED ([Id] ASC)
);
GO

View File

@ -315,6 +315,11 @@ namespace bsmd.ExcelReadService
{
reader.Conf.ConfirmText(bpolLocode, poi.PortOfItineraryLocode, ExcelReader.ReadState.WARN);
}
if(poi.PortOfItineraryName.IsNullOrEmpty() && !poi.PortOfItineraryLocode.IsNullOrEmpty() && (poi.PortOfItineraryLocode.Length == 5))
{
poi.PortOfItineraryName = LocodeDB.PortNameFromLocode(poi.PortOfItineraryLocode);
}
poi.PortOfItineraryETA = reader.ReadDateTime(bpolETADate, bpolETATime);
}
}

View File

@ -365,6 +365,19 @@ namespace bsmd.database
return DBManager.allReportingParties;
}
public List<ValidationRule> GetValidationRules()
{
ValidationRule vr = new ValidationRule();
SqlCommand cmd = new SqlCommand();
vr.PrepareLoadCommand(cmd, Message.LoadFilter.ALL);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> allRules = vr.LoadList(reader);
List<ValidationRule> result = new List<ValidationRule>();
foreach (ValidationRule aVR in allRules)
result.Add(aVR);
return result;
}
public Dictionary<string, PortArea> GetPortAreaDict()
{
if(DBManager.allPortAreas == null)
@ -672,10 +685,12 @@ namespace bsmd.database
}
}
}
/* Meldung ist überflüssig
else
{
_log.DebugFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass);
}
*/
}
}

View File

@ -53,7 +53,7 @@ namespace bsmd.database
[ShowReport]
[LookupName("INFO.PortArea")]
[Validation(ValidationCode.NOT_NULL)]
// [Validation(ValidationCode.NOT_NULL)] // ist bei NOK Transit leer
[MaxLength(50)]
public string PortArea { get; set; }

View File

@ -72,7 +72,7 @@ namespace bsmd.database
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, ImportHeaderId, NotificationClass, Name, Value, Identifier FROM {0} ", this.Tablename);
string query = string.Format("SELECT Id, ImportHeaderId, NotificationClass, Name, Value, Identifier, Status FROM {0} ", this.Tablename);
switch (filter)
{
@ -134,6 +134,11 @@ namespace bsmd.database
dc.AllowDBNull = true;
dc.DataType = Type.GetType("System.Int32");
}
else if(p.Name == "Status")
{
dc.AllowDBNull = true;
dc.DataType = Type.GetType("System.Byte");
}
else
{
dc.DataType = propType;

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.6.16")]
[assembly: AssemblyInformationalVersion("3.7.0")]
[assembly: AssemblyCopyright("Copyright © 2014-2017 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]

View File

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

View File

@ -0,0 +1,306 @@
// Copyright (c) 2015-2017 schick Informatik
// Description: Validierungsbedingung, die (als Gruppe) als Validierungsregel serialisiert und
// ausgewertet wird
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using log4net;
namespace bsmd.database
{
public class ValidationCondition : ICloneable
{
private static ILog log = LogManager.GetLogger(typeof(ValidationCondition));
public ValidationCondition() { }
public enum ConditionOperatorEnum
{
EQUAL,
NOT_EQUAL,
GREATER,
LESS
}
#region Properties
public string FieldName { get; set; }
public ConditionOperatorEnum ConditionOperator { get; set; }
public string Value { get; set; }
public string ErrorMessage { get; set; }
#endregion
#region static methods
public static bool? CheckConditions(MessageCore core, List<Message> messages, ConditionGroup cGroup, out string message)
{
bool? result = null;
message = "";
bool conditionResult = false;
try
{
foreach (ValidationCondition condition in cGroup.Conditions)
{
object[] otherargs = null;
// switch case type
string errorMessage = condition.ErrorMessage;
if (otherargs != null)
errorMessage = string.Format(errorMessage, otherargs);
result = ValidationCondition.CombineConditions(result, conditionResult, cGroup.GroupOperator);
// Fehlermeldung hinzufügen falls Bedingung verletzt wurde
if (!conditionResult && ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.AND) || (cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.OR)))
message += string.Format("- {0}{1}", errorMessage, Environment.NewLine);
//if (conditionResult && ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.NAND) || (cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.NOR)))
// message += string.Format("- {0}{1}", errorMessage, Environment.NewLine);
}
// check internal groups recursively
foreach (ConditionGroup subGroup in cGroup.SubGroups)
{
string subMessage = "";
bool? subResult = ValidationCondition.CheckConditions(core, messages, subGroup, out subMessage);
if (!subResult.HasValue) // an error occurred evaluating this element
{
return subResult;
}
else
{
result = ValidationCondition.CombineConditions(result, subResult.Value, cGroup.GroupOperator);
// Fehlermeldung hinzufügen falls Bedingung verletzt wurde
if (!subResult.Value && ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.AND) || (cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.OR)))
message += string.Format("- {0}{1}", subMessage, Environment.NewLine);
//if (subResult.Value && ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.NAND) || (cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.NOR)))
// message += string.Format("- {0}{1}", subMessage, Environment.NewLine);
}
}
// falls in einer "OR" Gruppe eine Bedingung fehlschlägt aber die Condition nach true evaluiert
// wird die Fehlermeldung zwecks Verwirrungsvermeidung gedroppt. Dasselbe natürl. auch für NAND
if ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.OR) && result.Value) message = "";
//if ((cGroup.GroupOperator == ConditionGroup.GroupOperatorEnum.NAND) && !result.Value) message = "";
}
catch (Exception ex)
{
message = string.Format("Validation threw exception: {0}", ex.ToString());
log.Error(message);
return false;
}
return result;
}
public static ConditionGroup LoadFromString(string serializedConditions)
{
if ((serializedConditions == null) ||
(serializedConditions.Trim().Length == 0))
return null;
using (StringReader sr = new StringReader(serializedConditions))
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(ConditionGroup));
ConditionGroup container = serializer.Deserialize(sr) as ConditionGroup;
return container;
}
catch (Exception)
{
return null;
}
}
}
public static string SaveToString(ConditionGroup group)
{
if (group == null) return null;
using (StringWriter sw = new StringWriter())
{
try
{
Type theType = Type.GetType("bsmd.database.ConditionGroup, bsmd.database");
XmlSerializer serializer = new XmlSerializer(theType);
serializer.Serialize(sw, group);
return sw.ToString();
}
catch (Exception)
{
return null;
}
}
}
/// <summary>
/// evaluate logical group operator
/// </summary>
private static bool CombineConditions(bool? c1, bool c2, ConditionGroup.GroupOperatorEnum op)
{
if (!c1.HasValue) return c2;
switch (op)
{
case ConditionGroup.GroupOperatorEnum.AND:
return c1.Value & c2;
case ConditionGroup.GroupOperatorEnum.OR:
return c1.Value | c2;
case ConditionGroup.GroupOperatorEnum.NOT:
return !(c1.Value);
case ConditionGroup.GroupOperatorEnum.XOR:
return (c1.Value ^ c2);
}
return false;
}
private static bool IsConditionTrue(string val1, string val2, ValidationCondition.ConditionOperatorEnum condition)
{
switch (condition)
{
case ValidationCondition.ConditionOperatorEnum.EQUAL:
return val1.Equals(val2);
default:
return !val1.Equals(val2);
}
}
private static bool IsConditionTrue(bool val1, bool val2, ValidationCondition.ConditionOperatorEnum condition)
{
switch (condition)
{
case ValidationCondition.ConditionOperatorEnum.EQUAL:
return val1.Equals(val2);
default:
return !val1.Equals(val2);
}
}
private static bool IsConditionTrue(DateTime val1, DateTime val2, ValidationCondition.ConditionOperatorEnum condition)
{
switch (condition)
{
case ValidationCondition.ConditionOperatorEnum.EQUAL:
return val1 == val2;
case ValidationCondition.ConditionOperatorEnum.GREATER:
return val1 > val2;
case ValidationCondition.ConditionOperatorEnum.LESS:
return val1 < val2;
case ValidationCondition.ConditionOperatorEnum.NOT_EQUAL:
return val1 != val2;
}
return true;
}
private static bool IsConditionTrue(TimeSpan val1, TimeSpan val2, ValidationCondition.ConditionOperatorEnum condition)
{
switch (condition)
{
case ValidationCondition.ConditionOperatorEnum.EQUAL:
return val1 == val2;
case ValidationCondition.ConditionOperatorEnum.GREATER:
return val1 > val2;
case ValidationCondition.ConditionOperatorEnum.LESS:
return val1 < val2;
case ValidationCondition.ConditionOperatorEnum.NOT_EQUAL:
return val1 != val2;
}
return true;
}
private static bool IsConditionTrue(double val1, double val2, ValidationCondition.ConditionOperatorEnum condition)
{
switch (condition)
{
case ValidationCondition.ConditionOperatorEnum.EQUAL:
return val1 == val2;
case ValidationCondition.ConditionOperatorEnum.GREATER:
return val1 > val2;
case ValidationCondition.ConditionOperatorEnum.LESS:
return val1 < val2;
case ValidationCondition.ConditionOperatorEnum.NOT_EQUAL:
return val1 != val2;
}
return true;
}
#endregion
#region ICloneable implementation
public object Clone()
{
return this.MemberwiseClone();
}
#endregion
}
#region class ConditionGroup
[Serializable]
public class ConditionGroup
{
public enum GroupOperatorEnum
{
AND,
OR,
NOT,
XOR
}
public ConditionGroup() { }
public List<ValidationCondition> Conditions
{
get;
set;
}
public GroupOperatorEnum GroupOperator
{
get;
set;
}
public List<ConditionGroup> SubGroups
{
get;
set;
}
}
#endregion
#region struct KeyValuePairS
[Serializable]
[XmlType(TypeName = "schickKeyValuePair")]
public struct KeyValuePairS<K, V>
{
public K Key { get; set; }
public V Value { get; set; }
}
#endregion
}

View File

@ -0,0 +1,122 @@
// Copyright (c) 2015-2017 schick Informatik
// Description: Klasse kapselt eine vom ENI-2 verwendete Validierungsregel
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace bsmd.database
{
public class ValidationRule : DatabaseEntity
{
public ValidationRule()
{
this.tablename = "[dbo].[ValidationRule]";
}
#region Properties
public string Name { get; set; }
public string Context { get; set; }
public string Rule { get; set; }
public DateTime Created { get; set; }
public string CreatedBy { get; set; }
public DateTime? Changed { get; set; }
public string ChangedBy { get; set; }
public bool? IsActive { get; set; }
#endregion
#region overrides
public override string ToString()
{
return this.Name;
}
#endregion
#region DatabaseEntity implementation
public override List<DatabaseEntity> LoadList(IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
ValidationRule vr = new ValidationRule();
vr.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) vr.Name = reader.GetString(1);
if (!reader.IsDBNull(2)) vr.Context = reader.GetString(2);
if (!reader.IsDBNull(3)) vr.Rule = reader.GetString(3);
if (!reader.IsDBNull(4)) vr.Changed = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) vr.ChangedBy = reader.GetString(5);
if (!reader.IsDBNull(6)) vr.Created = reader.GetDateTime(6);
if (!reader.IsDBNull(7)) vr.CreatedBy = reader.GetString(7);
if (!reader.IsDBNull(8)) vr.IsActive = reader.GetBoolean(8);
result.Add(vr);
}
reader.Close();
return result;
}
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, Name, Context, [Rule], Changed, ChangedBy, Created, CreatedBy, IsActive FROM {0} ORDER BY Name",
this.Tablename);
switch (filter)
{
case Message.LoadFilter.ALL:
default:
break;
}
cmd.CommandText = query;
}
public override void PrepareSave(IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithNullableValue("@P1", this.Name);
scmd.Parameters.AddWithNullableValue("@P2", this.Context);
scmd.Parameters.AddWithNullableValue("@P3", this.Rule);
scmd.Parameters.AddWithNullableValue("@P4", this.Changed);
scmd.Parameters.AddWithNullableValue("@P5", this.ChangedBy);
scmd.Parameters.AddWithNullableValue("@P6", this.Created);
scmd.Parameters.AddWithNullableValue("@P7", this.CreatedBy);
scmd.Parameters.AddWithNullableValue("@P8", this.IsActive);
if (this.IsNew)
{
this.CreateId();
scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("INSERT INTO {0} (Id, Name, Context, [Rule], Changed, ChangedBy, Created, CreatedBy, IsActive) " +
"VALUES ( @ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8 )",
this.Tablename);
}
else
{
scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET Name = @P1, Context = @P2, [Rule] = @P3, Changed = @P4, ChangedBy = @P5, " +
"Created = @P6, CreatedBy = @P7, IsActive = @P8 WHERE Id = @ID", this.Tablename);
}
}
#endregion
}
}

View File

@ -121,6 +121,8 @@
<Compile Include="TOWD.cs" />
<Compile Include="Util.cs" />
<Compile Include="ValidationAttribute.cs" />
<Compile Include="ValidationCondition.cs" />
<Compile Include="ValidationRule.cs" />
<Compile Include="WAS.cs" />
<Compile Include="Waste.cs" />
<Compile Include="WasteDisposalServiceProvider.cs" />

View File

@ -34,6 +34,7 @@ namespace bsmd.hisnord
//XNamespace ns15 = "http://api.national-single-window.de/statusForClientRequestId";
XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";
XNamespace ns15 = "http://api.national-single-window.de/visitIdResponse";
XNamespace ns16 = "http://api.national-single-window.de/transitIdResponse";
XNamespace ladgNS = "http://api.national-single-window.de/ladg";
XNamespace hazaNS = "http://api.national-single-window.de/haza";
XNamespace hazdNS = "http://api.national-single-window.de/hazd";
@ -94,7 +95,7 @@ namespace bsmd.hisnord
lookupName = ns15 + "VisitIdResponse";
break;
case Message.NotificationClass.TRANSIT:
lookupName = ns15 + "VisitIdResponse";
lookupName = ns16 + "TransitIdResponse";
break;
case Message.NotificationClass.LADG:
lookupName = ladgNS + "LADGResponse";