Änderungen nach zwei Tagen in Bremen

This commit is contained in:
Daniel Schick 2015-05-12 18:31:48 +00:00
parent e97cc741ae
commit 12fd2f9f8f
9 changed files with 155 additions and 17 deletions

Binary file not shown.

View File

@ -70,7 +70,8 @@ namespace bsmd.database
FAILURE, FAILURE,
REPORTREQUESTED, REPORTREQUESTED,
ARCHIVED, ARCHIVED,
HIS_FAILURE_DBH HIS_FAILURE_DBH,
SEND_ALL // nur für messageCore, wenn alle Sub-Nachrichten einer Core-Nachricht auf "TOSEND" gesetzt werden sollen.
} }
/// <summary> /// <summary>

View File

@ -98,7 +98,7 @@ namespace bsmd.database
scmd.Parameters.AddWithNullableValue("@P1", this.MessageHeader.Id); scmd.Parameters.AddWithNullableValue("@P1", this.MessageHeader.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.ETAToPortOfCall); scmd.Parameters.AddWithNullableValue("@P2", this.ETAToPortOfCall);
scmd.Parameters.AddWithNullableValue("@P3", this.ETDFromPortOfCall); scmd.Parameters.AddWithNullableValue("@P3", this.ETDFromPortOfCall);
scmd.Parameters.AddWithNullableValue("@P4", this.CallPurposeCode.Value); scmd.Parameters.AddWithNullableValue("@P4", this.CallPurposeCode);
scmd.Parameters.AddWithNullableValue("@P5", this.CallPurposeDescription); scmd.Parameters.AddWithNullableValue("@P5", this.CallPurposeDescription);
scmd.Parameters.AddWithNullableValue("@P6", this.ETAToKielCanal); scmd.Parameters.AddWithNullableValue("@P6", this.ETAToKielCanal);
scmd.Parameters.AddWithNullableValue("@P7", this.ETDFromKielCanal); scmd.Parameters.AddWithNullableValue("@P7", this.ETDFromKielCanal);

View File

@ -11,6 +11,8 @@
<AssemblyName>bsmd.database</AssemblyName> <AssemblyName>bsmd.database</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -103,6 +105,7 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- 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.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

View File

@ -7,6 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.herberg.FormService",
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6CC93FD5-8B0C-43A7-8F5B-903C5592C906}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

View File

@ -33,6 +33,7 @@ namespace bsmd.herberg.FormService
{ {
this.EventLog.Source = this.ServiceName; this.EventLog.Source = this.ServiceName;
this.EventLog.Log = "Application"; this.EventLog.Log = "Application";
/*
this.EventLog.BeginInit(); this.EventLog.BeginInit();
try try
{ {
@ -44,7 +45,7 @@ namespace bsmd.herberg.FormService
_log.ErrorFormat("Source exists exception: {0}", ex.ToString()); _log.ErrorFormat("Source exists exception: {0}", ex.ToString());
} }
this.EventLog.EndInit(); this.EventLog.EndInit();
*/
this.Init(args); this.Init(args);
this.EventLog.WriteEntry("NSW Send Service started.", EventLogEntryType.Information); this.EventLog.WriteEntry("NSW Send Service started.", EventLogEntryType.Information);
@ -63,6 +64,11 @@ namespace bsmd.herberg.FormService
} }
public void DoOnce()
{
this._timer_Elapsed(null, null);
}
void _timer_Elapsed(object sender, ElapsedEventArgs e) void _timer_Elapsed(object sender, ElapsedEventArgs e)
{ {
lock (this._timerlock) lock (this._timerlock)

View File

@ -26,7 +26,8 @@ namespace bsmd.herberg.FormService
if (Debugger.IsAttached) if (Debugger.IsAttached)
{ {
((FormService)ServicesToRun[0]).Init(null); // ((FormService)ServicesToRun[0]).Init(null);
((FormService)ServicesToRun[0]).DoOnce();
while (true) ; while (true) ;
} }
else else

View File

@ -64,7 +64,7 @@ namespace bsmd.herberg.FormService
Dictionary<string, string> vDict = groupedVals[messageType]; Dictionary<string, string> vDict = groupedVals[messageType];
DatabaseEntity derivedMessage = null; DatabaseEntity derivedMessage = null;
Message theMessage = null; Message theMessage = null;
if (!messages.ContainsKey(messageType)) if (!messages.ContainsKey(messageType.ToUpper()))
{ {
theMessage = new Message(); theMessage = new Message();
if (messageType.Equals("HAZ")) continue; // HE spezial, sollte HAZA o. HAZD sein if (messageType.Equals("HAZ")) continue; // HE spezial, sollte HAZA o. HAZD sein
@ -88,7 +88,8 @@ namespace bsmd.herberg.FormService
} }
else else
{ {
theMessage = messages[messageType]; _log.InfoFormat("found message type {0}", messageType);
theMessage = messages[messageType.ToUpper()];
} }
switch (messageType) switch (messageType)
@ -108,7 +109,7 @@ namespace bsmd.herberg.FormService
{ {
try try
{ {
if (vDict.ContainsKey("ATAPortOfCall")) ata.ATAPortOfCall = DateTime.Parse(vDict["ATAPortOfCall"]);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -117,6 +118,30 @@ namespace bsmd.herberg.FormService
} }
} }
break; break;
case "ATD":
{
if (theMessage.Elements.Count == 0)
{
ATD newATD = new ATD();
newATD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.ATD;
theMessage.Elements.Add(newATD);
}
ATD atd = theMessage.Elements[0] as ATD;
derivedMessage = atd;
if (atd != null)
{
try
{
if(vDict.ContainsKey("ATDPortOfCall")) atd.ATDPortOfCall = DateTime.Parse(vDict["ATDPortOfCall"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading ATD fields: {0}", ex.Message);
}
}
}
break;
case "NOA_NOD": case "NOA_NOD":
{ {
if (theMessage.Elements.Count == 0) if (theMessage.Elements.Count == 0)
@ -306,6 +331,31 @@ namespace bsmd.herberg.FormService
} }
} }
break; break;
case "BKRD":
{
if (theMessage.Elements.Count == 0)
{
BRKD newBRKD = new BRKD();
newBRKD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.BKRD;
theMessage.Elements.Add(newBRKD);
}
BRKD bkrd = theMessage.Elements[0] as BRKD;
derivedMessage = bkrd;
if (bkrd != null)
{
try
{
if (vDict.ContainsKey("BunkerFuelType")) bkrd.BunkerFuelType = vDict["BunkerFuelType"];
if (vDict.ContainsKey("BunkerFuelQuantity_TNE")) bkrd.BunkerFuelQuantity_TNE = (float)Double.Parse(vDict["BunkerFuelQuantity_TNE"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading BKRD fields: {0}", ex.Message);
}
}
}
break;
case "WAS": case "WAS":
break; break;
@ -319,14 +369,12 @@ namespace bsmd.herberg.FormService
} }
break;
case "Agency":
break; break;
case "Transit": case "Transit":
{
theMessage.MessageNotificationClass = Message.NotificationClass.TRANSIT;
}
break; break;
case "TOWA": case "TOWA":
if(theMessage.Elements.Count == 0) { if(theMessage.Elements.Count == 0) {
@ -364,6 +412,43 @@ namespace bsmd.herberg.FormService
} }
} }
break; break;
case "TOWD":
if (theMessage.Elements.Count == 0)
{
TOWD newTOWD = new TOWD();
newTOWD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.TOWD;
theMessage.Elements.Add(newTOWD);
}
TOWD towd = theMessage.Elements[0] as TOWD;
derivedMessage = towd;
if (towd != null)
{
try
{
if (vDict.ContainsKey("TowageOnDepartureBeam_MTR")) towd.TowageOnDepartureBeam_MTR = (float)Double.Parse(vDict["TowageOnDepartureBeam_MTR"]);
if (vDict.ContainsKey("TowageOnDepartureDraught_DMT")) towd.TowageOnDepartureDraught_DMT = (float)Double.Parse(vDict["TowageOnDepartureDraught_DMT"]);
if (vDict.ContainsKey("TowageOnDepartureLengthOverall_MTR")) towd.TowageOnDepartureLengthOverall_MTR = (float)Double.Parse(vDict["TowageOnDepartureLengthOverall_MTR"]);
if (vDict.ContainsKey("TowageOnDepartureGrossTonnage")) towd.TowageOnDepartureGrossTonnage = Int32.Parse(vDict["TowageOnDepartureGrossTonnage"]);
if (vDict.ContainsKey("TowageOnDepartureOperatorCountry")) towd.TowageOnDepartureOperatorCountry = vDict["TowageOnDepartureOperatorCountry"];
if (vDict.ContainsKey("TowageOnDeparturePurposeOfCall")) towd.TowageOnDeparturePurposeOfCall = vDict["TowageOnDeparturePurposeOfCall"];
if (vDict.ContainsKey("TowageOnDepartureName")) towd.TowageOnDepartureName = vDict["TowageOnDepartureName"];
if (vDict.ContainsKey("TowageOnDepartureFlag")) towd.TowageOnDepartureFlag = vDict["TowageOnDepartureFlag"];
if (vDict.ContainsKey("TowageOnDepartureOperatorCompanyName")) towd.TowageOnDepartureOperatorCompanyName = vDict["TowageOnDepartureOperatorCompanyName"];
if (vDict.ContainsKey("TowageOnDepartureOperatorStreetAndNumber")) towd.TowageOnDepartureOperatorStreetNameAndNumber = vDict["TowageOnDepartureOperatorStreetAndNumber"];
if (vDict.ContainsKey("TowageOnDepartureOperatorPostalCode")) towd.TowageOnDepartureOperatorPostalCode = vDict["TowageOnDepartureOperatorPostalCode"];
if (vDict.ContainsKey("TowageOnDepartureOperatorCity")) towd.TowageOnDepartureOperatorCity = vDict["TowageOnDepartureOperatorCity"];
if (vDict.ContainsKey("TowageOnDepartureOperatorPhone")) towd.TowageOnDepartureOperatorPhone = vDict["TowageOnDepartureOperatorPhone"];
if (vDict.ContainsKey("TowageOnDepartureOperatorFax")) towd.TowageOnDepartureOperatorFax = vDict["TowageOnDepartureOperatorFax"];
if (vDict.ContainsKey("TowageOnDepartureOperatorEmail")) towd.TowageOnDepartureOperatorEmail = vDict["TowageOnDepartureOperatorEmail"];
if (vDict.ContainsKey("TowageOnDepartureRemarks")) towd.TowageOnDepartureRemarks = vDict["TowageOnDepartureRemarks"];
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading TOWA fields: {0}", ex.Message);
}
}
break;
case "TIEFA": case "TIEFA":
{ {
if (theMessage.Elements.Count == 0) if (theMessage.Elements.Count == 0)
@ -388,12 +473,43 @@ namespace bsmd.herberg.FormService
} }
break; break;
} }
case "TIEFD":
{
if (theMessage.Elements.Count == 0)
{
TIEFD newTIEFD = new TIEFD();
newTIEFD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.TIEFD;
theMessage.Elements.Add(newTIEFD);
}
TIEFD tiefd = theMessage.Elements[0] as TIEFD;
derivedMessage = tiefd;
if (tiefd != null)
{
try
{
if (vDict.ContainsKey("DraughtUponDeparture_DMT")) tiefd.DraughtUponDeparture_DMT = (float)Double.Parse(vDict["DraughtUponDeparture_DMT"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading TIEFD fields: {0}", ex.Message);
}
}
break;
}
} }
// Die Logik dient dazu, dass bei "leeren" Nachrichten (also z.B. MDH ohne MDH Infos) nicht nur der
// Header gespeichert wird und danach in der Luft hängt
if ((theMessage.MessageNotificationClass == Message.NotificationClass.VISIT) ||
(theMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT) ||
(derivedMessage != null))
{
DBManager.Instance.Save(theMessage); DBManager.Instance.Save(theMessage);
if (derivedMessage != null) if (derivedMessage != null)
DBManager.Instance.Save(derivedMessage); DBManager.Instance.Save(derivedMessage);
} }
}
DBManager.Instance.Save(aMessageCore); // warum? DBManager.Instance.Save(aMessageCore); // warum?
} }
@ -406,6 +522,7 @@ namespace bsmd.herberg.FormService
{ {
List<Message> messages = DBManager.Instance.GetMessagesForCore(aMessageCore); List<Message> messages = DBManager.Instance.GetMessagesForCore(aMessageCore);
Dictionary<string, Message> result = new Dictionary<string, Message>(); Dictionary<string, Message> result = new Dictionary<string, Message>();
_log.InfoFormat("Core has {0} messages", messages.Count);
foreach (Message message in messages) foreach (Message message in messages)
{ {
if (!result.ContainsKey(message.MessageNotificationClass.ToString())) if (!result.ContainsKey(message.MessageNotificationClass.ToString()))

View File

@ -11,6 +11,8 @@
<AssemblyName>bsmd.herberg.FormService</AssemblyName> <AssemblyName>bsmd.herberg.FormService</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -139,10 +141,10 @@
<WebReferences Include="Web References\" /> <WebReferences Include="Web References\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<WebReferenceUrl Include="E:\work\bsmd\nsw\Herberg\WSAPIFormData.wsdl"> <WebReferenceUrl Include="C:\work\bsmd\nsw\Herberg\WSAPIFormData.wsdl">
<UrlBehavior>Dynamic</UrlBehavior> <UrlBehavior>Dynamic</UrlBehavior>
<RelPath>Web References\WebReference\</RelPath> <RelPath>Web References\WebReference\</RelPath>
<UpdateFromURL>E:\work\bsmd\nsw\Herberg\WSAPIFormData.wsdl</UpdateFromURL> <UpdateFromURL>C:\work\bsmd\nsw\Herberg\WSAPIFormData.wsdl</UpdateFromURL>
<ServiceLocationURL> <ServiceLocationURL>
</ServiceLocationURL> </ServiceLocationURL>
<CachedDynamicPropName> <CachedDynamicPropName>
@ -160,6 +162,7 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- 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.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">