├── Geta.Documentation ├── css │ ├── help.css │ └── shThemeDefault.css ├── help.html ├── img │ ├── filter1.jpg │ └── main1.jpg └── js │ ├── shBrushXml.js │ └── shBrushCSharp.js ├── libs ├── Twitterizer2.dll ├── Newtonsoft.Json.dll ├── MSDN.HtmlEditorControl.dll └── System.ComponentModel.Composition.dll ├── Geta.Setup ├── Images │ └── MSI BG.png ├── packages.config ├── license.rtf ├── Readme.md ├── Properties │ └── AssemblyInfo.cs └── Setup.Designer.cs ├── Geta.Tests ├── Fixtures │ └── Bunny.png ├── config.xml ├── TestData.cs ├── Helpers │ ├── TestDeliveryAgentManager.cs │ ├── AgentTestBase.cs │ ├── FactoryTestBase.cs │ ├── FilterableHandler.cs │ ├── FilterTestBase.cs │ ├── EmailMessageHelper.cs │ └── HandlerTestBase.cs ├── Base │ ├── Agents │ │ ├── GenericDeliveryAgentTests.cs │ │ ├── GenericRoutingAgentTests.cs │ │ └── GenericSmtpReceiveAgentTests.cs │ └── Factories │ │ ├── GenericRoutingAgentFactoryTests.cs │ │ ├── GenericSmtpReceiveAgentFactoryTests.cs │ │ └── GenericDeliveryAgentFactoryTests.cs ├── packages.config ├── Plugins │ ├── DkimSigningHandlerTests.cs │ ├── TwitterNotificationHandlerTests.cs │ ├── Common │ │ ├── PluginHostTests.cs │ │ ├── Extensions │ │ │ └── StringExtensionsTest.cs │ │ └── EmailItemTests.cs │ ├── NoopHandlerTests.cs │ ├── ExtractAttachmentHandlerTests.cs │ ├── ExecutableHandlerTests.cs │ └── DisclaimerHandlerTests.cs ├── App.config ├── Common │ └── NInjectHelperTests.cs ├── Properties │ └── AssemblyInfo.cs └── ConfigTests.cs ├── Geta.GuiApplication ├── Resources │ └── Icon.ico ├── packages.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ └── Resources.Designer.cs ├── GenericConfigForm.cs ├── App.config ├── Impl │ ├── Extensions │ │ └── GenericFormExtensions.cs │ └── Models │ │ └── Entry.cs ├── Program.cs ├── Plugins │ ├── Mail2NewsConfigForm.cs │ ├── DisclaimerConfigForm.cs │ ├── TwitterNotificationConfigForm.cs │ ├── ExtractAttachmentConfigForm.cs │ ├── MailEndpointConfigForm.cs │ ├── ExecutableConfigForm.cs │ └── ExtractAttachmentConfigForm.designer.cs ├── AboutForm.cs └── app.manifest ├── Geta ├── IAgentConfig.cs ├── IOptions.cs ├── IAgentEventHandler.cs ├── Enums │ ├── ExitCodeEnum.cs │ ├── FilterKeyEnum.cs │ └── FilterOperatorEnum.cs ├── IViewOptions.cs ├── IFilterable.cs ├── IHandler.cs ├── IPluginHost.cs ├── Impl │ ├── Extensions │ │ ├── StringExtensions.cs │ │ ├── TransportAgentExtensions.cs │ │ ├── OldNetExtensions.cs │ │ ├── EmailMessageExtensions.cs │ │ ├── WebRequestExtensions.cs │ │ └── StreamExtensions.cs │ ├── HandlerBase.cs │ ├── LoggingBase.cs │ ├── Config │ │ ├── Agents │ │ │ ├── DeliveryAgentConfig.cs │ │ │ ├── RoutingAgentConfig.cs │ │ │ └── SmtpReceiveAgentConfig.cs │ │ └── TransportAgentConfig.cs │ ├── Factories │ │ ├── GenericRoutingAgentFactory.cs │ │ ├── GenericSmtpReceiveAgentFactory.cs │ │ └── GenericDeliveryAgentFactory.cs │ ├── NInjectHelper.cs │ ├── FilterableHandlerBase.cs │ ├── PluginHost.cs │ ├── Utils │ │ └── Win32.cs │ ├── AgentEventHandler.cs │ ├── Agents │ │ ├── GenericDeliveryAgent.cs │ │ └── GenericRoutingAgent.cs │ └── EmailItem.cs ├── IEmailItem.cs ├── Extensions │ └── Net35Extensions.cs ├── packages.config ├── App.config └── Properties │ └── AssemblyInfo.cs ├── Geta.Plugins.NoopHandler ├── INoopHandler.cs ├── packages.config ├── Impl │ └── NoopHandler.cs ├── Properties │ └── AssemblyInfo.cs └── Geta.Plugins.NoopHandler.csproj ├── Geta.Plugins.DisclaimerHandler ├── IDisclaimerHandler.cs ├── packages.config ├── Impl │ ├── RtfDocument.cs │ └── DisclaimerHandler.cs ├── Properties │ └── AssemblyInfo.cs └── Geta.Plugins.DisclaimerHandler.csproj ├── Geta.Plugins.ExecutableHandler ├── IExecutableHandler.cs ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── Geta.Plugins.ExecutableHandler.csproj ├── Geta.Plugins.Mail2NewsHandler ├── IMail2NewsHandler.cs ├── packages.config ├── Impl │ ├── Forms │ │ └── ConfigForm.cs │ └── Mail2NewsHandler.cs └── Properties │ └── AssemblyInfo.cs ├── Geta.Plugins.DkimSigningHandler ├── IDkimSigningHandler.cs ├── packages.config ├── Impl │ ├── DkimAlgorithmKind.cs │ └── DkimSigningHandler.cs ├── IDkimSigner.cs └── Properties │ └── AssemblyInfo.cs ├── Geta.Plugins.MailEndpointHandler ├── IMailEndpointHandler.cs ├── Impl │ ├── MailContent.cs │ ├── HttpMethod.cs │ └── Forms │ │ └── ConfigForm.cs ├── packages.config └── Properties │ └── AssemblyInfo.cs ├── Geta.Plugins.ExtractAttachmentHandler ├── IExtractAttachmentHandler.cs ├── packages.config ├── Impl │ ├── Forms │ │ └── ConfigForm.cs │ └── ExtractAttachmentHandler.cs ├── Properties │ └── AssemblyInfo.cs └── Geta.Plugins.ExtractAttachmentHandler.csproj ├── Geta.Plugins.TwitterNotificationHandler ├── ITwitterNotificationHandler.cs ├── packages.config ├── Properties │ └── AssemblyInfo.cs ├── Impl │ └── TwitterNotificationHandler.cs └── Geta.Plugins.TwitterNotificationHandler.csproj ├── Geta.ConsoleApplication ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── Geta.ConsoleApplication.csproj ├── Geta.sln.DotSettings ├── set-ci-versions.ps1 └── .gitignore /Geta.Documentation/css/help.css: -------------------------------------------------------------------------------- 1 | dt, .italic { 2 | font-style: italic; 3 | } 4 | -------------------------------------------------------------------------------- /libs/Twitterizer2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/libs/Twitterizer2.dll -------------------------------------------------------------------------------- /libs/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/libs/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Geta.Documentation/help.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.Documentation/help.html -------------------------------------------------------------------------------- /Geta.Setup/Images/MSI BG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.Setup/Images/MSI BG.png -------------------------------------------------------------------------------- /Geta.Tests/Fixtures/Bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.Tests/Fixtures/Bunny.png -------------------------------------------------------------------------------- /Geta.Tests/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /libs/MSDN.HtmlEditorControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/libs/MSDN.HtmlEditorControl.dll -------------------------------------------------------------------------------- /Geta.Documentation/img/filter1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.Documentation/img/filter1.jpg -------------------------------------------------------------------------------- /Geta.Documentation/img/main1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.Documentation/img/main1.jpg -------------------------------------------------------------------------------- /Geta.GuiApplication/Resources/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/Geta.GuiApplication/Resources/Icon.ico -------------------------------------------------------------------------------- /Geta/IAgentConfig.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 2 | { 3 | public interface IAgentConfig 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /libs/System.ComponentModel.Composition.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NeosIT/generic-exchange-transport-agent/HEAD/libs/System.ComponentModel.Composition.dll -------------------------------------------------------------------------------- /Geta/IOptions.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 2 | { 3 | public interface IOptions 4 | { 5 | void Load(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Geta/IAgentEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 2 | { 3 | public interface IAgentEventHandler : IFilterable, IHandler 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Geta.GuiApplication/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Geta.Plugins.NoopHandler/INoopHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler 2 | { 3 | public interface INoopHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta/Enums/ExitCodeEnum.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Enums 2 | { 3 | public enum ExitCodeEnum 4 | { 5 | CommandNotRun = -1, 6 | CommandTimedOut = -2, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Geta/IViewOptions.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 2 | { 3 | public interface IViewOptions : IOptions 4 | { 5 | void Save(); 6 | void ShowConfigDialog(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/IDisclaimerHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler 2 | { 3 | public interface IDisclaimerHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.ExecutableHandler/IExecutableHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler 2 | { 3 | public interface IExecutableHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.Mail2NewsHandler/IMail2NewsHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.Mail2NewsHandler 2 | { 3 | public interface IMail2NewsHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/IDkimSigningHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler 2 | { 3 | public interface IDkimSigningHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/IMailEndpointHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler 2 | { 3 | public interface IMailEndpointHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/IExtractAttachmentHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler 2 | { 3 | public interface IExtractAttachmentHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.NoopHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.TwitterNotificationHandler/ITwitterNotificationHandler.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler 2 | { 3 | public interface ITwitterNotificationHandler : IHandler, IFilterable 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Geta.Plugins.ExecutableHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/Impl/MailContent.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler.Impl 2 | { 3 | public enum MailContent 4 | { 5 | Mail, 6 | Body, 7 | Attachments, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.Mail2NewsHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.Plugins.TwitterNotificationHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Geta.GuiApplication/GenericConfigForm.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication 2 | { 3 | public interface IGenericConfigForm where T : IHandler 4 | { 5 | T Handler { get; } 6 | 7 | void Init(T handler); 8 | 9 | void Show(); 10 | } 11 | } -------------------------------------------------------------------------------- /Geta.Setup/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Geta/IFilterable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 4 | { 5 | public interface IFilterable 6 | { 7 | IList Filters { get; set; } 8 | bool AppliesTo(IEmailItem emailItem, int? lastExitCode = null); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Geta.Tests/TestData.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests 5 | { 6 | public static class TestData 7 | { 8 | public static string RootPath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Geta.GuiApplication/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Geta.Tests/Helpers/TestDeliveryAgentManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport.Delivery; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 4 | { 5 | public class TestDeliveryAgentManager : DeliveryAgentManager 6 | { 7 | public override string SupportedDeliveryProtocol => "local"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Geta/IHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 4 | { 5 | public interface IHandler 6 | { 7 | string Name { get; } 8 | IList Handlers { get; set; } 9 | void Execute(IEmailItem emailItem = null, int? lastExitCode = null); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/Impl/HttpMethod.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler.Impl 2 | { 3 | public enum HttpMethod 4 | { 5 | Get = 0, 6 | Post, 7 | Head, 8 | Put, 9 | Delete, 10 | Options, 11 | Trace, 12 | Connect, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Geta/IPluginHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 5 | { 6 | public interface IPluginHost : IDisposable 7 | { 8 | IEnumerable KnownTypes { get; } 9 | IEnumerable Handlers { get; set; } 10 | IEnumerable Filters { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Geta.Tests/Base/Agents/GenericDeliveryAgentTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Agents 6 | { 7 | [TestFixture] 8 | public class GenericDeliveryAgentTests : AgentTestBase 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Geta.Tests/Base/Agents/GenericRoutingAgentTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Agents 6 | { 7 | [TestFixture] 8 | public class GenericRoutingAgentTests : AgentTestBase 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Geta.Tests/Base/Agents/GenericSmtpReceiveAgentTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Agents 6 | { 7 | [TestFixture] 8 | public class GenericSmtpReceiveAgentTests : AgentTestBase 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Geta/Impl/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 4 | { 5 | public static class StringExtensions 6 | { 7 | public static bool Contains(this string source, string value, StringComparison comp) 8 | { 9 | if (string.IsNullOrEmpty(value)) 10 | return true; 11 | 12 | return source.IndexOf(value, comp) >= 0; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Geta.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Geta/Impl/Extensions/TransportAgentExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using JetBrains.Annotations; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 6 | { 7 | public static class TransportAgentExtensions 8 | { 9 | [Pure] 10 | public static string GetTranslatedNameOrDefault(this Type type) 11 | { 12 | return type.GetCustomAttribute()?.DisplayName ?? type.Name; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Geta/Impl/HandlerBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 5 | { 6 | [DataContract(Namespace = "")] 7 | public abstract class HandlerBase : LoggingBase, IHandler 8 | { 9 | [DataMember] 10 | public IList Handlers { get; set; } = new List(); 11 | 12 | public abstract string Name { get; } 13 | public abstract void Execute(IEmailItem emailItem = null, int? lastExitCode = null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/DkimSigningHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler.Impl; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 6 | { 7 | public class DkimSigningHandlerHandlerTests : HandlerTestBase 8 | { 9 | [SetUp] 10 | public void TestFixtureSetUp() 11 | { 12 | Name = "DkimSigningHandler"; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/TwitterNotificationHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler.Impl; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 6 | { 7 | [TestFixture] 8 | public class TwitterNotificationHandlerHandlerTests : HandlerTestBase 9 | { 10 | [SetUp] 11 | public void TestFixtureSetUp() 12 | { 13 | Name = "TwitterNotificationHandler"; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Geta/Impl/LoggingBase.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using Ninject; 3 | using Ninject.Extensions.Logging; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 6 | { 7 | [DataContract(Namespace = "")] 8 | public abstract class LoggingBase 9 | { 10 | public IKernel Kernel { get; set; } 11 | public ILogger Logger { get; set; } 12 | 13 | [OnDeserialized] 14 | private void OnDeserialized(StreamingContext c) 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/Impl/DkimAlgorithmKind.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler.Impl 2 | { 3 | /// 4 | /// Enumeration of the kinds of signature and hashing algorithms 5 | /// that can be used with DKIM. 6 | /// 7 | public enum DkimAlgorithmKind 8 | { 9 | /// 10 | /// The RSA SHA-1 hashing algorithm should be used. 11 | /// 12 | RsaSha1, 13 | 14 | /// 15 | /// The RSA SHA-2 (256) hashing algorithm should be used. 16 | /// 17 | RsaSha256 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Geta/IEmailItem.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Microsoft.Exchange.Data.Transport; 3 | using Microsoft.Exchange.Data.Transport.Email; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent 6 | { 7 | public interface IEmailItem 8 | { 9 | EmailMessage Message { get; } 10 | RoutingAddress FromAddress { get; } 11 | Stream MimeReadStream { get; } 12 | bool IsExported { get; } 13 | bool IsImported { get; } 14 | Stream GetMimeWriteStream(); 15 | object GetUnderlyingObject(); 16 | void Save(string filename); 17 | void Load(string filename); 18 | bool ShouldBeDeletedFromQueue { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Geta/Impl/Config/Agents/DeliveryAgentConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config.Agents 5 | { 6 | [DataContract(Name = "DeliveryAgent", Namespace = "")] 7 | public class DeliveryAgentConfig : IAgentConfig 8 | { 9 | [DataMember(Name = "OnCloseConnection")] 10 | public IList OnCloseConnection { get; set; } = new List(); 11 | 12 | [DataMember(Name = "OnDeliverMailItem")] 13 | public IList OnDeliverMailItem { get; set; } = new List(); 14 | 15 | [DataMember(Name = "OnOpenConnection")] 16 | public IList OnOpenConnection { get; set; } = new List(); 17 | } 18 | } -------------------------------------------------------------------------------- /Geta/Extensions/Net35Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using JetBrains.Annotations; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Extensions 7 | { 8 | public static class Net35Extensions 9 | { 10 | #if NET35 11 | public static T GetCustomAttribute([NotNull] this Assembly assembly) where T : Attribute 12 | { 13 | return (T) assembly.GetCustomAttributes(typeof(T), true).FirstOrDefault(x => x is T); 14 | } 15 | #endif 16 | 17 | public static bool IsNullOrWhiteSpace(this string str) 18 | { 19 | #if NET35 20 | return str == null || str.Trim() == ""; 21 | #else 22 | return string.IsNullOrWhiteSpace(str); 23 | #endif 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Geta.Setup/license.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}} 2 | {\*\generator Riched20 10.0.17134}\viewkind4\uc1 3 | \pard\sa200\sl276\slmult1\f0\fs22\lang7 Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod temporinvidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\par 4 | } 5 | -------------------------------------------------------------------------------- /Geta.ConsoleApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.ConsoleApplication 6 | { 7 | internal class Program 8 | { 9 | private static void Main(string[] args) 10 | { 11 | using (var fac = Configuration.PluginHost) 12 | { 13 | if (null != fac.Handlers) 14 | { 15 | foreach (var handler in fac.Handlers) 16 | { 17 | Console.WriteLine(handler.Name); 18 | } 19 | } 20 | 21 | Console.ReadLine(); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Geta.Tests/Helpers/AgentTestBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using NUnit.Framework; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 5 | { 6 | [TestFixture] 7 | public abstract class AgentTestBase where T : Agent, new() 8 | { 9 | protected T TestObject { get; set; } 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | TestObject = new T(); 15 | } 16 | 17 | [Test] 18 | public void AssertNotNull() 19 | { 20 | Assert.NotNull(TestObject); 21 | } 22 | 23 | [Test] 24 | public void AssertInstanceOf() 25 | { 26 | Assert.IsInstanceOf(TestObject); 27 | Assert.IsInstanceOf(TestObject); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta/Impl/Config/TransportAgentConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config.Agents; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config 5 | { 6 | [DataContract(Name = "GenericTransportAgent", Namespace = "")] 7 | public class TransportAgentConfig 8 | { 9 | [DataMember(Name = "DeliveryAgent")] 10 | public DeliveryAgentConfig DeliveryAgentConfig { get; set; } = new DeliveryAgentConfig(); 11 | 12 | [DataMember(Name = "RoutingAgent")] 13 | public RoutingAgentConfig RoutingAgentConfig { get; set; } = new RoutingAgentConfig(); 14 | 15 | [DataMember(Name = "SmtpReceiveAgent")] 16 | public SmtpReceiveAgentConfig SmtpReceiveAgentConfig { get; set; } = new SmtpReceiveAgentConfig(); 17 | } 18 | } -------------------------------------------------------------------------------- /Geta.Tests/Helpers/FactoryTestBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using NUnit.Framework; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 5 | { 6 | [TestFixture] 7 | public abstract class FactoryTestBase where T : AgentFactory, new() 8 | { 9 | protected T TestObject { get; set; } 10 | 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | TestObject = new T(); 15 | } 16 | 17 | [Test] 18 | public void AssertNotNull() 19 | { 20 | Assert.NotNull(TestObject); 21 | } 22 | 23 | [Test] 24 | public void AssertInstanceOf() 25 | { 26 | Assert.IsInstanceOf(TestObject); 27 | Assert.IsInstanceOf(TestObject); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta.Tests/Helpers/FilterableHandler.cs: -------------------------------------------------------------------------------- 1 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 4 | { 5 | public class FilterableHandler : FilterableHandlerBase 6 | { 7 | public override string Name => "FilterableHandler"; 8 | 9 | public override string ToString() 10 | { 11 | return Name; 12 | } 13 | 14 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 15 | { 16 | var exitCode = lastExitCode; 17 | 18 | if (null == Handlers || Handlers.Count <= 0) return; 19 | 20 | foreach (var handler in Handlers) 21 | { 22 | handler.Execute(emailItem, exitCode); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Geta/Enums/FilterKeyEnum.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Enums 2 | { 3 | /// 4 | /// Defines on what mail item attribute 5 | /// the filter should be applied 6 | /// 7 | public enum FilterKeyEnum 8 | { 9 | /// 10 | /// Apply filter on FromAddress 11 | /// 12 | From = 0, 13 | 14 | /// 15 | /// Apply filter on ToAddress / RecipientAddress 16 | /// 17 | To = 1, 18 | 19 | /// 20 | /// Apply filter on Subject 21 | /// 22 | Subject = 2, 23 | 24 | /// 25 | /// Apply filter on status code 26 | /// of parent handler 27 | /// 28 | LastExitCode = 3, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/Common/PluginHostTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NUnit.Framework; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins.Common 6 | { 7 | [TestFixture] 8 | public class PluginHostTests 9 | { 10 | [Test] 11 | public void LoadPlugins() 12 | { 13 | var pluginHost = new PluginHost(); 14 | 15 | Assert.NotNull(pluginHost); 16 | Assert.NotNull(pluginHost.KnownTypes); 17 | Assert.NotNull(pluginHost.Handlers); 18 | Assert.NotNull(pluginHost.Filters); 19 | 20 | Assert.AreEqual(10, pluginHost.KnownTypes.Count()); 21 | Assert.AreEqual(8, pluginHost.Handlers.Count()); 22 | Assert.AreEqual(2, pluginHost.Filters.Count()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Geta/Impl/Config/Agents/RoutingAgentConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config.Agents 5 | { 6 | [DataContract(Name = "RoutingAgent", Namespace = "")] 7 | public class RoutingAgentConfig : IAgentConfig 8 | { 9 | [DataMember(Name = "OnCategorizedMessage")] 10 | public IList OnCategorizedMessage { get; set; } = new List(); 11 | 12 | [DataMember(Name = "OnResolvedMessage")] 13 | public IList OnResolvedMessage { get; set; } = new List(); 14 | 15 | [DataMember(Name = "OnRoutedMessage")] 16 | public IList OnRoutedMessage { get; set; } = new List(); 17 | 18 | [DataMember(Name = "OnSubmittedMessage")] 19 | public IList OnSubmittedMessage { get; set; } = new List(); 20 | } 21 | } -------------------------------------------------------------------------------- /Geta/Impl/Extensions/OldNetExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using JetBrains.Annotations; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 7 | { 8 | /// 9 | /// Extension class to bring newer .NET functionality to old .NET 3.5 10 | /// 11 | public static class OldNetExtensions 12 | { 13 | [Pure, CanBeNull] 14 | public static T GetCustomAttribute([NotNull]this Type type, bool inherit = false) where T : Attribute 15 | { 16 | return type.GetCustomAttributes(inherit).FirstOrDefault(); 17 | } 18 | 19 | [Pure] 20 | public static IEnumerable GetCustomAttributes([NotNull]this Type type, bool inherit = false) where T : Attribute 21 | { 22 | return type.GetCustomAttributes(typeof(T), inherit).Cast(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Geta.Tests/Base/Factories/GenericRoutingAgentFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Routing; 3 | using NUnit.Framework; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Factories 9 | { 10 | [TestFixture] 11 | public class GenericRoutingAgentFactoryTests : FactoryTestBase 12 | { 13 | [Test] 14 | public void CreateAgentTest() 15 | { 16 | var agent = TestObject.CreateAgent(null); 17 | 18 | Assert.NotNull(agent); 19 | Assert.IsInstanceOf(agent); 20 | Assert.IsInstanceOf(agent); 21 | Assert.IsInstanceOf(agent); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Geta.Tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Geta.Tests/Base/Factories/GenericSmtpReceiveAgentFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Smtp; 3 | using NUnit.Framework; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Factories 9 | { 10 | [TestFixture] 11 | public class GenericSmtpReceiveAgentFactoryTests : FactoryTestBase 12 | { 13 | [Test] 14 | public void CreateAgentTest() 15 | { 16 | var agent = TestObject.CreateAgent(null); 17 | 18 | Assert.NotNull(agent); 19 | Assert.IsInstanceOf(agent); 20 | Assert.IsInstanceOf(agent); 21 | Assert.IsInstanceOf(agent); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Geta/Impl/Factories/GenericRoutingAgentFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Routing; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 4 | using Ninject; 5 | using Ninject.Extensions.Logging; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories 8 | { 9 | public class GenericRoutingAgentFactory : RoutingAgentFactory 10 | { 11 | public IKernel Kernel { get; internal set; } 12 | public ILogger Logger { get; internal set; } 13 | 14 | public GenericRoutingAgentFactory() 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | } 19 | 20 | public override RoutingAgent CreateAgent(SmtpServer server) 21 | { 22 | Logger.Debug("[GenericTransportAgent] RoutingAgentFactory - Creating new RoutingAgent..."); 23 | return new GenericRoutingAgent(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Geta.Tests/Base/Factories/GenericDeliveryAgentFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Delivery; 3 | using NUnit.Framework; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Base.Factories 9 | { 10 | [TestFixture] 11 | public class GenericDeliveryAgentFactoryTests : FactoryTestBase> 12 | { 13 | [Test] 14 | public void CreateAgentTest() 15 | { 16 | var agent = TestObject.CreateAgent(null); 17 | 18 | Assert.NotNull(agent); 19 | Assert.IsInstanceOf(agent); 20 | Assert.IsInstanceOf(agent); 21 | Assert.IsInstanceOf(agent); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Geta.Plugins.NoopHandler/Impl/NoopHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Runtime.Serialization; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler.Impl 7 | { 8 | [Export(typeof(IHandler))] 9 | [DataContract(Name = "NoopHandler", Namespace = "")] 10 | public class NoopHandler : FilterableHandlerBase, INoopHandler 11 | { 12 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 13 | { 14 | if (null == emailItem) return; 15 | if (null == Handlers || Handlers.Count <= 0) return; 16 | 17 | foreach (var handler in Handlers) 18 | { 19 | handler.Execute(emailItem, lastExitCode); 20 | } 21 | } 22 | 23 | public override string Name => "NoopHandler"; 24 | 25 | public override string ToString() 26 | { 27 | return Name; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta/Enums/FilterOperatorEnum.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Enums 2 | { 3 | /// 4 | /// Defines what kind of comparision on 5 | /// subfilter type / value should be applied 6 | /// 7 | public enum FilterOperatorEnum 8 | { 9 | /// 10 | /// Value should be equal 11 | /// 12 | Equals = 0, 13 | 14 | /// 15 | /// Value should not be equal 16 | /// 17 | NotEquals = 1, 18 | 19 | /// 20 | /// Value should start with 21 | /// 22 | StartsWith = 2, 23 | 24 | /// 25 | /// Value should end with 26 | /// 27 | EndsWith = 3, 28 | 29 | /// 30 | /// Value should contain 31 | /// 32 | Contains = 4, 33 | 34 | /// 35 | /// Value should match regex 36 | /// 37 | Regex = 5, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Geta/Impl/Factories/GenericSmtpReceiveAgentFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Smtp; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 4 | using Ninject; 5 | using Ninject.Extensions.Logging; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories 8 | { 9 | public class GenericSmtpReceiveAgentFactory : SmtpReceiveAgentFactory 10 | { 11 | public IKernel Kernel { get; internal set; } 12 | public ILogger Logger { get; internal set; } 13 | 14 | public GenericSmtpReceiveAgentFactory() 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | } 19 | 20 | public override SmtpReceiveAgent CreateAgent(SmtpServer server) 21 | { 22 | Logger.Debug("[GenericTransportAgent] SmtpReceiveAgentFactory - Creating new SmtpReceiveAgent..."); 23 | return new GenericSmtpReceiveAgent(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Geta.GuiApplication/Impl/Extensions/GenericFormExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Windows.Forms; 6 | using JetBrains.Annotations; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Impl.Extensions 9 | { 10 | public static class GenericFormExtensions 11 | { 12 | [CanBeNull, Pure] 13 | public static Type GetGenericForm(this IEnumerable assemblies, Type genericType) 14 | { 15 | // TODO warn when multiple fitting types 16 | return assemblies.SelectMany(x => x.GetTypes()).FirstOrDefault(x => 17 | typeof(Form).IsAssignableFrom(x) && x.GetInterfaces().Any(i => 18 | i.IsGenericType && 19 | i.GetGenericTypeDefinition() == typeof(IGenericConfigForm<>) && 20 | i.GetGenericArguments().Length == 1 && 21 | i.GetGenericArguments()[0] == genericType 22 | ) 23 | ); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Geta/Impl/Factories/GenericDeliveryAgentFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport; 2 | using Microsoft.Exchange.Data.Transport.Delivery; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents; 4 | using Ninject; 5 | using Ninject.Extensions.Logging; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Factories 8 | { 9 | public class GenericDeliveryAgentFactory : DeliveryAgentFactory where T : DeliveryAgentManager, new() 10 | { 11 | public IKernel Kernel { get; internal set; } 12 | public ILogger Logger { get; internal set; } 13 | 14 | public GenericDeliveryAgentFactory() 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | } 19 | 20 | public override DeliveryAgent CreateAgent(SmtpServer server) 21 | { 22 | Logger.Debug("[GenericTransportAgent] DeliveryAgentFactory - Creating new DeliveryAgent..."); 23 | return new GenericDeliveryAgent(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Geta.Plugins.Mail2NewsHandler/Impl/Forms/ConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.Mail2NewsHandler.Impl.Forms 5 | { 6 | public partial class ConfigForm : Form 7 | { 8 | private readonly Mail2NewsHandler _handler; 9 | 10 | public ConfigForm(Mail2NewsHandler handler) 11 | { 12 | _handler = handler; 13 | InitializeComponent(); 14 | } 15 | 16 | private void ButtonApplyClick(object sender, EventArgs e) 17 | { 18 | _handler.ToSmtpAddress = TextBoxToSmtpAddress.Text; 19 | _handler.HeaderKey = TextBoxHeaderKey.Text; 20 | Close(); 21 | } 22 | 23 | private void ButtonCancelClick(object sender, EventArgs e) 24 | { 25 | Close(); 26 | } 27 | 28 | private void ConfigFormLoad(object sender, EventArgs e) 29 | { 30 | TextBoxToSmtpAddress.Text = _handler.ToSmtpAddress; 31 | TextBoxHeaderKey.Text = _handler.HeaderKey; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Geta/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/IDkimSigner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler 5 | { 6 | /// 7 | /// An object that knows how to sign a MIME message according to the DKIM standard. 8 | /// 9 | public interface IDkimSigner : IDisposable 10 | { 11 | /// 12 | /// Returns a value indicating whether or not the unsigned MIME message in the 13 | /// given stream can be signed. 14 | /// 15 | /// The input stream. 16 | /// The output stream. 17 | bool CanSign(Stream inputStream); 18 | 19 | /// 20 | /// Writes a signed version of the unsigned MIME message in the input stream 21 | /// to the output stream. 22 | /// 23 | /// The input stream. 24 | /// The output stream. 25 | void Sign(Stream inputStream, Stream outputStream); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Geta/Impl/Extensions/EmailMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using Microsoft.Exchange.Data.Transport.Email; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 6 | { 7 | public static class EmailMessageExtensions 8 | { 9 | public static string GetBody(this EmailMessage message) 10 | { 11 | var charsetName = message.Body.CharsetName; 12 | 13 | using (var reader = new StreamReader(message.Body.GetContentReadStream(), Encoding.GetEncoding(charsetName))) 14 | { 15 | return reader.ReadToEnd(); 16 | } 17 | } 18 | 19 | public static void SetBody(this EmailMessage message, string bodyText) 20 | { 21 | var charsetName = message.Body.CharsetName; 22 | 23 | using (var writeStream = message.Body.GetContentWriteStream(charsetName)) 24 | { 25 | var buffer = Encoding.GetEncoding(charsetName).GetBytes(bodyText); 26 | writeStream.Write(buffer, 0, buffer.Length); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | <data><IncludeFilters /><ExcludeFilters /></data> 3 | <data /> 4 | True 5 | True 6 | True 7 | True 8 | True 9 | True 10 | 11 | -------------------------------------------------------------------------------- /Geta/Impl/NInjectHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | using log4net.Config; 4 | using Ninject; 5 | using Ninject.Extensions.Logging.Log4net; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 8 | { 9 | public class NInjectHelper 10 | { 11 | private static IKernel _kernel; 12 | 13 | public static IKernel GetKernel() 14 | { 15 | return _kernel ?? (_kernel = CreateKernel(Assembly.GetCallingAssembly())); 16 | } 17 | 18 | private static IKernel CreateKernel(Assembly assembly) 19 | { 20 | var settings = CreateSettings(); 21 | IKernel kernel = new StandardKernel(settings, new Log4NetModule()); 22 | 23 | string configFilename = $"{assembly.Location}.config"; 24 | var fileInfo = new FileInfo(configFilename); 25 | 26 | XmlConfigurator.ConfigureAndWatch(fileInfo); 27 | return kernel; 28 | } 29 | 30 | private static INinjectSettings CreateSettings() 31 | { 32 | var settings = new NinjectSettings {LoadExtensions = false}; 33 | return settings; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Windows.Forms; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication 8 | { 9 | public static class Program 10 | { 11 | /// 12 | /// Der Haupteinstiegspunkt für die Anwendung. 13 | /// 14 | [STAThread] 15 | public static void Main() 16 | { 17 | // enforce all referenced assemblies to be loaded 18 | foreach (var referencedAssembly in Assembly.GetAssembly(typeof(EntryForm)).GetReferencedAssemblies()) 19 | { 20 | AppDomain.CurrentDomain.Load(referencedAssembly); 21 | } 22 | var pluginHost = new PluginHost(); 23 | pluginHost.Init("."); 24 | Configuration.HotReloadEnabled = false; 25 | 26 | Application.EnableVisualStyles(); 27 | Application.SetCompatibleTextRenderingDefault(false); 28 | Application.Run(new MainForm()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Geta.Tests/Common/NInjectHelperTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NUnit.Framework; 4 | using Ninject; 5 | using Ninject.Extensions.Logging.Log4net; 6 | using Ninject.Modules; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Common 9 | { 10 | [TestFixture] 11 | public class NInjectHelperTests 12 | { 13 | [Test] 14 | public void AssertSetUp() 15 | { 16 | var kernel = NInjectHelper.GetKernel(); 17 | Assert.NotNull(kernel); 18 | Assert.IsInstanceOf(kernel); 19 | Assert.IsInstanceOf(kernel); 20 | 21 | var modules = kernel.GetModules(); 22 | Assert.NotNull(modules); 23 | 24 | var modulesList = modules.ToList(); 25 | Assert.IsTrue(modulesList.Any()); 26 | 27 | var log4NetModule = modulesList.SingleOrDefault(x => x.GetType() == typeof(Log4NetModule)); 28 | Assert.NotNull(log4NetModule); 29 | Assert.IsInstanceOf(log4NetModule); 30 | Assert.IsInstanceOf(log4NetModule); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/Mail2NewsConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.Mail2NewsHandler.Impl; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 6 | { 7 | public partial class Mail2NewsConfigForm : Form, IGenericConfigForm 8 | { 9 | public Mail2NewsHandler Handler { get; private set; } 10 | 11 | public void Init(Mail2NewsHandler handler) 12 | { 13 | Handler = handler; 14 | } 15 | 16 | public Mail2NewsConfigForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void ButtonSaveClick(object sender, EventArgs e) 22 | { 23 | Handler.ToSmtpAddress = TextBoxToSmtpAddress.Text; 24 | Handler.HeaderKey = TextBoxHeaderKey.Text; 25 | Close(); 26 | } 27 | 28 | private void ButtonCancelClick(object sender, EventArgs e) 29 | { 30 | Close(); 31 | } 32 | 33 | private void ConfigFormLoad(object sender, EventArgs e) 34 | { 35 | TextBoxToSmtpAddress.Text = Handler.ToSmtpAddress; 36 | TextBoxHeaderKey.Text = Handler.HeaderKey; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Geta.Setup/Readme.md: -------------------------------------------------------------------------------- 1 | # GETA Installer 2 | 3 | This project creates an installer for the GUI application and all dependencies (GETA itself). In order to run the installer you must meet the following requirements: 4 | 5 | * Exchange Server installed (or `ExchangeInstallPath` systemwide environment variable set) 6 | * **Windows 7** / **Windows Server 2008 R2** or newer 7 | * **64 bit** OS. 8 | 9 | ## Requirements 10 | 11 | * MSBuild 15.0 (Included in VS 2017) 12 | 13 | ## Build the msi 14 | 15 | The .msi installer file is build directly after building the `Geta.Setup.csproj`. This takes longer than a usual project so do it only when needed. 16 | 17 | ```ps 18 | # in Geta.Setup/ 19 | # path to msbuild may vary 20 | & "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" Geta.Setup.csproj /restore /target:Compile /maxcpucount /verbosity:minimal 21 | ``` 22 | 23 | In order to create a localized version of the setup you must set your powershell culture to the desired culture before running the build process. 24 | 25 | ```ps1$ 26 | $cultureInfo = [System.Globalization.CultureInfo]::GetCultureInfo($culture) 27 | $currentThread = [System.Threading.Thread]::CurrentThread 28 | $currentThread.CurrentCulture = $cultureInfo 29 | $currentThread.CurrentUICulture = $cultureInfo 30 | ``` -------------------------------------------------------------------------------- /Geta.Tests/Helpers/FilterTestBase.cs: -------------------------------------------------------------------------------- 1 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 2 | using NUnit.Framework; 3 | using Ninject; 4 | using Ninject.Extensions.Logging; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 7 | { 8 | [TestFixture] 9 | public abstract class FilterTestBase where T : IFilterable, new() 10 | { 11 | protected T TestObject { get; set; } 12 | 13 | [SetUp] 14 | public void SetUp() 15 | { 16 | TestObject = new T(); 17 | } 18 | 19 | protected void PrepareLogger() 20 | { 21 | PrepareLogger(TestObject); 22 | } 23 | 24 | protected void PrepareLogger(object testObject) 25 | { 26 | if (testObject is LoggingBase loggingBase) 27 | { 28 | loggingBase.Kernel = NInjectHelper.GetKernel(); 29 | loggingBase.Logger = loggingBase.Kernel.Get().GetLogger(typeof(T)); 30 | } 31 | 32 | if (!(testObject is IFilterable ifilterable)) return; 33 | if (null == ifilterable.Filters || ifilterable.Filters.Count <= 0) return; 34 | 35 | foreach (var filter in ifilterable.Filters) 36 | { 37 | PrepareLogger(filter); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Geta/Impl/FilterableHandlerBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Runtime.Serialization; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 6 | { 7 | [DataContract(Namespace = "")] 8 | public abstract class FilterableHandlerBase : HandlerBase, IFilterable 9 | { 10 | [DataMember] 11 | public virtual IList Filters { get; set; } = new List(); 12 | 13 | public virtual bool AppliesTo(IEmailItem emailItem, int? lastExitCode = null) 14 | { 15 | if (null == emailItem) 16 | { 17 | Logger.Fatal("[GenericTransportAgent] FilterableHandlerBase - No MailItem available..."); 18 | return false; 19 | } 20 | 21 | if (null == Filters || 0 == Filters.Count) 22 | { 23 | Logger.Debug("[GenericTransportAgent] [MessageID {0}] FilterableHandlerBase - No filters defined, applying...", emailItem.Message.MessageId); 24 | return true; 25 | } 26 | 27 | Logger.Info("[GenericTransportAgent] [MessageID {0}] FilterableHandlerBase - Applying filters...", emailItem.Message.MessageId); 28 | return Filters.Aggregate(false, (current, filter) => current || filter.AppliesTo(emailItem, lastExitCode)); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /set-ci-versions.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Position = 0, Mandatory = $true)][String]$BuildNumber, 3 | [Parameter(Position = 1, Mandatory = $true)][String]$Revision 4 | ) 5 | 6 | $assemblyInfos = Get-ChildItem -Filter "AssemblyInfo.cs" -Recurse | ForEach-Object {$_.FullName} 7 | 8 | $fileVersionRegex = [System.Text.RegularExpressions.Regex]::new('^\[assembly: AssemblyFileVersion\("(\d+)"\)\]$') 9 | $informationalVersionRegex = [System.Text.RegularExpressions.Regex]::new('^\[assembly: AssemblyInformationalVersion\("(\d\w+)"\)\]$') 10 | 11 | foreach ($file in $assemblyInfos) { 12 | $lines = Get-Content -Encoding UTF8 $file 13 | $outLines = @() 14 | 15 | foreach ($line in $lines) { 16 | # check for AssemblyFileVersion attribute 17 | $fileVersionMatch = $fileVersionRegex.Match($line) 18 | if ($fileVersionMatch.Success) { 19 | $outLines += "[assembly: AssemblyFileVersion(""$BuildNumber"")]" 20 | } else { 21 | # check for AssemblyInformationalVersion attribute only if it's not already a AssemblyFileVersion 22 | $informationalVersionMatch = $informationalVersionRegex.Match($line) 23 | if($informationalVersionMatch.Success){ 24 | $outLines += "[assembly: AssemblyInformationalVersion(""$Revision"")]" 25 | } else { 26 | $outLines += $line 27 | } 28 | } 29 | } 30 | $txt = $outLines | Out-String 31 | Set-Content -Encoding UTF8 -Path $file -Value $txt 32 | } 33 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/NoopHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 2 | using NUnit.Framework; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler.Impl; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 7 | { 8 | [TestFixture] 9 | public class NoopHandlerHandlerTests : HandlerTestBase 10 | { 11 | [SetUp] 12 | public void TestFixtureSetUp() 13 | { 14 | Name = "NoopHandler"; 15 | } 16 | 17 | [Test] 18 | public void AppliesToTest() 19 | { 20 | var emailMessage = EmailMessageHelper.CreateHtmlEmailMessage("NoopHandlerAppliesToTest Subject", 21 | "NoopHandlerAppliesToTest Body"); 22 | 23 | PrepareLogger(); 24 | Assert.IsTrue(TestObject.AppliesTo(new EmailItem(emailMessage))); 25 | } 26 | 27 | [Test] 28 | public void ExecuteTest() 29 | { 30 | var emailMessage = EmailMessageHelper.CreateHtmlEmailMessage("NoopHandlerExecuteTest Subject", 31 | "NoopHandlerExecuteTest Body"); 32 | 33 | PrepareLogger(); 34 | TestObject.Execute(new EmailItem(emailMessage)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Geta.Setup/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Geta.Setup")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Geta.Setup")] 12 | [assembly: AssemblyCopyright("Copyright © 2019")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("8B4ACE24-D2F2-4DF8-BE01-28AF9A714910")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Tests/Helpers/EmailMessageHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Microsoft.Exchange.Data.Transport.Email; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 5 | { 6 | public static class EmailMessageHelper 7 | { 8 | public static EmailMessage CreateHtmlEmailMessage(string subject, string body) 9 | { 10 | return FillEmailMessage(EmailMessage.Create(BodyFormat.Html), subject, body); 11 | } 12 | 13 | public static EmailMessage CreateRtfEmailMessage(string subject, string body) 14 | { 15 | return FillEmailMessage(EmailMessage.Create(BodyFormat.Rtf), subject, body); 16 | } 17 | 18 | public static EmailMessage CreateTextEmailMessage(string subject, string body) 19 | { 20 | return FillEmailMessage(EmailMessage.Create(BodyFormat.Text), subject, body); 21 | } 22 | 23 | private static EmailMessage FillEmailMessage(EmailMessage emailMessage, string subject, string body) 24 | { 25 | emailMessage.From = new EmailRecipient("Alice", "alice@neos-it.de"); 26 | emailMessage.To.Add(new EmailRecipient("Bob", "bob@neos-it.de")); 27 | emailMessage.Subject = subject; 28 | 29 | using (var stream = emailMessage.Body.GetContentWriteStream()) 30 | { 31 | using (var sw = new StreamWriter(stream)) 32 | { 33 | sw.Write(body); 34 | } 35 | } 36 | 37 | return emailMessage; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Impl/Models/Entry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Impl.Models 5 | { 6 | /// 7 | /// Holds require data for all interactions in the GUI. 8 | /// Creates a shallow copy of the handler. It is not reference equal! 9 | /// 10 | public class Entry 11 | { 12 | public IAgentConfig AgentConfig { get; } 13 | public string EventName { get; } 14 | public IHandler Handler { get; } 15 | 16 | public Entry(IAgentConfig agentConfig, string eventName, IHandler handler) 17 | { 18 | AgentConfig = agentConfig; 19 | EventName = eventName; 20 | 21 | // don't use handler directly - use shallow copy instead to check whether it changed after editing in GUI 22 | var handlerType = handler.GetType(); 23 | Handler = (IHandler) Activator.CreateInstance(handlerType); 24 | var props = handlerType.GetProperties().Where(x => x.CanWrite); 25 | foreach (var propertyInfo in props) 26 | { 27 | var parameters = propertyInfo.GetValue(handler, new object[0]); 28 | propertyInfo.SetValue(Handler, parameters, new object[0]); 29 | } 30 | } 31 | 32 | public string EventNameFormatted => FormatEventName(EventName, AgentConfig.GetType().Name); 33 | 34 | public static string FormatEventName(string eventName, string agentName) 35 | { 36 | return $"{eventName} ({agentName})"; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/Impl/RtfDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler.Impl 4 | { 5 | public class RtfDocument 6 | { 7 | public string Content { get; internal set; } 8 | 9 | public RtfDocument(string rtfContent) 10 | { 11 | Content = rtfContent; 12 | } 13 | 14 | public bool Merge(RtfDocument mergeDoc) 15 | { 16 | try 17 | { 18 | var mergeFirst = mergeDoc.Content.IndexOf(@"\par", StringComparison.Ordinal); 19 | var mergeLast = mergeDoc.Content.LastIndexOf(@"\par", StringComparison.Ordinal) - 1; 20 | 21 | if ((mergeFirst < 0) || (mergeLast < 0)) 22 | { 23 | return false; 24 | } 25 | 26 | var docFirst = Content.LastIndexOf(@"}", StringComparison.Ordinal); 27 | 28 | if (docFirst < 0) 29 | { 30 | return false; 31 | } 32 | 33 | string migCont = mergeDoc.Content.Substring(mergeFirst, mergeLast - mergeFirst + 1); 34 | 35 | if (migCont.StartsWith(@"\pard", StringComparison.Ordinal)) 36 | { 37 | migCont = @"\par\par" + migCont.Remove(0, 5); 38 | } 39 | 40 | Content = Content.Insert(docFirst, migCont); 41 | 42 | return true; 43 | } 44 | catch (Exception) 45 | { 46 | return false; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Geta/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Geta/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("337e26bd-51cf-4570-8ffa-ac6865c24a91")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Tests")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("7f90e0a6-1054-4508-b478-66f61f1a0ac7")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.GuiApplication")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("1d1d407d-9875-4422-97e7-d9f082e275c9")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.ConsoleApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.ConsoleApplication")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.ConsoleApplication")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("971a8c27-1a7b-4e25-8fdc-b10d4e99906c")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Plugins.NoopHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Plugins.NoopHandler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("bbe83e18-b808-4dc4-b1ae-e298dcfa8d48")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Plugins.Mail2NewsHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Plugins.Mail2NewsHandler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.Mail2NewsHandler")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("18161731-42a7-4221-9011-d829348256e3")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Plugins.MailEndpointHandler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("f266a4fe-93f5-42f3-9264-5f64132ff146")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/Impl/Forms/ConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler.Impl.Forms 7 | { 8 | public partial class ConfigForm : Form 9 | { 10 | private readonly ExtractAttachmentHandler _handler; 11 | 12 | public ConfigForm(ExtractAttachmentHandler handler) 13 | { 14 | _handler = handler; 15 | InitializeComponent(); 16 | } 17 | 18 | private void ApplyButtonClick(object sender, EventArgs e) 19 | { 20 | var list = (BindingList) SettingsDataGridView.DataSource; 21 | _handler.Settings = list.ToDictionary(x => x.Key, x => x.Value); 22 | Close(); 23 | } 24 | 25 | private void CancelDialogButtonClick(object sender, EventArgs e) 26 | { 27 | Close(); 28 | } 29 | 30 | private void ConfigFormLoad(object sender, EventArgs e) 31 | { 32 | var list = new BindingList { AllowEdit = true, AllowNew = true, AllowRemove = true, RaiseListChangedEvents = true, }; 33 | 34 | foreach (var kvp in _handler.Settings) 35 | { 36 | list.Add(new Setting { Key = kvp.Key, Value = kvp.Value, }); 37 | } 38 | 39 | SettingsDataGridView.DataSource = list; 40 | } 41 | 42 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 43 | { 44 | if (Keys.Escape == keyData) 45 | { 46 | Close(); 47 | } 48 | 49 | return base.ProcessCmdKey(ref msg, keyData); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Plugins.ExtractAttachmentHandler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("c2af833e-9ccc-4dc0-9cc0-83b14437398a")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.Plugins.TwitterNotificationHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Allgemeine Informationen über eine Assembly werden über die folgenden 5 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 6 | // die mit einer Assembly verknüpft sind. 7 | [assembly: AssemblyTitle("Geta.Plugins.TwitterNotificationHandler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Microsoft")] 11 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler")] 12 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 17 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 18 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 19 | [assembly: ComVisible(false)] 20 | 21 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 22 | [assembly: Guid("046d84ed-f00d-4b30-8798-79312b32b3a3")] 23 | 24 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 25 | // 26 | // Hauptversion 27 | // Nebenversion 28 | // Buildnummer 29 | // Revision 30 | // 31 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 32 | // übernehmen, indem Sie "*" eingeben: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("0")] 36 | [assembly: AssemblyInformationalVersion("automated")] 37 | 38 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/DisclaimerConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler.Impl; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 6 | { 7 | public partial class DisclaimerConfigForm : Form, IGenericConfigForm 8 | { 9 | public DisclaimerHandler Handler { get; private set; } 10 | 11 | public void Init(DisclaimerHandler handler) 12 | { 13 | Handler = handler; 14 | } 15 | 16 | public DisclaimerConfigForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void ConfigFormLoad(object sender, EventArgs e) 22 | { 23 | DisclaimerTextTextBox.Text = Handler.Text ?? string.Empty; 24 | //DisclaimerRtfRichTextEditor.Rtf = _handler.Rtf ?? string.Empty; 25 | DisclaimerHtmlHtmlEditor.BodyHtml = Handler.Html ?? string.Empty; 26 | } 27 | 28 | private void CancelDialogButtonClick(object sender, EventArgs e) 29 | { 30 | Close(); 31 | } 32 | 33 | private void SaveDialogButtonClick(object sender, EventArgs e) 34 | { 35 | Handler.Text = DisclaimerTextTextBox.Text ?? string.Empty; 36 | //_handler.Rtf = DisclaimerRtfRichTextEditor.Rtf ?? string.Empty; 37 | Handler.Html = DisclaimerHtmlHtmlEditor.BodyHtml ?? string.Empty; 38 | Close(); 39 | } 40 | 41 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 42 | { 43 | if (Keys.Escape == keyData) 44 | { 45 | Close(); 46 | } 47 | 48 | return base.ProcessCmdKey(ref msg, keyData); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Geta.Plugins.DisclaimerHandler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("922eaa97-3a2c-4e4a-8949-63cef13c9368")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("0")] 37 | [assembly: AssemblyInformationalVersion("automated")] 38 | [assembly: InternalsVisibleTo("NeosIT.Exchange.GenericExchangeTransportAgent.Tests")] 39 | 40 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Geta.Plugins.DkimSigningHandler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("a992fc65-671c-411c-bf13-87612edec03a")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("0")] 37 | [assembly: AssemblyInformationalVersion("automated")] 38 | [assembly: InternalsVisibleTo("NeosIT.Exchange.GenericExchangeTransportAgent.Tests")] 39 | 40 | -------------------------------------------------------------------------------- /Geta.Plugins.ExecutableHandler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("Geta.Plugins.ExecutableHandler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("d95c321a-2846-418a-a66e-f56810b433ba")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("0")] 37 | [assembly: AssemblyInformationalVersion("automated")] 38 | [assembly: InternalsVisibleTo("NeosIT.Exchange.GenericExchangeTransportAgent.Tests")] 39 | 40 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/TwitterNotificationConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler.Impl; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 6 | { 7 | public partial class TwitterNotificationConfigForm : Form, IGenericConfigForm 8 | { 9 | public TwitterNotificationHandler Handler { get; private set; } 10 | 11 | public void Init(TwitterNotificationHandler handler) 12 | { 13 | Handler = handler; 14 | } 15 | 16 | public TwitterNotificationConfigForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void ConfigFormLoad(object sender, EventArgs e) 22 | { 23 | AccessTokenTextBox.Text = Handler.AccessToken; 24 | AccessTokenSecretTextBox.Text = Handler.AccessTokenSecret; 25 | ConsumerKeyTextBox.Text = Handler.ConsumerKey; 26 | ConsumerSecretTextBox.Text = Handler.ConsumerSecret; 27 | } 28 | 29 | private void SaveDialogButtonClick(object sender, EventArgs e) 30 | { 31 | Handler.AccessToken = AccessTokenTextBox.Text; 32 | Handler.AccessTokenSecret = AccessTokenSecretTextBox.Text; 33 | Handler.ConsumerKey = ConsumerKeyTextBox.Text; 34 | Handler.ConsumerSecret = ConsumerSecretTextBox.Text; 35 | 36 | Close(); 37 | } 38 | 39 | private void CancelDialogButtonClick(object sender, EventArgs e) 40 | { 41 | Close(); 42 | } 43 | 44 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 45 | { 46 | if (Keys.Escape == keyData) 47 | { 48 | Close(); 49 | } 50 | 51 | return base.ProcessCmdKey(ref msg, keyData); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/ExtractAttachmentConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler.Impl; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 9 | { 10 | public partial class ExtractAttachmentConfigForm : Form, IGenericConfigForm 11 | { 12 | public ExtractAttachmentHandler Handler { get; private set; } 13 | 14 | public void Init(ExtractAttachmentHandler handler) 15 | { 16 | Handler = handler; 17 | } 18 | 19 | public ExtractAttachmentConfigForm() 20 | { 21 | InitializeComponent(); 22 | } 23 | 24 | private void SaveButtonClick(object sender, EventArgs e) 25 | { 26 | var list = (BindingList>) SettingsDataGridView.DataSource; 27 | Handler.Settings = list.ToDictionary(x => x.Key, x => x.Value); 28 | Close(); 29 | } 30 | 31 | private void CancelDialogButtonClick(object sender, EventArgs e) 32 | { 33 | Close(); 34 | } 35 | 36 | private void ConfigFormLoad(object sender, EventArgs e) 37 | { 38 | var list = new BindingList> { AllowEdit = true, AllowNew = true, AllowRemove = true, RaiseListChangedEvents = true, }; 39 | 40 | foreach (var kvp in Handler.Settings) 41 | { 42 | list.Add(kvp); 43 | } 44 | 45 | SettingsDataGridView.DataSource = list; 46 | } 47 | 48 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 49 | { 50 | if (Keys.Escape == keyData) 51 | { 52 | Close(); 53 | } 54 | 55 | return base.ProcessCmdKey(ref msg, keyData); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/Common/Extensions/StringExtensionsTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins.Common.Extensions 6 | { 7 | [TestFixture] 8 | public class StringExtensionsTest 9 | { 10 | [Test] 11 | public void ContainsTest() 12 | { 13 | const string str = "alice@neos-it.de"; 14 | 15 | var subStr = "ice@neos"; 16 | Assert.IsTrue(str.Contains(subStr, StringComparison.CurrentCulture)); 17 | 18 | subStr = "ICE@NEOS"; 19 | Assert.IsTrue(str.Contains(subStr, StringComparison.CurrentCultureIgnoreCase)); 20 | } 21 | 22 | [Test] 23 | public void NotContainsTest() 24 | { 25 | const string str = "alice@neos-it.de"; 26 | 27 | var subStr = "ICE@NEOS"; 28 | Assert.IsFalse(str.Contains(subStr, StringComparison.CurrentCulture)); 29 | 30 | subStr = "does-not-contain"; 31 | Assert.IsFalse(str.Contains(subStr, StringComparison.CurrentCultureIgnoreCase)); 32 | } 33 | 34 | [Test] 35 | public void AssertEmptyStringTest() 36 | { 37 | // Should be true... 38 | Assert.IsTrue(string.Empty.Contains(string.Empty, StringComparison.CurrentCulture)); 39 | Assert.IsTrue(string.Empty.Contains(string.Empty, StringComparison.CurrentCultureIgnoreCase)); 40 | 41 | const string str = "this-is-a-test"; 42 | const string subStr = "Test"; 43 | 44 | // Should also be true... 45 | Assert.IsTrue(str.Contains(string.Empty, StringComparison.CurrentCulture)); 46 | Assert.IsTrue(str.Contains(string.Empty, StringComparison.CurrentCultureIgnoreCase)); 47 | 48 | // Should be false... 49 | Assert.IsFalse(string.Empty.Contains(subStr, StringComparison.CurrentCulture)); 50 | Assert.IsFalse(string.Empty.Contains(subStr, StringComparison.CurrentCultureIgnoreCase)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Geta/Impl/Extensions/WebRequestExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net; 4 | using System.Text; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 7 | { 8 | public static class WebRequestExtensions 9 | { 10 | public static void UploadFile(this WebRequest webRequest, Stream stream, string httpMethod, string fileName, string paramName) 11 | { 12 | const string linebreak = "\r\n"; 13 | var mime = Utils.Win32.GetMimeFromStream(stream); 14 | 15 | string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x"); 16 | byte[] trailer = Encoding.ASCII.GetBytes(linebreak + "--" + boundary + "--" + linebreak); 17 | 18 | StringBuilder sb = new StringBuilder(); 19 | sb.Append("--"); 20 | sb.Append(boundary); 21 | sb.Append(linebreak); 22 | sb.Append(string.Format("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"", paramName, 23 | fileName)); 24 | sb.Append(linebreak); 25 | sb.Append("Content-Type: " + mime); 26 | sb.Append(linebreak); 27 | sb.Append(linebreak); 28 | 29 | byte[] boundarybytes = Encoding.ASCII.GetBytes(sb.ToString()); 30 | 31 | webRequest.ContentType = "multipart/form-data; boundary=" + boundary; 32 | webRequest.ContentLength = stream.Length + boundarybytes.Length + trailer.Length; 33 | 34 | webRequest.Method = httpMethod; 35 | webRequest.Credentials = CredentialCache.DefaultCredentials; 36 | 37 | Stream requestStream = webRequest.GetRequestStream(); 38 | 39 | requestStream.Write(boundarybytes, 0, boundarybytes.Length); 40 | 41 | byte[] buffer = new byte[32768]; 42 | int bytesRead = 0; 43 | 44 | while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0) 45 | { 46 | requestStream.Write(buffer, 0, bytesRead); 47 | } 48 | 49 | requestStream.Write(trailer, 0, trailer.Length); 50 | requestStream.Close(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Geta.Plugins.MailEndpointHandler/Impl/Forms/ConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler.Impl.Forms 5 | { 6 | public partial class ConfigForm : Form 7 | { 8 | private readonly MailEndpointHandler _handler; 9 | 10 | public ConfigForm(MailEndpointHandler handler) 11 | { 12 | _handler = handler; 13 | InitializeComponent(); 14 | } 15 | 16 | private void ConfigFormLoad(object sender, EventArgs e) 17 | { 18 | ComboBoxHttpMethod.DataSource = Enum.GetValues(typeof (HttpMethod)); 19 | ComboBoxHttpMethod.SelectedItem = _handler.HttpMethod; 20 | ComboBoxDataContent.DataSource = Enum.GetValues(typeof (MailContent)); 21 | ComboBoxDataContent.SelectedItem = _handler.MailContent; 22 | TextBoxEndpointAddress.Text = _handler.Endpoint; 23 | TextBoxServiceMail.Text = _handler.ServiceMail; 24 | TextBoxAttachmentFileExtensions.Text = _handler.AttachmentFileExtensions; 25 | TextBoxRecipientsHeader.Text = _handler.RecipientsHeader; 26 | CheckBoxDropMailAfterProcessing.Checked = _handler.DropMailAfterProcessing; 27 | TextBoxUploadFieldName.Text = _handler.UploadFieldName; 28 | } 29 | 30 | private void ButtonCancelClick(object sender, EventArgs e) 31 | { 32 | Close(); 33 | } 34 | 35 | private void ButtonApplyClick(object sender, EventArgs e) 36 | { 37 | _handler.Endpoint = TextBoxEndpointAddress.Text; 38 | _handler.ServiceMail = TextBoxServiceMail.Text; 39 | _handler.AttachmentFileExtensions = TextBoxAttachmentFileExtensions.Text; 40 | _handler.RecipientsHeader = TextBoxRecipientsHeader.Text; 41 | _handler.HttpMethod = (HttpMethod) ComboBoxHttpMethod.SelectedItem; 42 | _handler.MailContent = (MailContent) ComboBoxDataContent.SelectedItem; 43 | _handler.DropMailAfterProcessing = CheckBoxDropMailAfterProcessing.Checked; 44 | _handler.UploadFieldName = TextBoxUploadFieldName.Text; 45 | Close(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | *.msi 40 | 41 | # Visual C++ cache files 42 | ipch/ 43 | *.aps 44 | *.ncb 45 | *.opensdf 46 | *.sdf 47 | 48 | # Visual Studio profiler 49 | *.psess 50 | *.vsp 51 | *.vspx 52 | 53 | # Guidance Automation Toolkit 54 | *.gpState 55 | 56 | # ReSharper is a .NET coding add-in 57 | _ReSharper* 58 | 59 | # NCrunch 60 | *.ncrunch* 61 | .*crunch*.local.xml 62 | 63 | # Installshield output folder 64 | [Ee]xpress 65 | 66 | # DocProject is a documentation generator add-in 67 | DocProject/buildhelp/ 68 | DocProject/Help/*.HxT 69 | DocProject/Help/*.HxC 70 | DocProject/Help/*.hhc 71 | DocProject/Help/*.hhk 72 | DocProject/Help/*.hhp 73 | DocProject/Help/Html2 74 | DocProject/Help/html 75 | 76 | # Click-Once directory 77 | publish 78 | 79 | # Publish Web Output 80 | *.Publish.xml 81 | 82 | # NuGet Packages Directory 83 | packages 84 | 85 | # Windows Azure Build Output 86 | csx 87 | *.build.csdef 88 | 89 | # Windows Store app package directory 90 | AppPackages/ 91 | 92 | # Others 93 | [Bb]in 94 | [Oo]bj 95 | sql 96 | TestResults 97 | [Tt]est[Rr]esult* 98 | *.Cache 99 | ClientBin 100 | [Ss]tyle[Cc]op.* 101 | ~$* 102 | *.dbmdl 103 | Generated_Code #added for RIA/Silverlight projects 104 | 105 | # Backup & report files from converting an old project file to a newer 106 | # Visual Studio version. Backup files are not needed, because we have git ;-) 107 | _UpgradeReport_Files/ 108 | Backup*/ 109 | UpgradeLog*.XML 110 | .idea/ 111 | .vs/ 112 | 113 | # ignore exchange dlls because we need to get them manually 114 | libs/Exchange*/ 115 | 116 | nuget.exe 117 | *.g.wxs 118 | -------------------------------------------------------------------------------- /Geta/Impl/PluginHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.ComponentModel.Composition.Hosting; 5 | using System.IO; 6 | using System.Reflection; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 9 | { 10 | public class PluginHost : IPluginHost 11 | { 12 | public CompositionContainer Container { get; private set; } 13 | 14 | [ImportMany(typeof(IHandler), AllowRecomposition = true)] 15 | public IEnumerable Handlers { get; set; } 16 | 17 | [ImportMany(typeof(IFilterable), AllowRecomposition = true)] 18 | public IEnumerable Filters { get; set; } 19 | 20 | public IEnumerable KnownTypes 21 | { 22 | get 23 | { 24 | if (null != Handlers) 25 | { 26 | foreach (var handler in Handlers) 27 | { 28 | yield return handler.GetType(); 29 | } 30 | } 31 | 32 | if (null != Filters) 33 | { 34 | foreach (var filter in Filters) 35 | { 36 | yield return filter.GetType(); 37 | } 38 | } 39 | } 40 | } 41 | 42 | public PluginHost() 43 | { 44 | var exePath = Assembly.GetExecutingAssembly().Location; 45 | 46 | if (string.IsNullOrEmpty(exePath)) return; 47 | 48 | var path = Path.GetDirectoryName(exePath); 49 | 50 | if (!string.IsNullOrEmpty(path)) 51 | { 52 | Init(path); 53 | } 54 | } 55 | 56 | public PluginHost(string path) 57 | { 58 | Init(path); 59 | } 60 | 61 | public void Init(string path) 62 | { 63 | var catalog = new AggregateCatalog(); 64 | catalog.Catalogs.Add(new DirectoryCatalog(path, "*.dll")); 65 | 66 | Container = new CompositionContainer(catalog); 67 | Container.ComposeParts(this); 68 | } 69 | 70 | public void Dispose() 71 | { 72 | Container?.Dispose(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Geta/Impl/Utils/Win32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Utils 6 | { 7 | public class Win32 8 | { 9 | [DllImport(@"urlmon.dll", CharSet = CharSet.Auto)] 10 | private static extern UInt32 FindMimeFromData(UInt32 pBC, [MarshalAs(UnmanagedType.LPStr)] String pwzUrl, 11 | [MarshalAs(UnmanagedType.LPArray)] byte[] pBuffer, UInt32 cbSize, 12 | [MarshalAs(UnmanagedType.LPStr)] String pwzMimeProposed, 13 | UInt32 dwMimeFlags, out UInt32 ppwzMimeOut, UInt32 dwReserved); 14 | 15 | public static string GetMimeFromStream(Stream stream) 16 | { 17 | if (null == stream) 18 | { 19 | throw new ArgumentNullException("stream"); 20 | } 21 | 22 | long originalPosition = 0; 23 | 24 | if (stream.CanSeek) 25 | { 26 | originalPosition = stream.Position; 27 | stream.Position = 0; 28 | } 29 | 30 | try 31 | { 32 | byte[] buffer = new byte[256]; 33 | 34 | if (stream.Length >= 256) 35 | { 36 | stream.Read(buffer, 0, 256); 37 | } 38 | else 39 | { 40 | stream.Read(buffer, 0, (int) stream.Length); 41 | } 42 | 43 | UInt32 mimetype; 44 | FindMimeFromData(0, null, buffer, 256, null, 0, out mimetype, 0); 45 | IntPtr mimeTypePtr = new IntPtr(mimetype); 46 | string mime = Marshal.PtrToStringUni(mimeTypePtr); 47 | Marshal.FreeCoTaskMem(mimeTypePtr); 48 | return mime; 49 | } 50 | catch (Exception) 51 | { 52 | return "unknown/unknown"; 53 | } 54 | finally 55 | { 56 | if (stream.CanSeek) 57 | { 58 | stream.Position = originalPosition; 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Geta/Impl/AgentEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 7 | { 8 | [Export(typeof(IFilterable))] 9 | [DataContract(Name = "EventHandler", Namespace = "")] 10 | public class AgentEventHandler : LoggingBase, IAgentEventHandler 11 | { 12 | public string Name => "EventHandler"; 13 | 14 | [DataMember] 15 | public IList Handlers { get; set; } = new List(); 16 | 17 | [DataMember] 18 | public IList Filters { get; set; } = new List(); 19 | 20 | #region IAgentEventHandler Members 21 | 22 | public void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 23 | { 24 | Logger.Debug("[GenericTransportAgent] AgentEventHandler - Execute called..."); 25 | if (!AppliesTo(emailItem)) return; 26 | 27 | Logger.Debug("[GenericTransportAgent] AgentEventHandler - Calling execute on handlers..."); 28 | Handlers.ToList().ForEach(x => x.Execute(emailItem)); 29 | } 30 | 31 | public bool AppliesTo(IEmailItem emailItem, int? lastExitCode = null) 32 | { 33 | if (null == emailItem) 34 | { 35 | Logger.Warn("[GenericTransportAgent] AgentEventHandler - No MailItem available..."); 36 | return false; 37 | } 38 | 39 | if (null == Filters || 0 == Filters.Count) 40 | { 41 | Logger.Warn("[GenericTransportAgent] [MessageID {0}] AgentEventHandler - No filters defined, applying...", emailItem.Message.MessageId); 42 | return true; 43 | } 44 | 45 | Logger.Info("[GenericTransportAgent] [MessageID {0}] AgentEventHandler - Applying filters...", emailItem.Message.MessageId); 46 | return Filters.Aggregate(false, (current, filter) => current || filter.AppliesTo(emailItem, lastExitCode)); 47 | } 48 | 49 | public void Dispose() 50 | { 51 | } 52 | 53 | #endregion 54 | 55 | public override string ToString() 56 | { 57 | return Name; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Geta.Documentation/js/shBrushXml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SyntaxHighlighter 3 | * http://alexgorbatchev.com/SyntaxHighlighter 4 | * 5 | * SyntaxHighlighter is donationware. If you are using it, please donate. 6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html 7 | * 8 | * @version 9 | * 3.0.83 (July 02 2010) 10 | * 11 | * @copyright 12 | * Copyright (C) 2004-2010 Alex Gorbatchev. 13 | * 14 | * @license 15 | * Dual licensed under the MIT and GPL licenses. 16 | */ 17 | ;(function() 18 | { 19 | // CommonJS 20 | typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null; 21 | 22 | function Brush() 23 | { 24 | function process(match, regexInfo) 25 | { 26 | var constructor = SyntaxHighlighter.Match, 27 | code = match[0], 28 | tag = new XRegExp('(<|<)[\\s\\/\\?]*(?[:\\w-\\.]+)', 'xg').exec(code), 29 | result = [] 30 | ; 31 | 32 | if (match.attributes != null) 33 | { 34 | var attributes, 35 | regex = new XRegExp('(? [\\w:\\-\\.]+)' + 36 | '\\s*=\\s*' + 37 | '(? ".*?"|\'.*?\'|\\w+)', 38 | 'xg'); 39 | 40 | while ((attributes = regex.exec(code)) != null) 41 | { 42 | result.push(new constructor(attributes.name, match.index + attributes.index, 'color1')); 43 | result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string')); 44 | } 45 | } 46 | 47 | if (tag != null) 48 | result.push( 49 | new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword') 50 | ); 51 | 52 | return result; 53 | } 54 | 55 | this.regexList = [ 56 | { regex: new XRegExp('(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)', 'gm'), css: 'color2' }, // 57 | { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // 58 | { regex: new XRegExp('(<|<)[\\s\\/\\?]*(\\w+)(?.*?)[\\s\\/\\?]*(>|>)', 'sg'), func: process } 59 | ]; 60 | }; 61 | 62 | Brush.prototype = new SyntaxHighlighter.Highlighter(); 63 | Brush.aliases = ['xml', 'xhtml', 'xslt', 'html']; 64 | 65 | SyntaxHighlighter.brushes.Xml = Brush; 66 | 67 | // CommonJS 68 | typeof(exports) != 'undefined' ? exports.Brush = Brush : null; 69 | })(); 70 | -------------------------------------------------------------------------------- /Geta.Tests/Helpers/HandlerTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NUnit.Framework; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler.Impl; 5 | using Ninject; 6 | using Ninject.Extensions.Logging; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers 9 | { 10 | [TestFixture] 11 | public abstract class HandlerTestBase where T : IHandler, new() 12 | { 13 | protected T TestObject { get; set; } 14 | 15 | protected string Name { get; set; } 16 | 17 | [SetUp] 18 | public void SetUp() 19 | { 20 | TestObject = new T(); 21 | TestObject.Handlers.Add(new NoopHandler()); 22 | } 23 | [Test] 24 | public void NameTest() 25 | { 26 | Assert.AreEqual(Name, TestObject.Name); 27 | } 28 | 29 | [Test] 30 | public void ToStringTest() 31 | { 32 | Assert.AreEqual(Name, TestObject.ToString()); 33 | } 34 | 35 | protected void PrepareLogger() 36 | { 37 | PrepareLogger(TestObject); 38 | } 39 | 40 | protected void PrepareLogger(object testObject) 41 | { 42 | if (testObject is LoggingBase loggingBase) 43 | { 44 | loggingBase.Kernel = NInjectHelper.GetKernel(); 45 | loggingBase.Logger = loggingBase.Kernel.Get().GetLogger(typeof(T)); 46 | } 47 | 48 | if (testObject is IHandler ihandler) 49 | { 50 | if (null != ihandler.Handlers && ihandler.Handlers.Count > 0) 51 | { 52 | foreach (var handler in ihandler.Handlers) 53 | { 54 | PrepareLogger(handler); 55 | } 56 | } 57 | } 58 | 59 | if (testObject is IFilterable ifilterable) 60 | { 61 | if (null != ifilterable.Filters && ifilterable.Filters.Count > 0) 62 | { 63 | foreach (var filter in ifilterable.Filters) 64 | { 65 | PrepareLogger(filter); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Geta.GuiApplication/AboutForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.ComponentModel.Composition.ReflectionModel; 4 | using System.Diagnostics; 5 | using System.Reflection; 6 | using System.Windows.Forms; 7 | using NeosIT.Exchange.GenericExchangeTransportAgent.Extensions; 8 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 9 | 10 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication 11 | { 12 | public partial class AboutForm : Form 13 | { 14 | private readonly PluginHost _pluginHost; 15 | private readonly Version _version; 16 | private readonly string _build; 17 | private readonly string _revision; 18 | 19 | public AboutForm(PluginHost pluginHost) 20 | { 21 | InitializeComponent(); 22 | 23 | _pluginHost = pluginHost; 24 | 25 | var assembly = typeof(IAgentConfig).Assembly; 26 | _version = assembly.GetName().Version; // AssemblyVersion 27 | _build = assembly.GetCustomAttribute().Version; // AssemblyFileVersion 28 | _revision = FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion; // AssemblyFileInformationVersion 29 | } 30 | 31 | private void AboutForm_Deactivate(object sender, EventArgs e) 32 | { 33 | Close(); 34 | } 35 | 36 | private void AboutForm_Load(object sender, EventArgs e) 37 | { 38 | labelTitle.Text = $"Generic Exchange Transport Agent {_version}"; 39 | labelBuild.Text = $"Build {_build}"; 40 | labelRevision.Text = $"Revision {_revision}"; 41 | } 42 | 43 | private void buttonCopy_Click(object sender, EventArgs e) 44 | { 45 | var pluginNames = _pluginHost.Container.Catalog.Parts 46 | .Select(x => ReflectionModelServices.GetPartType(x).Value.Assembly) 47 | .Distinct() 48 | .Select(x => $"{x.GetName().Name} @ {x.GetName().Version}") 49 | .ToArray(); 50 | 51 | var txt = $@"Generic Exchange Transport Agent @ {_version} 52 | Build: {_build} 53 | Revision {_revision} 54 | 55 | Loaded Plugins: 56 | {string.Join("\n", pluginNames)}"; 57 | Clipboard.SetText(txt, TextDataFormat.UnicodeText); 58 | 59 | buttonCopy.Text = "Copied!"; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/MailEndpointConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler.Impl; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 6 | { 7 | public partial class MailEndpointConfigForm : Form, IGenericConfigForm 8 | { 9 | public MailEndpointHandler Handler { get; private set; } 10 | 11 | public void Init(MailEndpointHandler handler) 12 | { 13 | Handler = handler; 14 | } 15 | 16 | public MailEndpointConfigForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void ConfigFormLoad(object sender, EventArgs e) 22 | { 23 | ComboBoxHttpMethod.DataSource = Enum.GetValues(typeof(HttpMethod)); 24 | ComboBoxHttpMethod.SelectedItem = Handler.HttpMethod; 25 | ComboBoxDataContent.DataSource = Enum.GetValues(typeof(MailContent)); 26 | ComboBoxDataContent.SelectedItem = Handler.MailContent; 27 | TextBoxEndpointAddress.Text = Handler.Endpoint; 28 | TextBoxServiceMail.Text = Handler.ServiceMail; 29 | TextBoxAttachmentFileExtensions.Text = Handler.AttachmentFileExtensions; 30 | TextBoxRecipientsHeader.Text = Handler.RecipientsHeader; 31 | CheckBoxDropMailAfterProcessing.Checked = Handler.DropMailAfterProcessing; 32 | TextBoxUploadFieldName.Text = Handler.UploadFieldName; 33 | } 34 | 35 | private void ButtonCancelClick(object sender, EventArgs e) 36 | { 37 | Close(); 38 | } 39 | 40 | private void ButtonSaveClick(object sender, EventArgs e) 41 | { 42 | Handler.Endpoint = TextBoxEndpointAddress.Text; 43 | Handler.ServiceMail = TextBoxServiceMail.Text; 44 | Handler.AttachmentFileExtensions = TextBoxAttachmentFileExtensions.Text; 45 | Handler.RecipientsHeader = TextBoxRecipientsHeader.Text; 46 | Handler.HttpMethod = (HttpMethod) ComboBoxHttpMethod.SelectedItem; 47 | Handler.MailContent = (MailContent) ComboBoxDataContent.SelectedItem; 48 | Handler.DropMailAfterProcessing = CheckBoxDropMailAfterProcessing.Checked; 49 | Handler.UploadFieldName = TextBoxUploadFieldName.Text; 50 | Close(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Geta/Impl/Config/Agents/SmtpReceiveAgentConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config.Agents 5 | { 6 | [DataContract(Name = "SmtpReceiveAgent", Namespace = "")] 7 | public class SmtpReceiveAgentConfig : IAgentConfig 8 | { 9 | [DataMember(Name = "OnAuthCommand")] 10 | public IList OnAuthCommand { get; set; } = new List(); 11 | 12 | [DataMember(Name = "OnConnect")] 13 | public IList OnConnect { get; set; } = new List(); 14 | 15 | [DataMember(Name = "OnDataCommand")] 16 | public IList OnDataCommand { get; set; } = new List(); 17 | 18 | [DataMember(Name = "OnDisconnect")] 19 | public IList OnDisconnect { get; set; } = new List(); 20 | 21 | [DataMember(Name = "OnEhloCommand")] 22 | public IList OnEhloCommand { get; set; } = new List(); 23 | 24 | [DataMember(Name = "OnEndOfAuthentication")] 25 | public IList OnEndOfAuthentication { get; set; } = new List(); 26 | 27 | [DataMember(Name = "OnEndOfData")] 28 | public IList OnEndOfData { get; set; } = new List(); 29 | 30 | [DataMember(Name = "OnEndOfHeaders")] 31 | public IList OnEndOfHeaders { get; set; } = new List(); 32 | 33 | [DataMember(Name = "OnHeloCommand")] 34 | public IList OnHeloCommand { get; set; } = new List(); 35 | 36 | [DataMember(Name = "OnHelpCommand")] 37 | public IList OnHelpCommand { get; set; } = new List(); 38 | 39 | [DataMember(Name = "OnMailCommand")] 40 | public IList OnMailCommand { get; set; } = new List(); 41 | 42 | [DataMember(Name = "OnNoopCommand")] 43 | public IList OnNoopCommand { get; set; } = new List(); 44 | 45 | [DataMember(Name = "OnRcptCommand")] 46 | public IList OnRcptCommand { get; set; } = new List(); 47 | 48 | [DataMember(Name = "OnReject")] 49 | public IList OnReject { get; set; } = new List(); 50 | 51 | [DataMember(Name = "OnRsetCommand")] 52 | public IList OnRsetCommand { get; set; } = new List(); 53 | } 54 | } -------------------------------------------------------------------------------- /Geta.Tests/Plugins/ExtractAttachmentHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 4 | using NUnit.Framework; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler.Impl; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 9 | { 10 | [TestFixture] 11 | public class ExtractAttachmentHandlerHandlerTests : HandlerTestBase 12 | { 13 | [SetUp] 14 | public void TestFixtureSetUp() 15 | { 16 | Name = "ExtractAttachmentHandler"; 17 | } 18 | 19 | [Test] 20 | public void ExtractTest() 21 | { 22 | string outputPath = TestData.RootPath + @"Fixtures\ExtractAttachmentHandler"; 23 | const string filename = @"Bunny.png"; 24 | 25 | string existingFilename = TestData.RootPath + @"Fixtures\" + filename; 26 | 27 | var emailMessage = EmailMessageHelper.CreateTextEmailMessage("ExtractAttachmentHandler Subject", 28 | "ExtractAttachmentHandler Body"); 29 | 30 | var attachment = emailMessage.Attachments.Add(filename); 31 | using (var writeStream = attachment.GetContentWriteStream()) 32 | { 33 | var dirName = Path.GetDirectoryName(existingFilename); 34 | if (dirName != null) 35 | { 36 | Directory.CreateDirectory(dirName); 37 | } 38 | using (var fileStream = new FileStream(existingFilename, FileMode.Open)) 39 | { 40 | fileStream.CopyTo(writeStream); 41 | } 42 | } 43 | 44 | 45 | TestObject.Settings[ExtractAttachmentHandler.OutputPathKey] = outputPath; 46 | 47 | PrepareLogger(); 48 | 49 | TestObject.Execute(new EmailItem(emailMessage)); 50 | 51 | var fileInfo = new FileInfo(Path.Combine(outputPath, filename)); 52 | Assert.IsTrue(fileInfo.Exists); 53 | Assert.IsTrue(fileInfo.Length > 0); 54 | 55 | var existingFileInfo = new FileInfo(existingFilename); 56 | Assert.AreEqual(existingFileInfo.Length, fileInfo.Length); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Geta/Impl/Extensions/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions 5 | { 6 | public static class StreamExtensions 7 | { 8 | public static void CopyTo(this Stream input, Stream output) 9 | { 10 | input.Position = 0; 11 | var buffer = new byte[4096]; 12 | int read; 13 | 14 | while ((read = input.Read(buffer, 0, buffer.Length)) > 0) 15 | { 16 | output.Write(buffer, 0, read); 17 | } 18 | } 19 | 20 | public static byte[] ReadToEnd(this Stream stream) 21 | { 22 | long originalPosition = 0; 23 | 24 | if (stream.CanSeek) 25 | { 26 | originalPosition = stream.Position; 27 | stream.Position = 0; 28 | } 29 | 30 | try 31 | { 32 | byte[] readBuffer = new byte[4096]; 33 | 34 | int totalBytesRead = 0; 35 | int bytesRead; 36 | 37 | while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0) 38 | { 39 | totalBytesRead += bytesRead; 40 | 41 | if (totalBytesRead == readBuffer.Length) 42 | { 43 | int nextByte = stream.ReadByte(); 44 | if (nextByte != -1) 45 | { 46 | byte[] temp = new byte[readBuffer.Length * 2]; 47 | Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length); 48 | Buffer.SetByte(temp, totalBytesRead, (byte)nextByte); 49 | readBuffer = temp; 50 | totalBytesRead++; 51 | } 52 | } 53 | } 54 | 55 | byte[] buffer = readBuffer; 56 | if (readBuffer.Length != totalBytesRead) 57 | { 58 | buffer = new byte[totalBytesRead]; 59 | Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead); 60 | } 61 | return buffer; 62 | } 63 | finally 64 | { 65 | if (stream.CanSeek) 66 | { 67 | stream.Position = originalPosition; 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Geta.Plugins.DkimSigningHandler/Impl/DkimSigningHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Runtime.Serialization; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DkimSigningHandler.Impl 8 | { 9 | [Export(typeof(IHandler))] 10 | [DataContract(Name = "DkimSigningHandler", Namespace = "")] 11 | public class DkimSigningHandler : FilterableHandlerBase, IDkimSigningHandler 12 | { 13 | [DataMember] 14 | public DkimAlgorithmKind Algorithm { get; set; } = DkimAlgorithmKind.RsaSha1; 15 | 16 | [DataMember] 17 | public string Selector { get; internal set; } 18 | 19 | [DataMember] 20 | public string Domain { get; internal set; } 21 | 22 | [DataMember] 23 | public IList HeadersToSign { get; internal set; } 24 | 25 | [DataMember] 26 | public string EncodedKey { get; internal set; } 27 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 28 | { 29 | if (AppliesTo(emailItem, lastExitCode)) 30 | { 31 | if (null != emailItem && !emailItem.Message.IsSystemMessage && null == emailItem.Message.TnefPart) 32 | { 33 | using (var dkimSigner = new DefaultDkimSigner(Algorithm, HeadersToSign, Selector, Domain, EncodedKey)) 34 | { 35 | using (var inputStream = emailItem.MimeReadStream) 36 | { 37 | if (dkimSigner.CanSign(inputStream)) 38 | { 39 | using (var outputStream = emailItem.GetMimeWriteStream()) 40 | { 41 | dkimSigner.Sign(inputStream, outputStream); 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | if (null != Handlers && Handlers.Count > 0) 49 | { 50 | foreach (var handler in Handlers) 51 | { 52 | handler.Execute(emailItem, lastExitCode); 53 | } 54 | } 55 | } 56 | } 57 | 58 | public override string Name => "DkimSigningHandler"; 59 | 60 | public override string ToString() 61 | { 62 | return Name; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/Impl/ExtractAttachmentHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using System.IO; 4 | using System.Runtime.Serialization; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler.Impl 9 | { 10 | [Export(typeof(IHandler))] 11 | [DataContract(Name = "ExtractAttachmentHandler", Namespace = "")] 12 | public class ExtractAttachmentHandler : FilterableHandlerBase, IExtractAttachmentHandler 13 | { 14 | public const string OutputPathKey = "OutputPath"; 15 | 16 | [DataMember] 17 | public IDictionary Settings { get; set; } = new Dictionary { { OutputPathKey, "" }, }; 18 | 19 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 20 | { 21 | if (!AppliesTo(emailItem, lastExitCode)) return; 22 | 23 | if (emailItem?.Message?.Attachments != null && 24 | emailItem.Message.Attachments.Count != 0 25 | ) 26 | { 27 | string outputPath = GetSetting(OutputPathKey); 28 | 29 | foreach (var attachment in emailItem.Message.Attachments) 30 | { 31 | if (!attachment.TryGetContentReadStream(out var contentStream)) continue; 32 | 33 | Logger.Debug("[GenericTransportAgent] Extracting {1} to {2}...", attachment.FileName, outputPath); 34 | Directory.CreateDirectory(outputPath); 35 | using (var fs = new FileStream( 36 | Path.Combine(outputPath, attachment.FileName), 37 | FileMode.Create, 38 | FileAccess.ReadWrite)) 39 | { 40 | contentStream.CopyTo(fs); 41 | } 42 | } 43 | } 44 | 45 | if (null == Handlers || Handlers.Count <= 0) return; 46 | 47 | foreach (var handler in Handlers) 48 | { 49 | handler.Execute(emailItem, lastExitCode); 50 | } 51 | } 52 | 53 | public override string Name => "ExtractAttachmentHandler"; 54 | 55 | private string GetSetting(string key) 56 | { 57 | return Settings.ContainsKey(key) ? Settings[key] : string.Empty; 58 | } 59 | 60 | public override string ToString() 61 | { 62 | return Name; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/Common/EmailItemTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using Microsoft.Exchange.Data.Transport.Email; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 5 | using NUnit.Framework; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins.Common 9 | { 10 | [TestFixture] 11 | public class EmailItemTests 12 | { 13 | private EmailItem TestObject { get; set; } 14 | 15 | [SetUp] 16 | public void SetUp() 17 | { 18 | TestObject = new EmailItem(EmailMessageHelper.CreateTextEmailMessage("EmailItemTest Subject", "EmailItemTest Body")); 19 | } 20 | 21 | [Test] 22 | public void AssertSetValues() 23 | { 24 | Assert.NotNull(TestObject); 25 | 26 | Assert.AreEqual("alice@neos-it.de", TestObject.FromAddress.ToString()); 27 | 28 | Assert.IsTrue(1 == TestObject.Message.To.Count); 29 | Assert.AreEqual("bob@neos-it.de", TestObject.Message.To.Single().SmtpAddress); 30 | Assert.AreEqual("bob@neos-it.de", TestObject.Message.To.Single().NativeAddress); 31 | 32 | Assert.IsNull(TestObject.GetMimeWriteStream()); 33 | 34 | var underlyingObject = TestObject.GetUnderlyingObject(); 35 | Assert.NotNull(underlyingObject); 36 | Assert.IsInstanceOf(underlyingObject); 37 | Assert.IsInstanceOf(underlyingObject); 38 | 39 | string testFilename = TestData.RootPath + @"Fixtures\EmailItem\testfile.eml"; 40 | 41 | TestObject.Save(testFilename); 42 | Assert.IsFalse(TestObject.IsExported); 43 | 44 | TestObject.Load(testFilename); 45 | Assert.IsFalse(TestObject.IsImported); 46 | 47 | TestObject.MimeReadStream = new MemoryStream(); 48 | 49 | const string str = "Dies ist ein einfacher Teststring\r\nDies ist die zweite Zeile\r\nUnd dies ist das Ende ;)"; 50 | 51 | StreamWriter sw = null; 52 | try 53 | { 54 | sw = new StreamWriter(TestObject.MimeReadStream); 55 | sw.Write(str); 56 | sw.Flush(); 57 | TestObject.Save(testFilename); 58 | Assert.IsTrue(TestObject.IsExported); 59 | Assert.IsTrue(File.Exists(testFilename)); 60 | } 61 | finally 62 | { 63 | sw?.Dispose(); 64 | } 65 | 66 | TestObject.Load(testFilename); 67 | Assert.IsFalse(TestObject.IsImported); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Geta.Documentation/js/shBrushCSharp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * SyntaxHighlighter 3 | * http://alexgorbatchev.com/SyntaxHighlighter 4 | * 5 | * SyntaxHighlighter is donationware. If you are using it, please donate. 6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html 7 | * 8 | * @version 9 | * 3.0.83 (July 02 2010) 10 | * 11 | * @copyright 12 | * Copyright (C) 2004-2010 Alex Gorbatchev. 13 | * 14 | * @license 15 | * Dual licensed under the MIT and GPL licenses. 16 | */ 17 | ;(function() 18 | { 19 | // CommonJS 20 | typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null; 21 | 22 | function Brush() 23 | { 24 | var keywords = 'abstract as base bool break byte case catch char checked class const ' + 25 | 'continue decimal default delegate do double else enum event explicit ' + 26 | 'extern false finally fixed float for foreach get goto if implicit in int ' + 27 | 'interface internal is lock long namespace new null object operator out ' + 28 | 'override params private protected public readonly ref return sbyte sealed set ' + 29 | 'short sizeof stackalloc static string struct switch this throw true try ' + 30 | 'typeof uint ulong unchecked unsafe ushort using virtual void while'; 31 | 32 | function fixComments(match, regexInfo) 33 | { 34 | var css = (match[0].indexOf("///") == 0) 35 | ? 'color1' 36 | : 'comments' 37 | ; 38 | 39 | return [new SyntaxHighlighter.Match(match[0], match.index, css)]; 40 | } 41 | 42 | this.regexList = [ 43 | { regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments 44 | { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments 45 | { regex: /@"(?:[^"]|"")*"/g, css: 'string' }, // @-quoted strings 46 | { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings 47 | { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings 48 | { regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion 49 | { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // c# keyword 50 | { regex: /\bpartial(?=\s+(?:class|interface|struct)\b)/g, css: 'keyword' }, // contextual keyword: 'partial' 51 | { regex: /\byield(?=\s+(?:return|break)\b)/g, css: 'keyword' } // contextual keyword: 'yield' 52 | ]; 53 | 54 | this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); 55 | }; 56 | 57 | Brush.prototype = new SyntaxHighlighter.Highlighter(); 58 | Brush.aliases = ['c#', 'c-sharp', 'csharp']; 59 | 60 | SyntaxHighlighter.brushes.CSharp = Brush; 61 | 62 | // CommonJS 63 | typeof(exports) != 'undefined' ? exports.Brush = Brush : null; 64 | })(); 65 | 66 | -------------------------------------------------------------------------------- /Geta/Impl/Agents/GenericDeliveryAgent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Exchange.Data.Transport.Delivery; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config; 4 | using Ninject; 5 | using Ninject.Extensions.Logging; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents 8 | { 9 | public class GenericDeliveryAgent : DeliveryAgent 10 | { 11 | public IKernel Kernel { get; internal set; } 12 | public ILogger Logger { get; internal set; } 13 | 14 | public GenericDeliveryAgent() 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | OnCloseConnection += OnCloseConnectionHandler; 19 | OnDeliverMailItem += OnDeliverMailItemHandler; 20 | OnOpenConnection += OnOpenConnectionHandler; 21 | } 22 | 23 | private void OnCloseConnectionHandler(CloseConnectionEventSource source, CloseConnectionEventArgs e) 24 | { 25 | Logger.Debug("[GenericTransportAgent] DeliveryAgent - OnClose fired..."); 26 | foreach (var x in Configuration.Config.DeliveryAgentConfig.OnCloseConnection) 27 | { 28 | try 29 | { 30 | x.Execute(); 31 | } 32 | catch (Exception ex) 33 | { 34 | Logger.Error(ex, @"Error executing ""OnCloseConnection"""); 35 | } 36 | } 37 | } 38 | 39 | private void OnDeliverMailItemHandler(DeliverMailItemEventSource source, DeliverMailItemEventArgs e) 40 | { 41 | Logger.Debug("[GenericTransportAgent] DeliveryAgent - OnDeliverMailItem fired..."); 42 | foreach (var x in Configuration.Config.DeliveryAgentConfig.OnDeliverMailItem) 43 | { 44 | try 45 | { 46 | x.Execute(new EmailItem(e.DeliverableMailItem)); 47 | } 48 | catch (Exception ex) 49 | { 50 | Logger.Error(ex, @"Error executing ""OnDeliverMailItem"""); 51 | } 52 | } 53 | } 54 | 55 | private void OnOpenConnectionHandler(OpenConnectionEventSource source, OpenConnectionEventArgs e) 56 | { 57 | Logger.Debug("[GenericTransportAgent] DeliveryAgent - OpenConnection fired..."); 58 | foreach (var x in Configuration.Config.DeliveryAgentConfig.OnOpenConnection) 59 | { 60 | try 61 | { 62 | x.Execute(new EmailItem(e.DeliverableMailItem)); 63 | } 64 | catch (Exception ex) 65 | { 66 | Logger.Error(ex, @"Error executing ""OnOpenConnection"""); 67 | } 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /Geta.Plugins.TwitterNotificationHandler/Impl/TwitterNotificationHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Runtime.Serialization; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 5 | using Twitterizer; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler.Impl 8 | { 9 | [Export(typeof(IHandler))] 10 | [DataContract(Name = "TwitterNotificationHandler", Namespace = "")] 11 | public class TwitterNotificationHandler : FilterableHandlerBase, ITwitterNotificationHandler 12 | { 13 | [DataMember] 14 | public string AccessToken { get; set; } 15 | [DataMember] 16 | public string AccessTokenSecret { get; set; } 17 | 18 | [DataMember] 19 | public string ConsumerKey { get; set; } 20 | 21 | [DataMember] 22 | public string ConsumerSecret { get; set; } 23 | 24 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 25 | { 26 | if (!AppliesTo(emailItem, lastExitCode)) return; 27 | 28 | if (emailItem?.Message?.From != null) 29 | { 30 | if (GetOAuthToken(out var oAuthTokens)) 31 | { 32 | var fromEmailRecipient = emailItem.Message.From; 33 | string from = !string.IsNullOrEmpty(fromEmailRecipient.DisplayName) ? fromEmailRecipient.DisplayName : !string.IsNullOrEmpty(fromEmailRecipient.NativeAddress) ? fromEmailRecipient.NativeAddress : fromEmailRecipient.SmtpAddress; 34 | var response = TwitterStatus.Update(oAuthTokens, 35 | $"[{DateTime.Now}] New mail from {@from}"); 36 | } 37 | } 38 | 39 | if (null == Handlers || Handlers.Count <= 0) return; 40 | 41 | foreach (var handler in Handlers) 42 | { 43 | handler.Execute(emailItem, lastExitCode); 44 | } 45 | } 46 | 47 | public override string Name => "TwitterNotificationHandler"; 48 | 49 | public override string ToString() 50 | { 51 | return Name; 52 | } 53 | 54 | private bool GetOAuthToken(out OAuthTokens oAuthTokens) 55 | { 56 | oAuthTokens = null; 57 | 58 | if (string.IsNullOrEmpty(AccessToken) || 59 | string.IsNullOrEmpty(AccessTokenSecret) || 60 | string.IsNullOrEmpty(ConsumerKey) || 61 | string.IsNullOrEmpty(ConsumerSecret)) return false; 62 | 63 | oAuthTokens = new OAuthTokens 64 | { 65 | AccessToken = AccessToken, 66 | AccessTokenSecret = AccessTokenSecret, 67 | ConsumerKey = ConsumerKey, 68 | ConsumerSecret = ConsumerSecret 69 | }; 70 | return true; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Geta/Impl/EmailItem.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Microsoft.Exchange.Data.Transport; 3 | using Microsoft.Exchange.Data.Transport.Email; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 5 | 6 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl 7 | { 8 | public sealed class EmailItem : IEmailItem 9 | { 10 | private readonly object _underlyingObject; 11 | 12 | private EmailItem(object underlyingObject, EmailMessage message, RoutingAddress fromAddress, 13 | Stream mimeReadStream) 14 | { 15 | _underlyingObject = underlyingObject; 16 | Message = message; 17 | FromAddress = fromAddress; 18 | MimeReadStream = mimeReadStream; 19 | } 20 | 21 | public EmailItem(MailItem mailItem) 22 | : this(mailItem, mailItem.Message, mailItem.FromAddress, mailItem.GetMimeReadStream()) 23 | { 24 | } 25 | 26 | public EmailItem(DeliverableMailItem mailItem) 27 | : this(mailItem, mailItem.Message, mailItem.FromAddress, mailItem.GetMimeReadStream()) 28 | { 29 | } 30 | 31 | public EmailItem(EmailMessage emailMessage) : this (emailMessage, emailMessage, new RoutingAddress(emailMessage.From.SmtpAddress), null) 32 | { 33 | } 34 | 35 | #region IEmailItem Members 36 | 37 | public EmailMessage Message { get; internal set; } 38 | public RoutingAddress FromAddress { get; internal set; } 39 | public Stream MimeReadStream { get; set; } 40 | public bool IsExported { get; internal set; } 41 | public bool IsImported { get; internal set; } 42 | public bool ShouldBeDeletedFromQueue { get; set; } 43 | 44 | public Stream GetMimeWriteStream() 45 | { 46 | var underlyingObject = _underlyingObject as MailItem; 47 | return underlyingObject?.GetMimeWriteStream(); 48 | } 49 | 50 | public object GetUnderlyingObject() 51 | { 52 | return _underlyingObject; 53 | } 54 | 55 | public void Save(string filename) 56 | { 57 | if (null == MimeReadStream) return; 58 | 59 | var dirName = Path.GetDirectoryName(filename); 60 | if (dirName != null) 61 | { 62 | Directory.CreateDirectory(dirName); 63 | } 64 | 65 | using (var fs = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite)) 66 | { 67 | MimeReadStream.CopyTo(fs); 68 | IsExported = true; 69 | } 70 | } 71 | 72 | public void Load(string filename) 73 | { 74 | if (!File.Exists(filename)) return; 75 | 76 | var writeStream = GetMimeWriteStream(); 77 | 78 | if (null == writeStream) return; 79 | 80 | using (writeStream) 81 | { 82 | using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) 83 | { 84 | fs.CopyTo(writeStream); 85 | IsImported = true; 86 | } 87 | } 88 | } 89 | 90 | #endregion 91 | } 92 | } -------------------------------------------------------------------------------- /Geta.Plugins.Mail2NewsHandler/Impl/Mail2NewsHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using Microsoft.Exchange.Data.Mime; 7 | using Microsoft.Exchange.Data.Transport; 8 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 9 | 10 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.Mail2NewsHandler.Impl 11 | { 12 | [Export(typeof(IHandler))] 13 | [DataContract(Name = "Mail2NewsHandler", Namespace = "")] 14 | public class Mail2NewsHandler: FilterableHandlerBase, IMail2NewsHandler 15 | { 16 | [DataMember] 17 | public string ToSmtpAddress { get; set; } 18 | 19 | [DataMember] 20 | public string HeaderKey { get; set; } 21 | 22 | public override string Name => "Mail2NewsHandler"; 23 | 24 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 25 | { 26 | if (!AppliesTo(emailItem, lastExitCode)) return; 27 | 28 | var sb = new StringBuilder(); 29 | 30 | if (emailItem.GetUnderlyingObject() is MailItem mailItem) 31 | { 32 | var rcptsToRemove = mailItem.Recipients.Where(x => !ToSmtpAddress.Equals(x.Address.ToString(), StringComparison.InvariantCultureIgnoreCase)); 33 | 34 | foreach (var rcpt in rcptsToRemove) 35 | { 36 | Logger.Info("[MessageID {0}] Removing {1} from CC...", emailItem.Message.MessageId, rcpt.Address.ToString()); 37 | sb.Append(rcpt.Address.ToString() + ";"); 38 | mailItem.Recipients.Remove(rcpt); 39 | } 40 | } 41 | 42 | Logger.Info("[MessageID {0}] Share-With: {1}...", emailItem.Message.MessageId, sb.ToString()); 43 | 44 | var header = new TextHeader(HeaderKey, sb.ToString()); 45 | emailItem.Message.RootPart.Headers.AppendChild(header); 46 | } 47 | 48 | public override bool AppliesTo(IEmailItem emailItem, int? lastExitCode = null) 49 | { 50 | if (null == emailItem) 51 | { 52 | Logger.Fatal("No MailItem available...", Name); 53 | return false; 54 | } 55 | 56 | if (string.IsNullOrEmpty(ToSmtpAddress) || string.IsNullOrEmpty(HeaderKey)) 57 | { 58 | Logger.Info(@"[MessageId {0}] Missing ToSmtpAddress ""{1}"" or HeaderKey ""{2}"" ...", emailItem.Message.MessageId, ToSmtpAddress, HeaderKey); 59 | return false; 60 | } 61 | 62 | if ( 63 | !emailItem.Message.To.Any( 64 | x => x.SmtpAddress.Equals(ToSmtpAddress, StringComparison.InvariantCultureIgnoreCase))) 65 | { 66 | Logger.Info("[MessageId {0}] - ToSmtpAddress not found in recipients...", emailItem.Message.MessageId); 67 | return false; 68 | } 69 | 70 | return base.AppliesTo(emailItem, lastExitCode); 71 | } 72 | 73 | public void Load() 74 | { 75 | } 76 | 77 | public override string ToString() 78 | { 79 | return Name; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/Impl/DisclaimerHandler.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Runtime.Serialization; 3 | using System.Text; 4 | using HtmlAgilityPack; 5 | using Microsoft.Exchange.Data.Transport.Email; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 7 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 8 | 9 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler.Impl 10 | { 11 | [Export(typeof(IHandler))] 12 | [DataContract(Name = "DisclaimerHandler", Namespace = "")] 13 | public class DisclaimerHandler : FilterableHandlerBase, IDisclaimerHandler 14 | { 15 | [DataMember(Name = "Text")] 16 | public string Text { get; set; } 17 | 18 | [DataMember(Name = "Rtf")] 19 | public string Rtf { get; set; } 20 | 21 | [DataMember(Name = "Html")] 22 | public string Html { get; set; } 23 | 24 | public override void Execute(IEmailItem emailItem = null, int? lastExitCode = null) 25 | { 26 | if (!AppliesTo(emailItem, lastExitCode)) return; 27 | 28 | // AppliesTo() will return false, if emailItem is null. 29 | // ReSharper disable once PossibleNullReferenceException 30 | if (BodyFormat.Text == emailItem.Message.Body.BodyFormat) 31 | { 32 | var sb = new StringBuilder(); 33 | sb.Append(emailItem.Message.GetBody()); 34 | sb.AppendLine(); 35 | sb.AppendLine(); 36 | sb.Append(Text); 37 | emailItem.Message.SetBody(sb.ToString()); 38 | } 39 | 40 | if (BodyFormat.Rtf == emailItem.Message.Body.BodyFormat) 41 | { 42 | var messageRtf = new RtfDocument(emailItem.Message.GetBody()); 43 | var mergeRtf = new RtfDocument(Rtf); 44 | 45 | if (messageRtf.Merge(mergeRtf)) 46 | { 47 | emailItem.Message.SetBody(messageRtf.Content); 48 | } 49 | } 50 | 51 | if (BodyFormat.Html == emailItem.Message.Body.BodyFormat) 52 | { 53 | var messageDoc = new HtmlDocument(); 54 | messageDoc.LoadHtml(emailItem.Message.GetBody()); 55 | 56 | var disclaimerDoc = new HtmlDocument(); 57 | disclaimerDoc.LoadHtml(Html); 58 | 59 | var messageBodyNode = messageDoc.DocumentNode.SelectSingleNode("//body"); 60 | var disclaimerBodyNode = disclaimerDoc.DocumentNode.SelectSingleNode("//body"); 61 | 62 | var brNode = messageDoc.CreateElement("br"); 63 | 64 | messageBodyNode.AppendChild(brNode); 65 | 66 | messageBodyNode.AppendChildren(disclaimerBodyNode.ChildNodes); 67 | 68 | emailItem.Message.SetBody(messageDoc.DocumentNode.InnerHtml); 69 | } 70 | 71 | if (null == Handlers || Handlers.Count <= 0) return; 72 | 73 | foreach (var handler in Handlers) 74 | { 75 | handler.Execute(emailItem, lastExitCode); 76 | } 77 | } 78 | 79 | public override string Name => "DisclaimerHandler"; 80 | 81 | public override string ToString() 82 | { 83 | return Name; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Geta.GuiApplication/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 54 | 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Geta.ConsoleApplication/Geta.ConsoleApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | x64 6 | ../libs 7 | {06EA279A-FF8F-47DE-A57D-CF49B1B14261} 8 | Exe 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.ConsoleApplication 11 | Geta.ConsoleApplication 12 | v4.7.2 13 | 512 14 | 15 | 16 | bin\2010\ 17 | 18 | 19 | bin\2016\ 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 36 | NeosIT.Exchange.GenericExchangeTransportAgent 37 | 38 | 39 | {0b8b0a99-cd43-46cd-bf2c-a317441e1f24} 40 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler 41 | 42 | 43 | {3395cd93-59e3-453a-8806-49f4def9e3b8} 44 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler 45 | 46 | 47 | {085e66f6-6806-456e-a33c-5ed32d636ee6} 48 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler 49 | 50 | 51 | {96949535-995a-4536-adba-f2d60d54b8d6} 52 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Geta.Tests/Plugins/ExecutableHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Enums; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 4 | using NUnit.Framework; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler.Impl; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 9 | { 10 | [TestFixture] 11 | public class ExecutableHandlerHandlerTests : HandlerTestBase 12 | { 13 | [SetUp] 14 | public void TestFixtureSetUp() 15 | { 16 | Name = "ExecutableHandler"; 17 | } 18 | 19 | [Test] 20 | public void ExecutableTest() 21 | { 22 | string path = TestData.RootPath + @"Fixtures\ExecutableHandler\"; 23 | string emlFilePath = path + @"testfile.eml"; 24 | string testFilePath = path + @"testfile.txt"; 25 | 26 | Directory.CreateDirectory(path); 27 | File.Delete(emlFilePath); 28 | File.Delete(testFilePath); 29 | 30 | var emailMessage = EmailMessageHelper.CreateTextEmailMessage("ExecutableHandlerTest Subject", 31 | "ExecutableHandlerTest Body"); 32 | 33 | TestObject.Cmd = "cmd.exe"; 34 | TestObject.Args = "/c echo Test >> " + testFilePath; 35 | 36 | PrepareLogger(); 37 | 38 | TestObject.Execute(new EmailItem(emailMessage)); 39 | 40 | var testFileInfo = new FileInfo(testFilePath); 41 | Assert.IsTrue(testFileInfo.Exists); 42 | Assert.IsTrue(testFileInfo.Length > 0); 43 | } 44 | 45 | [Test] 46 | public void RunTest() 47 | { 48 | var emailMessage = EmailMessageHelper.CreateHtmlEmailMessage("ExecutableHandlerRunTest Subject", 49 | "ExecutableHandlerRunTest Body"); 50 | 51 | TestObject.Cmd = "cmd.exe"; 52 | TestObject.Args = "/c echo test"; 53 | 54 | PrepareLogger(); 55 | 56 | TestObject.Execute(new EmailItem(emailMessage)); 57 | 58 | Assert.AreEqual(0, TestObject.ExitCode); 59 | } 60 | 61 | [Test] 62 | public void RunTestFailed() 63 | { 64 | var emailMessage = EmailMessageHelper.CreateHtmlEmailMessage("ExecutableHandlerRunTest Subject", 65 | "ExecutableHandlerRunTest Body"); 66 | 67 | TestObject.Cmd = "cmd.exe"; 68 | 69 | PrepareLogger(); 70 | 71 | TestObject.Execute(new EmailItem(emailMessage)); 72 | 73 | Assert.AreEqual((int) ExitCodeEnum.CommandTimedOut, TestObject.ExitCode); 74 | } 75 | 76 | [Test] 77 | public void RunTestNotSet() 78 | { 79 | var emailMessage = EmailMessageHelper.CreateHtmlEmailMessage("ExecutableHandlerRunTest Subject", 80 | "ExecutableHandlerRunTest Body"); 81 | 82 | PrepareLogger(); 83 | 84 | TestObject.Execute(new EmailItem(emailMessage)); 85 | 86 | Assert.AreEqual((int) ExitCodeEnum.CommandNotRun, TestObject.ExitCode); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Geta.Documentation/css/shThemeDefault.css: -------------------------------------------------------------------------------- 1 | /** 2 | * SyntaxHighlighter 3 | * http://alexgorbatchev.com/SyntaxHighlighter 4 | * 5 | * SyntaxHighlighter is donationware. If you are using it, please donate. 6 | * http://alexgorbatchev.com/SyntaxHighlighter/donate.html 7 | * 8 | * @version 9 | * 3.0.83 (July 02 2010) 10 | * 11 | * @copyright 12 | * Copyright (C) 2004-2010 Alex Gorbatchev. 13 | * 14 | * @license 15 | * Dual licensed under the MIT and GPL licenses. 16 | */ 17 | .syntaxhighlighter { 18 | background-color: white !important; 19 | } 20 | .syntaxhighlighter .line.alt1 { 21 | background-color: white !important; 22 | } 23 | .syntaxhighlighter .line.alt2 { 24 | background-color: white !important; 25 | } 26 | .syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 { 27 | background-color: #e0e0e0 !important; 28 | } 29 | .syntaxhighlighter .line.highlighted.number { 30 | color: black !important; 31 | } 32 | .syntaxhighlighter table caption { 33 | color: black !important; 34 | } 35 | .syntaxhighlighter .gutter { 36 | color: #afafaf !important; 37 | } 38 | .syntaxhighlighter .gutter .line { 39 | border-right: 3px solid #6ce26c !important; 40 | } 41 | .syntaxhighlighter .gutter .line.highlighted { 42 | background-color: #6ce26c !important; 43 | color: white !important; 44 | } 45 | .syntaxhighlighter.printing .line .content { 46 | border: none !important; 47 | } 48 | .syntaxhighlighter.collapsed { 49 | overflow: visible !important; 50 | } 51 | .syntaxhighlighter.collapsed .toolbar { 52 | color: blue !important; 53 | background: white !important; 54 | border: 1px solid #6ce26c !important; 55 | } 56 | .syntaxhighlighter.collapsed .toolbar a { 57 | color: blue !important; 58 | } 59 | .syntaxhighlighter.collapsed .toolbar a:hover { 60 | color: red !important; 61 | } 62 | .syntaxhighlighter .toolbar { 63 | color: white !important; 64 | background: #6ce26c !important; 65 | border: none !important; 66 | } 67 | .syntaxhighlighter .toolbar a { 68 | color: white !important; 69 | } 70 | .syntaxhighlighter .toolbar a:hover { 71 | color: black !important; 72 | } 73 | .syntaxhighlighter .plain, .syntaxhighlighter .plain a { 74 | color: black !important; 75 | } 76 | .syntaxhighlighter .comments, .syntaxhighlighter .comments a { 77 | color: #008200 !important; 78 | } 79 | .syntaxhighlighter .string, .syntaxhighlighter .string a { 80 | color: blue !important; 81 | } 82 | .syntaxhighlighter .keyword { 83 | color: #006699 !important; 84 | } 85 | .syntaxhighlighter .preprocessor { 86 | color: gray !important; 87 | } 88 | .syntaxhighlighter .variable { 89 | color: #aa7700 !important; 90 | } 91 | .syntaxhighlighter .value { 92 | color: #009900 !important; 93 | } 94 | .syntaxhighlighter .functions { 95 | color: #ff1493 !important; 96 | } 97 | .syntaxhighlighter .constants { 98 | color: #0066cc !important; 99 | } 100 | .syntaxhighlighter .script { 101 | font-weight: bold !important; 102 | color: #006699 !important; 103 | background-color: none !important; 104 | } 105 | .syntaxhighlighter .color1, .syntaxhighlighter .color1 a { 106 | color: gray !important; 107 | } 108 | .syntaxhighlighter .color2, .syntaxhighlighter .color2 a { 109 | color: #ff1493 !important; 110 | } 111 | .syntaxhighlighter .color3, .syntaxhighlighter .color3 a { 112 | color: red !important; 113 | } 114 | 115 | .syntaxhighlighter .keyword { 116 | font-weight: bold !important; 117 | } 118 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/ExecutableConfigForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler.Impl; 4 | 5 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 6 | { 7 | public partial class ExecutableConfigForm : Form, IGenericConfigForm 8 | { 9 | public ExecutableHandler Handler { get; private set; } 10 | 11 | public void Init(ExecutableHandler handler) 12 | { 13 | Handler = handler; 14 | } 15 | 16 | public ExecutableConfigForm() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void ConfigFormLoad(object sender, EventArgs e) 22 | { 23 | CommandTextBox.Text = Handler.Cmd; 24 | ArgumentsTextBox.Text = Handler.Args; 25 | TimeoutNumericUpDown.Value = Handler.Timeout; 26 | ExportEmlFileCheckBox.Checked = Handler.Export; 27 | ExportEmlFilePathTextBox.Enabled = ExportEmlFileCheckBox.Checked; 28 | ExportEmlFilePathBrowseButton.Enabled = ExportEmlFileCheckBox.Checked; 29 | ExportEmlFileFilenameLabel.Enabled = ExportEmlFileCheckBox.Checked; 30 | ExportEmlFileFilenameTextBox.Enabled = ExportEmlFileCheckBox.Checked; 31 | ExportEmlFilePathTextBox.Text = Handler.ExportPath; 32 | ExportEmlFileFilenameTextBox.Text = Handler.EmlFileName; 33 | } 34 | 35 | private void SaveButtonClick(object sender, EventArgs e) 36 | { 37 | Handler.Cmd = CommandTextBox.Text; 38 | Handler.Args = ArgumentsTextBox.Text; 39 | Handler.Timeout = Convert.ToInt32(TimeoutNumericUpDown.Value); 40 | Handler.Export = ExportEmlFileCheckBox.Checked; 41 | Handler.EmlFileName = ExportEmlFileFilenameTextBox.Text; 42 | Handler.ExportPath = ExportEmlFilePathTextBox.Text; 43 | 44 | Close(); 45 | } 46 | 47 | private void CancelDialogButtonClick(object sender, EventArgs e) 48 | { 49 | Close(); 50 | } 51 | 52 | private void CommandBrowseButtonClick(object sender, EventArgs e) 53 | { 54 | if (DialogResult.OK == CommandFileDialog.ShowDialog()) 55 | { 56 | CommandTextBox.Text = CommandFileDialog.FileName; 57 | } 58 | } 59 | 60 | private void ExportEmlFileCheckBoxCheckedChanged(object sender, EventArgs e) 61 | { 62 | ExportEmlFilePathTextBox.Enabled = ExportEmlFileCheckBox.Checked; 63 | ExportEmlFilePathBrowseButton.Enabled = ExportEmlFileCheckBox.Checked; 64 | ExportEmlFileFilenameLabel.Enabled = ExportEmlFileCheckBox.Checked; 65 | ExportEmlFileFilenameTextBox.Enabled = ExportEmlFileCheckBox.Checked; 66 | } 67 | 68 | private void ExportEmlFilePathBrowseButtonClick(object sender, EventArgs e) 69 | { 70 | if (DialogResult.OK == ExportFolderBrowserDialog.ShowDialog()) 71 | { 72 | ExportEmlFilePathTextBox.Text = ExportFolderBrowserDialog.SelectedPath; 73 | } 74 | } 75 | 76 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 77 | { 78 | if (Keys.Escape == keyData) 79 | { 80 | Close(); 81 | } 82 | 83 | return base.ProcessCmdKey(ref msg, keyData); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Geta.Tests/Plugins/DisclaimerHandlerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Exchange.Data.Transport.Email; 2 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Extensions; 4 | using NUnit.Framework; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler.Impl; 6 | using NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Helpers; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests.Plugins 9 | { 10 | [TestFixture] 11 | public class DisclaimerHandlerHandlerTests : HandlerTestBase 12 | { 13 | [SetUp] 14 | public void TestFixtureSetUp() 15 | { 16 | Name = "DisclaimerHandler"; 17 | } 18 | 19 | [Test] 20 | public void DisclaimerHandlerHtmlTest() 21 | { 22 | const string value = "
DisclaimerHandlerHtmlTest Value
"; 23 | const string wrappedValue = "" + value + ""; 24 | 25 | var emailMessage = EmailMessage.Create(BodyFormat.Html); 26 | emailMessage.From = new EmailRecipient("Alice", "alice@neos-it.de"); 27 | emailMessage.To.Add(new EmailRecipient("Bob", "bob@neos-it.de")); 28 | emailMessage.SetBody("DisclaimerHandlerHtmlTest SubjectDisclaimerHandlerHtmlTest Body"); 29 | emailMessage.Subject = "DisclaimerHandlerHtmlTest Subject"; 30 | 31 | TestObject.Html = wrappedValue; 32 | 33 | PrepareLogger(); 34 | 35 | TestObject.Execute(new EmailItem(emailMessage)); 36 | 37 | string body = emailMessage.GetBody(); 38 | 39 | Assert.IsTrue(body.Contains(value)); 40 | } 41 | 42 | [Test] 43 | [Ignore("Warum zur Hölle wird keine EmailMessage mit BodyFormat.Rtf unterstützt???")] 44 | public void DisclaimerHandlerRtfTest() 45 | { 46 | const string value = "DisclaimerHandlerRtfTest Value"; 47 | 48 | var emailMessage = EmailMessage.Create(BodyFormat.Rtf); 49 | emailMessage.From = new EmailRecipient("Alice", "alice@neos-it.de"); 50 | emailMessage.To.Add(new EmailRecipient("Bob", "bob@neos-it.de")); 51 | emailMessage.SetBody("DisclaimerHandlerRtfTest Body"); 52 | emailMessage.Subject = "DisclaimerHandlerRtfTest Subject"; 53 | 54 | TestObject.Rtf = value; 55 | 56 | PrepareLogger(); 57 | 58 | TestObject.Execute(new EmailItem(emailMessage)); 59 | 60 | string body = emailMessage.GetBody(); 61 | 62 | Assert.IsTrue(body.Contains(value)); 63 | } 64 | 65 | [Test] 66 | public void DisclaimerHandlerTextTest() 67 | { 68 | const string value = "DisclaimerHandlerTextTest Value"; 69 | 70 | var emailMessage = EmailMessage.Create(BodyFormat.Text); 71 | emailMessage.From = new EmailRecipient("Alice", "alice@neos-it.de"); 72 | emailMessage.To.Add(new EmailRecipient("Bob", "bob@neos-it.de")); 73 | emailMessage.SetBody("DisclaimerHandlerHtmlTest Body"); 74 | emailMessage.Subject = "DisclaimerHandlerHtmlTest Subject"; 75 | 76 | TestObject.Text = value; 77 | 78 | PrepareLogger(); 79 | 80 | TestObject.Execute(new EmailItem(emailMessage)); 81 | 82 | string body = emailMessage.GetBody(); 83 | 84 | Assert.IsTrue(body.Contains(value)); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Properties.Resources" + 43 | "", typeof(Resources).Assembly); 44 | resourceMan = temp; 45 | } 46 | return resourceMan; 47 | } 48 | } 49 | 50 | /// 51 | /// Overrides the current thread's CurrentUICulture property for all 52 | /// resource lookups using this strongly typed resource class. 53 | /// 54 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 55 | internal static global::System.Globalization.CultureInfo Culture { 56 | get { 57 | return resourceCulture; 58 | } 59 | set { 60 | resourceCulture = value; 61 | } 62 | } 63 | 64 | /// 65 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 66 | /// 67 | internal static System.Drawing.Icon Icon { 68 | get { 69 | object obj = ResourceManager.GetObject("Icon", resourceCulture); 70 | return ((System.Drawing.Icon)(obj)); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Geta.Tests/ConfigTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config; 5 | using NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.MailEndpointHandler.Impl; 6 | using NUnit.Framework; 7 | 8 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Tests 9 | { 10 | /// 11 | /// In these test we have to delay the tests because the filesystem watcher is not instant. We wait for ~1s every 12 | /// time we rely on the filesystem watcher. 13 | /// 14 | [TestFixture] 15 | public class ConfigTests 16 | { 17 | private string _configFileContents; 18 | 19 | [SetUp] 20 | public void Setup() 21 | { 22 | _configFileContents = File.ReadAllText(Configuration.FullPath); 23 | } 24 | 25 | [TearDown] 26 | public async Task Teardown() 27 | { 28 | Configuration.HotReloadEnabled = true; 29 | // relies on the file watcher to reload / reset the config. 30 | File.WriteAllText(Configuration.FullPath, _configFileContents); 31 | await Task.Delay(1000); 32 | } 33 | 34 | [Test] 35 | public async Task TestHotReload() 36 | { 37 | var config = Configuration.Config; 38 | 39 | Assert.IsEmpty(config.RoutingAgentConfig.OnRoutedMessage); 40 | 41 | File.WriteAllText(Configuration.FullPath, @" 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | "); 50 | 51 | await Task.Delay(1000); // wait for filesystem watcher to catch up 52 | 53 | var config2 = Configuration.Config; 54 | 55 | Assert.AreSame(config, config2); 56 | 57 | Assert.IsNotEmpty(config.RoutingAgentConfig.OnRoutedMessage); 58 | Assert.IsInstanceOf(config.RoutingAgentConfig.OnRoutedMessage.First()); 59 | } 60 | 61 | [Test] 62 | public async Task TestHotReloadSwitch() 63 | { 64 | Configuration.HotReloadEnabled = false; 65 | 66 | var config = Configuration.Config; 67 | 68 | Assert.IsEmpty(config.RoutingAgentConfig.OnRoutedMessage); 69 | 70 | File.WriteAllText(Configuration.FullPath, ""); 71 | 72 | await Task.Delay(1000); // be sure to wait. When the watcher is still enabled it may not be fast enough. 73 | 74 | Assert.IsEmpty(config.RoutingAgentConfig.OnRoutedMessage); 75 | } 76 | 77 | [Test] 78 | public async Task TestHotReloadIsFailSafe() 79 | { 80 | var config = Configuration.Config; 81 | 82 | File.WriteAllText(Configuration.FullPath, @" 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | "); 91 | 92 | await Task.Delay(1000); // wait for filesystem watcher to catch up 93 | 94 | Assert.IsNotEmpty(config.RoutingAgentConfig.OnRoutedMessage); 95 | 96 | File.WriteAllText(Configuration.FullPath, @""); 97 | 98 | await Task.Delay(1000); // wait for filesystem watcher to catch up 99 | 100 | Assert.IsNotEmpty(config.RoutingAgentConfig.OnRoutedMessage); 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /Geta.Plugins.DisclaimerHandler/Geta.Plugins.DisclaimerHandler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | AnyCPU 6 | ../libs 7 | {0B8B0A99-CD43-46CD-BF2C-A317441E1F24} 8 | Library 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.DisclaimerHandler 11 | Geta.Plugins.DisclaimerHandler 12 | 512 13 | v4.7.2 14 | 15 | 16 | v3.5 17 | bin\2010\ 18 | EXCHANGE_2010;NET35 19 | 20 | 21 | bin\2016 RTM\ 22 | EXCHANGE_2016_RTM 23 | 24 | 25 | 26 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Transport.dll 27 | 28 | 29 | ..\libs\System.ComponentModel.Composition.dll 30 | 31 | 32 | 33 | 34 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Transport.dll 35 | 36 | 37 | 38 | 39 | 40 | ..\packages\HtmlAgilityPack.1.4.6\lib\Net20\HtmlAgilityPack.dll 41 | 42 | 43 | ..\packages\Ninject.3.0.1.10\lib\net35\Ninject.dll 44 | 45 | 46 | ..\packages\Ninject.Extensions.Logging.3.0.1.0\lib\net35\Ninject.Extensions.Logging.dll 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 67 | NeosIT.Exchange.GenericExchangeTransportAgent 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Geta.Setup/Setup.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Geta.Setup { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Setup { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Setup() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geta.Setup.Setup", typeof(Setup).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Lorem Ipsum. 65 | /// 66 | internal static string AppDescription { 67 | get { 68 | return ResourceManager.GetString("AppDescription", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to A 64 bit operation system is required. 74 | /// 75 | internal static string ErrorPlatform64Required { 76 | get { 77 | return ResourceManager.GetString("ErrorPlatform64Required", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Windows 7 or Server 2008 R2 or higher is required.. 83 | /// 84 | internal static string ErrorVersionTooLow { 85 | get { 86 | return ResourceManager.GetString("ErrorVersionTooLow", resourceCulture); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Geta.Plugins.NoopHandler/Geta.Plugins.NoopHandler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | AnyCPU 6 | ../libs 7 | {96949535-995A-4536-ADBA-F2D60D54B8D6} 8 | Library 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.NoopHandler 11 | Geta.Plugins.NoopHandler 12 | 512 13 | v4.7.2 14 | 15 | 16 | v3.5 17 | bin\2010\ 18 | EXCHANGE_2010;NET35 19 | 20 | 21 | bin\2016 RTM\ 22 | EXCHANGE_2016_RTM 23 | 24 | 25 | 26 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Common.dll 27 | 28 | 29 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Transport.dll 30 | 31 | 32 | ..\libs\System.ComponentModel.Composition.dll 33 | 34 | 35 | 36 | 37 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Common.dll 38 | 39 | 40 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Transport.dll 41 | 42 | 43 | 44 | 45 | 46 | ..\packages\Ninject.3.0.1.10\lib\net35\Ninject.dll 47 | 48 | 49 | ..\packages\Ninject.Extensions.Logging.3.0.1.0\lib\net35\Ninject.Extensions.Logging.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 69 | NeosIT.Exchange.GenericExchangeTransportAgent 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Geta.Plugins.ExecutableHandler/Geta.Plugins.ExecutableHandler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | AnyCPU 6 | ../libs 7 | {3395CD93-59E3-453A-8806-49F4DEF9E3B8} 8 | Library 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExecutableHandler 11 | Geta.Plugins.ExecutableHandler 12 | 512 13 | v4.7.2 14 | 15 | 16 | v3.5 17 | bin\2010\ 18 | EXCHANGE_2010;NET35 19 | 20 | 21 | bin\2016 RTM\ 22 | EXCHANGE_2016_RTM 23 | 24 | 25 | 26 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Common.dll 27 | 28 | 29 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Transport.dll 30 | 31 | 32 | ..\libs\System.ComponentModel.Composition.dll 33 | 34 | 35 | 36 | 37 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Common.dll 38 | 39 | 40 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Transport.dll 41 | 42 | 43 | 44 | 45 | 46 | ..\packages\Ninject.3.0.1.10\lib\net35\Ninject.dll 47 | 48 | 49 | ..\packages\Ninject.Extensions.Logging.3.0.1.0\lib\net35\Ninject.Extensions.Logging.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 69 | NeosIT.Exchange.GenericExchangeTransportAgent 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Geta.GuiApplication/Plugins/ExtractAttachmentConfigForm.designer.cs: -------------------------------------------------------------------------------- 1 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.GuiApplication.Plugins 2 | { 3 | partial class ExtractAttachmentConfigForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExtractAttachmentConfigForm)); 32 | this.SettingsDataGridView = new System.Windows.Forms.DataGridView(); 33 | this.SaveDialogButton = new System.Windows.Forms.Button(); 34 | this.CancelDialogButton = new System.Windows.Forms.Button(); 35 | this.SettingsLabel = new System.Windows.Forms.Label(); 36 | ((System.ComponentModel.ISupportInitialize)(this.SettingsDataGridView)).BeginInit(); 37 | this.SuspendLayout(); 38 | // 39 | // SettingsDataGridView 40 | // 41 | this.SettingsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 42 | resources.ApplyResources(this.SettingsDataGridView, "SettingsDataGridView"); 43 | this.SettingsDataGridView.Name = "SettingsDataGridView"; 44 | // 45 | // SaveDialogButton 46 | // 47 | resources.ApplyResources(this.SaveDialogButton, "SaveDialogButton"); 48 | this.SaveDialogButton.Name = "SaveDialogButton"; 49 | this.SaveDialogButton.UseVisualStyleBackColor = true; 50 | this.SaveDialogButton.Click += new System.EventHandler(this.SaveButtonClick); 51 | // 52 | // CancelDialogButton 53 | // 54 | resources.ApplyResources(this.CancelDialogButton, "CancelDialogButton"); 55 | this.CancelDialogButton.Name = "CancelDialogButton"; 56 | this.CancelDialogButton.UseVisualStyleBackColor = true; 57 | this.CancelDialogButton.Click += new System.EventHandler(this.CancelDialogButtonClick); 58 | // 59 | // SettingsLabel 60 | // 61 | resources.ApplyResources(this.SettingsLabel, "SettingsLabel"); 62 | this.SettingsLabel.Name = "SettingsLabel"; 63 | // 64 | // ExtractAttachmentConfigForm 65 | // 66 | resources.ApplyResources(this, "$this"); 67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 68 | this.Controls.Add(this.SettingsLabel); 69 | this.Controls.Add(this.CancelDialogButton); 70 | this.Controls.Add(this.SaveDialogButton); 71 | this.Controls.Add(this.SettingsDataGridView); 72 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 73 | this.Name = "ExtractAttachmentConfigForm"; 74 | this.Load += new System.EventHandler(this.ConfigFormLoad); 75 | ((System.ComponentModel.ISupportInitialize)(this.SettingsDataGridView)).EndInit(); 76 | this.ResumeLayout(false); 77 | this.PerformLayout(); 78 | 79 | } 80 | 81 | #endregion 82 | 83 | private System.Windows.Forms.DataGridView SettingsDataGridView; 84 | private System.Windows.Forms.Button SaveDialogButton; 85 | private System.Windows.Forms.Button CancelDialogButton; 86 | private System.Windows.Forms.Label SettingsLabel; 87 | } 88 | } -------------------------------------------------------------------------------- /Geta.Plugins.ExtractAttachmentHandler/Geta.Plugins.ExtractAttachmentHandler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | AnyCPU 6 | ../libs 7 | {085E66F6-6806-456E-A33C-5ED32D636EE6} 8 | Library 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.ExtractAttachmentHandler 11 | Geta.Plugins.ExtractAttachmentHandler 12 | 512 13 | v4.7.2 14 | 15 | 16 | v3.5 17 | bin\2010\ 18 | EXCHANGE_2010;NET35 19 | 20 | 21 | bin\2016 RTM\ 22 | EXCHANGE_2016_RTM 23 | 24 | 25 | 26 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Common.dll 27 | 28 | 29 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Transport.dll 30 | 31 | 32 | ..\libs\System.ComponentModel.Composition.dll 33 | 34 | 35 | 36 | 37 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Transport.dll 38 | 39 | 40 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Net.dll 41 | 42 | 43 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Common.IL.dll 44 | 45 | 46 | 47 | 48 | 49 | ..\packages\Ninject.3.0.1.10\lib\net35\Ninject.dll 50 | 51 | 52 | ..\packages\Ninject.Extensions.Logging.3.0.1.0\lib\net35\Ninject.Extensions.Logging.dll 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 72 | NeosIT.Exchange.GenericExchangeTransportAgent 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Geta/Impl/Agents/GenericRoutingAgent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Exchange.Data.Transport.Routing; 3 | using NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Config; 4 | using Ninject; 5 | using Ninject.Extensions.Logging; 6 | 7 | namespace NeosIT.Exchange.GenericExchangeTransportAgent.Impl.Agents 8 | { 9 | public class GenericRoutingAgent : RoutingAgent 10 | { 11 | public IKernel Kernel { get; internal set; } 12 | public ILogger Logger { get; internal set; } 13 | 14 | public GenericRoutingAgent() 15 | { 16 | Kernel = NInjectHelper.GetKernel(); 17 | Logger = Kernel.Get().GetCurrentClassLogger(); 18 | 19 | OnCategorizedMessage += OnCategorizedMessageHandler; 20 | OnResolvedMessage += OnResolvedMessageHandler; 21 | OnRoutedMessage += OnRoutedMessageHandler; 22 | OnSubmittedMessage += OnSubmittedMessageHandler; 23 | } 24 | 25 | private void OnCategorizedMessageHandler(CategorizedMessageEventSource source, QueuedMessageEventArgs e) 26 | { 27 | Logger.Debug("[GenericTransportAgent] RoutingAgent - OnCategorizedMessage fired..."); 28 | var emailItem = new EmailItem(e.MailItem); 29 | foreach(var x in Configuration.Config.RoutingAgentConfig.OnCategorizedMessage) 30 | { 31 | try 32 | { 33 | x.Execute(emailItem); 34 | } 35 | catch (Exception ex) 36 | { 37 | Logger.Error(ex, @"Error Executing ""OnCategorizedMessage"""); 38 | } 39 | } 40 | 41 | if (emailItem.ShouldBeDeletedFromQueue) 42 | { 43 | source.Delete(); 44 | } 45 | } 46 | 47 | private void OnResolvedMessageHandler(ResolvedMessageEventSource source, QueuedMessageEventArgs e) 48 | { 49 | Logger.Debug("[GenericTransportAgent] RoutingAgent - OnResolvedMessage fired..."); 50 | var emailItem = new EmailItem(e.MailItem); 51 | foreach (var x in Configuration.Config.RoutingAgentConfig.OnResolvedMessage) 52 | { 53 | try 54 | { 55 | x.Execute(emailItem); 56 | } 57 | catch (Exception ex) 58 | { 59 | Logger.Error(ex, @"Error Executing ""OnResolvedMessage"""); 60 | } 61 | } 62 | 63 | if (emailItem.ShouldBeDeletedFromQueue) 64 | { 65 | source.Delete(); 66 | } 67 | } 68 | 69 | private void OnRoutedMessageHandler(RoutedMessageEventSource source, QueuedMessageEventArgs e) 70 | { 71 | Logger.Debug("[GenericTransportAgent] RoutingAgent - OnRoutedMessage fired..."); 72 | var emailItem = new EmailItem(e.MailItem); 73 | foreach (var x in Configuration.Config.RoutingAgentConfig.OnRoutedMessage) 74 | { 75 | try 76 | { 77 | x.Execute(emailItem); 78 | } 79 | catch (Exception ex) 80 | { 81 | Logger.Error(ex, @"Error Executing ""OnRoutedMessage"""); 82 | } 83 | } 84 | 85 | if (emailItem.ShouldBeDeletedFromQueue) 86 | { 87 | source.Delete(); 88 | } 89 | } 90 | 91 | private void OnSubmittedMessageHandler(SubmittedMessageEventSource source, QueuedMessageEventArgs e) 92 | { 93 | Logger.Debug("[GenericTransportAgent] RoutingAgent - OnSubmittedMessage fired..."); 94 | var emailItem = new EmailItem(e.MailItem); 95 | foreach (var x in Configuration.Config.RoutingAgentConfig.OnSubmittedMessage) 96 | { 97 | try 98 | { 99 | x.Execute(emailItem); 100 | } 101 | catch (Exception ex) 102 | { 103 | Logger.Error(ex, @"Error Executing ""OnSubmittedMessage"""); 104 | } 105 | } 106 | 107 | if (emailItem.ShouldBeDeletedFromQueue) 108 | { 109 | source.Delete(); 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /Geta.Plugins.TwitterNotificationHandler/Geta.Plugins.TwitterNotificationHandler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2016 RTM 5 | AnyCPU 6 | ../libs 7 | {A5486C2F-19D1-4C91-B0AD-7E3BFAE2D259} 8 | Library 9 | Properties 10 | NeosIT.Exchange.GenericExchangeTransportAgent.Plugins.TwitterNotificationHandler 11 | Geta.Plugins.TwitterNotificationHandler 12 | 512 13 | v4.7.2 14 | 15 | 16 | v3.5 17 | bin\2010\ 18 | EXCHANGE_2010;NET35 19 | 20 | 21 | bin\2016 RTM\ 22 | EXCHANGE_2016_RTM 23 | 24 | 25 | 26 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Common.dll 27 | 28 | 29 | $(ExchangeLibrariesPath)\Exchange 2010\Microsoft.Exchange.Data.Transport.dll 30 | 31 | 32 | ..\libs\System.ComponentModel.Composition.dll 33 | 34 | 35 | 36 | 37 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Common.dll 38 | 39 | 40 | $(ExchangeLibrariesPath)\Exchange 2016 RTM\Microsoft.Exchange.Data.Transport.dll 41 | 42 | 43 | 44 | 45 | 46 | ..\libs\Newtonsoft.Json.dll 47 | 48 | 49 | ..\libs\Twitterizer2.dll 50 | 51 | 52 | ..\packages\Ninject.3.0.2-unstable-9037\lib\net35\Ninject.dll 53 | 54 | 55 | ..\packages\Ninject.Extensions.Logging.3.0.1.0\lib\net35\Ninject.Extensions.Logging.dll 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | {BBEA07C8-5924-4A67-8A03-9E6459A66E68} 76 | NeosIT.Exchange.GenericExchangeTransportAgent 77 | 78 | 79 | 80 | 81 | --------------------------------------------------------------------------------