fixes for comments from Christin

This commit is contained in:
Daniel Schick 2022-10-20 12:28:10 +02:00
parent bd39d4dd14
commit d52d8b90bb
7 changed files with 158 additions and 39 deletions

View File

@ -56,6 +56,12 @@ namespace ENI2.Controls
set { var addButton = (Button)Template.FindName("buttonAdd", this); addButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
public bool OkVisible
{
get { var okButton = (Button)Template.FindName("buttonOK", this); return okButton.Visibility == Visibility.Visible; }
set { var okButton = (Button)Template.FindName("buttonOK", this); okButton.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
private void Window_Closing(object sender, CancelEventArgs e)
{
if (this.shouldCancel) e.Cancel = true;

View File

@ -36,7 +36,7 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationRevision>9</ApplicationRevision>
<ApplicationVersion>7.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>

View File

@ -40,6 +40,7 @@ namespace ENI2.EditControls
this.listBoxDescription.ItemsSource = _data;
this.comboBoxType.ItemsSource = Enum.GetValues(typeof(HAZPosTemplate.SublistType));
this.AddVisible = true;
this.OkVisible = false;
}
private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@ -2087,20 +2087,23 @@ namespace ENI2.Excel
crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
crew.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)));
crew.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)), out bool canceled);
if (canceled) return true;
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));
crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)));
crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled);
if (canceled) return true;
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18));
crew.CrewMemberCountryOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
crew.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)));
crew.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out canceled);
if (canceled) return true;
crew.CrewMemberIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("L{0}", i + 18));
crew.CrewMemberVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 18));
crew.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)));
crew.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)), out canceled);
if (canceled) return true;
if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
crew.CrewMemberIdentityDocumentIssuingState = "XX";
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
@ -2141,20 +2144,24 @@ namespace ENI2.Excel
crewd.CrewMemberLastName = lastName;
crewd.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
crewd.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)));
crewd.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)), out bool canceled);
if (canceled) return true;
crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));
crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)));
crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)), out canceled);
if (canceled) return true;
crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18));
crewd.CrewMemberCountryOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crewd.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)));
crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)), out canceled);
if (canceled) return true;
crewd.CrewMemberIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("L{0}", i + 18));
crewd.CrewMemberVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 18));
crewd.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)));
crewd.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)), out canceled);
if (canceled) return true;
if (crewd.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty())
crewd.CrewMemberIdentityDocumentIssuingState = "XX";
crewd.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
@ -2172,45 +2179,54 @@ namespace ENI2.Excel
private static bool ScanPAS(Message pasMessage, ExcelReader reader, bool isOldVersion)
{
pasMessage.DeleteElements();
List<PAS> newPasList = new List<PAS>();
string sheetTitle = "8. PAX - Arrival";
bool? notificationSchengen = reader.ReadBoolean("PAS.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("PAS.NotificationPAX");
bool? notificationPax = reader.ReadBoolean("PAS.NotificationPAX");
for (int i = 0; i < 5000; i++)
{
{
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 17));
if (lastName.IsNullOrEmpty()) break;
if (lastName.IsNullOrEmpty()) break; // finish after reading last row
string firstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 17));
DateTime? dateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17));
if (!(pasMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is PAS pas))
{
pas = new PAS();
pas.Identifier = (i + 1).ToString();
pas.MessageHeader = pasMessage;
pasMessage.Elements.Add(pas);
}
PAS pas = new PAS();
pas.Identifier = (i + 1).ToString();
pas.MessageHeader = pasMessage;
newPasList.Add(pas);
pas.NotificationSchengen = notificationSchengen;
pas.NotificationPAX = notificationPax;
pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 17));
pas.PassengerFirstName = firstName;
pas.PassengerNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 17)));
pas.PassengerIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 17)));
pas.PassengerNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 17)), out bool canceled);
if (canceled) return true;
pas.PassengerIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 17)), out canceled);
if (canceled) return true;
if (pas.PassengerIdentityDocumentIssuingState == null) return true;
pas.PassengerGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 17)));
pas.PassengerPortOfEmbarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 17)));
pas.PassengerPortOfDisembarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 17)));
pas.PassengerGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 17)), out canceled);
if (canceled) return true;
pas.PassengerPortOfEmbarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 17)), out canceled);
if (canceled) return true;
pas.PassengerPortOfDisembarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 17)), out canceled);
if (canceled) return true;
pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 17));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 17));
pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)));
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17));
pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)), out canceled);
if (canceled) return true;
pas.PassengerDateOfBirth = dateOfBirth;
pas.PassengerIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 17)));
pas.PassengerIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 17)), out canceled);
if (canceled) return true;
pas.PassengerIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("N{0}", i + 17));
pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("P{0}", i + 17));
@ -2219,9 +2235,15 @@ namespace ENI2.Excel
pas.PassengerVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("Q{0}", i + 17));
pas.EmergencyCare = reader.ReadCellAsText(sheetTitle, string.Format("R{0}", i + 17));
pas.EmergencyContactNumber = reader.ReadCellAsText(sheetTitle, string.Format("S{0}", i + 17));
pas.EmergencyContactNumber = reader.ReadCellAsText(sheetTitle, string.Format("S{0}", i + 17));
}
DBManager.Instance.DeleteAllPASForMessage(pasMessage.Id);
pasMessage.Elements.Clear();
foreach (PAS pas in newPasList)
pasMessage.Elements.Add(pas);
return true;
}
@ -2424,9 +2446,10 @@ namespace ENI2.Excel
#region "Semi-Manual" import functions (may open interactive dialog)
public static byte? ReadGender(string gender)
public static byte? ReadGender(string gender, out bool canceled)
{
byte? result = DakosyUtil.ParseGender(gender);
canceled = false;
if (!gender.IsNullOrEmpty() && !result.HasValue)
{
@ -2448,6 +2471,10 @@ namespace ENI2.Excel
_genderImportDict[gender] = fid.SelectedValue;
result = byte.Parse(_genderImportDict[gender]);
}
}
else
{
canceled = true;
}
}
}
@ -2455,9 +2482,10 @@ namespace ENI2.Excel
return result;
}
public static byte? ReadDocumentType(string documentType)
public static byte? ReadDocumentType(string documentType, out bool canceled)
{
byte? result = DakosyUtil.ParseDocumentType(documentType);
canceled = false;
if (!documentType.IsNullOrEmpty() && !result.HasValue)
{
@ -2479,6 +2507,10 @@ namespace ENI2.Excel
_genderImportDict[documentType] = fid.SelectedValue;
result = byte.Parse(_genderImportDict[documentType]);
}
}
else
{
canceled = true;
}
}
}
@ -2490,9 +2522,10 @@ namespace ENI2.Excel
return result;
}
public static string ReadNationality(string nationality)
public static string ReadNationality(string nationality, out bool canceled)
{
string result = null;
canceled = false;
nationality = nationality.Trim();
if (nationality.IsNullOrEmpty())
{
@ -2523,15 +2556,20 @@ namespace ENI2.Excel
_countryImportDict[nationality] = fid.SelectedValue;
result = fid.SelectedValue.Substring(0,2); // attention manual entry
}
}
else
{
canceled = true;
}
}
return result;
}
public static string ReadLocode(string val)
public static string ReadLocode(string val, out bool canceled)
{
string result = null;
canceled = false;
val = val.ToUpper();
@ -2560,6 +2598,10 @@ namespace ENI2.Excel
if (fid.ShowDialog() ?? false)
{
_locodeImportDict[val] = fid.SelectedValue;
}
else
{
canceled = true;
}
}
if(_locodeImportDict.ContainsKey(val))

View File

@ -272,6 +272,37 @@ namespace bsmd.database
#endregion
#region Validation
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
{
if (this.CrewMemberIdentityDocumentType.HasValue)
{
if (this.CrewMemberIdentityDocumentType.Value == 5)
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Doc. type set to OTHER_LEGAL_IDENTITY_DOCUMENT", null, this.Title, this.Identifier, this.Tablename));
}
if (this.CrewMemberIdentityDocumentIssuingState != null)
{
if (this.CrewMemberIdentityDocumentIssuingState.Equals("XX"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id. doc issuing state set to XX", null, this.Title, this.Identifier, this.Tablename));
}
if (this.CrewMemberNationality != null)
{
if (this.CrewMemberNationality.Equals("XX"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Nationality set to XX", null, this.Title, this.Identifier, this.Tablename));
}
if (this.CrewMemberIdentityDocumentExpiryDate.HasValue)
{
if (this.CrewMemberIdentityDocumentExpiryDate.Equals(new DateTime(2100, 12, 31)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id doc expiry date set to 31/12/2100", null, this.Title, this.Identifier, this.Tablename));
}
}
#endregion
#region IBulkSaver implementation
public DataTable PrepareBulkInsert(List<DatabaseEntity> databaseEntities)

View File

@ -729,6 +729,18 @@ namespace bsmd.database
return result;
}
public void DeleteAllPASForMessage(Guid? id)
{
if (!id.HasValue) return;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "DELETE FROM PAS WHERE MessageHeaderId = @MESSAGEHEADERID";
cmd.Parameters.AddWithValue("@MESSAGEHEADERID", id);
int numDel = this.PerformNonQuery(cmd);
_log.InfoFormat("Deleted all elements ({0}) from PAS message", numDel);
}
}
#endregion
#region internal/private funcs
@ -1611,7 +1623,7 @@ namespace bsmd.database
bulkCopy.WriteToServer(table);
}
}
}
}
#endregion

View File

@ -17,11 +17,15 @@ namespace bsmd.database
public class PAS : DatabaseEntity, ISublistElement, IBulkSaver
{
#region Construction
public PAS()
{
this.tablename = "[dbo].[PAS]";
}
#endregion
#region Properties
[ShowReport]
@ -320,15 +324,38 @@ namespace bsmd.database
if (this.PassengerPortOfDisembarkation != null)
{
if (this.PassengerPortOfDisembarkation.Equals("ZZUKN"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfDisembarkation", null, this.Title, this.Identifier, this.Tablename));
violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "Port of disembarkation set to ZZUKN", null, this.Title, this.Identifier, this.Tablename));
}
if (this.PassengerPortOfEmbarkation != null)
{
if (this.PassengerPortOfEmbarkation.Equals("ZZUKN"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfEmbarkation", null, this.Title, this.Identifier, this.Tablename));
violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "Port of embarkation set to ZZUKN", null, this.Title, this.Identifier, this.Tablename));
}
if(this.PassengerIdentityDocumentType.HasValue)
{
if(this.PassengerIdentityDocumentType.Value == 5)
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Doc. type set to OTHER_LEGAL_IDENTITY_DOCUMENT", null, this.Title, this.Identifier, this.Tablename));
}
if(this.PassengerNationality != null)
{
if (this.PassengerNationality.Equals("XX"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Nationality set to XX", null, this.Title, this.Identifier, this.Tablename));
}
if (this.PassengerIdentityDocumentIssuingState != null)
{
if (this.PassengerIdentityDocumentIssuingState.Equals("XX"))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id. doc issuing state set to XX", null, this.Title, this.Identifier, this.Tablename));
}
if (this.PassengerIdentityDocumentExpiryDate.HasValue)
{
if(this.PassengerIdentityDocumentExpiryDate.Equals(new DateTime(2100, 12, 31)))
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Id doc expiry date set to 31/12/2100", null, this.Title, this.Identifier, this.Tablename));
}
// */
}
#endregion