fehlende Dateien POService eingecheckt
This commit is contained in:
parent
f800543b6a
commit
5501e50c4b
30
nsw/Source/bsmd.POService/App.config
Normal file
30
nsw/Source/bsmd.POService/App.config
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="bsmd.POService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<applicationSettings>
|
||||
<bsmd.POService.Properties.Settings>
|
||||
<setting name="ConnectionString" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="SleepSeconds" serializeAs="String">
|
||||
<value>30</value>
|
||||
</setting>
|
||||
<setting name="ValidSender" serializeAs="Xml">
|
||||
<value>
|
||||
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<string>guettner@bsmd.de</string>
|
||||
<string>hsok@gmx.de</string>
|
||||
</ArrayOfString>
|
||||
</value>
|
||||
</setting>
|
||||
</bsmd.POService.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
37
nsw/Source/bsmd.POService/POService.Designer.cs
generated
Normal file
37
nsw/Source/bsmd.POService/POService.Designer.cs
generated
Normal file
@ -0,0 +1,37 @@
|
||||
namespace bsmd.POService
|
||||
{
|
||||
partial class POService
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.ServiceName = "Service1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
227
nsw/Source/bsmd.POService/POService.cs
Normal file
227
nsw/Source/bsmd.POService/POService.cs
Normal file
@ -0,0 +1,227 @@
|
||||
// Copyright (c) 2020-present schick Informatik
|
||||
// Description:
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using bsmd.email;
|
||||
using bsmd.database;
|
||||
using log4net;
|
||||
|
||||
namespace bsmd.POService
|
||||
{
|
||||
public partial class POService : ServiceBase
|
||||
{
|
||||
|
||||
#region Fields
|
||||
|
||||
private Timer _timer;
|
||||
private readonly ILog _log = LogManager.GetLogger(typeof(POService));
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construction
|
||||
|
||||
public POService()
|
||||
{
|
||||
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start/Stop Service
|
||||
|
||||
protected override void OnStart(string[] args)
|
||||
{
|
||||
this.EventLog.Source = this.ServiceName;
|
||||
this.EventLog.Log = "Application";
|
||||
this.Init();
|
||||
this.EventLog.WriteEntry("NSW PO Number Service started.", EventLogEntryType.Information);
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
string version = fvi.FileVersion;
|
||||
_log.InfoFormat("Starting PO Number Service. v.{0} -------------- ", version);
|
||||
this.DoOnce();
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
{
|
||||
this._log.Info("Stopping PO Number Service");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region helper
|
||||
|
||||
private void Init()
|
||||
{
|
||||
this._timer = new Timer
|
||||
{
|
||||
Interval = Properties.Settings.Default.SleepSeconds * 1000
|
||||
};
|
||||
this._timer.Elapsed += _timer_Elapsed;
|
||||
this._timer.Enabled = true;
|
||||
}
|
||||
|
||||
internal void DoOnce()
|
||||
{
|
||||
this._timer_Elapsed(null, null);
|
||||
}
|
||||
|
||||
internal static bool ParsePO(string inputValue)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// Betreffzeile parsen. Ein Beispiel:
|
||||
// "WG: PO:8204730095 DEWVNTM-ADELINA D-005E-310120";
|
||||
// Hier kann man designen: https://regex101.com/
|
||||
const string poPattern = @"PO:(\d+) ([A-Z]+)-(.*?)-(.*?)-(\d{6})";
|
||||
Regex poRegex = new Regex(poPattern);
|
||||
Match aMatch = poRegex.Match(inputValue);
|
||||
if (aMatch.Success)
|
||||
{
|
||||
string poNummer = aMatch.Groups[1].Captures[0].Value;
|
||||
string hafen = aMatch.Groups[2].Captures[0].Value;
|
||||
string name = aMatch.Groups[3].Captures[0].Value;
|
||||
string irgendwas = aMatch.Groups[4].Captures[0].Value;
|
||||
string datumString = aMatch.Groups[5].Captures[0].Value;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void _timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
|
||||
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
string messageId = "";
|
||||
string attachmentLocalPath = null;
|
||||
string mailSender = "";
|
||||
const string receiptSubject = "PO number service INFO";
|
||||
string mailSubject = "";
|
||||
string body = "";
|
||||
|
||||
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
|
||||
{
|
||||
if (bsmdPopClient.IsConnected)
|
||||
{
|
||||
// check and download next e-Mail, saving attachment
|
||||
while (bsmdPopClient.ReceiveSingleMailText(out messageId, out mailSender, out mailSubject, out body))
|
||||
{
|
||||
|
||||
bool readResult = false;
|
||||
string readMessage = "";
|
||||
string receiptText = "";
|
||||
MessageCore messageCore = null;
|
||||
|
||||
if (attachmentLocalPath == null)
|
||||
{
|
||||
receiptText = "incoming E-Mail did not contain an Excel attachment!";
|
||||
_log.WarnFormat(receiptText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// only a valid sender gets a reply
|
||||
bool isValidSender = false;
|
||||
foreach (string aValidSender in Properties.Settings.Default.ValidSender)
|
||||
{
|
||||
if (mailSender.Equals(aValidSender, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
isValidSender = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidSender)
|
||||
{
|
||||
receiptText = string.Format("ignored e - mail from illegal sender: {0}", mailSender);
|
||||
_log.Warn(receiptText);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if(!ParsePO(mailSubject))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// aus (ungefährem) Datum, Name und Hafen den MessageCore suchen
|
||||
|
||||
|
||||
// PO-Nummer und Schiffs/Anlaufklassifizierung eintragen
|
||||
|
||||
|
||||
}
|
||||
catch (Exception someException)
|
||||
{
|
||||
receiptText = string.Format("Error processing po mail: {0}", someException.Message);
|
||||
_log.Error(receiptText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (receiptText.Length > 0)
|
||||
{
|
||||
_log.Debug("sending system info email");
|
||||
BSMDMail.SendSystemInfo(receiptSubject, receiptText, mailSender);
|
||||
}
|
||||
|
||||
// remove e-Mail
|
||||
_log.InfoFormat("deleting mail with messageId {0}", messageId);
|
||||
_log.InfoFormat("mail delete {0}", bsmdPopClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Phase II - Excel Sheets auf Anforderung erzeugen
|
||||
|
||||
List<MessageCore> excelMessageCoreList = DBManager.Instance.GetMessageCoresForExcelCreate();
|
||||
if (excelMessageCoreList.Count > 0)
|
||||
_log.InfoFormat("{0} excel sheets to create from database", excelMessageCoreList.Count);
|
||||
foreach (MessageCore excelCore in excelMessageCoreList)
|
||||
{
|
||||
// load messages
|
||||
List<Message> messages = DBManager.Instance.GetMessagesForCore(excelCore, DBManager.MessageLoad.ALL);
|
||||
|
||||
// template
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
DBManager.Instance.Disconnect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorFormat("Exception occurred: {0}", ex.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Error("DB Connection failure");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
31
nsw/Source/bsmd.POService/Program.cs
Normal file
31
nsw/Source/bsmd.POService/Program.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2020-present schick Informatik
|
||||
// Description:
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bsmd.POService
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
public static void Main()
|
||||
{
|
||||
ServiceBase[] ServicesToRun;
|
||||
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
ServicesToRun = new ServiceBase[]
|
||||
{
|
||||
new POService()
|
||||
};
|
||||
ServiceBase.Run(ServicesToRun);
|
||||
}
|
||||
}
|
||||
}
|
||||
94
nsw/Source/bsmd.POService/bsmd.POService.csproj
Normal file
94
nsw/Source/bsmd.POService/bsmd.POService.csproj
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7DCDEEB1-8192-4F82-8549-768F80776F04}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>bsmd.POService</RootNamespace>
|
||||
<AssemblyName>bsmd.POService</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>false</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<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>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\bsmd.database\Properties\AssemblyProductInfo.cs">
|
||||
<Link>Properties\AssemblyProductInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bsmd.database\Properties\AssemblyProjectInfo.cs">
|
||||
<Link>Properties\AssemblyProjectInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\bsmd.database\Properties\AssemblyProjectKeyInfo.cs">
|
||||
<Link>Properties\AssemblyProjectKeyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="POService.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POService.Designer.cs">
|
||||
<DependentUpon>POService.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="bsmd.database.licenseheader" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
|
||||
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
|
||||
<Name>bsmd.database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\bsmd.email\bsmd.email.csproj">
|
||||
<Project>{4b48a8ad-926d-4e0c-beb3-59e040928137}</Project>
|
||||
<Name>bsmd.email</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
37
nsw/Source/bsmd.POService/bsmd.POService.sln
Normal file
37
nsw/Source/bsmd.POService/bsmd.POService.sln
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29806.167
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.POService", "bsmd.POService.csproj", "{7DCDEEB1-8192-4F82-8549-768F80776F04}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "..\bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.email", "..\bsmd.email\bsmd.email.csproj", "{4B48A8AD-926D-4E0C-BEB3-59E040928137}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7DCDEEB1-8192-4F82-8549-768F80776F04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7DCDEEB1-8192-4F82-8549-768F80776F04}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7DCDEEB1-8192-4F82-8549-768F80776F04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7DCDEEB1-8192-4F82-8549-768F80776F04}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4B48A8AD-926D-4E0C-BEB3-59E040928137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B48A8AD-926D-4E0C-BEB3-59E040928137}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B48A8AD-926D-4E0C-BEB3-59E040928137}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B48A8AD-926D-4E0C-BEB3-59E040928137}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {FDDA69A2-BC62-40A3-891C-030FFB120992}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Loading…
Reference in New Issue
Block a user