some bugfixes..
This commit is contained in:
parent
c04099edb2
commit
d981bc4093
@ -10,7 +10,7 @@
|
||||
xmlns:local="clr-namespace:ENI2.Controls"
|
||||
xmlns:db="clr-namespace:bsmd.database;assembly=bsmd.database"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
d:DesignHeight="450" d:DesignWidth="900">
|
||||
<UserControl.Resources>
|
||||
<col:ArrayList x:Key="arrList">
|
||||
<col:DictionaryEntry Key="None" Value="0" />
|
||||
@ -34,6 +34,7 @@
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="80" />
|
||||
@ -46,9 +47,10 @@
|
||||
<Button x:Name="buttonLoad" Grid.Column="4" Content="Load" Margin="2" Click="buttonLoad_Click" />
|
||||
<Button x:Name="buttonSave" Grid.Column="5" Content="Save" Margin="2" Click="buttonSave_Click" />
|
||||
<Button x:Name="buttonRequestIds" Grid.Column="6" Content="Request Ids" Margin="2" Click="buttonRequestIds_Click" />
|
||||
<Button x:Name="buttonImport" Grid.Column="8" Margin="2" Content="Import" Click="buttonImport_Click" />
|
||||
<Button x:Name="buttonExport" Grid.Column="9" Margin="2" Content="Export" Click="buttonExport_Click" />
|
||||
<local:BusyControl x:Name="busyControl" Grid.Column="10" />
|
||||
<Button x:Name="buttonRequestPlus3" Grid.Column="7" Content="Request +3" Margin="2" Click="buttonRequestIds_Click" />
|
||||
<Button x:Name="buttonImport" Grid.Column="9" Margin="2" Content="Import" Click="buttonImport_Click" />
|
||||
<Button x:Name="buttonExport" Grid.Column="10" Margin="2" Content="Export" Click="buttonExport_Click" />
|
||||
<local:BusyControl x:Name="busyControl" Grid.Column="11" />
|
||||
</Grid>
|
||||
<local:ENIDataGrid Grid.Row="1" Margin="2,8,2,2" x:Name="dataGridPOCores" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||
SelectionMode="Extended" AutoGenerateColumns="False" CellEditEnding="dataGridPOCores_CellEditEnding" CanUserAddRows="False">
|
||||
|
||||
@ -10,15 +10,13 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Win32;
|
||||
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using bsmd.database;
|
||||
using ExcelDataReader;
|
||||
using System.Collections.ObjectModel;
|
||||
using ENI2.Excel;
|
||||
using ENI2.Locode;
|
||||
using ENI2.Util;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ENI2.Controls
|
||||
{
|
||||
@ -259,9 +257,12 @@ namespace ENI2.Controls
|
||||
if (!reader.IsDBNull(6)) md.ColG = ReadFieldAsString(reader, 6);
|
||||
if (!reader.IsDBNull(7)) md.ColH = ReadFieldAsString(reader, 7);
|
||||
if (!reader.IsDBNull(8)) md.ColI = ReadFieldAsString(reader, 8);
|
||||
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
|
||||
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
|
||||
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
|
||||
if (md.ColI != null)
|
||||
{
|
||||
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
|
||||
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
|
||||
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
|
||||
}
|
||||
if (!reader.IsDBNull(9)) md.ColJ = ReadFieldAsString(reader, 9);
|
||||
if (!reader.IsDBNull(10)) { md.ETA = reader.GetDateTime(10); md.ColK = md.ETA.ToString(); }
|
||||
if (!reader.IsDBNull(11)) md.ColL = ReadFieldAsString(reader, 11);
|
||||
@ -325,9 +326,11 @@ namespace ENI2.Controls
|
||||
private void buttonExport_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Export of the current collection
|
||||
string predefFilename = string.Format("{0}_{1}.xlsx", this.PortLocode, DateTime.Today.ToString("yyyyMMdd"));
|
||||
SaveFileDialog sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files|*.xls;*.xlsx"
|
||||
Filter = "Excel Files|*.xlsx;*.xls",
|
||||
FileName = predefFilename
|
||||
};
|
||||
if(sfd.ShowDialog() ?? false)
|
||||
{
|
||||
@ -337,6 +340,7 @@ namespace ENI2.Controls
|
||||
{
|
||||
List<MaerskData> exportList = new List<MaerskData>(this.maerskDataList);
|
||||
em.ExportMaersk(exportList, sfd.FileName);
|
||||
Process.Start(sfd.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -365,12 +369,26 @@ namespace ENI2.Controls
|
||||
{
|
||||
// find all entries from now until 3 days into the future and track parallel requests
|
||||
List<MaerskData> requestList = new List<MaerskData>();
|
||||
foreach (MaerskData md in this.dataGridPOCores.SelectedItems)
|
||||
if (sender == this.buttonRequestIds)
|
||||
{
|
||||
if ((md.MessageCore != null) || (!md.ColM.IsNullOrEmpty())) continue; // already requested
|
||||
requestList.Add(md);
|
||||
md.Status = MaerskData.MDStatus.REQUESTING_ID;
|
||||
foreach (MaerskData md in this.dataGridPOCores.SelectedItems)
|
||||
{
|
||||
if ((md.MessageCore != null) || (!md.ColM.IsNullOrEmpty())) continue; // already requested
|
||||
requestList.Add(md);
|
||||
}
|
||||
}
|
||||
if(sender == this.buttonRequestPlus3)
|
||||
{
|
||||
foreach(MaerskData md in this.maerskDataList)
|
||||
{
|
||||
if((md.MessageCore == null) && (md.ColM.IsNullOrEmpty()))
|
||||
{
|
||||
if (md.ETA.HasValue && md.ETA.Value.IsNextXDays(3))
|
||||
requestList.Add(md);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(requestList.Count == 0)
|
||||
{
|
||||
MessageBox.Show("No valid rows selected", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
@ -380,6 +398,8 @@ namespace ENI2.Controls
|
||||
// Todo:
|
||||
foreach (MaerskData md in requestList)
|
||||
{
|
||||
md.Status = MaerskData.MDStatus.REQUESTING_ID;
|
||||
|
||||
// create MessageCore and message classes
|
||||
md.MessageCore = new MessageCore();
|
||||
md.MessageCore.InitialHIS = Message.NSWProvider.DBH;
|
||||
@ -401,10 +421,6 @@ namespace ENI2.Controls
|
||||
|
||||
// watchdog registrieren
|
||||
this._dbWatchDog.Register(md.MessageCore);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.dataGridPOCores.Items.Refresh();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user