5.1.13 Restpunkte bearbeitet

This commit is contained in:
Daniel Schick 2018-12-10 09:23:09 +00:00
parent 518623fa81
commit be978be025
17 changed files with 80 additions and 67 deletions

View File

@ -58,7 +58,7 @@ namespace ENI2.Controls
case RuleEngine.LocodeMode.STANDARD:
portName = LocodeDB.PortNameFromLocode(value); break;
case RuleEngine.LocodeMode.SSN:
portName = LocalizedLookup.SSNPortNameFromLocode(value); break;
portName = LocodeDB.SSNPortNameFromLocode(value); break;
}
LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK;
this.SetLocodeStateImage(this.imageLocodeState, locodeState);
@ -143,7 +143,7 @@ namespace ENI2.Controls
case RuleEngine.LocodeMode.STANDARD:
portname = LocodeDB.PortNameFromLocode(directLocode); break;
case RuleEngine.LocodeMode.SSN:
portname = LocalizedLookup.SSNPortNameFromLocode(directLocode); break;
portname = LocodeDB.SSNPortNameFromLocode(directLocode); break;
}
bool isLocode = !portname.IsNullOrEmpty();

View File

@ -214,27 +214,7 @@ namespace ENI2
}
reader.Close();
return result;
}
public static string SSNPortNameFromLocode(string locode)
{
if (locode.IsNullOrEmpty()) return null;
if (locode.Length != 5) return null;
string result = null;
string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode);
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (!reader.IsDBNull(0))
result = reader.GetString(0);
break;
}
reader.Close();
return result;
}
}
public static List<LocodeDB.LocodeEntry> SSNAllLocodesForCityNameAsEntries(string city)
{

View File

@ -206,7 +206,7 @@ namespace ENI2.Util
case RuleEngine.LocodeMode.NO_PORT_FLAG:
return !LocodeDB.LocationNameFromLocode(locode).IsNullOrEmpty();
case RuleEngine.LocodeMode.SSN:
return !LocalizedLookup.SSNPortNameFromLocode(locode).IsNullOrEmpty();
return !LocodeDB.SSNPortNameFromLocode(locode).IsNullOrEmpty();
default:
return !LocodeDB.PortNameFromLocode(locode).IsNullOrEmpty();
}

Binary file not shown.

View File

@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\..\mtc\puls200.frame\frame.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>

View File

@ -21,12 +21,10 @@ using bsmd.database;
namespace bsmd.ExcelReadService
{
internal class ExcelReader : ExcelBase
{
private Dictionary<string, string> stringVals = new Dictionary<string, string>();
{
internal enum ReadState { NONE, OK, WARN, FAIL };
internal enum ReadState { NONE, OK, WARN, FAIL };
internal Dictionary<string, string> ImportValues { get { return this.stringVals; } }
internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>();
public ExcelReader(string filePath)
{
@ -129,7 +127,7 @@ namespace bsmd.ExcelReadService
if (result != null)
{
result = result.Trim();
this.stringVals[lookup] = result;
this.ImportValues[lookup] = result;
}
return result;
@ -147,6 +145,7 @@ namespace bsmd.ExcelReadService
string val = this.ReadText(lookup);
if(!val.IsNullOrEmpty())
{
val = val.ToUpper();
string portName = LocodeDB.PortNameFromLocode(val);
if(portName == null)
{
@ -292,9 +291,9 @@ namespace bsmd.ExcelReadService
if(val != null)
{
if (val.IndexOf("load", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
if (val.IndexOf("discharge", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
if (val.IndexOf("transit", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if ((val.IndexOf("load", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("1")) result = 0;
if ((val.IndexOf("discharge", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("2")) result = 1;
if ((val.IndexOf("transit", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("3")) result = 2;
if (result == null)
this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else
@ -422,9 +421,9 @@ namespace bsmd.ExcelReadService
if (val != null)
{
if (val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if ((val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("1")) result = 0;
if ((val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("2")) result = 1;
if ((val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("3")) result = 2;
if (result == null)
this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else
@ -473,7 +472,7 @@ namespace bsmd.ExcelReadService
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateString = val.ToString();
string format = "yyyyMMdd";
const string format = "yyyyMMdd";
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
date = tmpDate;
}
@ -562,7 +561,7 @@ namespace bsmd.ExcelReadService
string dateString = val.ToString();
if (!dateString.Contains(":"))
{
string format = "HHmm";
const string format = "HHmm";
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
result = tmpDate;
}

View File

@ -162,6 +162,30 @@ namespace bsmd.ExcelReadService
return result;
}
/// <summary>
/// SSN Portname from Locode (for validation)
/// </summary>
public static string SSNPortNameFromLocode(string locode)
{
if (locode.IsNullOrEmpty()) return null;
if (locode.Length != 5) return null;
string result = null;
string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode);
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (!reader.IsDBNull(0))
result = reader.GetString(0);
break;
}
reader.Close();
return result;
}
/// <summary>
/// Get Locationname from LOCODE
/// </summary>

View File

@ -147,7 +147,7 @@ namespace bsmd.ExcelReadService
#region ATA
static void ScanATA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
private static void ScanATA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
{
Message ataMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.ATA);
if (ataMessage.Elements.Count == 0)
@ -172,7 +172,7 @@ namespace bsmd.ExcelReadService
#region ATD
static void ScanATD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
private static void ScanATD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
{
Message atdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.ATD);
if (atdMessage.Elements.Count == 0)
@ -197,7 +197,7 @@ namespace bsmd.ExcelReadService
#region TIEFA
static void ScanTIEFA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
private static void ScanTIEFA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
{
Message tiefaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TIEFA);
if (tiefaMessage.Elements.Count == 0)
@ -297,8 +297,7 @@ namespace bsmd.ExcelReadService
if (!bpolNameValue.IsNullOrEmpty() || !bpolLocodeValue.IsNullOrEmpty())
{
PortOfItinerary poi = bpol.GetSublistElementWithIdentifier(i.ToString()) as PortOfItinerary;
if (poi == null)
if (!(bpol.GetSublistElementWithIdentifier(i.ToString()) is PortOfItinerary poi))
{
poi = new PortOfItinerary();
poi.BPOL = bpol;
@ -1098,7 +1097,7 @@ namespace bsmd.ExcelReadService
reader.Conf.ConfirmText("STAT.MMSINumber", stat.MMSINumber, (stat.MMSINumber.IsNullOrEmpty() || (stat.MMSINumber.Length != 9)) ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
stat.CallSign = reader.ReadTextNoWhitespace("STAT.CallSign");
reader.Conf.ConfirmText("STAT.CallSign", stat.CallSign, (stat.CallSign.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK));
reader.Conf.ConfirmText("STAT.CallSign", stat.CallSign, stat.CallSign.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId");
@ -1220,14 +1219,19 @@ namespace bsmd.ExcelReadService
reader.Conf.ConfirmText("NOA_NOD.LastPort", lastPort, noa_nod.LastPort.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
string nextPort = reader.ReadText("NOA_NOD.NextPort");
bool? isValidSSNPort = false;
if (!nextPort.IsNullOrEmpty())
{
noa_nod.NextPort = nextPort.Trim();
if (noa_nod.NextPort.Length > 5)
noa_nod.NextPort = noa_nod.NextPort.Substring(0, 5); //trunc
}
isValidSSNPort = !LocodeDB.SSNPortNameFromLocode(noa_nod.NextPort).IsNullOrEmpty();
}
reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, noa_nod.NextPort.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
if(!isValidSSNPort.HasValue)
reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, ExcelReader.ReadState.WARN);
else
reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, isValidSSNPort.Value ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
if(messageCore.IsTransit)
{
@ -1248,7 +1252,7 @@ namespace bsmd.ExcelReadService
noa_nod.ETDFromLastPort = reader.ReadDateTime("NOA_NOD.ETDDateFromLastPort", "NOA_NOD.ETDTimeFromLastPort");
noa_nod.ETAToNextPort = reader.ReadDateTime("NOA_NOD.ETADateToNextPort", "NOA_NOD.ETATimeToNextPort");
// DK
noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", (reader.Mode == ExcelReader.CountryMode.DE));
noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", reader.Mode == ExcelReader.CountryMode.DE);
}
@ -1728,9 +1732,9 @@ namespace bsmd.ExcelReadService
string isscType = reader.ReadText("SEC.ISSCType");
if(isscType != null)
{
if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase))
if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase) || isscType.Equals("1"))
sec.ISSCType = 0;
if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase))
if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase) || isscType.Equals("2"))
sec.ISSCType = 1;
}
@ -1752,9 +1756,9 @@ namespace bsmd.ExcelReadService
string isscIssuerType = reader.ReadText("SEC.ISSCIssuerType");
if(isscIssuerType != null)
{
if (isscIssuerType.Equals("rso", StringComparison.OrdinalIgnoreCase))
if (isscIssuerType.Equals("rso", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("2"))
sec.ISSCIssuerType = 1;
if (isscIssuerType.Contains("admin", StringComparison.OrdinalIgnoreCase))
if (isscIssuerType.Contains("admin", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("1"))
sec.ISSCIssuerType = 0;
}

View File

@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\..\mtc\puls200.frame\frame.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("5.1.2")]
[assembly: AssemblyInformationalVersion("5.1.3")]
[assembly: AssemblyCopyright("Copyright © 2014-2018 schick Informatik")]
[assembly: AssemblyTrademark("")]

View File

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

View File

@ -401,7 +401,7 @@ namespace bsmd.database
// individuelle Fehler nach Nachrichtenklasse prüfen
derivedEntity.MessageCore = aMessage.MessageCore; // some instance we need info from core (NOA / Transit)
if ((derivedEntity is LADG) && aMessage.MessageCore.IsTransit) continue; // kein error reporting für LADG bei Transit (CH, 1.2.16)
if ((derivedEntity is SEC) && aMessage.MessageCore.IsSmallShip) continue; // keine STAT Validierung für kleine Schiffe (CH, 1.11.18)
if ((derivedEntity is SEC) && aMessage.MessageCore.IsSmallShip) continue; // keine SEC Validierung für kleine Schiffe (CH, 1.11.18)
RuleEngine.ValidateProperties(derivedEntity, errors, violations);
derivedEntity.Validate(errors, violations);
}

View File

@ -383,6 +383,11 @@ namespace bsmd.database
L10Called.Validate(errors, violations);
}
if(this.LastTenPortFacilitesCalled.Count != 10)
{
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Number of last port facilities != 10", null, this.Title, null, this.Tablename));
}
foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s in this.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
{
RuleEngine.ValidateProperties(s2s, errors, violations);

View File

@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\..\mtc\puls200.frame\frame.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@ -19,21 +19,17 @@ namespace bsmd.hisnord
{
public class Request
{
private static ILog _log = LogManager.GetLogger(typeof(Request));
private static readonly ILog _log = LogManager.GetLogger(typeof(Request));
private static Dictionary<Guid, ReportingParty> _reportingPartyDict = null;
private static Dictionary<MessageCore, Dictionary<Message, string>> coreFilenameDict = new Dictionary<MessageCore, Dictionary<Message,string>>();
private static Dictionary<MessageCore, bool> coreUseTestDict = new Dictionary<MessageCore, bool>();
private static readonly Dictionary<MessageCore, Dictionary<Message, string>> coreFilenameDict = new Dictionary<MessageCore, Dictionary<Message,string>>();
private static readonly Dictionary<MessageCore, bool> coreUseTestDict = new Dictionary<MessageCore, bool>();
//private static Dictionary<Message.NotificationClass, Message> noteMessageDict = new Dictionary<Message.NotificationClass, Message>();
internal static Dictionary<Guid, ReportingParty> ReportingPartyDict
{
get
{
if (_reportingPartyDict == null)
{
_reportingPartyDict = DBManager.Instance.GetReportingPartyDict();
}
return _reportingPartyDict;
return _reportingPartyDict ?? (_reportingPartyDict = DBManager.Instance.GetReportingPartyDict());
}
}
@ -105,8 +101,8 @@ namespace bsmd.hisnord
return false;
}
_nsw.conveyance.owner_sender.name_short = @"BSMD";
_nsw.conveyance.owner_sender.name_long = @"BSMD";// rp.Name; // core.Customer.Name;
_nsw.conveyance.owner_sender.name_short = "BSMD";
_nsw.conveyance.owner_sender.name_long = "BSMD";// rp.Name; // core.Customer.Name;
_nsw.conveyance.owner_sender.address = new addresstype();
@ -116,7 +112,7 @@ namespace bsmd.hisnord
// das hier ist der e-mail(!) Empfänger für Error/Violation Meldungen
_nsw.conveyance.owner_sender.contact = new contacts();
_nsw.conveyance.owner_sender.contact.name = @"BSMD"; // rp.LastName;
_nsw.conveyance.owner_sender.contact.name = "BSMD"; // rp.LastName;
_nsw.conveyance.owner_sender.contact.email = rp.EMail;
_nsw.conveyance.owner_sender.contact.firstname = string.Format("{0} {1}", rp.FirstName, rp.LastName);
_nsw.conveyance.owner_sender.contact.phone = rp.Phone;
@ -207,7 +203,7 @@ namespace bsmd.hisnord
hn_stat.InmarsatCallNumbers.InmarsatCallNumber = callNumbers.ToArray();
}
if (!stat.ISMCompanyName.IsNullOrEmpty() || ((stat.GrossTonnage ?? 0) > 500)) // Vio. 821
if (!stat.ISMCompanyName.IsNullOrEmpty() && ((stat.GrossTonnage ?? 0) >= 500)) // Vio. 821
{
hn_stat.ISMCompany = new ismcompany();
if (!stat.ISMCompanyCity.IsNullOrEmpty())
@ -1024,7 +1020,7 @@ namespace bsmd.hisnord
List<object> mdh_items = new List<object>();
List<ItemsChoiceType5> mdh_types = new List<ItemsChoiceType5>();
if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value)
if (mdh.MDHSimplification == true)
{
mdh_items.Add(ytype.Y);
mdh_types.Add(ItemsChoiceType5.MDHSimplification);

View File

@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\..\mtc\puls200.frame\frame.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\..\mtc\puls200.frame\frame.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>