3.6.0 neuer Stand (DB Erweiterung für NSW "Live"-Abfrage

This commit is contained in:
Daniel Schick 2017-05-21 10:23:11 +00:00
parent f1cb014fa3
commit f02530f960
37 changed files with 686 additions and 230 deletions

View File

@ -48,6 +48,9 @@ namespace ENI2.Controls
} }
*/ */
public event EventHandler TabClosing;
public void SetHeaderText(string headerText) public void SetHeaderText(string headerText)
{ {
// Container for header controls // Container for header controls
@ -80,6 +83,8 @@ namespace ENI2.Controls
{ {
var tabControl = Parent as ItemsControl; var tabControl = Parent as ItemsControl;
tabControl.Items.Remove(this); tabControl.Items.Remove(this);
if (TabClosing != null)
this.TabClosing(this, new EventArgs());
}; };
dockPanel.Children.Add(closeButton); dockPanel.Children.Add(closeButton);

View File

@ -32,11 +32,14 @@ namespace ENI2.Controls
{ {
var okButton = (Button)Template.FindName("buttonOK", this); var okButton = (Button)Template.FindName("buttonOK", this);
var cancelButton = (Button)Template.FindName("buttonCancel", this); var cancelButton = (Button)Template.FindName("buttonCancel", this);
okButton.Click += (s, e) => { DialogResult = true; OKClicked?.Invoke(); }; okButton.Click += (s, e) => { if (IsModal) DialogResult = true; else this.Close(); OKClicked?.Invoke(); };
cancelButton.Click += (s, e) => { DialogResult = false; CancelClicked?.Invoke(); }; cancelButton.Click += (s, e) => { if (IsModal) DialogResult = false; else this.Close(); CancelClicked?.Invoke(); };
}; };
this.IsModal = true; // default
} }
public bool IsModal { get; set; }
private void Window_Closing(object sender, CancelEventArgs e) private void Window_Closing(object sender, CancelEventArgs e)
{ {
if (this.shouldCancel) e.Cancel = true; if (this.shouldCancel) e.Cancel = true;

View File

@ -26,7 +26,6 @@ namespace ENI2
AMBIGUOUS AMBIGUOUS
} }
#endregion #endregion
#region events #region events
@ -37,6 +36,11 @@ namespace ENI2
/// </summary> /// </summary>
public event Action<int> JumpToListElementRequest; public event Action<int> JumpToListElementRequest;
/// <summary>
/// Mit diesem Event kann ein Listen-Element einen Reload der gesamten Anmeldung auslösen (ob das so eine tolle Idee ist.)
/// </summary>
public event Action RequestReload;
#endregion #endregion
#region Properties #region Properties
@ -47,19 +51,27 @@ namespace ENI2
#endregion #endregion
#region protected methods #region public methods
public virtual void Initialize() { public virtual void Initialize() {
} }
#endregion
#region protected methods
protected virtual void OnJumpToListElementRequest(int index) protected virtual void OnJumpToListElementRequest(int index)
{ {
this.JumpToListElementRequest?.Invoke(index); this.JumpToListElementRequest?.Invoke(index);
} }
protected virtual void OnRequestReload()
{
this.RequestReload?.Invoke();
}
protected void SetLocodeStateImage(Image stateImage, LocodeState state) protected void SetLocodeStateImage(Image stateImage, LocodeState state)
{ {
switch(state) switch(state)

View File

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2" xmlns:local="clr-namespace:ENI2"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"> d:DesignHeight="300" d:DesignWidth="300">
@ -16,8 +17,8 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label x:Name="shipNameLabel" Grid.Row="0" Grid.Column="0" VerticalContentAlignment="Center" FontWeight="Bold" /> <xctk:AutoSelectTextBox x:Name="shipNameLabel" Grid.Row="0" Grid.Column="0" VerticalContentAlignment="Center" FontWeight="Bold" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" />
<Label x:Name="displayIdLabel" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center" FontWeight="Bold" /> <xctk:AutoSelectTextBox x:Name="displayIdLabel" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center" FontWeight="Bold" IsReadOnly="True" BorderThickness="0" AutoSelectBehavior="OnFocus" />
<ListBox x:Name="listBoxMessages" Margin="2" SelectionMode="Single" SelectionChanged="listBoxMessages_SelectionChanged" <ListBox x:Name="listBoxMessages" Margin="2" SelectionMode="Single" SelectionChanged="listBoxMessages_SelectionChanged"
Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"> Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

View File

@ -19,13 +19,16 @@ namespace ENI2
private MessageCore _core; private MessageCore _core;
private List<MessageGroup> _listBoxList = new List<MessageGroup>(); private List<MessageGroup> _listBoxList = new List<MessageGroup>();
private List<Message> _messages; private List<Message> _messages;
private Dictionary<Type, DetailBaseControl> controlCache = new Dictionary<Type, DetailBaseControl>();
public MessageCore Core { get { return this._core; } }
public DetailRootControl(MessageCore aCore) public DetailRootControl(MessageCore aCore)
{ {
_core = aCore; _core = aCore;
InitializeComponent(); InitializeComponent();
shipNameLabel.Content = aCore.Shipname; shipNameLabel.Text = aCore.Shipname;
displayIdLabel.Content = aCore.DisplayId; displayIdLabel.Text = aCore.DisplayId;
// Listbox befüllen // Listbox befüllen
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" }); this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
@ -70,21 +73,45 @@ namespace ENI2
if(listBoxMessages.SelectedItem != null) if(listBoxMessages.SelectedItem != null)
{ {
MessageGroup mg = this.listBoxMessages.SelectedItem as MessageGroup; MessageGroup mg = this.listBoxMessages.SelectedItem as MessageGroup;
// create control instance for display: if (!controlCache.ContainsKey(mg.MessageGroupControlType))
DetailBaseControl detailControl = (DetailBaseControl) Activator.CreateInstance(mg.MessageGroupControlType); {
detailControl.Core = _core; // create control instance for display:
detailControl.Messages = _messages; DetailBaseControl detailControl = (DetailBaseControl)Activator.CreateInstance(mg.MessageGroupControlType);
detailControl.JumpToListElementRequest += (index) => { detailControl.Core = _core;
if((index >= 0) && (index < _listBoxList.Count)) detailControl.Messages = _messages;
detailControl.JumpToListElementRequest += (index) =>
{ {
this.listBoxMessages.SelectedIndex = index; if ((index >= 0) && (index < _listBoxList.Count))
} {
}; this.listBoxMessages.SelectedIndex = index;
detailControl.Initialize(); }
};
detailControl.RequestReload += DetailControl_RequestReload;
detailControl.Initialize();
controlCache.Add(mg.MessageGroupControlType, detailControl);
}
// plug it in ;-) // plug it in ;-)
detailView.Children.Clear(); detailView.Children.Clear();
detailView.Children.Add(detailControl); detailView.Children.Add(controlCache[mg.MessageGroupControlType]);
} }
} }
private void DetailControl_RequestReload()
{
/// core und messages neu laden
///
this._core = DBManager.Instance.GetMessageCoreById(this.Core.Id.Value);
this._messages = DBManager.Instance.GetMessagesForCore(this._core, DBManager.MessageLoad.ALL);
// clear existing controls
this.detailView.Children.Clear();
this.controlCache.Clear();
// return to "new" overview
Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages_SelectionChanged(this, null)));
}
} }
} }

View File

@ -10,28 +10,42 @@
xmlns:local="clr-namespace:ENI2.DetailViewControls" xmlns:local="clr-namespace:ENI2.DetailViewControls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600"> d:DesignHeight="300" d:DesignWidth="600">
<GroupBox Name="visitTransitGroupBox" Header="{x:Static p:Resources.textVisitTransit}"> <xctk:BusyIndicator Name="busyIndicator">
<Grid> <xctk:BusyIndicator.ProgressBarStyle>
<Grid.RowDefinitions> <Style TargetType="ProgressBar">
<RowDefinition Height="24" /> <Setter Property="Visibility" Value="Collapsed" />
<RowDefinition Height="24" /> </Style>
<RowDefinition Height="24" /> </xctk:BusyIndicator.ProgressBarStyle>
<RowDefinition Height="24" /> <xctk:BusyIndicator.BusyContent>
<RowDefinition Height="24" /> <StackPanel>
<RowDefinition Height="24" /> <Label Name="labelBusyWaitLabel" Content="{x:Static p:Resources.textBusyCheckStatus}" />
<RowDefinition Height="*" /> <Label Name="labelBusyTimeElapsed" Content=""/>
</Grid.RowDefinitions> <Button Name="buttonStopWaiting" Content="{x:Static p:Resources.textStopWaiting}" Click="buttonStopWaiting_Click"/>
<Grid.ColumnDefinitions> </StackPanel>
<ColumnDefinition Width="1*" /> </xctk:BusyIndicator.BusyContent>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" /> <GroupBox Name="visitTransitGroupBox" Header="{x:Static p:Resources.textVisitTransit}">
<ColumnDefinition Width="1*" /> <Grid>
<ColumnDefinition Width="1*" /> <Grid.RowDefinitions>
<ColumnDefinition Width="1*" /> <RowDefinition Height="24" />
</Grid.ColumnDefinitions> <RowDefinition Height="24" />
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" Margin="0,0,10,0"/> <RowDefinition Height="24" />
<enictrl:LocodeControl Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}"/> <RowDefinition Height="24" />
<!--Grid Grid.Column="1" Grid.Row="0" Width="Auto"> <RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}"/>
<!--Grid Grid.Column="1" Grid.Row="0" Width="Auto">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -39,77 +53,84 @@
<xctk:WatermarkComboBox Grid.Column="0" x:Name="comboBoxPoC" Margin="2" IsEditable="True" Watermark="Type for Locode.." TextBoxBase.TextChanged="ComboBox_TextChanged" ItemsSource="{Binding LocodePoCList, Mode=TwoWay}" SelectedItem="{Binding PoC, Mode=TwoWay}" /> <xctk:WatermarkComboBox Grid.Column="0" x:Name="comboBoxPoC" Margin="2" IsEditable="True" Watermark="Type for Locode.." TextBoxBase.TextChanged="ComboBox_TextChanged" ItemsSource="{Binding LocodePoCList, Mode=TwoWay}" SelectedItem="{Binding PoC, Mode=TwoWay}" />
<Image Name="imagePoCState" Grid.Column="1" Source="../Resources/bullet_ball_grey.png" /> <Image Name="imagePoCState" Grid.Column="1" Source="../Resources/bullet_ball_grey.png" />
</--> </-->
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="3" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="3" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" />
<TextBox Name="textBoxDisplayId" Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" IsReadOnly="True" Margin="2" /> <TextBox Name="textBoxDisplayId" Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" IsReadOnly="True" Margin="2" />
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textIMO}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textIMO}" Margin="0,0,10,0" />
<TextBox Name="textBoxIMO" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="1" Text="{Binding IMO}" Margin="2" IsReadOnly="True" /> <TextBox Name="textBoxIMO" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="1" Text="{Binding IMO}" Margin="2" IsReadOnly="True" />
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="3" Content="{x:Static p:Resources.textENI}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="3" Content="{x:Static p:Resources.textENI}" Margin="0,0,10,0" />
<TextBox Name="textBoxENI" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="2" Text="{Binding ENI}" Margin="2" IsReadOnly="True" /> <TextBox Name="textBoxENI" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="2" Text="{Binding ENI}" Margin="2" IsReadOnly="True" />
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textETAPortOfCall}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textETAPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="3" Content="{x:Static p:Resources.textETDPortOfCall}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="2" Grid.Column="3" Content="{x:Static p:Resources.textETDPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textATAPortOfCall}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textATAPortOfCall}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="3" Content="{x:Static p:Resources.textATDPortOfCall}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="3" Grid.Column="3" Content="{x:Static p:Resources.textATDPortOfCall}" Margin="0,0,10,0" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETAToPortOfCall, Mode=TwoWay}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}"/> <xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETAToPortOfCall, Mode=TwoWay}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}"/>
<xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETDFromPortOfCall, Mode=TwoWay}" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" /> <xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="2" Value="{Binding ETDFromPortOfCall, Mode=TwoWay}" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" />
<xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATAPortOfCall, Mode=TwoWay}" Name="dateTimePickerATA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" /> <xctk:DateTimePicker Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATAPortOfCall, Mode=TwoWay}" Name="dateTimePickerATA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" />
<xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATDPortOfCall, Mode=TwoWay}" Name="dateTimePickerATD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" /> <xctk:DateTimePicker Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="3" Value="{Binding ATDPortOfCall, Mode=TwoWay}" Name="dateTimePickerATD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" />
<Label HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" /> <Label HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="3" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="3" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" />
<Label Name="labelCreated" Grid.Column="4" Grid.Row="4" Margin="2, 0, 0, 0" /> <Label Name="labelCreated" Grid.Column="4" Grid.Row="4" Margin="2, 0, 0, 0" />
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding TicketNo}" Margin="2" /> <TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding TicketNo}" Margin="2" />
<!-- Command buttons --> <!-- Command buttons -->
<Button IsEnabled="False" Name="buttonStorno" Grid.Column="1" Grid.Row="5" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}"/> <Button IsEnabled="False" Name="buttonStorno" Grid.Column="1" Grid.Row="5" Margin="2" Click="buttonStorno_Click" Content="{x:Static p:Resources.textCancelDeclaration}"/>
<Button IsEnabled="False" Name="buttonCopy" Grid.Column="2" Grid.Row="5" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/> <Button IsEnabled="False" Name="buttonCopy" Grid.Column="2" Grid.Row="5" Margin="2" Click="buttonCopy_Click" Content="{x:Static p:Resources.textCopyData}"/>
<Button IsEnabled="False" Name="buttonSendPDF" Grid.Column="3" Grid.Row="5" Margin="2" Click="buttonSendPDF_Click" Content="{x:Static p:Resources.textCreatePDF}"/> <Button IsEnabled="False" Name="buttonSendPDF" Grid.Column="3" Grid.Row="5" Margin="2" Click="buttonSendPDF_Click" Content="{x:Static p:Resources.textCreatePDF}"/>
<Button IsEnabled="False" Name="buttonQueryHIS" Grid.Column="5" Grid.Row="5" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/> <Button Name="buttonQueryHIS" Grid.Column="4" Grid.Row="5" Margin="2" Click="buttonQueryHIS_Click" Content="{x:Static p:Resources.textQueryHIS}"/>
<Button Name="buttonRefresh" Grid.Column="5" Grid.Row="5" Margin="2" Click="buttonRefresh_Click">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/nav_refresh_blue.png" Margin="0,0,10,0"/>
<TextBlock Text="{x:Static p:Resources.textRefresh}"/>
</StackPanel>
</Button>
<!-- Data Grid --> <!-- Data Grid -->
<DataGrid Grid.Row="6" Grid.ColumnSpan="6" Margin="0,8,0,0" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False" <DataGrid Grid.Row="6" Grid.ColumnSpan="6" Margin="0,8,0,0" x:Name="dataGridMessages" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" CanUserAddRows="False"
SelectionMode="Single" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown"> SelectionMode="Single" AutoGenerateColumns="False" MouseDoubleClick="dataGrid_MouseDoubleClick" PreviewKeyDown="dataGrid_PreviewKeyDown">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn Header=" " Width="SizeToCells" IsReadOnly="True"> <DataGridTemplateColumn Header=" " Width="SizeToCells" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<!--Image Source="{Binding src:Util.ImageDict[ENINotificationDetailGroup]}" /--> <!--Image Source="{Binding src:Util.ImageDict[ENINotificationDetailGroup]}" /-->
<!--Image Source="{Binding Source={x:Static src:Util.ImageDict}, Path=[ENINotificationDetailGroup]}"></--> <!--Image Source="{Binding Source={x:Static src:Util.ImageDict}, Path=[ENINotificationDetailGroup]}"></-->
<Image Source="{Binding ENINotificationIconString}" /> <Image Source="{Binding ENINotificationIconString}" />
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<!-- <!--
<DataGridTextColumn Header="{x:Static p:Resources.textNotificationGroup}" Binding="{Binding ENINotificationDetailGroup}" IsReadOnly="True" Width="0.25*" /> <DataGridTextColumn Header="{x:Static p:Resources.textNotificationGroup}" Binding="{Binding ENINotificationDetailGroup}" IsReadOnly="True" Width="0.25*" />
--> -->
<DataGridTextColumn Header="{x:Static p:Resources.textNotificationClass}" Binding="{Binding MessageNotificationClassDisplay}" IsReadOnly="True" Width="0.1*" FontWeight="Bold"> <DataGridTextColumn Header="{x:Static p:Resources.textNotificationClass}" Binding="{Binding MessageNotificationClassDisplay}" IsReadOnly="True" Width="0.1*" FontWeight="Bold">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10,0,0,0" /> <Setter Property="Margin" Value="10,0,0,0" />
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChanged}" Binding="{Binding Changed}" IsReadOnly="True" Width="0.15*"> <DataGridTextColumn Header="{x:Static p:Resources.textChanged}" Binding="{Binding Changed}" IsReadOnly="True" Width="0.15*">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textStatus}" Binding="{Binding InternalStatus}" IsReadOnly="True" Width="0.1*"> <DataGridTextColumn Header="{x:Static p:Resources.textStatus}" Binding="{Binding InternalStatus}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textChangedBy}" Binding="{Binding ChangedBy}" IsReadOnly="True" Width="0.5*"> <DataGridTextColumn Header="{x:Static p:Resources.textChangedBy}" Binding="{Binding ChangedBy}" IsReadOnly="True" Width="0.5*">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
</Style> </Style>
</DataGridTextColumn.ElementStyle> </DataGridTextColumn.ElementStyle>
</DataGridTextColumn> </DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>
</GroupBox> </GroupBox>
</xctk:BusyIndicator>
</src:DetailBaseControl> </src:DetailBaseControl>

View File

@ -3,10 +3,12 @@
// //
using System.Collections.Generic; using System.Collections.Generic;
using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Timers;
using bsmd.database; using bsmd.database;
@ -21,6 +23,8 @@ namespace ENI2.DetailViewControls
private Message _ataMessage; private Message _ataMessage;
private Message _atdMessage; private Message _atdMessage;
private Message _noanodMessage; private Message _noanodMessage;
private Timer _checkStatusTimer;
private DateTime _startStatusCheck;
public OverViewDetailControl() public OverViewDetailControl()
{ {
@ -313,10 +317,65 @@ namespace ENI2.DetailViewControls
private void buttonQueryHIS_Click(object sender, RoutedEventArgs e) private void buttonQueryHIS_Click(object sender, RoutedEventArgs e)
{ {
this._startStatusCheck = DateTime.Now;
this.Core.QueryNSWStatus = true;
DBManager.Instance.Save(this.Core);
this.busyIndicator.IsBusy = true;
// Hintergrund-Thread starten, der gelegentlich auf das Ergebnis prüft..
if (_checkStatusTimer == null)
{
_checkStatusTimer = new Timer(3000);
_checkStatusTimer.Elapsed += _checkStatusTimer_Elapsed;
_checkStatusTimer.AutoReset = true;
}
_checkStatusTimer.Start();
}
private void _checkStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
{
bool? statusFlag = DBManager.Instance.GetMessageCoreQueryStatusFlag(this.Core.Id.Value);
if(statusFlag ?? true)
{
// not yet.. (calling ui thread async)
this.Dispatcher.BeginInvoke(new Action(() =>
{
this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, (DateTime.Now - _startStatusCheck).TotalSeconds.ToString("N1"));
}));
}
else
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
this.busyIndicator.IsBusy = false;
this.OnRequestReload();
}));
}
}
private void buttonStopWaiting_Click(object sender, RoutedEventArgs e)
{
this.busyIndicator.IsBusy = false;
}
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
{
// reload Core and all message classes
// container class needs to dismiss all created controls
this.Dispatcher.BeginInvoke(new Action(() =>
{
this.OnRequestReload();
}));
} }
#endregion #endregion
#region private methods
#endregion
} }
} }

View File

@ -232,6 +232,7 @@
<Compile Include="SucheControl.xaml.cs"> <Compile Include="SucheControl.xaml.cs">
<DependentUpon>SucheControl.xaml</DependentUpon> <DependentUpon>SucheControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Util\BoolToVisibilityConverter.cs" />
<Compile Include="VorgaengeControl.xaml.cs"> <Compile Include="VorgaengeControl.xaml.cs">
<DependentUpon>VorgaengeControl.xaml</DependentUpon> <DependentUpon>VorgaengeControl.xaml</DependentUpon>
</Compile> </Compile>
@ -365,6 +366,7 @@
<Generator>WCF Proxy Generator</Generator> <Generator>WCF Proxy Generator</Generator>
<LastGenOutput>Reference.cs</LastGenOutput> <LastGenOutput>Reference.cs</LastGenOutput>
</None> </None>
<Resource Include="Resources\nav_refresh_blue.png" />
<Content Include="x64\SQLite.Interop.dll"> <Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

View File

@ -5,6 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:ENI2.Properties" xmlns:p="clr-namespace:ENI2.Properties"
xmlns:enidtctrl="clr-namespace:ENI2.DetailViewControls" xmlns:enidtctrl="clr-namespace:ENI2.DetailViewControls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:local="clr-namespace:ENI2" xmlns:local="clr-namespace:ENI2"
mc:Ignorable="d" mc:Ignorable="d"
Title="ENI 2" Height="450" Width="825" Icon="Resources/logo_schwarz.ico" Loaded="Window_Loaded" Closing="Window_Closing" Title="ENI 2" Height="450" Width="825" Icon="Resources/logo_schwarz.ico" Loaded="Window_Loaded" Closing="Window_Closing"
@ -15,6 +17,9 @@
Executed="ExecutedClearCommand" Executed="ExecutedClearCommand"
CanExecute="CanExecuteClearCommand" /> CanExecute="CanExecuteClearCommand" />
</Window.CommandBindings> </Window.CommandBindings>
<Window.Resources>
<util:BoolToVisibilityConverter x:Key="BoolToHiddenConverter" TrueValue="Visible" FalseValue="Hidden" />
</Window.Resources>
<DockPanel Name="mainPanel"> <DockPanel Name="mainPanel">
<Grid DockPanel.Dock="Top" Height="80" Background="#FFE8F6FF"> <Grid DockPanel.Dock="Top" Height="80" Background="#FFE8F6FF">
@ -67,4 +72,7 @@
</TabItem> </TabItem>
</TabControl> </TabControl>
</DockPanel> </DockPanel>
<!--Rectangle Fill="White" Opacity="0.7" Visibility="{Binding IsWaiting, Converter={StaticResource BoolToHiddenConverter}}" /-->
</Window> </Window>

View File

@ -27,6 +27,7 @@ namespace ENI2
private List<MessageCore> anmeldungen = new List<MessageCore>(); private List<MessageCore> anmeldungen = new List<MessageCore>();
private bool efMode = false; private bool efMode = false;
ScaleTransform _transform = new ScaleTransform(1.0, 1.0); ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
private Dictionary<Guid, ClosableTabItem> openTabs = new Dictionary<Guid, ClosableTabItem>();
public MainWindow() public MainWindow()
{ {
@ -43,12 +44,32 @@ namespace ENI2
{ {
if(aMessageCore != null) if(aMessageCore != null)
{ {
ClosableTabItem searchResultItem = new ClosableTabItem(); if (!openTabs.ContainsKey(aMessageCore.Id.Value))
searchResultItem.SetHeaderText(string.Format("{0} [{1}-{2}]", aMessageCore.Shipname, aMessageCore.PoC, aMessageCore.ETA.HasValue ? aMessageCore.ETA.Value.ToShortDateString() : "")); {
DetailRootControl drc = new DetailRootControl(aMessageCore); ClosableTabItem searchResultItem = new ClosableTabItem();
searchResultItem.Content = drc; searchResultItem.TabClosing += SearchResultItem_TabClosing;
this.mainFrame.Items.Add(searchResultItem); searchResultItem.SetHeaderText(string.Format("{0} [{1}-{2}]", aMessageCore.Shipname, aMessageCore.PoC, aMessageCore.ETA.HasValue ? aMessageCore.ETA.Value.ToShortDateString() : ""));
Dispatcher.BeginInvoke((Action)(() => this.mainFrame.SelectedIndex = (this.mainFrame.Items.Count - 1))); DetailRootControl drc = new DetailRootControl(aMessageCore);
searchResultItem.Content = drc;
this.mainFrame.Items.Add(searchResultItem);
Dispatcher.BeginInvoke((Action)(() => this.mainFrame.SelectedIndex = (this.mainFrame.Items.Count - 1)));
this.openTabs.Add(aMessageCore.Id.Value, searchResultItem);
}
else
{
Dispatcher.BeginInvoke((Action)(() => this.mainFrame.SelectedItem = openTabs[aMessageCore.Id.Value]));
}
}
}
private void SearchResultItem_TabClosing(object sender, EventArgs e)
{
ClosableTabItem tabItem = sender as ClosableTabItem;
if(tabItem != null)
{
DetailRootControl drc = tabItem.Content as DetailRootControl;
if (openTabs.ContainsKey(drc.Core.Id.Value))
openTabs.Remove(drc.Core.Id.Value);
} }
} }
@ -121,11 +142,8 @@ namespace ENI2
MessageCore newCore = new MessageCore(); MessageCore newCore = new MessageCore();
VisitIdDialog visitIdDialog = new VisitIdDialog(); VisitIdDialog visitIdDialog = new VisitIdDialog();
visitIdDialog.Core = newCore; visitIdDialog.Core = newCore;
visitIdDialog.IsModal = false;
if (visitIdDialog.ShowDialog() ?? false) visitIdDialog.Show();
{
}
} }
private void closeButton_Click(object sender, RoutedEventArgs e) private void closeButton_Click(object sender, RoutedEventArgs e)

View File

@ -280,6 +280,16 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap nav_refresh_blue {
get {
object obj = ResourceManager.GetObject("nav_refresh_blue", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@ -420,6 +430,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Checking declaration status...
/// </summary>
public static string textBusyCheckStatus {
get {
return ResourceManager.GetString("textBusyCheckStatus", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Call Purposes. /// Looks up a localized string similar to Call Purposes.
/// </summary> /// </summary>
@ -1023,6 +1042,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Refresh.
/// </summary>
public static string textRefresh {
get {
return ResourceManager.GetString("textRefresh", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Requested position in port of call. /// Looks up a localized string similar to Requested position in port of call.
/// </summary> /// </summary>
@ -1041,6 +1069,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to {0} seconds elapsed.
/// </summary>
public static string textSecondsElapsed {
get {
return ResourceManager.GetString("textSecondsElapsed", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Security. /// Looks up a localized string similar to Security.
/// </summary> /// </summary>
@ -1167,6 +1204,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Stop waiting...
/// </summary>
public static string textStopWaiting {
get {
return ResourceManager.GetString("textStopWaiting", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Street / number. /// Looks up a localized string similar to Street / number.
/// </summary> /// </summary>

View File

@ -235,8 +235,8 @@
<data name="textPrint" xml:space="preserve"> <data name="textPrint" xml:space="preserve">
<value>_Print</value> <value>_Print</value>
</data> </data>
<data name="textPortCall" xml:space="preserve"> <data name="textPortCall" xml:space="preserve">
<value>Port Call</value> <value>Port of call</value>
</data> </data>
<data name="textArrivalDeparture" xml:space="preserve"> <data name="textArrivalDeparture" xml:space="preserve">
<value>Arrival/Departure</value> <value>Arrival/Departure</value>
@ -250,7 +250,7 @@
<data name="textLastPort" xml:space="preserve"> <data name="textLastPort" xml:space="preserve">
<value>Last Port</value> <value>Last Port</value>
</data> </data>
<data name="textNextPort" xml:space="preserve"> <data name="textNextPort" xml:space="preserve">
<value>Next Port</value> <value>Next Port</value>
</data> </data>
<data name="textETDPortOfCall" xml:space="preserve"> <data name="textETDPortOfCall" xml:space="preserve">
@ -268,7 +268,7 @@
<data name="textAnchored" xml:space="preserve"> <data name="textAnchored" xml:space="preserve">
<value>Anchored</value> <value>Anchored</value>
</data> </data>
<data name="textCallPurposes" xml:space="preserve"> <data name="textCallPurposes" xml:space="preserve">
<value>Call Purposes</value> <value>Call Purposes</value>
</data> </data>
<data name="textCode" xml:space="preserve"> <data name="textCode" xml:space="preserve">
@ -310,9 +310,6 @@
<data name="textVisitTransit" xml:space="preserve"> <data name="textVisitTransit" xml:space="preserve">
<value>Visit / transit</value> <value>Visit / transit</value>
</data> </data>
<data name="textPortCall" xml:space="preserve">
<value>Port of call</value>
</data>
<data name="textIMO" xml:space="preserve"> <data name="textIMO" xml:space="preserve">
<value>IMO number</value> <value>IMO number</value>
</data> </data>
@ -352,7 +349,7 @@
<data name="textShipData" xml:space="preserve"> <data name="textShipData" xml:space="preserve">
<value>Ship data</value> <value>Ship data</value>
</data> </data>
<data name="textBorderPolice" xml:space="preserve"> <data name="textBorderPolice" xml:space="preserve">
<value>Border Police</value> <value>Border Police</value>
</data> </data>
<data name="textDepartureNotification" xml:space="preserve"> <data name="textDepartureNotification" xml:space="preserve">
@ -505,4 +502,19 @@
<data name="textTicketNo" xml:space="preserve"> <data name="textTicketNo" xml:space="preserve">
<value>Ticket No</value> <value>Ticket No</value>
</data> </data>
<data name="textBusyCheckStatus" xml:space="preserve">
<value>Checking declaration status..</value>
</data>
<data name="textSecondsElapsed" xml:space="preserve">
<value>{0} seconds elapsed</value>
</data>
<data name="textStopWaiting" xml:space="preserve">
<value>Stop waiting..</value>
</data>
<data name="nav_refresh_blue" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\nav_refresh_blue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textRefresh" xml:space="preserve">
<value>Refresh</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,43 @@
// Copyright (c) 2017 schick Informatik
// Description: Converter
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace ENI2.Util
{
[ValueConversion(typeof(bool), typeof(Visibility))]
public sealed class BoolToVisibilityConverter : IValueConverter
{
public Visibility TrueValue { get; set; }
public Visibility FalseValue { get; set; }
public BoolToVisibilityConverter()
{
// set defaults
TrueValue = Visibility.Visible;
FalseValue = Visibility.Collapsed;
}
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
if (!(value is bool))
return null;
return (bool)value ? TrueValue : FalseValue;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
if (Equals(value, TrueValue))
return true;
if (Equals(value, FalseValue))
return false;
return null;
}
}
}

Binary file not shown.

View File

@ -0,0 +1,17 @@
-- Update für Status Check
PRINT N'Altering [dbo].[MessageCore]...';
GO
ALTER TABLE [dbo].[MessageCore]
ADD [Cancelled] BIT NULL,
[VisitIdOrTransitIdCancellable] BIT NULL,
[BlockedNotificationClasses] NVARCHAR (128) NULL,
[FreeNotificationClasses] NVARCHAR (128) NULL,
[OwnNotificationClasses] NVARCHAR (128) NULL,
[StatusCheckErrorCode] NVARCHAR (50) NULL,
[StatusCheckErrorMessage] NVARCHAR (50) NULL,
[QueryNSWStatus] BIT NULL
GO

View File

@ -1,4 +1,5 @@
using bsmd.database; using bsmd.database;
using bsmd.status;
using log4net; using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -20,6 +21,14 @@ namespace SendNSWMessageService
{ {
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
InitializeComponent(); InitializeComponent();
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true; // **** Immer OK weil wir nur mit einem dedizierten Endpoint reden..
};
} }
public void Commandline(string[] args) public void Commandline(string[] args)
@ -172,7 +181,7 @@ namespace SendNSWMessageService
// 28.12.2015: Das über "Overview" eingestellte HIS ist immer "führend" (zumindest aktuell zum Testen) // 28.12.2015: Das über "Overview" eingestellte HIS ist immer "führend" (zumindest aktuell zum Testen)
// if (message.HIS == Message.NSWProvider.UNDEFINED) // if (message.HIS == Message.NSWProvider.UNDEFINED)
message.HIS = core.InitialHIS; message.HIS = core.InitialHIS;
if (core.DefaultReportingPartyId.HasValue) if (core.DefaultReportingPartyId.HasValue)
{ {
message.ReportingPartyId = core.DefaultReportingPartyId; // Referenz umbiegen message.ReportingPartyId = core.DefaultReportingPartyId; // Referenz umbiegen
@ -241,7 +250,9 @@ namespace SendNSWMessageService
if (toSendMessageList.Count > 0) if (toSendMessageList.Count > 0)
{ {
core.BSMDStatusInternal = MessageCore.BSMDStatus.SENT; core.BSMDStatusInternal = MessageCore.BSMDStatus.SENT;
} else { }
else
{
core.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE; core.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE;
} }
DBManager.Instance.Save(core); DBManager.Instance.Save(core);
@ -249,6 +260,15 @@ namespace SendNSWMessageService
} }
} }
List<MessageCore> coresMarkedForStatusQuery = DBManager.Instance.GetMessageCoresWithNSWStatusFlag();
foreach (MessageCore core in coresMarkedForStatusQuery)
{
core.QueryNSWStatus = false; // reset flag
Status aStatus = new Status(core);
aStatus.PerformQuery();
}
// Auf erhaltene Visit-Ids prüfen (HIS-NORD) // Auf erhaltene Visit-Ids prüfen (HIS-NORD)
// TODO // TODO
// bsmd.hisnord.Request.ReadAnswers(); // bsmd.hisnord.Request.ReadAnswers();

View File

@ -1,11 +1,5 @@
using System; using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess; using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using log4net;
namespace SendNSWMessageService namespace SendNSWMessageService
{ {

View File

@ -38,8 +38,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.7" targetFramework="net45" /> <package id="log4net" version="2.0.8" targetFramework="net45" />
</packages> </packages>

View File

@ -36,8 +36,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.7" targetFramework="net45" /> <package id="log4net" version="2.0.8" targetFramework="net45" />
</packages> </packages>

View File

@ -26,6 +26,7 @@ namespace bsmd.database
private static ILog _log = LogManager.GetLogger(typeof(DBManager)); private static ILog _log = LogManager.GetLogger(typeof(DBManager));
private static Dictionary<Guid, ReportingParty> allReportingParties; private static Dictionary<Guid, ReportingParty> allReportingParties;
private static Dictionary<string, PortArea> allPortAreas; private static Dictionary<string, PortArea> allPortAreas;
private object _lock = new object();
#endregion #endregion
@ -85,6 +86,7 @@ namespace bsmd.database
get { return (this._con != null) && (this._con.State == ConnectionState.Open); } get { return (this._con != null) && (this._con.State == ConnectionState.Open); }
} }
#endregion #endregion
#region public helper funcs #region public helper funcs
@ -140,6 +142,23 @@ namespace bsmd.database
return result; return result;
} }
public List<MessageCore> GetMessageCoresWithNSWStatusFlag()
{
MessageCore aMessageCore = new MessageCore();
SqlCommand cmd = new SqlCommand();
aMessageCore.PrepareLoadCommand(cmd, Message.LoadFilter.QUERY_NSW_STATUS);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> cores = aMessageCore.LoadList(reader);
List<MessageCore> result = new List<MessageCore>();
foreach (MessageCore core in cores)
{
this.LoadCustomer(core);
result.Add(core);
}
return result;
}
public List<MessageCore> GetMessageCoresWithFilters(Dictionary<MessageCore.SearchFilterType, string> filters) public List<MessageCore> GetMessageCoresWithFilters(Dictionary<MessageCore.SearchFilterType, string> filters)
{ {
MessageCore aMessageCore = new MessageCore(); MessageCore aMessageCore = new MessageCore();
@ -464,6 +483,13 @@ namespace bsmd.database
this.LogNonQueryResult(cmd.CommandText, queryResult); this.LogNonQueryResult(cmd.CommandText, queryResult);
} }
public bool? GetMessageCoreQueryStatusFlag(Guid messageCoreId)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = string.Format("SELECT QueryNSWStatus FROM MessageCore WHERE Id = '{0}'", messageCoreId);
return this.PerformReadFlagQuery(cmd);
}
#endregion #endregion
#region internal/private funcs #region internal/private funcs
@ -922,49 +948,83 @@ namespace bsmd.database
internal SqlDataReader PerformCommand(SqlCommand cmd) internal SqlDataReader PerformCommand(SqlCommand cmd)
{ {
try SqlDataReader reader = null;
lock (this._lock)
{ {
cmd.Connection = this._con; try
// Stopwatch sw = new Stopwatch();
// sw.Start();
SqlDataReader reader = cmd.ExecuteReader();
// sw.Stop();
// _log.DebugFormat("{1}ms: {0}", cmd.CommandText, sw.ElapsedMilliseconds);
return reader;
}
catch (SqlException ex)
{
System.Diagnostics.Trace.WriteLine("SQL Exception:" + ex.Message);
_log.Error("Error performing command", ex);
_log.DebugFormat("Query: {0}", cmd.CommandText);
_log.Debug("Parameters:");
for (int i = 0; i < cmd.Parameters.Count; i++)
{ {
_log.DebugFormat("{0}:{1}", cmd.Parameters[i].ParameterName, cmd.Parameters[i].Value); cmd.Connection = this._con;
// Stopwatch sw = new Stopwatch();
// sw.Start();
reader = cmd.ExecuteReader();
// sw.Stop();
// _log.DebugFormat("{1}ms: {0}", cmd.CommandText, sw.ElapsedMilliseconds);
}
catch (SqlException ex)
{
Trace.WriteLine("SQL Exception:" + ex.Message);
_log.Error("Error performing command", ex);
_log.DebugFormat("Query: {0}", cmd.CommandText);
_log.Debug("Parameters:");
for (int i = 0; i < cmd.Parameters.Count; i++)
{
_log.DebugFormat("{0}:{1}", cmd.Parameters[i].ParameterName, cmd.Parameters[i].Value);
}
} }
return null;
} }
return reader;
} }
internal int PerformNonQuery(SqlCommand cmd) internal int PerformNonQuery(SqlCommand cmd)
{ {
try int result = -1;
lock (this._lock)
{ {
cmd.Connection = this._con; try
return cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
System.Diagnostics.Trace.WriteLine("SQL Exception:" + ex.Message);
_log.Error("Error performing command", ex);
_log.DebugFormat("Query: {0}", cmd.CommandText);
_log.Debug("Parameters:");
for (int i = 0; i < cmd.Parameters.Count; i++)
{ {
_log.DebugFormat("{0}:{1}", cmd.Parameters[i].ParameterName, cmd.Parameters[i].Value); cmd.Connection = this._con;
result = cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
System.Diagnostics.Trace.WriteLine("SQL Exception:" + ex.Message);
_log.Error("Error performing command", ex);
_log.DebugFormat("Query: {0}", cmd.CommandText);
_log.Debug("Parameters:");
for (int i = 0; i < cmd.Parameters.Count; i++)
{
_log.DebugFormat("{0}:{1}", cmd.Parameters[i].ParameterName, cmd.Parameters[i].Value);
}
} }
return -1;
} }
return result;
}
internal bool? PerformReadFlagQuery(SqlCommand cmd)
{
bool? result = null;
lock (this._lock)
{
try
{
cmd.Connection = this._con;
result = (bool?)cmd.ExecuteScalar();
}
catch (SqlException ex)
{
_log.Error("Error performing command", ex);
_log.DebugFormat("Query: {0}", cmd.CommandText);
_log.Debug("Parameters:");
for (int i = 0; i < cmd.Parameters.Count; i++)
{
_log.DebugFormat("{0}:{1}", cmd.Parameters[i].ParameterName, cmd.Parameters[i].Value);
}
}
}
return result;
} }
#endregion #endregion

View File

@ -136,7 +136,8 @@ namespace bsmd.database
BY_CORE_EXCEL, BY_CORE_EXCEL,
BY_CORE_HE, BY_CORE_HE,
CREATE_EXCEL, CREATE_EXCEL,
SEARCH_CORE_FILTERS SEARCH_CORE_FILTERS,
QUERY_NSW_STATUS
} }
/// <summary> /// <summary>

View File

@ -198,9 +198,11 @@ namespace bsmd.database
public string FreeNotificationClasses { get; set; } public string FreeNotificationClasses { get; set; }
public string ErrorCode { get; set; } public string StatusCheckErrorCode { get; set; }
public string ErrorMessage { get; set; } public string StatusCheckErrorMessage { get; set; }
public bool? QueryNSWStatus { get; set; }
#endregion #endregion
@ -251,6 +253,14 @@ namespace bsmd.database
scmd.Parameters.AddWithValue("@P26", this.CreateExcel ? 1 : 0); scmd.Parameters.AddWithValue("@P26", this.CreateExcel ? 1 : 0);
scmd.Parameters.AddWithNullableValue("@P27", this.EditedBy); scmd.Parameters.AddWithNullableValue("@P27", this.EditedBy);
scmd.Parameters.AddWithNullableValue("@P28", this.TicketNo); scmd.Parameters.AddWithNullableValue("@P28", this.TicketNo);
scmd.Parameters.AddWithNullableValue("@P29", this.Cancelled);
scmd.Parameters.AddWithNullableValue("@P30", this.VisitIdOrTransitIdCancellable);
scmd.Parameters.AddWithNullableValue("@P31", this.BlockedNotificationClasses);
scmd.Parameters.AddWithNullableValue("@P32", this.FreeNotificationClasses);
scmd.Parameters.AddWithNullableValue("@P33", this.OwnNotificationClasses);
scmd.Parameters.AddWithNullableValue("@P34", this.StatusCheckErrorCode);
scmd.Parameters.AddWithNullableValue("@P35", this.StatusCheckErrorMessage);
scmd.Parameters.AddWithNullableValue("@P36", this.QueryNSWStatus);
if (this.IsNew) if (this.IsNew)
{ {
@ -260,9 +270,10 @@ namespace bsmd.database
"Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " + "Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " +
"HerbergFormTemplateGuid, HerbergReportType, HerbergEmailcontactReportingVessel, HerbergEmail24HrsContact, " + "HerbergFormTemplateGuid, HerbergReportType, HerbergEmailcontactReportingVessel, HerbergEmail24HrsContact, " +
"ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion, Incoming, DefaultReportingPartyId, CreateExcel, " + "ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion, Incoming, DefaultReportingPartyId, CreateExcel, " +
"EditedBy, TicketNo) VALUES " + "EditedBy, TicketNo, Cancelled, VisitIdOrTransitIdCancellable, BlockedNotificationClasses, FreeNotificationClasses, " +
"OwnNotificationClasses, StatusCheckErrorCode, StatusCheckErrorMessage, QueryNSWStatus) VALUES " +
"(@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, " + "(@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, " +
"@P18, @P19, @P20, @P21, @P22, @P23, @P24, @P25, @P26, @P27, @P28)", "@P18, @P19, @P20, @P21, @P22, @P23, @P24, @P25, @P26, @P27, @P28, @P29, @P30, @P31, @P32, @P33, @P34, @P35, @P36)",
this.Tablename); this.Tablename);
scmd.CommandText = query; scmd.CommandText = query;
} }
@ -275,7 +286,9 @@ namespace bsmd.database
"HerbergFormTemplateGuid = @P16, HerbergReportType = @P17, HerbergEmailContactReportingVessel = @P18, " + "HerbergFormTemplateGuid = @P16, HerbergReportType = @P17, HerbergEmailContactReportingVessel = @P18, " +
"HerbergEmail24HrsContact = @P19, ETAKielCanal = @P20, HerbergRevDate = @P21, ReportStatus = @P22, " + "HerbergEmail24HrsContact = @P19, ETAKielCanal = @P20, HerbergRevDate = @P21, ReportStatus = @P22, " +
"SietasSheetVersion = @P23, Incoming = @P24, DefaultReportingPartyId = @P25, CreateExcel = @P26, EditedBy = @P27, " + "SietasSheetVersion = @P23, Incoming = @P24, DefaultReportingPartyId = @P25, CreateExcel = @P26, EditedBy = @P27, " +
"TicketNo = @P28 WHERE Id = @ID", this.Tablename); "TicketNo = @P28, Cancelled = @P29, VisitIdOrTransitIdCancellable = @P30, BlockedNotificationClasses = @P31, " +
"FreeNotificationClasses = @P32, OwnNotificationClasses = @P33, StatusCheckErrorCode = @P34, StatusCheckErrorMessage = @P35, " +
"QueryNSWStatus = @P36 WHERE Id = @ID", this.Tablename);
scmd.CommandText = query; scmd.CommandText = query;
} }
} }
@ -287,7 +300,9 @@ namespace bsmd.database
"[{0}].[ETA], [{0}].[CustomerId], [{0}].[Previous], [{0}].[Next], [{0}].[IsTransit], [{0}].[Wetris_zz_56_datensatz_id], [{0}].[BSMDStatus], " + "[{0}].[ETA], [{0}].[CustomerId], [{0}].[Previous], [{0}].[Next], [{0}].[IsTransit], [{0}].[Wetris_zz_56_datensatz_id], [{0}].[BSMDStatus], " +
"[{0}].[InitialHIS], [{0}].[HerbergFormGuid], [{0}].[HerbergFormTemplateGuid], [{0}].[HerbergReportType], [{0}].[HerbergEmailContactReportingVessel], " + "[{0}].[InitialHIS], [{0}].[HerbergFormGuid], [{0}].[HerbergFormTemplateGuid], [{0}].[HerbergReportType], [{0}].[HerbergEmailContactReportingVessel], " +
"[{0}].[HerbergEmail24HrsContact], [{0}].[ETAKielCanal], [{0}].[HerbergRevDate], [{0}].[ReportStatus], [{0}].[SietasSheetVersion], [{0}].[Incoming], " + "[{0}].[HerbergEmail24HrsContact], [{0}].[ETAKielCanal], [{0}].[HerbergRevDate], [{0}].[ReportStatus], [{0}].[SietasSheetVersion], [{0}].[Incoming], " +
"[{0}].[DefaultReportingPartyId], [{0}].[Created], [{0}].[Changed], [{0}].[CreateExcel], [{0}].[EditedBy], [{0}].[TicketNo] FROM {0} ", "[{0}].[DefaultReportingPartyId], [{0}].[Created], [{0}].[Changed], [{0}].[CreateExcel], [{0}].[EditedBy], [{0}].[TicketNo], " +
"[{0}].[Cancelled], [{0}].[VisitIdOrTransitIdCancellable], [{0}].[BlockedNotificationClasses], [{0}].[FreeNotificationClasses], " +
"[{0}].[OwnNotificationClasses], [{0}].[StatusCheckErrorCode], [{0}].[StatusCheckErrorMessage], [{0}].[QueryNSWStatus] FROM {0} ",
this.Tablename)); this.Tablename));
switch (filter) switch (filter)
@ -347,6 +362,11 @@ namespace bsmd.database
sb.Append("WHERE CreateExcel = 1"); sb.Append("WHERE CreateExcel = 1");
break; break;
} }
case Message.LoadFilter.QUERY_NSW_STATUS:
{
sb.Append("WHERE QueryNSWStatus = 1");
break;
}
case Message.LoadFilter.SEARCH_CORE_FILTERS: case Message.LoadFilter.SEARCH_CORE_FILTERS:
{ {
// object ist jetzt ein dict aus filtertyp und filterparameter // object ist jetzt ein dict aus filtertyp und filterparameter
@ -478,6 +498,14 @@ namespace bsmd.database
if (!reader.IsDBNull(28)) core.CreateExcel = reader.GetBoolean(28); if (!reader.IsDBNull(28)) core.CreateExcel = reader.GetBoolean(28);
if (!reader.IsDBNull(29)) core.EditedBy = reader.GetString(29); if (!reader.IsDBNull(29)) core.EditedBy = reader.GetString(29);
if (!reader.IsDBNull(30)) core.TicketNo = reader.GetString(30); if (!reader.IsDBNull(30)) core.TicketNo = reader.GetString(30);
if (!reader.IsDBNull(31)) core.Cancelled = reader.GetBoolean(31);
if (!reader.IsDBNull(32)) core.VisitIdOrTransitIdCancellable = reader.GetBoolean(32);
if (!reader.IsDBNull(33)) core.BlockedNotificationClasses = reader.GetString(33);
if (!reader.IsDBNull(34)) core.FreeNotificationClasses = reader.GetString(34);
if (!reader.IsDBNull(35)) core.OwnNotificationClasses = reader.GetString(35);
if (!reader.IsDBNull(36)) core.StatusCheckErrorCode = reader.GetString(36);
if (!reader.IsDBNull(37)) core.StatusCheckErrorMessage = reader.GetString(37);
if (!reader.IsDBNull(38)) core.QueryNSWStatus = reader.GetBoolean(38);
result.Add(core); result.Add(core);
} }

View File

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

View File

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

View File

@ -39,8 +39,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
@ -126,9 +126,7 @@
<ItemGroup> <ItemGroup>
<None Include="..\bsmdKey.snk" /> <None Include="..\bsmdKey.snk" />
<None Include="bsmd.database.licenseheader" /> <None Include="bsmd.database.licenseheader" />
<None Include="packages.config"> <None Include="packages.config" />
<SubType>Designer</SubType>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.7" targetFramework="net45" /> <package id="log4net" version="2.0.8" targetFramework="net45" />
</packages> </packages>

View File

@ -36,8 +36,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.7" targetFramework="net45" /> <package id="log4net" version="2.0.8" targetFramework="net45" />
</packages> </packages>

View File

@ -36,8 +36,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.7" targetFramework="net45" /> <package id="log4net" version="2.0.8" targetFramework="net45" />
</packages> </packages>

View File

@ -1,43 +1,103 @@
// Copyright (c) 2017 schick Informatik // Copyright (c) 2017 schick Informatik
// Description: // Description: Query NSW via HIS-Nord for free / taken message classes and visit id
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
using System.Net; using System.Net;
using log4net;
using bsmd.database;
namespace bsmd.status namespace bsmd.status
{ {
public class Status public class Status
{ {
public void PerformQuery(string visitId) private static ILog _log = LogManager.GetLogger(typeof(bsmd.status.Status));
private MessageCore _queryCore;
public Status(MessageCore core2Query) { _queryCore = core2Query; }
public void PerformQuery()
{ {
if (this._queryCore == null) return;
using (WebClient client = new WebClient()) using (WebClient client = new WebClient())
{ {
client.UploadValuesCompleted += Client_UploadValuesCompleted; try
{
client.UploadValuesAsync(new Uri(Properties.Settings.Default.url), byte[] resultData = client.UploadValues(new Uri(Properties.Settings.Default.url),
new NameValueCollection() new NameValueCollection()
{ {
// ich glaube ein HTML Encoding braucht man hier nicht? // ich glaube ein HTML Encoding braucht man hier nicht?
{ "login", Properties.Settings.Default.login }, { "login", Properties.Settings.Default.login },
{ "password", Properties.Settings.Default.password }, { "password", Properties.Settings.Default.password },
{ "visitIdTransitId", visitId }, { "visitIdTransitId", _queryCore.IsTransit ? _queryCore.TransitId : _queryCore.VisitId },
{ "format", Properties.Settings.Default.format } { "format", Properties.Settings.Default.format }
}); });
}
}
private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
{ // Do some log output
if(e.Result != null)
{ string resultString = Encoding.UTF8.GetString(resultData);
string result = Encoding.UTF8.GetString(e.Result);
_log.InfoFormat("Status query result: {0}", resultString);
dataset result = null;
try
{
result = dataset.ReadStatus(resultString);
}
catch (Exception ex)
{
_log.ErrorFormat("Error parsing status request result: {0}", ex.ToString());
}
if (result != null)
{
// Update database with result values
if (result.NswResponse != null)
{
// three-way bool!
if (result.NswResponse.Cancelled != null)
_queryCore.Cancelled = result.NswResponse.Equals("Y") ? true : false;
else
_queryCore.Cancelled = null;
if (result.NswResponse.VisitIdOrTransitIdCancellable != null)
_queryCore.VisitIdOrTransitIdCancellable = result.NswResponse.VisitIdOrTransitIdCancellable.Equals("Y") ? true : false;
else
_queryCore.VisitIdOrTransitIdCancellable = null;
_queryCore.BlockedNotificationClasses = result.NswResponse.BlockedNotificationClasses;
_queryCore.OwnNotificationClasses = result.NswResponse.OwnNotificationClasses;
_queryCore.FreeNotificationClasses = result.NswResponse.FreeNotificationClasses;
_queryCore.StatusCheckErrorCode = result.NswResponse.ErrorCode;
_queryCore.StatusCheckErrorMessage = result.NswResponse.ErrorMessage;
}
else
{
if(result.LoginError != null)
{
_log.ErrorFormat("Login error: {0}", result.LoginError);
}
}
}
else
{
_log.Error("parsing result status failed");
}
DBManager.Instance.Save(_queryCore);
}
catch (Exception e)
{
_log.ErrorFormat("Error uploading status request values: {0}", e.ToString());
}
} }
} }
} }

View File

@ -30,7 +30,17 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -66,8 +76,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\bsmdKey.snk">
<Link>bsmdKey.snk</Link>
</None>
<None Include="app.config" /> <None Include="app.config" />
<None Include="bsmd.status.licenseheader" /> <None Include="bsmd.status.licenseheader" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -25,6 +25,10 @@ namespace bsmd.status
public string VisitIdTransitId { get; set; } public string VisitIdTransitId { get; set; }
public string LoginError { get; set; }
public NswResponse NswResponse { get; set; }
#endregion #endregion
#region Deserialization #region Deserialization
@ -55,6 +59,9 @@ namespace bsmd.status
[Serializable] [Serializable]
public class NswResponse public class NswResponse
{ {
public NswResponse() { }
#region Properties #region Properties
public string Cancelled { get; set; } public string Cancelled { get; set; }

Binary file not shown.