Maersk Import komplett abbrechen wenn eine ungültige IMO dabei ist
This commit is contained in:
parent
8d94534021
commit
ce5327821b
@ -30,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
|
||||||
@ -306,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,9 +373,10 @@ 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 = 1;
|
int currentRow = 1;
|
||||||
|
bool imosAreOkay = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -431,28 +430,25 @@ 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);
|
||||||
|
|
||||||
bool imoIsOkay = false;
|
|
||||||
if(!md.ColF.IsNullOrEmpty())
|
if(!md.ColF.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
if (Int32.TryParse(md.ColF, out int imo))
|
if (Int32.TryParse(md.ColF, out int imo))
|
||||||
{
|
{
|
||||||
if ((imo > 1000000) && (imo < 9999999))
|
if ((imo < 1000000) && (imo > 9999999))
|
||||||
{
|
{
|
||||||
imoIsOkay = true;
|
imosAreOkay = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!imoIsOkay)
|
if(!imosAreOkay)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"Invalid IMO in row {currentRow}, skipping entry", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"Invalid IMO in row {currentRow}, aborting import", Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imoIsOkay)
|
importData.Add(md);
|
||||||
importData.Add(md);
|
|
||||||
else
|
|
||||||
emptyRowCnt++;
|
|
||||||
if (emptyRowCnt > MAX_EMPTY_ROWS_ON_IMPORT) break;
|
|
||||||
if (isFirstRow) isFirstRow = false;
|
if (isFirstRow) isFirstRow = false;
|
||||||
currentRow++;
|
currentRow++;
|
||||||
}
|
}
|
||||||
@ -462,7 +458,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;
|
||||||
|
|
||||||
@ -491,9 +487,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();
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
<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>4</ApplicationRevision>
|
<ApplicationRevision>5</ApplicationRevision>
|
||||||
<ApplicationVersion>7.10.0.%2a</ApplicationVersion>
|
<ApplicationVersion>7.10.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user