fixed import / updating
This commit is contained in:
parent
65e45f40b8
commit
4d9b430cd3
@ -17,6 +17,7 @@ using ENI2.Excel;
|
||||
using ENI2.Locode;
|
||||
using ENI2.Util;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace ENI2.Controls
|
||||
{
|
||||
@ -177,7 +178,7 @@ namespace ENI2.Controls
|
||||
List<MessageCore> searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict);
|
||||
|
||||
// alle anderen Häfen weg
|
||||
searchResult.RemoveAll(item => (item.PoC == null) || (!item.PoC.Equals("DEBRV") && !item.PoC.Equals("DEWHV") && !item.PoC.Equals("DEWVN")));
|
||||
searchResult.RemoveAll(item => (item.PoC == null) || (!item.PoC.Equals(PortLocode)));
|
||||
|
||||
// alles entfernen was keine Maersk Xtra-Data hat (=noch nicht schon einmal importiert wurde)
|
||||
foreach(MessageCore core in searchResult)
|
||||
@ -291,37 +292,36 @@ namespace ENI2.Controls
|
||||
if (importData.Count > 0)
|
||||
{
|
||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.BUSY;
|
||||
// TODO: find matching message cores..
|
||||
foreach(MaerskData md in importData)
|
||||
importData.Sort();
|
||||
|
||||
foreach (MaerskData md in importData)
|
||||
{
|
||||
if(!md.ColM.IsNullOrEmpty())
|
||||
if (this.maerskDataList.Contains(md))
|
||||
{
|
||||
md.MessageCore = await DBManagerAsync.LoadCoreByVisitIdAsync(md.ColM);
|
||||
MaerskData foundData = this.maerskDataList.First((m) => ((m.ColF != null) ? m.ColF.Equals(md.ColF) : false) && ((m.ColG != null) ? m.ColG.Equals(md.ColG) : false) && ((md.ColH != null) ? md.ColH.Equals(md.ColH) : false));
|
||||
if (foundData.Update(md))
|
||||
foundData.Status = MaerskData.MDStatus.UPDATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
md.Status = MaerskData.MDStatus.ID;
|
||||
|
||||
if (!md.ColM.IsNullOrEmpty())
|
||||
{
|
||||
md.MessageCore = await DBManagerAsync.LoadCoreByVisitIdAsync(md.ColM);
|
||||
}
|
||||
else
|
||||
{
|
||||
md.Status = MaerskData.MDStatus.NO_ID;
|
||||
if (md.ETA.HasValue && md.ETA.Value.IsNextXDays(3))
|
||||
md.Status = MaerskData.MDStatus.NO_ID_AND_DUE;
|
||||
}
|
||||
maerskDataList.Add(md);
|
||||
}
|
||||
}
|
||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
||||
}
|
||||
|
||||
// sort
|
||||
// importData.Sort((x, y) => DateTime.Compare(x.ETA ?? DateTime.MaxValue, y.ETA ?? DateTime.MaxValue));
|
||||
|
||||
foreach (MaerskData md in importData)
|
||||
{
|
||||
md.Status = MaerskData.MDStatus.ID;
|
||||
|
||||
if (md.ColM.IsNullOrEmpty())
|
||||
{
|
||||
md.Status = MaerskData.MDStatus.NO_ID;
|
||||
if (md.ETA.HasValue && md.ETA.Value.IsNextXDays(3))
|
||||
md.Status = MaerskData.MDStatus.NO_ID_AND_DUE;
|
||||
}
|
||||
|
||||
// TODO: check if data has been updated
|
||||
|
||||
// TODO: Check if data is already present
|
||||
|
||||
maerskDataList.Add(md);
|
||||
}
|
||||
this.dataGridPOCores.Items.Refresh();
|
||||
}
|
||||
|
||||
|
||||
@ -551,7 +551,7 @@ namespace ENI2.DetailViewControls
|
||||
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8).ToUpper();
|
||||
|
||||
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
|
||||
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
|
||||
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
|
||||
|
||||
importWasteList.Add(waste);
|
||||
cnt++;
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>publish.html</WebPage>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationRevision>2</ApplicationRevision>
|
||||
<ApplicationVersion>7.9.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
|
||||
@ -19,7 +19,7 @@ namespace bsmd.database
|
||||
/// we use a generic storage class called "XtraData" that hopefully might be useful in another
|
||||
/// future scenario as well
|
||||
/// </summary>
|
||||
public class MaerskData : DatabaseEntity
|
||||
public class MaerskData : DatabaseEntity, IEquatable<MaerskData>, IComparable<MaerskData>
|
||||
{
|
||||
|
||||
#region Construction
|
||||
@ -233,6 +233,44 @@ namespace bsmd.database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality means if IMO and Voyage no. In/Out are the same
|
||||
/// </summary>
|
||||
public bool Equals(MaerskData other)
|
||||
{
|
||||
if (this.ColG == null) return false;
|
||||
if (this.ColH == null) return false;
|
||||
if (this.ColF == null) return false;
|
||||
if (other == null) return false;
|
||||
return this.ColF.Equals(other.ColF) && this.ColG.Equals(other.ColG) && this.ColH.Equals(other.ColH);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort-Order is by ETA
|
||||
/// </summary>
|
||||
public int CompareTo(MaerskData other)
|
||||
{
|
||||
if (this.ColK == null) return 0;
|
||||
if (other == null) return 0;
|
||||
return this.ColK.CompareTo(other.ColK);
|
||||
}
|
||||
|
||||
public bool Update(MaerskData md)
|
||||
{
|
||||
bool result = false;
|
||||
if (!md.ColA.IsNullOrEmpty() && !md.ColA.Equals(ColA)) { ColA = md.ColA; result = true; }
|
||||
if (!md.ColB.IsNullOrEmpty() && !md.ColB.Equals(ColB)) { ColB = md.ColB; result = true; }
|
||||
if (!md.ColC.IsNullOrEmpty() && !md.ColC.Equals(ColC)) { ColC = md.ColC; result = true; }
|
||||
if (!md.ColD.IsNullOrEmpty() && !md.ColD.Equals(ColD)) { ColD = md.ColD; result = true; }
|
||||
if (!md.ColE.IsNullOrEmpty() && !md.ColE.Equals(ColE)) { ColE = md.ColE; result = true; }
|
||||
if (!md.ColI.IsNullOrEmpty() && !md.ColI.Equals(ColI)) { ColI = md.ColI; result = true; }
|
||||
if (!md.ColJ.IsNullOrEmpty() && !md.ColJ.Equals(ColJ)) { ColJ = md.ColJ; result = true; }
|
||||
if (!md.ColK.IsNullOrEmpty() && !md.ColK.Equals(ColK)) { ColK = md.ColK; result = true; }
|
||||
if (!md.ColL.IsNullOrEmpty() && !md.ColL.Equals(ColL)) { ColL = md.ColL; result = true; }
|
||||
if (!md.ColM.IsNullOrEmpty() && !md.ColM.Equals(ColM)) { ColM = md.ColM; result = true; }
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user