Merge branch 'release/eni_7.10'

This commit is contained in:
Daniel Schick 2023-03-22 11:15:20 +01:00
commit 4d7211a39e
43 changed files with 392 additions and 126 deletions

View File

@ -78,6 +78,9 @@
<DataTrigger Binding="{Binding Status}" Value="{x:Static db:MaerskData+MDStatus.NO_ID_AND_DUE}"> <DataTrigger Binding="{Binding Status}" Value="{x:Static db:MaerskData+MDStatus.NO_ID_AND_DUE}">
<Setter Property="Background" Value="Red"></Setter> <Setter Property="Background" Value="Red"></Setter>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="{x:Static db:MaerskData+MDStatus.CANCELLED}">
<Setter Property="Foreground" Value="DarkGray"/>
</DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</local:ENIDataGrid.RowStyle> </local:ENIDataGrid.RowStyle>

View File

@ -18,6 +18,7 @@ using ENI2.Locode;
using ENI2.Util; using ENI2.Util;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace ENI2.Controls namespace ENI2.Controls
{ {
@ -29,8 +30,7 @@ namespace ENI2.Controls
#region Fields #region Fields
private readonly ObservableCollection<MaerskData> maerskDataList = new ObservableCollection<MaerskData>(); private readonly ObservableCollection<MaerskData> maerskDataList = new ObservableCollection<MaerskData>();
private const uint MAX_EMPTY_ROWS_ON_IMPORT = 3; // import breaks if more than this count of empty rows have been read
private readonly DatabaseEntityWatchdog _dbWatchDog; private readonly DatabaseEntityWatchdog _dbWatchDog;
#endregion #endregion
@ -73,7 +73,16 @@ namespace ENI2.Controls
md.MessageCore = core; md.MessageCore = core;
md.Status = MaerskData.MDStatus.ID; md.Status = MaerskData.MDStatus.ID;
md.ColM = core.VisitId; md.ColM = core.VisitId;
await DBManagerAsync.Save(md); if (core.PoC.Equals("DEBRE") && md.ColJ.Equals("MSK"))
core.Flags = 1;
if (core.PoC.Equals("DEWVN") && md.ColJ.Equals("MSK"))
core.Flags = 1;
if (core.PoC.Equals("DEBRE") && md.ColJ.Equals("SGL"))
core.Flags = 2;
if (core.PoC.Equals("DEWVN") && md.ColJ.Equals("SGL"))
core.Flags = 3;
await DBManagerAsync.SaveAsync(core);
await DBManagerAsync.SaveAsync(md);
_dbWatchDog.UnRegister(core); _dbWatchDog.UnRegister(core);
this.Dispatcher.Invoke(() => this.Dispatcher.Invoke(() =>
{ {
@ -150,7 +159,7 @@ namespace ENI2.Controls
maerskData.Remark = el.Text; maerskData.Remark = el.Text;
if (maerskData.MessageCore != null) if (maerskData.MessageCore != null)
await DBManagerAsync.Save(maerskData); await DBManagerAsync.SaveAsync(maerskData);
} }
/* /*
if(e.Column == gridColumnGroup) if(e.Column == gridColumnGroup)
@ -235,6 +244,11 @@ namespace ENI2.Controls
// no ETA means done // no ETA means done
md.Status = MaerskData.MDStatus.NO_ETA; md.Status = MaerskData.MDStatus.NO_ETA;
} }
// if there is an declaration and it has been cancelled.. override the state to CANCELLED
if (md.MessageCore != null && (md.MessageCore.Cancelled ?? false))
md.Status = MaerskData.MDStatus.CANCELLED;
} }
@ -247,9 +261,7 @@ namespace ENI2.Controls
uint from = this.dateTimePickerFrom.SelectedDate.Value.ToUniversalTime().ToUnixTimeStamp(); uint from = this.dateTimePickerFrom.SelectedDate.Value.ToUniversalTime().ToUnixTimeStamp();
DateTime toDate = this.dateTimePickerTo.SelectedDate.Value.ToUniversalTime().Add(new TimeSpan(23, 59, 59)); DateTime toDate = this.dateTimePickerTo.SelectedDate.Value.ToUniversalTime().Add(new TimeSpan(23, 59, 59));
uint to = toDate.ToUnixTimeStamp(); uint to = toDate.ToUnixTimeStamp();
filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from.ToString() ?? "", to.ToString() ?? "")); filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from.ToString() ?? "", to.ToString() ?? ""));
// eingeschränkt auf flags
filterDict.Add(MessageCore.SearchFilterType.FILTER_FLAG_EQ, "0");
// suche auslösen // suche auslösen
List<MessageCore> searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict); List<MessageCore> searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict);
@ -266,8 +278,15 @@ namespace ENI2.Controls
md.MessageCore = core; md.MessageCore = core;
md.MessageCoreId = core.Id.Value; md.MessageCoreId = core.Id.Value;
this.UpdateStatus(md); this.UpdateStatus(md);
if(!maerskDataList.Contains(md)) // DatabaseEntity implements IEquatable if (!maerskDataList.Contains(md)) // DatabaseEntity implements IEquatable
{
this.maerskDataList.Add(md); this.maerskDataList.Add(md);
if(!core.VisitId.IsNullOrEmpty() && md.ColM.IsNullOrEmpty())
{
md.ColM = core.VisitId; // this can happen if client is closed before an Id has been returned, so we have to manually set it here
Task<int> saveResult = DBManagerAsync.SaveAsync(md); // actually we do not need to await this
}
}
} }
} }
this.TimeFilterItemSource(); this.TimeFilterItemSource();
@ -286,8 +305,7 @@ namespace ENI2.Controls
if (reader.GetFieldType(fieldNum) == typeof(int)) if (reader.GetFieldType(fieldNum) == typeof(int))
return reader.GetInt32(fieldNum).ToString(); return reader.GetInt32(fieldNum).ToString();
if (reader.GetFieldType(fieldNum) == typeof(double)) if (reader.GetFieldType(fieldNum) == typeof(double))
return ((int) reader.GetDouble(fieldNum)).ToString(); return ((int) reader.GetDouble(fieldNum)).ToString();
Type theType = reader.GetFieldType(fieldNum);
return null; return null;
} }
@ -355,17 +373,20 @@ namespace ENI2.Controls
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream)) using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{ {
List<MaerskData> importData = new List<MaerskData>(); List<MaerskData> importData = new List<MaerskData>();
uint emptyRowCnt = 0;
bool isFirstRow = true; bool isFirstRow = true;
int currentRow = 0;
bool imosAreOkay = true;
try try
{ {
while (reader.Read()) while (reader.Read())
{ {
currentRow++;
if (isFirstRow) if (isFirstRow)
{ {
isFirstRow = false; // this must be a header row, skip isFirstRow = false; // this must be a header row, skip
continue; continue;
} }
@ -410,13 +431,35 @@ namespace ENI2.Controls
if (!reader.IsDBNull(11)) md.ColL = ReadFieldAsString(reader, 11); if (!reader.IsDBNull(11)) md.ColL = ReadFieldAsString(reader, 11);
if (!reader.IsDBNull(12)) md.ColM = ReadFieldAsString(reader, 12); if (!reader.IsDBNull(12)) md.ColM = ReadFieldAsString(reader, 12);
if (!reader.IsDBNull(13)) md.Remark = ReadFieldAsString(reader, 13); if (!reader.IsDBNull(13)) md.Remark = ReadFieldAsString(reader, 13);
if (!md.ColF.IsNullOrEmpty()) // only add this if IMO is set if(!md.ColF.IsNullOrEmpty())
importData.Add(md); {
if (Int32.TryParse(md.ColF, out int imo))
{
if ((imo < 1000000) || (imo > 9999999))
{
imosAreOkay = false;
}
}
else
{
imosAreOkay = false;
}
}
else else
emptyRowCnt++; {
if (emptyRowCnt > MAX_EMPTY_ROWS_ON_IMPORT) break; imosAreOkay = false;
if (isFirstRow) isFirstRow = false; }
if (!imosAreOkay)
{
MessageBox.Show($"Invalid IMO in row {currentRow}, aborting import", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
break;
}
importData.Add(md);
if (isFirstRow) isFirstRow = false;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -424,7 +467,7 @@ namespace ENI2.Controls
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
} }
if (importData.Count > 0) if (imosAreOkay && importData.Count > 0)
{ {
busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY; busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY;
@ -453,9 +496,9 @@ namespace ENI2.Controls
this.TimeFilterItemSource(); this.TimeFilterItemSource();
// this.SortItemSource(); // this.SortItemSource();
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL; busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
}
this.dataGridPOCores.Items.Refresh(); this.dataGridPOCores.Items.Refresh();
}
} }
stream.Close(); stream.Close();
@ -557,9 +600,9 @@ namespace ENI2.Controls
md.MessageCore.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND; md.MessageCore.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
md.MessageCore.Incoming = true; md.MessageCore.Incoming = true;
md.MessageCore.DefaultReportingPartyId = App.UserId.Value; md.MessageCore.DefaultReportingPartyId = App.UserId.Value;
await DBManagerAsync.Save(md.MessageCore); await DBManagerAsync.SaveAsync(md.MessageCore);
md.MessageCoreId = md.MessageCore.Id.Value; md.MessageCoreId = md.MessageCore.Id.Value;
await DBManagerAsync.Save(md); await DBManagerAsync.SaveAsync(md);
// Meldeklassen für neuen Anlauf erzeugen // Meldeklassen für neuen Anlauf erzeugen
// TODO: pre-set certain fields taken from Maersk data // TODO: pre-set certain fields taken from Maersk data

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion> <MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage> <WebPage>publish.html</WebPage>
<ApplicationRevision>11</ApplicationRevision> <ApplicationRevision>8</ApplicationRevision>
<ApplicationVersion>7.9.0.%2a</ApplicationVersion> <ApplicationVersion>7.10.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@ -137,11 +137,11 @@
<Reference Include="ExcelDataReader, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL"> <Reference Include="ExcelDataReader, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL">
<HintPath>packages\ExcelDataReader.3.6.0\lib\net45\ExcelDataReader.dll</HintPath> <HintPath>packages\ExcelDataReader.3.6.0\lib\net45\ExcelDataReader.dll</HintPath>
</Reference> </Reference>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"> <Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath> <HintPath>packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="MigraDoc.DocumentObjectModel-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> <Reference Include="MigraDoc.DocumentObjectModel-gdi, Version=1.50.5147.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL">
@ -162,8 +162,8 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.115.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <Reference Include="System.Data.SQLite, Version=1.0.117.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.115.0\lib\net46\System.Data.SQLite.dll</HintPath> <HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
@ -1009,12 +1009,12 @@
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>"$(SignToolPath)signtool.exe" sign /f $(ProjectDir)\..\misc\codesigning.pfx /p t5bj2dk9ifdIWBPhPra4U $(TargetPath)</PostBuildEvent> <PostBuildEvent>"$(SignToolPath)signtool.exe" sign /f $(ProjectDir)\..\misc\codesigning.pfx /p t5bj2dk9ifdIWBPhPra4U $(TargetPath)</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.115.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.115.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" /> <Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.115.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.115.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" /> <Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.117.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -28,7 +28,7 @@
</AccessText> </AccessText>
</Label> </Label>
<Image x:Name="imageSource" Grid.Row="1" Grid.Column="1" Margin="4" Source="../Resources/import2.png" AllowDrop="True" Drop="imageSource_Drop" DragEnter="imageSource_DragEnter"/> <Image x:Name="imageSource" Grid.Row="1" Grid.Column="1" Margin="4" Source="../Resources/import2.png" AllowDrop="True" Drop="imageSource_Drop" DragEnter="imageSource_DragEnter"/>
<TextBox TextWrapping="Wrap" x:Name="textBoxSource" Grid.Row="1" Grid.Column="2" IsReadOnly="True" Margin="2" Drop="imageSource_Drop" AllowDrop="True" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver"/> <TextBox TextWrapping="Wrap" x:Name="textBoxSource" Grid.Row="1" Grid.Column="2" IsReadOnly="True" Margin="2" Drop="imageSource_Drop" AllowDrop="True" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver" PreviewMouseDown="textBoxSource_PreviewMouseDown"/>
<Label VerticalAlignment="Center" Grid.Row="2" Grid.Column="0"> <Label VerticalAlignment="Center" Grid.Row="2" Grid.Column="0">
<AccessText TextWrapping="Wrap"> <AccessText TextWrapping="Wrap">
@ -36,7 +36,7 @@
</AccessText> </AccessText>
</Label> </Label>
<Image x:Name="imageTarget" Grid.Row="2" Grid.Column="1" Margin="4" Source="../Resources/import1.png" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter"/> <Image x:Name="imageTarget" Grid.Row="2" Grid.Column="1" Margin="4" Source="../Resources/import1.png" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter"/>
<TextBox TextWrapping="Wrap" x:Name="textBoxTarget" Grid.Row="2" Grid.Column="2" IsReadOnly="True" Margin="2" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver"/> <TextBox TextWrapping="Wrap" x:Name="textBoxTarget" Grid.Row="2" Grid.Column="2" IsReadOnly="True" Margin="2" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver" PreviewMouseDown="textBoxTarget_PreviewMouseDown"/>
<Button x:Name="buttonCompare" Margin="2" Grid.Row="3" Grid.Column="1" Content="Compare" IsEnabled="False" Click="buttonCompare_Click"/> <Button x:Name="buttonCompare" Margin="2" Grid.Row="3" Grid.Column="1" Content="Compare" IsEnabled="False" Click="buttonCompare_Click"/>
</Grid> </Grid>

View File

@ -210,5 +210,37 @@ namespace ENI2.EditControls
#endregion #endregion
#region click on textboxes opens file selection
private void textBoxSource_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
textBoxSource.Text = ofd.FileName;
_sourcePath = ofd.FileName;
}
EnableCompareButton();
}
private void textBoxTarget_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "Excel Files|*.xls;*.xlsx"
};
if (ofd.ShowDialog() ?? false)
{
textBoxTarget.Text = ofd.FileName;
_targetPath = ofd.FileName;
}
EnableCompareButton();
}
#endregion
} }
} }

View File

@ -40,9 +40,10 @@ namespace ENI2.Excel
for (int i = 0; i < data.Count; i++) for (int i = 0; i < data.Count; i++)
{ {
MaerskData md = data[i]; MaerskData md = data[i];
ws.Cells[i + 2, 1].NumberFormat = "TT/hh:mm"; ws.Cells[i + 2, 1].NumberFormat = "TT/hh:mm";
ws.Cells[i + 2, 1] = md.ColA; ws.Cells[i + 2, 1] = md.ColA;
ws.Cells[i + 2, 2].NumberFormat = "TT/hh:mm"; ws.Cells[i + 2, 2].NumberFormat = "TT/hh:mm";
ws.Cells[i + 2, 2] = md.ColB; ws.Cells[i + 2, 2] = md.ColB;
ws.Cells[i + 2, 3] = md.ColC; ws.Cells[i + 2, 3] = md.ColC;
@ -57,6 +58,12 @@ namespace ENI2.Excel
ws.Cells[i + 2, 12] = md.ColL; ws.Cells[i + 2, 12] = md.ColL;
ws.Cells[i + 2, 13] = md.ColM ; ws.Cells[i + 2, 13] = md.ColM ;
// ws.Cells[i + 2, 14] = md.Remark; // ws.Cells[i + 2, 14] = md.Remark;
if((md.MessageCore != null) && (md.MessageCore.Cancelled ?? false))
{
ws.Rows[i + 2].Font.Strikethrough = true;
}
} }
wb.SaveAs(filename, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, wb.SaveAs(filename, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,

View File

@ -1072,7 +1072,15 @@ namespace ENI2.Excel
noa_nod.CallPurposes.Add(callPurpose); noa_nod.CallPurposes.Add(callPurpose);
} }
callPurpose.CallPurposeCode = ((int?)reader.ReadNumber(callPurposeCodeKey)) ?? 0; callPurpose.CallPurposeCode = ((int?)reader.ReadNumber(callPurposeCodeKey)) ?? 0;
callPurpose.CallPurposeDescription = callPurposeDescription; if (callPurposeDescription.IsNullOrEmpty())
{
if(Util.GlobalStructures.Edifact8025.ContainsKey(callPurpose.CallPurposeCode))
callPurpose.CallPurposeDescription = Util.GlobalStructures.Edifact8025[callPurpose.CallPurposeCode];
}
else
{
callPurpose.CallPurposeDescription = callPurposeDescription;
}
} }
} }
} }
@ -2019,7 +2027,7 @@ namespace ENI2.Excel
{ {
if (Int32.TryParse(ladg.CargoCodeNST, out int ccnst)) if (Int32.TryParse(ladg.CargoCodeNST, out int ccnst))
{ {
if ((ccnst <= 0) && (ccnst > 20)) if ((ccnst <= 0) || (ccnst > 20))
{ {
ladg.CargoCodeNST = null; ladg.CargoCodeNST = null;
} }

View File

@ -333,8 +333,9 @@ namespace ENI2
this.dbConnected = DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString); this.dbConnected = DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString);
labelGeneralStatus.Text = dbConnected ? "DB Connected" : "DB Connect failed"; labelGeneralStatus.Text = dbConnected ? "DB Connected" : "DB Connect failed";
labelVersion.Text = "V. " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; labelVersion.Text = "V. " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
labelUsername.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name; labelUsername.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded; Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded;
this.textUsername.Focus();
} }
private void SystemEvents_SessionEnded(object sender, Microsoft.Win32.SessionEndedEventArgs e) private void SystemEvents_SessionEnded(object sender, Microsoft.Win32.SessionEndedEventArgs e)
@ -661,11 +662,12 @@ namespace ENI2
this.labelStatusBar.Text = string.Format("Rep.Party: {0} {1} [{2}]", this.userEntity.FirstName, this.userEntity.LastName, this.userEntity.Logon); this.labelStatusBar.Text = string.Format("Rep.Party: {0} {1} [{2}]", this.userEntity.FirstName, this.userEntity.LastName, this.userEntity.Logon);
App.UserId = this.userEntity.Id; App.UserId = this.userEntity.Id;
ReportingParty.CurrentReportingParty = this.userEntity; ReportingParty.CurrentReportingParty = this.userEntity;
this.menuItemMaersk.Visibility = Visibility.Visible;
if (this.userEntity.IsAdmin) if (this.userEntity.IsAdmin)
{ {
this.menuItemUserAdministration.Visibility = Visibility.Visible; this.menuItemUserAdministration.Visibility = Visibility.Visible;
this.menuItemMaersk.Visibility = Visibility.Visible; this.sucheControl.AdminMode = true;
this.sucheControl.AdminMode = true;
} }
break; break;
case ReportingParty.LogonResult.FAILED: case ReportingParty.LogonResult.FAILED:

View File

@ -5,9 +5,9 @@ Sample license text.
<packages> <packages>
<package id="ExcelDataReader" version="3.6.0" targetFramework="net452" /> <package id="ExcelDataReader" version="3.6.0" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="4.3.0" targetFramework="net48" /> <package id="Extended.Wpf.Toolkit" version="4.3.0" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
<package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1000" targetFramework="net452" /> <package id="Microsoft.Office.Interop.Excel" version="15.0.4795.1001" targetFramework="net48" />
<package id="PDFsharp-MigraDoc-gdi" version="1.50.5147" targetFramework="net452" /> <package id="PDFsharp-MigraDoc-gdi" version="1.50.5147" targetFramework="net452" />
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.115.0" targetFramework="net48" /> <package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.117.0" targetFramework="net48" />
<package id="System.Data.SQLite.Core" version="1.0.115.0" targetFramework="net48" /> <package id="System.Data.SQLite.Core" version="1.0.117.0" targetFramework="net48" />
</packages> </packages>

Binary file not shown.

Binary file not shown.

View File

@ -34,6 +34,12 @@
<setting name="ConnectionString" serializeAs="String"> <setting name="ConnectionString" serializeAs="String">
<value>Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value> <value>Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value>
</setting> </setting>
<setting name="PurgeFilesTimerIntervalHours" serializeAs="String">
<value>24</value>
</setting>
<setting name="TempFilesMaxAgeDays" serializeAs="String">
<value>10</value>
</setting>
</SendNSWMessageService.Properties.Settings> </SendNSWMessageService.Properties.Settings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>

View File

@ -13,6 +13,7 @@ namespace SendNSWMessageService
public partial class NSWSendService : ServiceBase public partial class NSWSendService : ServiceBase
{ {
private Timer _timer; private Timer _timer;
private Timer _filesTimer;
private readonly object _timerlock = new object(); private readonly object _timerlock = new object();
private bool processRunning = false; private bool processRunning = false;
private readonly ILog _log = LogManager.GetLogger(typeof(NSWSendService)); private readonly ILog _log = LogManager.GetLogger(typeof(NSWSendService));
@ -62,11 +63,23 @@ namespace SendNSWMessageService
this._timer = new Timer(); this._timer = new Timer();
this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000; this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000;
this._timer.Elapsed += _timer_Elapsed; this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true; this._timer.Enabled = true;
this._filesTimer = new Timer();
this._filesTimer.Interval = Properties.Settings.Default.PurgeFilesTimerIntervalHours * 60 * 60 * 1000; // hours to millisecs
this._filesTimer.Elapsed += _filesTimer_Elapsed;
this._filesTimer.Enabled = true;
}
private void _filesTimer_Elapsed(object sender, ElapsedEventArgs e)
{
bsmd.dbh.MessageController.PurgeOldFiles(Properties.Settings.Default.TempFilesMaxAgeDays);
bsmd.hisnord.transmitter.PurgeOldFiles(Properties.Settings.Default.TempFilesMaxAgeDays);
} }
public void DoOnce() public void DoOnce()
{ {
this._filesTimer_Elapsed(null, null);
this._timer_Elapsed(null, null); this._timer_Elapsed(null, null);
} }
@ -307,17 +320,20 @@ namespace SendNSWMessageService
protected override void OnPause() protected override void OnPause()
{ {
this._timer.Stop(); this._timer.Stop();
this._filesTimer.Stop();
} }
protected override void OnContinue() protected override void OnContinue()
{ {
this._timer.Start(); this._timer.Start();
this._filesTimer.Start();
} }
protected override void OnStop() protected override void OnStop()
{ {
this._timer.Enabled = false; this._timer.Enabled = false;
this._filesTimer.Enabled = false;
this.EventLog.WriteEntry("NSW Send Service stopped.", EventLogEntryType.Information); this.EventLog.WriteEntry("NSW Send Service stopped.", EventLogEntryType.Information);
_log.Info("NSW Send Service stopped"); _log.Info("NSW Send Service stopped");
} }

View File

@ -41,5 +41,23 @@ namespace SendNSWMessageService.Properties {
return ((string)(this["ConnectionString"])); return ((string)(this["ConnectionString"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("24")]
public int PurgeFilesTimerIntervalHours {
get {
return ((int)(this["PurgeFilesTimerIntervalHours"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("10")]
public int TempFilesMaxAgeDays {
get {
return ((int)(this["TempFilesMaxAgeDays"]));
}
}
} }
} }

View File

@ -8,5 +8,11 @@
<Setting Name="ConnectionString" Type="System.String" Scope="Application"> <Setting Name="ConnectionString" Type="System.String" Scope="Application">
<Value Profile="(Default)">Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</Value> <Value Profile="(Default)">Initial Catalog=nswtest;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</Value>
</Setting> </Setting>
<Setting Name="PurgeFilesTimerIntervalHours" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">24</Value>
</Setting>
<Setting Name="TempFilesMaxAgeDays" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">10</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -40,8 +40,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>

View File

@ -46,8 +46,8 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\ENI2\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\ENI2\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>

View File

@ -38,8 +38,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>

View File

@ -29,7 +29,7 @@ namespace bsmd.database
#region public methods #region public methods
public static async Task<int> Save(DatabaseEntity entity) public static async Task<int> SaveAsync(DatabaseEntity entity)
{ {
SqlCommand cmd = new SqlCommand(); SqlCommand cmd = new SqlCommand();
entity.PrepareSave(cmd); entity.PrepareSave(cmd);

View File

@ -159,7 +159,6 @@ namespace bsmd.database
public string VehicleLicenseNumber { get; set; } public string VehicleLicenseNumber { get; set; }
[ShowReport] [ShowReport]
[Validation(ValidationCode.NOT_NULL)]
[MaxLength(24)] [MaxLength(24)]
[ENI2Validation] [ENI2Validation]
[MaxWordLength(9)] [MaxWordLength(9)]
@ -515,30 +514,39 @@ namespace bsmd.database
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "IMOClass", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "IMOClass", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
} }
if(!this.Bay.IsNullOrEmpty()) if (!this.StowagePosition.IsNullOrEmpty() && (!this.Bay.IsNullOrEmpty() || !this.Row.IsNullOrEmpty() || !this.Tier.IsNullOrEmpty()))
{ {
const string pattern = @"^[0-9]{3}$"; errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "StowagePosition AND Bay/Row/Tier SET", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.Bay))
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Bay", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
} }
else
if(!this.Row.IsNullOrEmpty())
{ {
const string pattern = @"^[0-9]{2}$"; if (StowagePosition.IsNullOrEmpty())
Regex regex = new Regex(pattern); {
if (!regex.IsMatch(this.Row)) if (!this.Bay.IsNullOrEmpty())
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Row", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); {
} const string pattern = @"^[0-9]{3}$";
Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.Bay))
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Bay", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
}
if(!this.Tier.IsNullOrEmpty()) if (!this.Row.IsNullOrEmpty())
{ {
const string pattern = @"^[0-9]{2}$"; const string pattern = @"^[0-9]{2}$";
Regex regex = new Regex(pattern); Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.Tier)) if (!regex.IsMatch(this.Row))
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Tier", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Row", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
} }
if (!this.Tier.IsNullOrEmpty())
{
const string pattern = @"^[0-9]{2}$";
Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.Tier))
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Tier", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
}
}
}
} }
#endregion #endregion

View File

@ -49,7 +49,9 @@ namespace bsmd.database
[Description("In the past, id or not")] [Description("In the past, id or not")]
DONE, DONE,
[Description("no ETA found on data record")] [Description("no ETA found on data record")]
NO_ETA NO_ETA,
[Description("VISIT-ID was cancelled")]
CANCELLED
} }

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")] [assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")] [assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("7.9.0")] [assembly: AssemblyInformationalVersion("7.10.0")]
[assembly: AssemblyCopyright("Copyright © 2014-2022 schick Informatik")] [assembly: AssemblyCopyright("Copyright © 2014-2023 schick Informatik")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]

View File

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

View File

@ -205,7 +205,7 @@ namespace bsmd.database
{ {
MaxLengthAttribute mla = Attribute.GetCustomAttribute(property, typeof(MaxLengthAttribute)) as MaxLengthAttribute; MaxLengthAttribute mla = Attribute.GetCustomAttribute(property, typeof(MaxLengthAttribute)) as MaxLengthAttribute;
bool isStandardML = (mla.MaxLength == 99) || (mla.MaxLength == 100); bool isStandardML = (mla.MaxLength == 99) || (mla.MaxLength == 100);
if((value.Length >= 90) && ((mla.MaxLength == value.Length) || isStandardML)) if(((value.Length >= 90) && isStandardML) || ((mla.MaxLength == value.Length) && (value.Length > 20) && !isStandardML))
{ {
// put out a warning this might be truncated // put out a warning this might be truncated
violations.Add(RuleEngine.CreateViolation(ValidationCode.TRUNCATE, property.Name, value, entity.Title, identifier, entity.Tablename)); violations.Add(RuleEngine.CreateViolation(ValidationCode.TRUNCATE, property.Name, value, entity.Title, identifier, entity.Tablename));

View File

@ -269,7 +269,7 @@ namespace bsmd.database
message.MessageCore = core; message.MessageCore = core;
message.MessageCoreId = core.Id; message.MessageCoreId = core.Id;
message.MessageNotificationClass = notificationClass; message.MessageNotificationClass = notificationClass;
await DBManagerAsync.Save(message); await DBManagerAsync.SaveAsync(message);
result.Add(message); result.Add(message);
} }
else else
@ -297,7 +297,7 @@ namespace bsmd.database
if (classElement != null) // null für Visit/Transit if (classElement != null) // null für Visit/Transit
{ {
classElement.MessageHeader = message; classElement.MessageHeader = message;
await DBManagerAsync.Save(classElement); await DBManagerAsync.SaveAsync(classElement);
message.Elements.Add(classElement); message.Elements.Add(classElement);
} }
} }

View File

@ -37,7 +37,7 @@ namespace bsmd.database
DOT_NO_COMMA, DOT_NO_COMMA,
VESSEL_TYPE, VESSEL_TYPE,
NOT_NULL_MAX_LEN, NOT_NULL_MAX_LEN,
FRZ, FRZ,
POSITION_COUNT = 22, POSITION_COUNT = 22,
STRING_UNNUMBER = 23, STRING_UNNUMBER = 23,
STRING_IMOCLASS = 24, STRING_IMOCLASS = 24,

View File

@ -83,11 +83,11 @@
<CodeAnalysisRuleSet>..\code.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\code.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\ENI2\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\ENI2\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
</packages> </packages>

View File

@ -6,6 +6,7 @@ using System;
using System.IO; using System.IO;
using bsmd.database; using bsmd.database;
using System.Linq;
namespace bsmd.dbh namespace bsmd.dbh
{ {
@ -14,6 +15,8 @@ namespace bsmd.dbh
private static readonly ILog _log = LogManager.GetLogger(typeof(MessageController)); private static readonly ILog _log = LogManager.GetLogger(typeof(MessageController));
private static int? _fileSequenceCounter = null; private static int? _fileSequenceCounter = null;
#region send single message
public static bool SendMessage(MessageCore core, Message message) public static bool SendMessage(MessageCore core, Message message)
{ {
bool result = true; bool result = true;
@ -63,6 +66,10 @@ namespace bsmd.dbh
return result; return result;
} }
#endregion
#region send cancel core messaage
public static bool SendCancelCore(MessageCore core) public static bool SendCancelCore(MessageCore core)
{ {
bool result = true; bool result = true;
@ -103,6 +110,10 @@ namespace bsmd.dbh
return result; return result;
} }
#endregion
#region send and receive files (SFTP)
public static void SendAndReceive() public static void SendAndReceive()
{ {
// sent unsent messages in output folder // sent unsent messages in output folder
@ -144,5 +155,50 @@ namespace bsmd.dbh
} }
} }
#endregion
#region Purge old files
public static void PurgeOldFiles(int maxAgeDays)
{
try
{
int cnt = 0;
DirectoryInfo info = new DirectoryInfo(Properties.Settings.Default.IncomingArchiveFolder);
FileInfo[] files = info.GetFiles();
foreach (FileInfo file in files)
{
if (file.CreationTime < DateTime.Now.AddDays(-maxAgeDays))
{
_log.Debug($"deleting {file.Name}");
file.Delete();
cnt++;
}
}
_log.Info($"deleted {cnt} files from {Properties.Settings.Default.IncomingArchiveFolder}");
cnt = 0;
info = new DirectoryInfo(Properties.Settings.Default.OutgoingArchiveFolder);
files = info.GetFiles();
foreach (FileInfo file in files)
{
if (file.CreationTime < DateTime.Now.AddDays(-maxAgeDays))
{
_log.Debug($"deleting {file.Name}");
file.Delete();
cnt++;
}
}
_log.Info($"deleted {cnt} files from {Properties.Settings.Default.OutgoingArchiveFolder}");
}
catch(Exception ex)
{
_log.ErrorFormat("Error deleting old files: {0}", ex.Message);
}
}
#endregion
} }
} }

View File

@ -38,8 +38,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>

View File

@ -34,7 +34,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\IMP")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\IMP")]
public string OutputDir { public string OutputDir {
get { get {
return ((string)(this["OutputDir"])); return ((string)(this["OutputDir"]));
@ -43,7 +43,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\client.bat")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\client.bat")]
public string Transmitter { public string Transmitter {
get { get {
return ((string)(this["Transmitter"])); return ((string)(this["Transmitter"]));
@ -52,7 +52,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\RESULTS")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\RESULTS")]
public string ResultDir { public string ResultDir {
get { get {
return ((string)(this["ResultDir"])); return ((string)(this["ResultDir"]));
@ -61,7 +61,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\ANSWERS")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\ANSWERS")]
public string AnswerDir { public string AnswerDir {
get { get {
return ((string)(this["AnswerDir"])); return ((string)(this["AnswerDir"]));
@ -70,7 +70,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\ANSWERS_DONE")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\ANSWERS_DONE")]
public string AnswerArchiveDir { public string AnswerArchiveDir {
get { get {
return ((string)(this["AnswerArchiveDir"])); return ((string)(this["AnswerArchiveDir"]));
@ -79,7 +79,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\ANSWERS_CORRUPT")] [global::System.Configuration.DefaultSettingValueAttribute("Transmitter-Tool\\ANSWERS_CORRUPT")]
public string AnswerCorruptDir { public string AnswerCorruptDir {
get { get {
return ((string)(this["AnswerCorruptDir"])); return ((string)(this["AnswerCorruptDir"]));

View File

@ -6,22 +6,22 @@
<Value Profile="(Default)">1</Value> <Value Profile="(Default)">1</Value>
</Setting> </Setting>
<Setting Name="OutputDir" Type="System.String" Scope="Application"> <Setting Name="OutputDir" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\IMP</Value> <Value Profile="(Default)">Transmitter-Tool\IMP</Value>
</Setting> </Setting>
<Setting Name="Transmitter" Type="System.String" Scope="Application"> <Setting Name="Transmitter" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\client.bat</Value> <Value Profile="(Default)">Transmitter-Tool\client.bat</Value>
</Setting> </Setting>
<Setting Name="ResultDir" Type="System.String" Scope="Application"> <Setting Name="ResultDir" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\RESULTS</Value> <Value Profile="(Default)">Transmitter-Tool\RESULTS</Value>
</Setting> </Setting>
<Setting Name="AnswerDir" Type="System.String" Scope="Application"> <Setting Name="AnswerDir" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS</Value> <Value Profile="(Default)">Transmitter-Tool\ANSWERS</Value>
</Setting> </Setting>
<Setting Name="AnswerArchiveDir" Type="System.String" Scope="Application"> <Setting Name="AnswerArchiveDir" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</Value> <Value Profile="(Default)">Transmitter-Tool\ANSWERS_DONE</Value>
</Setting> </Setting>
<Setting Name="AnswerCorruptDir" Type="System.String" Scope="Application"> <Setting Name="AnswerCorruptDir" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</Value> <Value Profile="(Default)">Transmitter-Tool\ANSWERS_CORRUPT</Value>
</Setting> </Setting>
<Setting Name="TransmitterRoot" Type="System.String" Scope="Application"> <Setting Name="TransmitterRoot" Type="System.String" Scope="Application">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\</Value> <Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\</Value>

View File

@ -74,7 +74,9 @@ namespace bsmd.hisnord
} }
} }
} }
#region Create message file to send
public static bool? CreateSendFile(MessageCore core, Message message) public static bool? CreateSendFile(MessageCore core, Message message)
{ {
@ -1807,7 +1809,9 @@ namespace bsmd.hisnord
} }
return retval; return retval;
} }
#endregion
#region helper func for HAZ positions #region helper func for HAZ positions

View File

@ -11,22 +11,22 @@
<value>1</value> <value>1</value>
</setting> </setting>
<setting name="OutputDir" serializeAs="String"> <setting name="OutputDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\IMP</value> <value>Transmitter-Tool\IMP</value>
</setting> </setting>
<setting name="Transmitter" serializeAs="String"> <setting name="Transmitter" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\client.bat</value> <value>Transmitter-Tool\client.bat</value>
</setting> </setting>
<setting name="ResultDir" serializeAs="String"> <setting name="ResultDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\RESULTS</value> <value>Transmitter-Tool\RESULTS</value>
</setting> </setting>
<setting name="AnswerDir" serializeAs="String"> <setting name="AnswerDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS</value> <value>Transmitter-Tool\ANSWERS</value>
</setting> </setting>
<setting name="AnswerArchiveDir" serializeAs="String"> <setting name="AnswerArchiveDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</value> <value>Transmitter-Tool\ANSWERS_DONE</value>
</setting> </setting>
<setting name="AnswerCorruptDir" serializeAs="String"> <setting name="AnswerCorruptDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</value> <value>Transmitter-Tool\ANSWERS_CORRUPT</value>
</setting> </setting>
<setting name="TransmitterRoot" serializeAs="String"> <setting name="TransmitterRoot" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\</value> <value>E:\svnlager\BSMD\nsw\HIS-NORD\</value>

View File

@ -38,8 +38,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>

View File

@ -61,7 +61,7 @@ namespace bsmd.hisnord
// _log.DebugFormat("started {0}", transmitterProcess.ProcessName); // _log.DebugFormat("started {0}", transmitterProcess.ProcessName);
int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms
_log.InfoFormat($"starting transmitter, process ID: {processId}, timeout {timeout} ms."); _log.DebugFormat($"starting transmitter, process ID: {processId}, timeout {timeout} ms.");
if (!transmitterProcess.WaitForExit((timeout == 0) ? int.MaxValue : timeout)) if (!transmitterProcess.WaitForExit((timeout == 0) ? int.MaxValue : timeout))
{ {
@ -84,7 +84,7 @@ namespace bsmd.hisnord
private static void TransmitterProcess_OutputDataReceived(object sender, DataReceivedEventArgs e) private static void TransmitterProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{ {
if(!e.Data.IsNullOrEmpty()) if(!e.Data.IsNullOrEmpty())
_log.Info(e.Data); _log.Debug(e.Data);
} }
private static void TransmitterProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e) private static void TransmitterProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
@ -95,7 +95,7 @@ namespace bsmd.hisnord
private static void TransmitterProcess_Exited(object sender, EventArgs e) private static void TransmitterProcess_Exited(object sender, EventArgs e)
{ {
_log.Info("Transmitter process exited"); _log.Debug("Transmitter process exited");
processId = null; processId = null;
} }
@ -106,8 +106,63 @@ namespace bsmd.hisnord
string resultDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.ResultDir); string resultDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.ResultDir);
string resultFullPath = Path.Combine(resultDir, resultFilename); string resultFullPath = Path.Combine(resultDir, resultFilename);
return result.ReadResult(resultFullPath); return result.ReadResult(resultFullPath);
} }
public static void PurgeOldFiles(int maxAgeDays)
{
try
{
// "ANSWERS_DONE"
DirectoryInfo info = new DirectoryInfo(Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.AnswerArchiveDir));
FileInfo[] files = info.GetFiles();
int cnt = 0;
foreach (FileInfo file in files)
{
if (file.CreationTime < DateTime.Now.AddDays(-maxAgeDays))
{
_log.Debug($"deleting {file.Name}");
file.Delete();
cnt++;
}
}
_log.Info($"deleted {cnt} files from {Properties.Settings.Default.AnswerArchiveDir}");
// "RESULTS"
cnt = 0;
info = new DirectoryInfo(Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.ResultDir));
files = info.GetFiles();
foreach (FileInfo file in files)
{
if (file.CreationTime < DateTime.Now.AddDays(-maxAgeDays))
{
_log.Debug($"deleting {file.Name}");
file.Delete();
cnt++;
}
}
_log.Info($"deleted {cnt} files from {Properties.Settings.Default.ResultDir}");
// "READY"
cnt = 0;
info = new DirectoryInfo(Path.Combine(Properties.Settings.Default.TransmitterRoot, "READY"));
files = info.GetFiles();
foreach (FileInfo file in files)
{
if (file.CreationTime < DateTime.Now.AddDays(-maxAgeDays))
{
_log.Debug($"deleting {file.Name}");
file.Delete();
cnt++;
}
}
_log.Info($"deleted {cnt} files from READY");
}
catch(Exception ex)
{
_log.ErrorFormat("Error trying to delete old files: {0}", ex.Message);
}
}
/// <summary> /// <summary>
/// class to read transmitter result xml files /// class to read transmitter result xml files
/// </summary> /// </summary>

View File

@ -38,8 +38,8 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />

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.14" targetFramework="net48" /> <package id="log4net" version="2.0.15" targetFramework="net48" />
</packages> </packages>