diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index d12f3c20..af25a339 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.POService/Properties/Settings.Designer.cs b/nsw/Source/bsmd.POService/Properties/Settings.Designer.cs new file mode 100644 index 00000000..50674e92 --- /dev/null +++ b/nsw/Source/bsmd.POService/Properties/Settings.Designer.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace bsmd.POService.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.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"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("30")] + public int SleepSeconds { + get { + return ((int)(this["SleepSeconds"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n guettner@bsmd.de\r\n hsok@gmx.de\r\n")] + public global::System.Collections.Specialized.StringCollection ValidSender { + get { + return ((global::System.Collections.Specialized.StringCollection)(this["ValidSender"])); + } + } + } +} diff --git a/nsw/Source/bsmd.POService/Properties/Settings.settings b/nsw/Source/bsmd.POService/Properties/Settings.settings new file mode 100644 index 00000000..e522985c --- /dev/null +++ b/nsw/Source/bsmd.POService/Properties/Settings.settings @@ -0,0 +1,19 @@ + + + + + + + + + 30 + + + <?xml version="1.0" encoding="utf-16"?> +<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> + + + \ No newline at end of file diff --git a/nsw/Source/bsmd.POService/bsmd.database.licenseheader b/nsw/Source/bsmd.POService/bsmd.database.licenseheader new file mode 100644 index 00000000..09823f72 --- /dev/null +++ b/nsw/Source/bsmd.POService/bsmd.database.licenseheader @@ -0,0 +1,15 @@ +extensions: designer.cs generated.cs +extensions: .cs .cpp .h +// Copyright (c) 2015-present schick Informatik +// Description: + +extensions: .aspx .ascx +<%-- +Copyright (c) 2015-present schick Informatik +--%> +extensions: .vb +'Sample license text. +extensions: .xml .config .xsd + \ No newline at end of file diff --git a/nsw/Source/bsmd.POService/packages.config b/nsw/Source/bsmd.POService/packages.config new file mode 100644 index 00000000..6059782b --- /dev/null +++ b/nsw/Source/bsmd.POService/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nsw/Source/bsmd.database/bsmd.database.licenseheader b/nsw/Source/bsmd.database/bsmd.database.licenseheader index d6f3d796..ef60f8ea 100644 --- a/nsw/Source/bsmd.database/bsmd.database.licenseheader +++ b/nsw/Source/bsmd.database/bsmd.database.licenseheader @@ -1,11 +1,11 @@ extensions: designer.cs generated.cs extensions: .cs .cpp .h -// Copyright (c) 2015-2017 schick Informatik +// Copyright (c) 2020-present schick Informatik // Description: extensions: .aspx .ascx <%-- -Copyright (c) 2015-present schick Informatik +Copyright (c) 2020-present schick Informatik --%> extensions: .vb 'Sample license text. diff --git a/nsw/Source/bsmd.email/BSMDPopClient.cs b/nsw/Source/bsmd.email/BSMDPopClient.cs index f20d7c3b..5702fc99 100644 --- a/nsw/Source/bsmd.email/BSMDPopClient.cs +++ b/nsw/Source/bsmd.email/BSMDPopClient.cs @@ -19,9 +19,8 @@ namespace bsmd.email { public class BSMDPopClient : IDisposable { - private Pop3Client pop3Client; - private bool _connected = false; - private ILog _log = LogManager.GetLogger(typeof(BSMDPopClient)); + private readonly Pop3Client pop3Client; + private readonly ILog _log = LogManager.GetLogger(typeof(BSMDPopClient)); private int currentMail = 1; public BSMDPopClient() @@ -34,7 +33,7 @@ namespace bsmd.email 60000, 60000, new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate)); this.pop3Client.Authenticate(Properties.Settings.Default.POP3User, Properties.Settings.Default.POP3Password); - this._connected = true; + this.IsConnected = true; } catch (Exception ex) { @@ -51,7 +50,40 @@ namespace bsmd.email return true; } - public bool IsConnected { get { return this._connected; } } + public bool IsConnected { get; } = false; + + public bool ReceiveSingleMailText(out string messageId, out string sender, out string subject, out string body) + { + messageId = null; + sender = null; + subject = null; + body = null; + + if (!IsConnected) return false; + int messageCount = this.pop3Client.GetMessageCount(); + + if (messageCount > (this.currentMail - 1)) + { + Message mailMessage = this.pop3Client.GetMessage(this.currentMail); + + if (mailMessage.Headers.Sender?.HasValidMailAddress == true) + sender = mailMessage.Headers.Sender.MailAddress.Address; + if ((sender == null) && (mailMessage.Headers.From?.HasValidMailAddress == true)) + sender = mailMessage.Headers.From.MailAddress.Address; + + MessagePart aPart = mailMessage.FindFirstPlainTextVersion(); + body = aPart?.GetBodyAsText(); + messageId = mailMessage.Headers.MessageId; + subject = mailMessage.Headers.Subject; + this.currentMail++; // advance message pointer + + return true; + } + else + { + return false; + } +} public bool ReceiveSingleMail(out string attachmentLocalFile, out string messageId, out string sender, out string subject) { @@ -60,16 +92,16 @@ namespace bsmd.email sender = null; subject = null; - if (!_connected) return false; + if (!IsConnected) return false; int messageCount = this.pop3Client.GetMessageCount(); if (messageCount > (this.currentMail - 1)) { Message mailMessage = this.pop3Client.GetMessage(this.currentMail); - if ((mailMessage.Headers.Sender != null) && mailMessage.Headers.Sender.HasValidMailAddress) + if (mailMessage.Headers.Sender?.HasValidMailAddress == true) sender = mailMessage.Headers.Sender.MailAddress.Address; - if ((sender == null) && (mailMessage.Headers.From != null) && mailMessage.Headers.From.HasValidMailAddress) + if ((sender == null) && (mailMessage.Headers.From?.HasValidMailAddress == true)) sender = mailMessage.Headers.From.MailAddress.Address; messageId = mailMessage.Headers.MessageId; @@ -107,7 +139,7 @@ namespace bsmd.email /// true if successful public bool DeleteMessageByMessageId(string messageId) { - if (!_connected) return false; + if (!IsConnected) return false; // Get the number of messages on the POP3 server int messageCount = this.pop3Client.GetMessageCount();