Skip to content

Commit

Permalink
Merge branch 'next' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Flozi95 authored Aug 31, 2017
2 parents ccb1717 + 593ed7a commit b38b9d7
Show file tree
Hide file tree
Showing 211 changed files with 17,091 additions and 5,210 deletions.
10 changes: 8 additions & 2 deletions AlarmSources/AlarmSources.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fax", "Fax\Fax.csproj", "{32F1988F-1EBF-476E-A882-A7145267C5DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sms", "Sms\Sms.csproj", "{F8AB12D3-A2D6-4208-8029-8C51BE8BC203}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail", "Mail\Mail.csproj", "{02413C11-2F8A-404E-9D66-40AE7ED13283}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Network", "Network\Network.csproj", "{58E3F6F2-3020-4239-B674-E9A41B9015BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{02413C11-2F8A-404E-9D66-40AE7ED13283}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02413C11-2F8A-404E-9D66-40AE7ED13283}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02413C11-2F8A-404E-9D66-40AE7ED13283}.Release|Any CPU.Build.0 = Release|Any CPU
{58E3F6F2-3020-4239-B674-E9A41B9015BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{58E3F6F2-3020-4239-B674-E9A41B9015BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58E3F6F2-3020-4239-B674-E9A41B9015BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58E3F6F2-3020-4239-B674-E9A41B9015BE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
30 changes: 6 additions & 24 deletions AlarmSources/Fax/FaxConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,17 @@ sealed class FaxConfiguration : DisposableObject, INotifyPropertyChanged

#region Properties

internal string FaxPath
{
get { return _settings.GetSetting(FaxSettingKeys.FaxPath).GetValue<string>(); }
}
internal string FaxPath => _settings.GetSetting(FaxSettingKeys.FaxPath).GetValue<string>();

internal string ArchivePath
{
get { return _settings.GetSetting(FaxSettingKeys.ArchivePath).GetValue<string>(); }
}
internal string ArchivePath => _settings.GetSetting(FaxSettingKeys.ArchivePath).GetValue<string>();

internal string AnalysisPath
{
get { return _settings.GetSetting(FaxSettingKeys.AnalysisPath).GetValue<string>(); }
}
internal string AnalysisPath => _settings.GetSetting(FaxSettingKeys.AnalysisPath).GetValue<string>();

internal string OCRSoftwarePath
{
get { return _settings.GetSetting(FaxSettingKeys.OcrPath).GetValue<string>(); }
}
internal string OCRSoftwarePath => _settings.GetSetting(FaxSettingKeys.OcrPath).GetValue<string>();

internal string AlarmFaxParserAlias
{
get { return _settings.GetSetting(FaxSettingKeys.AlarmFaxParserAlias).GetValue<string>(); }
}
internal string AlarmFaxParserAlias => _settings.GetSetting(FaxSettingKeys.AlarmFaxParserAlias).GetValue<string>();

internal ReplaceDictionary ReplaceDictionary
{
get { return _settings.GetSetting(SettingKeys.ReplaceDictionary).GetValue<ReplaceDictionary>(); }
}
internal ReplaceDictionary ReplaceDictionary => _settings.GetSetting(SettingKeys.ReplaceDictionary).GetValue<ReplaceDictionary>();

#endregion

Expand Down
24 changes: 23 additions & 1 deletion AlarmSources/Fax/OcrSoftware/TesseractOcrSoftware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,43 @@
using System.IO;
using AlarmWorkflow.AlarmSource.Fax.Extensibility;
using AlarmWorkflow.Shared.Core;
using System;
using AlarmWorkflow.Shared.Diagnostics;

namespace AlarmWorkflow.AlarmSource.Fax.OcrSoftware
{
class TesseractOcrSoftware : IOcrSoftware
{

#region Constants

private const string EnvTessdata = "TESSDATA_PREFIX";

#endregion

#region IOcrSoftware Members

string[] IOcrSoftware.ProcessImage(OcrProcessOptions options)
{
using (ProcessWrapper proc = new ProcessWrapper())
{
string tesseractPath = Path.Combine(Utilities.GetWorkingDirectory(), "tesseract");

try
{
Environment.SetEnvironmentVariable(EnvTessdata, tesseractPath);
}
catch (Exception ex)
{
Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.OcrSoftwareTesseractError);
Logger.Instance.LogException(this, ex);
}


// If there is no custom directory
if (string.IsNullOrEmpty(options.SoftwarePath))
{
proc.WorkingDirectory = Path.Combine(Utilities.GetWorkingDirectory(), "tesseract");
proc.WorkingDirectory = tesseractPath;
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions AlarmSources/Fax/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AlarmSources/Fax/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,7 @@
<value>Unable to access fax source directory '{0}'
{1}</value>
</data>
<data name="OcrSoftwareTesseractError" xml:space="preserve">
<value>Error set tesseract environment variable: {0}</value>
</data>
</root>
15 changes: 6 additions & 9 deletions AlarmSources/Mail/Mail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@
<Reference Include="AlarmWorkflow.BackendService.SettingsContracts">
<HintPath>..\..\Build\AlarmWorkflow.BackendService.SettingsContracts.dll</HintPath>
</Reference>
<Reference Include="BouncyCastle, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>..\packages\MimeKit.1.2.22\lib\net45\BouncyCastle.dll</HintPath>
<Private>True</Private>
<Reference Include="BouncyCastle.Crypto">
<HintPath>..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="MailKit, Version=1.2.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b, processorArchitecture=MSIL">
<HintPath>..\packages\MailKit.1.2.21\lib\net451\MailKit.dll</HintPath>
<Private>True</Private>
<Reference Include="MailKit">
<HintPath>..\packages\MailKit.1.4.1\lib\net451\MailKit.dll</HintPath>
</Reference>
<Reference Include="MimeKit, Version=1.2.0.0, Culture=neutral, PublicKeyToken=bede1c8a46c66814, processorArchitecture=MSIL">
<HintPath>..\packages\MimeKit.1.2.22\lib\net45\MimeKit.dll</HintPath>
<Private>True</Private>
<Reference Include="MimeKit">
<HintPath>..\packages\MimeKit.1.4.1\lib\net451\MimeKit.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
16 changes: 8 additions & 8 deletions AlarmSources/Mail/MailAlarmSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using AlarmWorkflow.Shared.Core;
using AlarmWorkflow.Shared.Diagnostics;
using AlarmWorkflow.Shared.Extensibility;
using AlarmWorkflow.Shared.Specialized;
using MailKit;
using MailKit.Net.Imap;
using MailKit.Search;
Expand Down Expand Up @@ -90,11 +91,7 @@ void IAlarmSource.RunThread()

private void OnNewAlarm(Operation operation)
{
var copy = NewAlarm;
if (copy != null)
{
copy(this, new AlarmSourceEventArgs(operation));
}
NewAlarm?.Invoke(this, new AlarmSourceEventArgs(operation));
}

#endregion
Expand Down Expand Up @@ -155,12 +152,15 @@ private void ProcessMail(MimeMessage message)
string[] lines = (_configuration.AnalyzeAttachment) ? AnalyzeAttachment(message) : AnalyzeBody(message);
if (lines != null)
{
if (!_serviceProvider.GetService<IAlarmFilter>().QueryAcceptSource(string.Join(" ", lines)))

ReplaceDictionary replDict = _configuration.ReplaceDictionary;

string[] analyzedLines = lines.Select(preParsedLine => replDict.ReplaceInString(preParsedLine)).ToArray();
if (!_serviceProvider.GetService<IAlarmFilter>().QueryAcceptSource(string.Join(" ", analyzedLines)))
{
return;
}

Operation operation = _mailParser.Parse(lines);
Operation operation = _mailParser.Parse(analyzedLines);
OnNewAlarm(operation);
}
}
Expand Down
67 changes: 23 additions & 44 deletions AlarmSources/Mail/MailConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
using System.IO;
using System.Text;
using AlarmWorkflow.BackendService.SettingsContracts;
using AlarmWorkflow.Shared;
using AlarmWorkflow.Shared.Core;
using AlarmWorkflow.Shared.Specialized;

namespace AlarmWorkflow.AlarmSource.Mail
{
Expand All @@ -31,52 +33,29 @@ sealed class MailConfiguration : DisposableObject

#region Properties

internal string ServerName
{
get { return _settings.GetSetting("MailAlarmSource", "ServerName").GetValue<string>(); }
}
internal int Port
{
get { return _settings.GetSetting("MailAlarmSource", "Port").GetValue<int>(); }
}
internal string UserName
{
get { return _settings.GetSetting("MailAlarmSource", "UserName").GetValue<string>(); }
}
internal string Password
{
get { return _settings.GetSetting("MailAlarmSource", "Password").GetValue<string>(); }
}
internal bool SSL
{
get { return _settings.GetSetting("MailAlarmSource", "SSL").GetValue<bool>(); }
}
internal string ServerName => _settings.GetSetting("MailAlarmSource", "ServerName").GetValue<string>();

internal string MailSubject
{
get { return _settings.GetSetting("MailAlarmSource", "MailSubject").GetValue<string>(); }
}
internal string MailSender
{
get { return _settings.GetSetting("MailAlarmSource", "MailSender").GetValue<string>(); }
}
internal int Port => _settings.GetSetting("MailAlarmSource", "Port").GetValue<int>();

internal bool AnalyzeAttachment
{
get { return _settings.GetSetting("MailAlarmSource", "AnalyseAttachment").GetValue<bool>(); }
}
internal string AttachmentName
{
get { return _settings.GetSetting("MailAlarmSource", "AttachmentName").GetValue<string>(); }
}
internal string ParserAlias
{
get { return _settings.GetSetting("MailAlarmSource", "MailParser").GetValue<string>(); }
}
internal Encoding Encoding
{
get { return GetEncodingFromSettings(); }
}
internal string UserName => _settings.GetSetting("MailAlarmSource", "UserName").GetValue<string>();

internal string Password => _settings.GetSetting("MailAlarmSource", "Password").GetValue<string>();

internal bool SSL => _settings.GetSetting("MailAlarmSource", "SSL").GetValue<bool>();

internal string MailSubject => _settings.GetSetting("MailAlarmSource", "MailSubject").GetValue<string>();

internal string MailSender => _settings.GetSetting("MailAlarmSource", "MailSender").GetValue<string>();

internal bool AnalyzeAttachment => _settings.GetSetting("MailAlarmSource", "AnalyseAttachment").GetValue<bool>();

internal string AttachmentName => _settings.GetSetting("MailAlarmSource", "AttachmentName").GetValue<string>();

internal ReplaceDictionary ReplaceDictionary => _settings.GetSetting(SettingKeys.ReplaceDictionary).GetValue<ReplaceDictionary>();

internal string ParserAlias => _settings.GetSetting("MailAlarmSource", "MailParser").GetValue<string>();

internal Encoding Encoding => GetEncodingFromSettings();

#endregion

Expand Down
5 changes: 3 additions & 2 deletions AlarmSources/Mail/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MailKit" version="1.2.21" targetFramework="net46" />
<package id="MimeKit" version="1.2.22" targetFramework="net46" />
<package id="BouncyCastle" version="1.8.1" targetFramework="net46" />
<package id="MailKit" version="1.4.1" targetFramework="net46" />
<package id="MimeKit" version="1.4.1" targetFramework="net46" />
</packages>
87 changes: 87 additions & 0 deletions AlarmSources/Network/Network.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{58E3F6F2-3020-4239-B674-E9A41B9015BE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AlarmWorkflow.AlarmSource.Network</RootNamespace>
<AssemblyName>AlarmWorkflow.AlarmSource.Network</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AlarmWorkflow.Backend.ServiceContracts">
<HintPath>..\..\Build\AlarmWorkflow.Backend.ServiceContracts.dll</HintPath>
</Reference>
<Reference Include="AlarmWorkflow.BackendService.EngineContracts">
<HintPath>..\..\Build\AlarmWorkflow.BackendService.EngineContracts.dll</HintPath>
</Reference>
<Reference Include="AlarmWorkflow.BackendService.SettingsContracts">
<HintPath>..\..\Build\AlarmWorkflow.BackendService.SettingsContracts.dll</HintPath>
</Reference>
<Reference Include="AlarmWorkflow.Shared">
<HintPath>..\..\Build\AlarmWorkflow.Shared.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="NetworkAlarmSource.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NetworkSettingKeys.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Server\AlarmServer.cs" />
<Compile Include="Server\HandleAlarmClient.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="settings.info.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="settings.xml" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit b38b9d7

Please sign in to comment.