excel Tool 3.2.14

neue Locode DB
This commit is contained in:
Daniel Schick 2016-10-25 06:23:37 +00:00
parent 2a54e905e6
commit 3cbc32d6da
10 changed files with 137 additions and 60 deletions

Binary file not shown.

View File

@ -12,18 +12,50 @@ namespace SafeSeaNetTest
{ {
class Program class Program
{ {
private static string veryBasicUri = "https://nswtestapi.safeseanet.dk/";
private static string baseUri = "https://nswtestapi.safeseanet.dk/api/v1/"; private static string baseUri = "https://nswtestapi.safeseanet.dk/api/v1/";
private static string searchUri = "search?query=contentType: ship&take=5"; private static string searchUri = "search?query=contentType: ship&take=5";
static void Main(string[] args) static void Main(string[] args)
{ {
Login(); Login3();
Console.Read(); Console.Read();
} }
private static async void Login3()
{
var credential = new NetworkCredential("bsm-schick", "R1g048r20l", "SSNTEST");
var myCache = new CredentialCache();
Uri uri = new Uri(Path.Combine(baseUri, searchUri));
Uri authUri = new Uri(uri.GetLeftPart(UriPartial.Authority));
// welche Uri wird hier tatsächlich hinzugefügt? nur die Base oder ganz speziell?
myCache.Add(authUri, "ntlm", credential);
var handler = new HttpClientHandler();
handler.AllowAutoRedirect = true;
handler.Credentials = myCache;
// Create an HttpClient with the handler object
HttpClient httpClient = new HttpClient(handler);
// Wait to get the reponse, and you can use the reponse in your code
HttpResponseMessage responseMessage = await httpClient.GetAsync(uri);
string jsonMessage;
using (Stream responseStream = await responseMessage.Content.ReadAsStreamAsync())
{
jsonMessage = new StreamReader(responseStream).ReadToEnd();
}
}
private static async void Login() private static async void Login()
{ {
NetworkCredential credential = new NetworkCredential("bsm-schick", "R1g048r20l"); NetworkCredential credential = new NetworkCredential("bsm-schick", "R1g048r20l");

View File

@ -4,8 +4,7 @@ G
Anmeldung: bsm-schick Anmeldung: bsm-schick
PW: Melder2016 PW: Melder2016
Januar-2016 Januar-2016
--> R1g048r20l
(funktioniert aktuell beides nicht)
https://nswtest.safeseanet.dk/api/v1/search?query=contentType: ship&take=5 https://nswtest.safeseanet.dk/api/v1/search?query=contentType: ship&take=5

View File

@ -314,6 +314,12 @@ namespace bsmd.ExcelReadService
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber"); stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId"); stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId");
if(!stat.ISMCompanyId.IsNullOrEmpty() && stat.ISMCompanyId.Length < 7)
{
while (stat.ISMCompanyId.Length < 7)
stat.ISMCompanyId = "0" + stat.ISMCompanyId;
}
if (!stat.Flag.IsNullOrEmpty() && stat.Flag.Length > 2) if (!stat.Flag.IsNullOrEmpty() && stat.Flag.Length > 2)
stat.Flag = LocodeDB.CountryCodeFromName(stat.Flag); stat.Flag = LocodeDB.CountryCodeFromName(stat.Flag);
@ -430,6 +436,9 @@ namespace bsmd.ExcelReadService
} }
AGNT agnt = agntMessage.Elements[0] as AGNT; AGNT agnt = agntMessage.Elements[0] as AGNT;
Util.ScanMessage(agnt, reader); Util.ScanMessage(agnt, reader);
if (agnt.AgentLastName.IsNullOrEmpty()) agnt.AgentLastName = "-";
// wird nicht mehr entfernt, egal welche Felder gelesen werden // wird nicht mehr entfernt, egal welche Felder gelesen werden
} }
@ -527,58 +536,92 @@ namespace bsmd.ExcelReadService
mdh.MDHSimplification = false; mdh.MDHSimplification = false;
mdh.PortOfCallWhereCompleteMDHNotified = ""; mdh.PortOfCallWhereCompleteMDHNotified = "";
// POC last 30 days
for (int i = 0; i < mdh.NumberOfExcelRows; i++) string kuerzelErsteZelle = reader.ReadText("MDH.PortOfCallLast30DaysLocode_1");
// lt. Mail von Christin am 11.10.2016
// "SEC" Mode, die Werte aus last10PortFacilitesCalled (SEC) werden übernommen
// das funktioniert, da SEC vor MDH gelesen wird
if (!kuerzelErsteZelle.IsNullOrEmpty() && kuerzelErsteZelle.Equals("sec", StringComparison.OrdinalIgnoreCase))
{ {
string portName = string.Format("MDH.PortOfCallLast30DaysPort_{0}", i + 1); Message secMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.SEC);
string portCountry = string.Format("MDH.PortOfCallLast30DaysCountry_{0}", i + 1); if (secMessage.Elements.Count == 0) return;
string locode = string.Format("MDH.PortOfCallLast30DaysLocode_{0}", i + 1); SEC sec = secMessage.Elements[0] as SEC;
string crewJoined = string.Format("MDH.PortOfCallLast30DaysCrewMembersJoined_{0}", i + 1); int i = 1;
string crewName = string.Format("MDH.PortOfCallLast30DaysCrewJoinedShipName_{0}", i + 1); foreach (LastTenPortFacilitiesCalled ltpfc in sec.LastTenPortFacilitesCalled)
string depDate = string.Format("MDH.PortOfCallLast30DaysDateOfDeparture_{0}", i + 1);
PortOfCallLast30Days poc30d = mdh.GetSublistElementWithIdentifier((i + 1).ToString()) as PortOfCallLast30Days;
if (poc30d == null)
{ {
poc30d = new PortOfCallLast30Days(); PortOfCallLast30Days poc30d = mdh.GetSublistElementWithIdentifier((i + 1).ToString()) as PortOfCallLast30Days;
poc30d.Identifier = (i + 1).ToString(); if (poc30d == null)
poc30d.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30d);
}
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate);
poc30d.PortOfCallLast30DaysLocode = reader.ReadTextNoWhitespace(locode);
poc30d.PortOfCallLast30DaysCrewMembersJoined = reader.ReadBoolean(crewJoined);
if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false)
{
string crewNameString = reader.ReadText(crewName);
if (!crewName.IsNullOrEmpty())
{ {
// try different separators poc30d = new PortOfCallLast30Days();
string[] crew = crewNameString.Split(';'); poc30d.Identifier = (i + 1).ToString();
if (crew.Length == 1) poc30d.MDH = mdh;
crew = crewNameString.Split(','); mdh.PortOfCallLast30Days.Add(poc30d);
}
for (int j = 0; j < crew.Length; j++) poc30d.PortOfCallLast30DaysCrewMembersJoined = false;
poc30d.PortOfCallLast30DaysLocode = ltpfc.PortFacilityPortLoCode;
poc30d.PortOfCallLast30DaysDateOfDeparture = ltpfc.PortFacilityDateOfDeparture;
i++;
}
}
else // "normal mode", aus den Zellen lesen
{
// POC last 30 days
for (int i = 0; i < mdh.NumberOfExcelRows; i++)
{
string portName = string.Format("MDH.PortOfCallLast30DaysPort_{0}", i + 1);
string portCountry = string.Format("MDH.PortOfCallLast30DaysCountry_{0}", i + 1);
string locode = string.Format("MDH.PortOfCallLast30DaysLocode_{0}", i + 1);
string crewJoined = string.Format("MDH.PortOfCallLast30DaysCrewMembersJoined_{0}", i + 1);
string crewName = string.Format("MDH.PortOfCallLast30DaysCrewJoinedShipName_{0}", i + 1);
string depDate = string.Format("MDH.PortOfCallLast30DaysDateOfDeparture_{0}", i + 1);
PortOfCallLast30Days poc30d = mdh.GetSublistElementWithIdentifier((i + 1).ToString()) as PortOfCallLast30Days;
if (poc30d == null)
{
poc30d = new PortOfCallLast30Days();
poc30d.Identifier = (i + 1).ToString();
poc30d.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30d);
}
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate);
poc30d.PortOfCallLast30DaysLocode = reader.ReadTextNoWhitespace(locode);
poc30d.PortOfCallLast30DaysCrewMembersJoined = reader.ReadBoolean(crewJoined);
if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false)
{
string crewNameString = reader.ReadText(crewName);
if (!crewName.IsNullOrEmpty())
{ {
PortOfCallLast30DaysCrewJoinedShip poc30dCrew = poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) as PortOfCallLast30DaysCrewJoinedShip; // try different separators
if (poc30dCrew == null) string[] crew = crewNameString.Split(';');
{ if (crew.Length == 1)
poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip(); crew = crewNameString.Split(',');
poc30dCrew.Identifier = (j + 1).ToString();
poc30dCrew.PortOfCallLast30Days = poc30d;
poc30d.CrewJoinedShip.Add(poc30dCrew);
}
poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j]; for (int j = 0; j < crew.Length; j++)
{
PortOfCallLast30DaysCrewJoinedShip poc30dCrew = poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) as PortOfCallLast30DaysCrewJoinedShip;
if (poc30dCrew == null)
{
poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip();
poc30dCrew.Identifier = (j + 1).ToString();
poc30dCrew.PortOfCallLast30Days = poc30d;
poc30d.CrewJoinedShip.Add(poc30dCrew);
}
poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j];
}
} }
} }
}
// Leer/def. Zeilen entfernen // Leer/def. Zeilen entfernen
if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode == null)) if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode == null))
mdh.PortOfCallLast30Days.Remove(poc30d); mdh.PortOfCallLast30Days.Remove(poc30d);
}
} }
// wird nicht wieder entfernt falls keine Daten vorliegen // wird nicht wieder entfernt falls keine Daten vorliegen
@ -638,11 +681,7 @@ namespace bsmd.ExcelReadService
string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i); string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i);
string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i); string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i);
string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i); string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i);
string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i); string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i);
if((portGISISCode != null) && (portGISISCode.Length < 4))
{
while (portGISISCode.Length < 4) portGISISCode = "0" + portGISISCode;
}
string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i); string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i);
LastTenPortFacilitiesCalled l10fc = sec.GetPortFacilityWithIdentifier(i.ToString()) as LastTenPortFacilitiesCalled; LastTenPortFacilitiesCalled l10fc = sec.GetPortFacilityWithIdentifier(i.ToString()) as LastTenPortFacilitiesCalled;
@ -661,6 +700,13 @@ namespace bsmd.ExcelReadService
l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture); l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture);
l10fc.PortFacilityShipSecurityLevel = (byte) reader.ReadNumber(portShipSecLevel); l10fc.PortFacilityShipSecurityLevel = (byte) reader.ReadNumber(portShipSecLevel);
l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode); l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode);
if (l10fc.PortFacilityGISISCode.IsNullOrEmpty() || l10fc.PortFacilityGISISCode == "0")
l10fc.PortFacilityGISISCode = "0000";
if((l10fc.PortFacilityGISISCode != null) && (l10fc.PortFacilityGISISCode.Length < 4))
{
while (l10fc.PortFacilityGISISCode.Length < 4) l10fc.PortFacilityGISISCode = "0" + l10fc.PortFacilityGISISCode;
}
l10fc.PortFacilitySecurityMattersToReport = reader.ReadText(portSecMatters); l10fc.PortFacilitySecurityMattersToReport = reader.ReadText(portSecMatters);
} }

View File

@ -48,8 +48,8 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" /> <Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.101.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <Reference Include="System.Data.SQLite, Version=1.0.103.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.101.0\lib\net45\System.Data.SQLite.dll</HintPath> <HintPath>..\packages\System.Data.SQLite.Core.1.0.103\lib\net45\System.Data.SQLite.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -128,12 +128,12 @@
<WCFMetadata Include="Service References\" /> <WCFMetadata Include="Service References\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.101.0\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.101.0\build\net45\System.Data.SQLite.Core.targets')" /> <Import Project="..\packages\System.Data.SQLite.Core.1.0.103\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.103\build\net45\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.101.0\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.101.0\build\net45\System.Data.SQLite.Core.targets'))" /> <Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.103\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.103\build\net45\System.Data.SQLite.Core.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -2,5 +2,5 @@
<packages> <packages>
<package id="log4net" version="2.0.5" targetFramework="net45" /> <package id="log4net" version="2.0.5" targetFramework="net45" />
<package id="OpenPop.NET" version="2.0.6.1120" targetFramework="net45" /> <package id="OpenPop.NET" version="2.0.6.1120" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.101.0" targetFramework="net45" /> <package id="System.Data.SQLite.Core" version="1.0.103" targetFramework="net45" />
</packages> </packages>

View File

@ -136,7 +136,7 @@ namespace bsmd.database
[ShowReport] [ShowReport]
[Validation2(ValidationCode.NOT_NULL)] [Validation2(ValidationCode.NOT_NULL)]
[LookupName("SanitaryControlReinspectionRequired")] [LookupName("MDH.SanitaryControlReinspectionRequired")]
public bool? SanitaryControlReinspectionRequired { get; set; } public bool? SanitaryControlReinspectionRequired { get; set; }
[ShowReport] [ShowReport]

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")] [assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")] [assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.2.10")] [assembly: AssemblyInformationalVersion("3.2.14")]
[assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")] [assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]

View File

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

Binary file not shown.