NSW Service Suche implementiert, noch nicht getestet
This commit is contained in:
parent
75524ed6fb
commit
cf869eff57
Binary file not shown.
@ -26,11 +26,23 @@ namespace bsmd.nsw.service
|
||||
[DataMember]
|
||||
public string PoC;
|
||||
|
||||
[DataMember]
|
||||
public DateTime ETA;
|
||||
|
||||
[DataMember]
|
||||
public string IMO_ENI;
|
||||
|
||||
[DataMember]
|
||||
public STAT STAT { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public NOA_NOD NOA_NOD { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public INFO INFO { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public AGNT AGNT { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
nsw/Source/bsmd.nsw.service/Properties/Settings.Designer.cs
generated
Normal file
35
nsw/Source/bsmd.nsw.service/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace bsmd.nsw.service.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string ConnectionString {
|
||||
get {
|
||||
return ((string)(this["ConnectionString"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
nsw/Source/bsmd.nsw.service/Properties/Settings.settings
Normal file
9
nsw/Source/bsmd.nsw.service/Properties/Settings.settings
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="bsmd.nsw.service.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="ConnectionString" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -1,33 +1,82 @@
|
||||
using System;
|
||||
using bsmd.database;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Web;
|
||||
using System.Text;
|
||||
|
||||
namespace bsmd.nsw.service
|
||||
{
|
||||
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
|
||||
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
|
||||
public class Service1 : IService
|
||||
public class Service : IService
|
||||
{
|
||||
public string GetData(int value)
|
||||
{
|
||||
return string.Format("You entered: {0}", value);
|
||||
}
|
||||
|
||||
public CompositeType GetDataUsingDataContract(CompositeType composite)
|
||||
private readonly ILog _log = LogManager.GetLogger(typeof(Service));
|
||||
public NSWEntry[] GetData(string poc, DateTime? fromDate, DateTime? toDate)
|
||||
{
|
||||
if (composite == null)
|
||||
List<NSWEntry> entries = new List<NSWEntry>();
|
||||
|
||||
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
||||
{
|
||||
throw new ArgumentNullException("composite");
|
||||
// add search criteria
|
||||
if (!poc.IsNullOrEmpty())
|
||||
{
|
||||
Dictionary<MessageCore.SearchFilterType, string> filterDict = new Dictionary<MessageCore.SearchFilterType, string>();
|
||||
filterDict.Add(MessageCore.SearchFilterType.FILTER_PORT, poc);
|
||||
uint? from = null, to = null;
|
||||
if (fromDate.HasValue)
|
||||
{
|
||||
from = fromDate.Value.ToUniversalTime().ToUnixTimeStamp();
|
||||
}
|
||||
if(toDate.HasValue)
|
||||
{
|
||||
to = toDate.Value.ToUniversalTime().ToUnixTimeStamp();
|
||||
}
|
||||
if (from.HasValue || to.HasValue)
|
||||
filterDict.Add(MessageCore.SearchFilterType.FILTER_ETA, string.Format("{0}:{1}", from?.ToString() ?? "", to?.ToString() ?? ""));
|
||||
|
||||
int? resultLimit;
|
||||
int? expectedResultNum = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetNumCoresWithFilters(filterDict);
|
||||
if ((expectedResultNum ?? 0) > 100)
|
||||
resultLimit = 100;
|
||||
else
|
||||
resultLimit = expectedResultNum;
|
||||
|
||||
foreach(MessageCore core in DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict, resultLimit))
|
||||
{
|
||||
NSWEntry entry = new NSWEntry();
|
||||
if(core.ETA.HasValue)
|
||||
entry.ETA = core.ETA.Value;
|
||||
entry.IMO_ENI = core.IMOENIDisplay;
|
||||
entry.PoC = core.PoC;
|
||||
|
||||
foreach(Message message in DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessagesForCore(core, DBManager.MessageLoad.EXCEL))
|
||||
{
|
||||
if ((message.MessageNotificationClass == Message.NotificationClass.AGNT) && (message.Elements.Count > 0))
|
||||
entry.AGNT = message.Elements[0] as AGNT;
|
||||
if ((message.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && (message.Elements.Count > 0))
|
||||
entry.NOA_NOD = message.Elements[0] as NOA_NOD;
|
||||
if ((message.MessageNotificationClass == Message.NotificationClass.STAT) && (message.Elements.Count > 0))
|
||||
entry.STAT = message.Elements[0] as STAT;
|
||||
if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && (message.Elements.Count > 0))
|
||||
entry.INFO = message.Elements[0] as INFO;
|
||||
}
|
||||
|
||||
entries.Add(entry);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Warn("PoC data missing - ignoring search");
|
||||
}
|
||||
|
||||
DBManager.Instance.Disconnect();
|
||||
}
|
||||
if (composite.BoolValue)
|
||||
else
|
||||
{
|
||||
composite.StringValue += "Suffix";
|
||||
_log.Error("failed to connect to database");
|
||||
}
|
||||
return composite;
|
||||
return entries.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="bsmd.nsw.service.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
|
||||
</appSettings>
|
||||
@ -33,4 +38,11 @@
|
||||
<directoryBrowse enabled="true"/>
|
||||
</system.webServer>
|
||||
|
||||
<applicationSettings>
|
||||
<bsmd.nsw.service.Properties.Settings>
|
||||
<setting name="ConnectionString" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</bsmd.nsw.service.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
|
||||
@ -41,6 +41,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
@ -65,6 +68,11 @@
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service.svc.cs">
|
||||
<DependentUpon>Service.svc</DependentUpon>
|
||||
</Compile>
|
||||
@ -75,6 +83,11 @@
|
||||
<Folder Include="App_Data\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
|
||||
4
nsw/Source/bsmd.nsw.service/packages.config
Normal file
4
nsw/Source/bsmd.nsw.service/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.12" targetFramework="net452" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user