Härten der Anwendung ;-)

"Hänger" der Transmitter-Situation geklärt (umgeleitete Streams und vollgelaufene Buffer führen hier zu einem (obskuren!) Deadlock.
This commit is contained in:
Daniel Schick 2017-11-10 18:23:42 +00:00
parent dd453176e4
commit fc92303439
23 changed files with 424 additions and 129 deletions

View File

@ -28,13 +28,20 @@ namespace ENI2.Controls
InitializeComponent();
}
public enum LocodeMode
{
STANDARD,
NO_PORT_FLAG,
SSN
};
protected enum LocodeState
{
UNKNOWN,
INVALID,
OK,
AMBIGUOUS
}
};
/// <summary>
/// used internally to load up drop down
@ -50,8 +57,16 @@ namespace ENI2.Controls
get { return this.comboBoxLocode.SelectedItem as string; }
set {
this._locodeList.Clear();
string portName = this.UseSSNCodes ? LocalizedLookup.SSNPortNameFromLocode(value) : LocodeDB.PortNameFromLocode(value);
string portName = null;
switch (this.LocodeSource)
{
case LocodeMode.NO_PORT_FLAG:
portName = LocodeDB.LocationNameFromLocode(value); break;
case LocodeMode.STANDARD:
portName = LocodeDB.PortNameFromLocode(value); break;
case LocodeMode.SSN:
portName = LocalizedLookup.SSNPortNameFromLocode(value); break;
}
LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK;
this.SetLocodeStateImage(this.imageLocodeState, locodeState);
@ -74,10 +89,7 @@ namespace ENI2.Controls
set { SetValue(LocodeValueProperty, value); }
}
/// <summary>
/// Use alternate Locode Source (for NOA_NOD NextPort if unspecif. (888))
/// </summary>
public bool UseSSNCodes { get; set; }
public LocodeMode LocodeSource { get; set; }
#region static methods
@ -122,7 +134,17 @@ namespace ENI2.Controls
if (this.comboBoxLocode.Text.Length == 5)
{
string directLocode = this.comboBoxLocode.Text.Trim().ToUpper();
string portname = this.UseSSNCodes ? LocalizedLookup.SSNPortNameFromLocode(directLocode) : LocodeDB.PortNameFromLocode(directLocode);
string portname = null;
switch(this.LocodeSource)
{
case LocodeMode.NO_PORT_FLAG:
portname = LocodeDB.LocationNameFromLocode(directLocode); break;
case LocodeMode.STANDARD:
portname = LocodeDB.PortNameFromLocode(directLocode); break;
case LocodeMode.SSN:
portname = LocalizedLookup.SSNPortNameFromLocode(directLocode); break;
}
bool isLocode = !portname.IsNullOrEmpty();
if (isLocode)
{
@ -138,7 +160,17 @@ namespace ENI2.Controls
{
// assume this is a harbour name typed out..
string lookupString = string.Format("%{0}%", this.comboBoxLocode.Text.Trim());
List<LocodeDB.LocodeEntry> locodeEntries = this.UseSSNCodes ? LocalizedLookup.SSNAllLocodesForCityNameAsEntries(lookupString) : LocodeDB.AllLocodesForCityNameAsEntries(lookupString);
List<LocodeDB.LocodeEntry> locodeEntries = null;
switch(this.LocodeSource)
{
case LocodeMode.NO_PORT_FLAG:
locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(lookupString, false); break;
case LocodeMode.STANDARD:
locodeEntries = LocodeDB.AllLocodesForCityNameAsEntries(lookupString); break;
case LocodeMode.SSN:
locodeEntries = LocalizedLookup.SSNAllLocodesForCityNameAsEntries(lookupString); break;
}
locodeEntries.Sort();
foreach (LocodeDB.LocodeEntry entry in locodeEntries)

View File

@ -65,7 +65,7 @@
<CheckBox Name="checkSimplification" IsChecked="{Binding MDHSimplification}" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"/>
<enictrl:LocodeControl x:Name="locodePortWhereHealthDeclarationWasGiven" Grid.Row="1" Grid.Column="1" LocodeValue="{Binding PortOfCallWhereCompleteMDHNotified}" />
<enictrl:LocodeControl x:Name="locodePortWhereHealthDeclarationWasGiven" Grid.Row="1" Grid.Column="1" LocodeValue="{Binding PortOfCallWhereCompleteMDHNotified, Mode=TwoWay}" />
<CheckBox Name="checkBoxHavePersonsDied" IsChecked="{Binding NonAccidentalDeathsDuringVoyage}" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"/>
<xctk:IntegerUpDown Name="integerUpDownNumberOfDeaths" Grid.Row="3" Grid.Column="3" Value="{Binding NonAccidentalDeathsDuringVoyageCount}" Margin="2" ShowButtonSpinner="False" TextAlignment="Left"/>
<CheckBox Name="checkBoxIsSuspectedInfectious" IsChecked="{Binding SuspisionInfectiousNature}" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"/>

View File

@ -48,7 +48,7 @@
<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}"/>
<enictrl:LocodeControl Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Width="Auto" x:Name="locodePoC" LocodeValue="{Binding PoC, Mode=TwoWay}" IsEnabled="False" />
<!--Grid Grid.Column="1" Grid.Row="0" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@ -60,9 +60,9 @@
<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" VerticalContentAlignment="Center" />
<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" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxIMO" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="1" Text="{Binding IMO, Mode=TwoWay}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<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" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxENI" Grid.Row="1" Grid.Column="4" Grid.ColumnSpan="2" Text="{Binding ENI, Mode=TwoWay}" Margin="2" IsReadOnly="True" VerticalContentAlignment="Center"/>
<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="3" Grid.Column="0" Content="{x:Static p:Resources.textATAPortOfCall}" Margin="0,0,10,0" />
@ -241,6 +241,13 @@
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="HIS" Binding="{Binding HIS}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textStatusInfo}" Binding="{Binding StatusInfo}" IsReadOnly="True" Width="0.3*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">

View File

@ -38,9 +38,13 @@ namespace ENI2.DetailViewControls
private void OverViewDetailControl_Loaded(object sender, RoutedEventArgs e)
{
// die Controls nach Änderungen monitoren
// diese Einträge gehen auf core
this.RegisterTextboxChange(this.textBoxTicketNo, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxDisplayId, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxIMO, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxENI, Message.NotificationClass.ATA);
this.RegisterLocodeChange(this.locodePoC, Message.NotificationClass.ATA);
this.RegisterTextboxChange(this.textBoxTicketNo, this.Core.IsTransit ? Message.NotificationClass.TRANSIT : Message.NotificationClass.VISIT);
this.RegisterTextboxChange(this.textBoxDisplayId, this.Core.IsTransit ? Message.NotificationClass.TRANSIT : Message.NotificationClass.VISIT);
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
this.RegisterDateTimePickerChange(this.dateTimePickerETA, Message.NotificationClass.NOA_NOD);
@ -56,6 +60,14 @@ namespace ENI2.DetailViewControls
if (this.Messages == null) return;
if (this.Core == null) return;
if(DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin)
{
this.textBoxENI.IsReadOnly = false;
this.textBoxIMO.IsReadOnly = false;
this.locodePoC.IsEnabled = true;
this.textBoxDisplayId.IsReadOnly = false;
}
this.textBoxENI.DataContext = this.Core;
this.textBoxIMO.DataContext = this.Core;
this.locodePoC.DataContext = this.Core;
@ -330,6 +342,7 @@ namespace ENI2.DetailViewControls
#endregion
this.dataGridMessages.ItemsSource = this.Messages;
base.Initialize(); // wenn Meldeklassen erst bei der Init. erzeugt werden, fehlen die Handler, die hier erneut festgelegt werden
this._initialized = true;
}
@ -414,6 +427,12 @@ namespace ENI2.DetailViewControls
{
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
string userName = "?";
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
{
userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
}
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
}

View File

@ -48,7 +48,7 @@
<xctk:DateTimePicker Grid.Column="3" Grid.Row="1" Value="{Binding ETDFromKielCanal, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePicker_ETDFromKielCanal" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="2" Width="Auto" x:Name="locodeControl_LastPort" LocodeValue="{Binding LastPort, Mode=TwoWay}"/>
<xctk:DateTimePicker Grid.Column="3" Grid.Row="2" Value="{Binding ETDFromLastPort, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePicker_ETDFromLastPort" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="3" Width="Auto" x:Name="locodeControl_NextPort" LocodeValue="{Binding NextPort, Mode=TwoWay}" UseSSNCodes="True"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="3" Width="Auto" x:Name="locodeControl_NextPort" LocodeValue="{Binding NextPort, Mode=TwoWay}" LocodeSource="SSN" />
<xctk:DateTimePicker Grid.Column="3" Grid.Row="3" Value="{Binding ETAToNextPort, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePicker_ETAToNextPort" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="False" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left"/>

View File

@ -10,7 +10,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.DetailViewControls"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1024">
d:DesignHeight="700" d:DesignWidth="1024">
<TabControl Margin="10" Name="mainFrame">
<TabItem Header="{x:Static p:Resources.textSecurityNotification}" Name="tabSecurityNotification">
<GroupBox Name="secGroupBox" Header="{x:Static p:Resources.textSEC}">
@ -72,7 +72,7 @@
<xctk:DateTimePicker Name="dateTimePickerKielCanalPassagePlannedOutgoing" Grid.Row="1" Grid.Column="3" Value="{Binding KielCanalPassagePlannedOutgoing, Converter={util:UtcToLocalDateTimeConverter}}" Margin="2" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" ContextMenu="{DynamicResource ClearContextMenu}" TextAlignment="Left"/>
<ComboBox Name="comboBoxCurrentShipSecurityLevel" Grid.Row="3" Grid.Column="1" SelectedValue="{Binding CurrentShipSecurityLevel}" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<CheckBox Name="checkBoxSECSimplification" IsChecked="{Binding SECSimplification}" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"/>
<enictrl:LocodeControl x:Name="locodePortOfCallWhereCompleteSECNotified" Grid.Row="6" Grid.Column="1" LocodeValue="{Binding PortOfCallWhereCompleteSECNotified}" />
<enictrl:LocodeControl x:Name="locodePortOfCallWhereCompleteSECNotified" Grid.Row="6" Grid.Column="1" LocodeValue="{Binding PortOfCallWhereCompleteSECNotified, Mode=TwoWay}" />
<TextBox Name="textBoxCSOFirstName" Grid.Row="8" Grid.Column="1" MaxLength="100" Text="{Binding CSOFirstName}" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxCSOLastName" Grid.Row="8" Grid.Column="3" MaxLength="100" Text="{Binding CSOLastName}" Margin="2" VerticalContentAlignment="Center"/>
<TextBox Name="textBoxCSOPhoneName" Grid.Row="9" Grid.Column="1" MaxLength="100" Text="{Binding CSOPhone}" Margin="2" VerticalContentAlignment="Center"/>

View File

@ -53,7 +53,7 @@
<TextBox Name="textBoxCallsign" Grid.Column="4" Grid.Row="1" Text="{Binding CallSign}" Margin="2" VerticalContentAlignment="Center"/>
<ComboBox Name="comboBoxTransportMode" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Margin="2" SelectedValue="{Binding TransportMode}" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<ComboBox Name="comboBoxFlag" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Margin="2" SelectedValue="{Binding Flag}" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<enictrl:LocodeControl x:Name="locodePortOfRegistry" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2" LocodeValue="{Binding PortOfRegistry, Mode=TwoWay}" />
<enictrl:LocodeControl x:Name="locodePortOfRegistry" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2" LocodeValue="{Binding PortOfRegistry, Mode=TwoWay}" LocodeSource="NO_PORT_FLAG" />
<xctk:IntegerUpDown Name="integerUpDownGrossTonnage" Grid.Column="1" Grid.Row="4" Margin="2" Value="{Binding GrossTonnage}" ShowButtonSpinner="False" TextAlignment="Left"/>
<Label Content="t" Grid.Column="2" Grid.Row="4" />

View File

@ -35,8 +35,8 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.8.1.%2a</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>3.8.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -8,7 +8,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textCoreStatus}" Height="316" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" >
Title="{x:Static p:Resources.textCoreStatus}" Height="436" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"/>
@ -17,9 +17,9 @@
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="80" />
<RowDefinition Height="80" />
<RowDefinition Height="80" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>

View File

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:util="clr-namespace:ENI2.Util"
xmlns:local="clr-namespace:ENI2"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
@ -37,7 +38,7 @@
<Label HorizontalContentAlignment="Right" Grid.Column="2" Grid.Row="1" Content="ETA" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Column="2" Grid.Row="2" Content="Ticket-No." Margin="0,0,10,0"/>
<TextBox Grid.Column="1" Grid.Row="0" Name="textBoxId" VerticalContentAlignment="Center" Margin="2"/>
<TextBox Grid.Column="1" Grid.Row="1" Name="textBoxIMO" VerticalContentAlignment="Center" Margin="2" MaxLength="7"/>
<TextBox Grid.Column="1" Grid.Row="1" Name="textBoxIMO" VerticalContentAlignment="Center" Margin="2" MaxLength="8"/>
<TextBox Grid.Column="1" Grid.Row="2" Name="textBoxName" VerticalContentAlignment="Center" Margin="2"/>
<TextBox Grid.Column="3" Grid.Row="0" Name="textBoxHafen" VerticalContentAlignment="Center" Margin="2"/>
<Grid Grid.Column="3" Grid.Row="1" Height="Auto" Margin="2">
@ -71,12 +72,12 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="IMO" Binding="{Binding IMO}" IsReadOnly="True" />
<DataGridTextColumn Header="IMO/ENI" Binding="{Binding IMOENIDisplay}" IsReadOnly="True" />
<DataGridTextColumn Header="Ship name" Binding="{Binding Shipname}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA_NOA_NOD, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="ETD" Binding="{Binding ETD_NOA_NOD, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="ATA" Binding="{Binding ATA, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="ATD" Binding="{Binding ATD, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" IsReadOnly="True" />
<DataGridTextColumn Header="ETA" Binding="{Binding ETA_NOA_NOD, StringFormat=\{0:dd.MM.yyyy HH:mm\}, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" />
<DataGridTextColumn Header="ETD" Binding="{Binding ETD_NOA_NOD, StringFormat=\{0:dd.MM.yyyy HH:mm\}, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" />
<DataGridTextColumn Header="ATA" Binding="{Binding ATA, StringFormat=\{0:dd.MM.yyyy HH:mm\}, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" />
<DataGridTextColumn Header="ATD" Binding="{Binding ATD, StringFormat=\{0:dd.MM.yyyy HH:mm\}, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" />
<DataGridTextColumn Header="Hafen" Binding="{Binding PortnameDisplay}" IsReadOnly="True" />
<DataGridTextColumn Header="Id" Binding="{Binding DisplayId}" IsReadOnly="True" />
<DataGridTextColumn Header="Status" Binding="{Binding BSMDStatusInternal}" IsReadOnly="True" />

View File

@ -237,18 +237,16 @@ namespace SendNSWMessageService
didSendSomething = true;
break;
case Message.NSWProvider.DBH:
coreSendSucceeded = bsmd.dbh.Request.SendCancelCore(core, false);
break;
case Message.NSWProvider.DBH_TEST:
coreSendSucceeded = bsmd.dbh.Request.SendCancelCore(core, true);
break;
default:
_log.WarnFormat("Cancelling for HIS {0} is not supported", core.InitialHIS);
break;
}
}
}

View File

@ -80,7 +80,7 @@ namespace bsmd.ExcelReadService
return results;
}
public static List<LocodeEntry> AllLocodesForCityNameAsEntries(string city)
public static List<LocodeEntry> AllLocodesForCityNameAsEntries(string city, bool onlyPorts = true)
{
List<LocodeEntry> results = new List<LocodeEntry>();
if (city.Contains(","))
@ -96,7 +96,11 @@ namespace bsmd.ExcelReadService
results.Add(entry);
}
}
string query = "SELECT locodes.name_wo_diacritics, city_code, countries.code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND (locodes.name like $PAR OR locodes.name_wo_diacritics like $PAR)";
if(!onlyPorts)
query = "SELECT locodes.name_wo_diacritics, city_code, countries.code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE (locodes.name like $PAR OR locodes.name_wo_diacritics like $PAR)";
SQLiteCommand cmd = new SQLiteCommand(query, _con);
cmd.Parameters.AddWithValue("$PAR", city);
IDataReader reader = cmd.ExecuteReader();
@ -157,6 +161,31 @@ namespace bsmd.ExcelReadService
return result;
}
/// <summary>
/// Get Locationname from LOCODE
/// </summary>
/// <param name="locode"></param>
/// <returns></returns>
public static string LocationNameFromLocode(string locode)
{
if (locode.IsNullOrEmpty()) return null;
if (locode.Length != 5) return null;
string result = null;
string query = string.Format("SELECT locodes.name_wo_diacritics FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.city_code = '{0}' AND countries.code = '{1}'",
locode.Substring(2), locode.Substring(0, 2));
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (!reader.IsDBNull(0))
result = reader.GetString(0);
break;
}
reader.Close();
return result;
}
public static void CloseDB()
{

View File

@ -1825,6 +1825,7 @@ namespace bsmd.ExcelReadService
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = null;
s2sActivity.ShipToShipActivityDateFrom = reader.ReadDate(s2sFromDate);
s2sActivity.ShipToShipActivityDateTo = reader.ReadDate(s2sToDate);
s2sActivity.ShipToShipActivityTypeCode = (int?) reader.ReadNumber(s2sActivityString);
s2sActivity.ShipToShipActivityType = reader.ReadShip2ShipActivityType(s2sActivityString);
s2sActivity.ShipToShipActivitySecurityMattersToReport = reader.ReadText(s2sSec);
reader.Conf.ConfirmText(s2sSec, s2sActivity.ShipToShipActivitySecurityMattersToReport, s2sActivity.ShipToShipActivitySecurityMattersToReport.IsNullOrEmpty() ? ExcelReader.ReadState.NONE : ExcelReader.ReadState.OK);

View File

@ -362,7 +362,9 @@ namespace bsmd.database
/// <summary>
/// Dieses Flag wird gesetzt, sobald die Meldeklasse *einmal* erfolgreich gesendet wurde. Es bleibt bestehen, auch
/// wenn ein nachfolgender Sendevorgang auf einen Fehler läuft
/// wenn ein nachfolgender Sendevorgang auf einen Fehler läuft. Neue Interpretation (10.11.17):
/// Das Flag bedeutet, dass beim NSW Inhalte hinterlegt sind
/// -> bei einem erfolgreichen Reset muss das Flag wieder zurück gesetzt werden
/// </summary>
public bool? SendSuccess { get; set; }

View File

@ -114,6 +114,20 @@ namespace bsmd.database
[ENI2Validation]
public string ENI { get; set; }
/// <summary>
/// ENI-2 helper field
/// </summary>
public string IMOENIDisplay
{
get
{
if (this.IMO.IsNullOrEmpty())
return this.ENI;
else
return this.IMO;
}
}
[MaxLength(5)]
[ENI2Validation]
public string PoC { get; set; }
@ -473,18 +487,18 @@ namespace bsmd.database
if (from.HasValue && !to.HasValue)
{
sb.Append(" (ETA > @SEARCHFROM) ");
sb.Append(" ((ETA > @SEARCHFROM) OR (ETAKielCanal > @SEARCHFROM)) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHFROM", from.Value.FromUnixTimeStamp());
}
if (to.HasValue && !from.HasValue)
{
sb.Append(" (ETA < @SEARCHTO) ");
sb.Append(" ((ETA < @SEARCHTO) OR (ETAKielCanal < @SEARCHTO)) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHTO", to.Value.FromUnixTimeStamp());
}
if (from.HasValue && to.HasValue)
{
sb.Append(" (ETA > @SEARCHFROM AND ETA < @SEARCHTO) ");
sb.Append(" ((ETA > @SEARCHFROM AND ETA < @SEARCHTO) OR (ETAKielCanal > @SEARCHFROM AND ETAKielCanal < @SEARCHTO)) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHFROM", from.Value.FromUnixTimeStamp());
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCHTO", to.Value.FromUnixTimeStamp());
}
@ -495,7 +509,7 @@ namespace bsmd.database
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCH_ID", string.Format("%{0}%", searchDict[key]));
break;
case SearchFilterType.FILTER_IMO:
sb.Append(" IMO = @SEARCH_IMO ");
sb.Append(" (IMO = @SEARCH_IMO OR ENI = @SEARCH_IMO) ");
((SqlCommand)cmd).Parameters.AddWithValue("@SEARCH_IMO", searchDict[key]);
break;
case SearchFilterType.FILTER_PORT:

View File

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

View File

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

View File

@ -5,7 +5,7 @@
// Author: dani
// Created: 3/1/2015 8:05:05 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
// Copyright (c) 2015-2017 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
@ -21,6 +21,90 @@ namespace bsmd.dbh
{
private static ILog _log = LogManager.GetLogger(typeof(Request));
public static bool SendCancelCore(MessageCore core, bool useTest)
{
if ((core == null) || !(core.Cancelled ?? false)) return false;
if (!core.DefaultReportingPartyId.HasValue ||
!DBManager.Instance.GetReportingPartyDict().ContainsKey(core.DefaultReportingPartyId.Value))
{
_log.ErrorFormat("Default reporting party not set / found on core {0}, aborting CANCEL", core.Id);
return false;
}
RootType rootType = RootType.CANCEL;
Dbh_Osis_Answ_Ws client = new Dbh_Osis_Answ_Ws();
if (useTest)
client.Url = "https://edi-gate.dbh.de/test/bsmd-soap";
bsmd.database.ReportingParty reportingParty = DBManager.Instance.GetReportingPartyDict()[core.DefaultReportingPartyId.Value];
DBHWebReference.ReportingParty rp = new DBHWebReference.ReportingParty();
rp.RPCity = reportingParty.City;
rp.RPCountry = reportingParty.Country;
rp.RPEMail = reportingParty.EMail;
rp.RPFax = reportingParty.Fax;
rp.RPFirstName = reportingParty.FirstName;
rp.RPLastName = reportingParty.LastName;
rp.RPName = reportingParty.Name;
rp.RPPhone = reportingParty.Phone;
rp.RPPostalCode = reportingParty.PostalCode;
rp.RPStreetAndNumber = reportingParty.StreetAndNumber;
rp.RPTypeSpecified = reportingParty.ReportingPartyType.HasValue;
if (rp.RPTypeSpecified)
rp.RPType = (ReportingPartyRPType)reportingParty.ReportingPartyType.Value;
try
{
object[] items = new object[1];
DateTime timestamp = DateTime.Now;
string version = "3.0";
object item = null;
string senderReference = core.Id.Value.ToString("N");
items[0] = item;
ItemChoiceType2 itemChoiceType2;
if (core.IsTransit)
{
item = core.TransitId;
itemChoiceType2 = DBHWebReference.ItemChoiceType2.TransitId;
}
else
{
item = core.VisitId;
itemChoiceType2 = DBHWebReference.ItemChoiceType2.VisitId;
}
_log.InfoFormat("Send Url: {0}", client.Url);
RootVersion rootVersion = RootVersion.Item40;
string result = client.Root(
rootVersion,
version,
timestamp,
Properties.Settings.Default.Sender, // BSMD sender Kennung (festverdrahtet)
senderReference,
rootType,
item,
itemChoiceType2,
null, // sisnumbers (weglassen)
rp,
items,
null // violations (weglassen)
);
}
catch (Exception ex)
{
_log.ErrorFormat("Exception on dbh message send: {0}", ex.Message);
if (ex.InnerException != null)
_log.ErrorFormat("Inner exception: {0}", ex.InnerException.Message);
return false;
}
return true;
}
public static bool SendMessage(Message message, bool useTest)
{
if (message == null) return false;
@ -363,10 +447,14 @@ namespace bsmd.dbh
if (shipToShip.ShipToShipActivityDateTo.HasValue)
s2s.ShipToShipActivityDateTo = shipToShip.ShipToShipActivityDateTo.Value;
int activityType;
if (!Int32.TryParse(shipToShip.ShipToShipActivityType, out activityType))
activityType = NOA_NOD.getCallPurposeCodeFromDescription(shipToShip.ShipToShipActivityType) ?? 0;
s2s.ShipToShipActivityType = activityType;
//int activityType;
//if (!Int32.TryParse(shipToShip.ShipToShipActivityType, out activityType))
//activityType = NOA_NOD.getCallPurposeCodeFromDescription(shipToShip.ShipToShipActivityType) ?? 0;
//s2s.ShipToShipActivityType = activityType;
if (shipToShip.ShipToShipActivityTypeCode.HasValue)
s2s.ShipToShipActivityType = shipToShip.ShipToShipActivityTypeCode.Value;
s2s.ShipToShipActivitySecurityMattersToReport = shipToShip.ShipToShipActivitySecurityMattersToReport;
}
}

View File

@ -50,15 +50,28 @@ namespace bsmd.dbh
_log.WarnFormat("SenderReference {0} is not a guid, skipping message processing!", SenderReference);
return;
}
DatabaseEntity dbEntity = DBManager.Instance.GetMessageById(messageId);
MessageCore aCore = null;
if (dbEntity == null)
{
aCore = DBManager.Instance.GetMessageCoreById(messageId);
if((aCore != null) && (Type == response.RootType.CANCEL))
{
_log.InfoFormat("Cancel confirmation received for {0} ({1})", aCore.Id, aCore.DisplayId);
aCore.BSMDStatusInternal = MessageCore.BSMDStatus.RESPONDED;
aCore.Cancelled = true;
DBManager.Instance.Save(aCore);
}
}
if (dbEntity == null)
{
_log.WarnFormat("Message with ID {0} not found in database, skipping", messageId);
_log.WarnFormat("Message / Core with ID {0} not found in database, skipping", messageId);
return;
}
if (!(dbEntity is Message))
if (!(dbEntity is Message) && (Type != dbh.response.RootType.CANCEL))
{
_log.WarnFormat("SenderReference DB Entity Object is no MessageHeader, aborting ({0})", dbEntity.GetType());
return;
@ -80,19 +93,12 @@ namespace bsmd.dbh
aMessage.SendSuccess = true;
DBManager.Instance.Save(aMessage.MessageCore);
break;
case dbh.response.RootType.CANCEL:
if ((ReportingClassesFull != null) && (ReportingClassesFull.Count > 0) &&
(int) ReportingClassesFull[0].ReportingClass[0] == (int)aMessage.MessageNotificationClass)
{
aMessage.Cancel = true;
aMessage.InternalStatus = Message.BSMDStatus.CONFIRMED;
}
break;
case dbh.response.RootType.RESET:
if ((ReportingClassesResetted != null) && (ReportingClassesResetted.Count > 0) &&
(int) ReportingClassesResetted[0] .ReportingClass[0] == (int)aMessage.MessageNotificationClass)
{
aMessage.Reset = true;
aMessage.SendSuccess = false; // zurücksetzen des "grünen Punkts" im ENI-2
aMessage.InternalStatus = Message.BSMDStatus.CONFIRMED;
}
break;

View File

@ -32,7 +32,7 @@ namespace bsmd.hisnord
{
XNamespace ns1 = "http://api.national-single-window.de/visitIdRequest";
XNamespace ns6 = "http://api.national-single-window.de/receipt";
//XNamespace ns15 = "http://api.national-single-window.de/statusForClientRequestId";
XNamespace statusNS = "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";
@ -65,6 +65,10 @@ namespace bsmd.hisnord
XNamespace bpolNS = "http://api.national-single-window.de/bpol";
XNamespace towaNS = "http://api.national-single-window.de/towa";
XNamespace towdNS = "http://api.national-single-window.de/towd";
XNamespace cancelVisitNS = "http://api.national-single-window.de/visitIdCancelRequest";
XNamespace cancelTransitNS = "http://api.national-single-window.de/transitIdCancelRequest";
XName lookupName = "dontmatchmeplease";
XName idName = "ConveyanceCode";
var elem = xml.Descendants(idName);
@ -104,16 +108,38 @@ namespace bsmd.hisnord
if (xml.Descendants(test).Count() > 0) notificationClass = Message.NotificationClass.TRANSIT;
}
if(!notificationClass.HasValue)
if (!notificationClass.HasValue)
{
XName cancelVisit = cancelVisitNS + "CancelVisitIdResponse";
XName cancelTransit = cancelTransitNS + "CancelTransitIdResponse";
if (xml.Descendants(cancelVisit).Count() > 0)
{
lookupName = cancelVisit;
notificationClass = Message.NotificationClass.STO; // HACK, es gibt keine Klasse für "Cancel"
_log.WarnFormat("CANCEL VISIT, setting Not.Class to STO (experimental)");
_notificationClass = Message.NotificationClass.STO;
}
else if(xml.Descendants(cancelTransit).Count() > 0)
{
lookupName = cancelTransit;
notificationClass = Message.NotificationClass.STO; // HACK, es gibt keine Klasse für "Cancel"
_log.WarnFormat("CANCEL TRANSIT, setting Not.Class to STO (experimental)");
_notificationClass = Message.NotificationClass.STO;
}
else
{
_log.WarnFormat("NSWResponse does not contain Notification class");
}
}
}
}
// detect response type
if(notificationClass.HasValue)
{
XName lookupName;
XName resetLookup = resetNS + "ResetResponse";
switch (notificationClass.Value)
@ -204,19 +230,10 @@ namespace bsmd.hisnord
case Message.NotificationClass.TOWD:
lookupName = towdNS + "TOWDResponse";
break;
default:
// we won't get answers for these message types
case Message.NotificationClass.STO:
case Message.NotificationClass.CREWD:
case Message.NotificationClass.PASD:
lookupName = "dontmatchmeplease";
resetLookup = "dontmatchmeplease";
break;
}
bool lookupMatch = (xml.Descendants(lookupName).Count() > 0);
bool resetMatch = (xml.Descendants(resetLookup).Count() > 0);

View File

@ -195,17 +195,20 @@ namespace bsmd.hisnord
hn_stat.GrossTonnage = stat.GrossTonnage.Value.ToString();
if(!stat.InmarsatCallNumber.IsNullOrEmpty())
hn_stat.InmarsatCallNumber = stat.InmarsatCallNumber;
if (!stat.ISMCompanyName.IsNullOrEmpty() || ((stat.GrossTonnage ?? 0) > 500)) // Vio. 821
{
hn_stat.ISMCompany = new ismcompany();
if(!stat.ISMCompanyCity.IsNullOrEmpty())
if (!stat.ISMCompanyCity.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity;
if(!stat.ISMCompanyCountry.IsNullOrEmpty())
if (!stat.ISMCompanyCountry.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry;
hn_stat.ISMCompany.ISMCompanyId = stat.ISMCompanyId;
hn_stat.ISMCompany.ISMCompanyName = stat.ISMCompanyName;
if(!stat.ISMCompanyPostalCode.IsNullOrEmpty())
if (!stat.ISMCompanyPostalCode.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode;
if(!stat.ISMCompanyStreetAndNumber.IsNullOrEmpty())
if (!stat.ISMCompanyStreetAndNumber.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber;
}
if (stat.LengthOverall_MTR.HasValue)
hn_stat.LengthOverall_MTR = (float)stat.LengthOverall_MTR.Value;
hn_stat.MMSINumber = stat.MMSINumber;
@ -905,7 +908,7 @@ namespace bsmd.hisnord
if (l10Called.PortFacilityDateOfDeparture.HasValue)
hn_last10port.PortFacilityDateOfDeparture = l10Called.PortFacilityDateOfDeparture.Value;
if (l10Called.PortFacilityShipSecurityLevel.HasValue)
hn_last10port.PortFacilityShipSecurityLevel = (posint13type)l10Called.PortFacilityShipSecurityLevel.Value;
hn_last10port.PortFacilityShipSecurityLevel = (posint13type) (l10Called.PortFacilityShipSecurityLevel.Value - 1);
if(!l10Called.PortFacilitySecurityMattersToReport.IsNullOrEmpty())
hn_last10port.PortFacilitySecurityMattersToReport = l10Called.PortFacilitySecurityMattersToReport;
hn_last10port.PortFacilityGISISCode = l10Called.PortFacilityGISISCode;
@ -948,10 +951,13 @@ namespace bsmd.hisnord
hn_lastactivity.ShipToShipActivityDateFrom = s2s.ShipToShipActivityDateFrom.Value;
if (s2s.ShipToShipActivityDateTo.HasValue)
hn_lastactivity.ShipToShipActivityDateTo = s2s.ShipToShipActivityDateTo.Value;
/*
int edifact8025;
if (Int32.TryParse(s2s.ShipToShipActivityType, out edifact8025) && (edifact8025 > 0) && (edifact8025 < 24))
hn_lastactivity.ShipToShipActivityType = edifact8025.ToString();
*/
if (s2s.ShipToShipActivityTypeCode.HasValue)
hn_lastactivity.ShipToShipActivityType = s2s.ShipToShipActivityTypeCode.Value.ToString();
hn_lastactivity.ShipToShipActivitySecurityMattersToReportOf = s2s.ShipToShipActivitySecurityMattersToReport;

View File

@ -67,7 +67,7 @@ namespace bsmd.hisnord
// declare Namespaces
XNamespace ns1 = "http://api.national-single-window.de/visitIdRequest";
XNamespace ns6 = "http://api.national-single-window.de/receipt";
//XNamespace ns15 = "http://api.national-single-window.de/statusForClientRequestId";
XNamespace ns14 = "http://api.national-single-window.de/statusForClientRequestId";
XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";
XNamespace ns15 = "http://api.national-single-window.de/visitIdResponse";
@ -133,6 +133,20 @@ namespace bsmd.hisnord
core.TransitId = nswResponse.TransitId;
}
if(nswResponse.NotificationClass == Message.NotificationClass.STO)
{
_log.InfoFormat("NSWRESPONSE Cancel Visit/Transit Reply: {0} Cancel? {1}",
nswResponse.Status,
(core.Cancelled ?? false) ? "YES" : "NO"
);
if ((nswResponse.Status == "REJECTED") && ((core.Cancelled ?? false) == true))
{
core.Cancelled = false; // CANCEL fehlgeschlagen
_log.InfoFormat("Cancel rejected for {0}", core.DisplayId);
}
}
core.BSMDStatusInternal = MessageCore.BSMDStatus.RESPONDED;
DBManager.Instance.Save(core);
@ -240,15 +254,29 @@ namespace bsmd.hisnord
// archive file
string answerArchiveDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot,
Properties.Settings.Default.AnswerArchiveDir);
try
{
File.Move(answerFile, Path.Combine(answerArchiveDir, Path.GetFileName(answerFile)));
}
catch(Exception ex)
{
_log.ErrorFormat("cannot move {0} to {1}:{2}", answerFile, answerArchiveDir, ex.Message);
}
}
else
{
// save in separate folder (to look at it later?)
string answerCorruptDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot,
Properties.Settings.Default.AnswerCorruptDir);
try
{
File.Move(answerFile, Path.Combine(answerCorruptDir, Path.GetFileName(answerFile)));
}
catch(Exception ex)
{
_log.ErrorFormat("cannot move {0} to {1}:{2}", answerFile, answerCorruptDir, ex.Message);
}
}
}
}

View File

@ -8,11 +8,8 @@
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using bsmd.database;
using log4net;
@ -22,56 +19,106 @@ namespace bsmd.hisnord
public class transmitter
{
private static ILog _log = LogManager.GetLogger(typeof(transmitter));
private static int? processId; // Achtung, das müsste getrennt behandelt werden Test <-> Livesystem!
private static int? processTestId;
public static void CallTransmitter(bool useTest)
{
string rootDir = useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot;
Process process = new Process();
process.StartInfo.WorkingDirectory = rootDir;
process.StartInfo.FileName = Path.Combine(rootDir, Properties.Settings.Default.Transmitter);
//_log.Debug(process.StartInfo.FileName);
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.UseShellExecute = false;
if(!useTest && processId.HasValue)
{
_log.InfoFormat("Transmitter process {0} still running, aborting call", processId);
return;
}
if(useTest && processTestId.HasValue)
{
_log.InfoFormat("Transmitter process (Test system) {0} still running, aborting call", processId);
return;
}
ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(rootDir, Properties.Settings.Default.Transmitter));
startInfo.WorkingDirectory = rootDir;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = false;
startInfo.UseShellExecute = false;
// der Transmitter schickt alles was im Ausgabe-Verzeichnis ist
// damit das gut geht schicken wir die Nachrichten einzeln und arbeiten jeweils das
// Ergebnis ab
process.Start();
int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms
if(!process.WaitForExit((timeout == 0) ? int.MaxValue : timeout))
Process transmitterProcess = new Process();
if (useTest)
{
_log.WarnFormat("Transmitter process not exited within {0} minute", Properties.Settings.Default.BatchTimeoutMins);
// kill Kill KILLLL!!!
try
{
process.Kill();
process.WaitForExit(500);
if (process.HasExited)
{
_log.Info("Transmitter killed, process exited");
transmitterProcess.Exited += TransmitterTestProcess_Exited;
}
else
{
_log.Warn("Killing Transmitter failed, this thing hangs and we're in trouble now");
transmitterProcess.Exited += TransmitterProcess_Exited;
}
transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived;
transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived;
transmitterProcess.StartInfo = startInfo;
transmitterProcess.EnableRaisingEvents = true;
transmitterProcess.Start();
transmitterProcess.BeginErrorReadLine();
transmitterProcess.BeginOutputReadLine();
int aProcessId = transmitterProcess.Id;
if (useTest)
{
processTestId = aProcessId;
}
else
{
processId = aProcessId;
}
// _log.DebugFormat("started {0}", transmitterProcess.ProcessName);
int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms
if(!transmitterProcess.WaitForExit((timeout == 0) ? int.MaxValue : timeout))
{
_log.WarnFormat("Transmitter process not exited within {0} minute", Properties.Settings.Default.BatchTimeoutMins);
// dauert zu lang, beende Prozess..
try
{
transmitterProcess.Kill();
_log.Info("Transmitter killed");
}
catch (Exception e)
{
_log.WarnFormat("Killing Transmitter failed: {0}", e.Message);
}
}
string errorString = process.StandardError.ReadToEnd();
if(!errorString.IsNullOrEmpty())
_log.ErrorFormat("HIS-Nord transmitter error: {0}", errorString);
}
// process.WaitForExit();
string outputString = process.StandardOutput.ReadToEnd();
if(!outputString.IsNullOrEmpty())
_log.DebugFormat("HIS-Nord transmitter: {0}", outputString);
// process.WaitForExit();
private static void TransmitterProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if(!e.Data.IsNullOrEmpty())
_log.Debug(e.Data);
}
private static void TransmitterProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if(!e.Data.IsNullOrEmpty())
_log.Error(e.Data);
}
private static void TransmitterTestProcess_Exited(object sender, EventArgs e)
{
_log.Debug("Transmitter process (test) exited");
processTestId = null;
}
private static void TransmitterProcess_Exited(object sender, EventArgs e)
{
_log.Debug("Transmitter process exited");
processId = null;
}
public static result GetResult(string filenameFullPath, bool useTest)