Changed project names
This commit is contained in:
parent
b4c4aa4010
commit
a29e57e66d
130 changed files with 501 additions and 504 deletions
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D66F55E5-B3F7-4C61-A4F2-B55C4D412E01}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AmagnoVirtualPrinter.ProgressInfo.Lib</RootNamespace>
|
||||
<AssemblyName>AmagnoVirtualPrinter.ProgressInfo.Lib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Files\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Interfaces\IProgressInfoProcessManager.cs" />
|
||||
<Compile Include="Interfaces\IProgressInfoServer.cs" />
|
||||
<Compile Include="Interfaces\IProgressInfoServerFactory.cs" />
|
||||
<Compile Include="Message\MessageFactory.cs" />
|
||||
<Compile Include="ProgressInfoBroker.cs" />
|
||||
<Compile Include="ProgressInfoProcessManager.cs" />
|
||||
<Compile Include="ProgressInfoServer.cs" />
|
||||
<Compile Include="ProgressInfoServerFactory.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\AmagnoVirtualPrinter.Agent.Core\AmagnoVirtualPrinter.Agent.Core.csproj">
|
||||
<Project>{135c85eb-2116-4cc4-8ccb-b6804b9d6467}</Project>
|
||||
<Name>AmagnoVirtualPrinter.Agent.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\AmagnoVirtualPrinter.Agent.Lib\AmagnoVirtualPrinter.Agent.Lib.csproj">
|
||||
<Project>{94e8105f-5001-403b-b9f1-b0b0b236ad65}</Project>
|
||||
<Name>AmagnoVirtualPrinter.Agent.Lib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\AmagnoVirtualPrinter.Logging\AmagnoVirtualPrinter.Logging.csproj">
|
||||
<Project>{aa25364d-22d5-44b0-86a5-6fb14c686308}</Project>
|
||||
<Name>AmagnoVirtualPrinter.Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\AmagnoVirtualPrinter.Utils\AmagnoVirtualPrinter.Utils.csproj">
|
||||
<Project>{cd1c8e9d-5335-41ac-b0c0-88fd7c7c55f3}</Project>
|
||||
<Name>AmagnoVirtualPrinter.Utils</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\AmagnoVirtualPrinter.ProgressInfo.Core\AmagnoVirtualPrinter.ProgressInfo.Core.csproj">
|
||||
<Project>{24d28558-c825-43e6-85d2-7c59f4a97698}</Project>
|
||||
<Name>AmagnoVirtualPrinter.ProgressInfo.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
<PackageReference Include="NamedPipeWrapper" Version="1.5.3-Beta" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using AmagnoVirtualPrinter.Agent.Core.Interfaces;
|
||||
using AmagnoVirtualPrinter.Agent.Core;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces
|
||||
{
|
||||
public interface IProgressInfoProcessManager
|
||||
{
|
||||
bool IsRunning();
|
||||
|
||||
void Run(IJob job);
|
||||
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
using NamedPipeWrapper;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces
|
||||
{
|
||||
public interface IProgressInfoServer
|
||||
{
|
||||
[CanBeNull]
|
||||
event ConnectionEventHandler<Core.Message.Message, Core.Message.Message> ClientConnected;
|
||||
|
||||
void PushMessage([NotNull] Core.Message.Message message);
|
||||
|
||||
void Start();
|
||||
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces
|
||||
{
|
||||
public interface IProgressInfoServerFactory
|
||||
{
|
||||
IProgressInfoServer Create();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Core.Message;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib.Message
|
||||
{
|
||||
public class MessageFactory : IMessageFactory
|
||||
{
|
||||
[NotNull]
|
||||
private readonly Func<MessageType, uint, Core.Message.Message> _factory;
|
||||
|
||||
public MessageFactory([NotNull]Func<MessageType, uint, Core.Message.Message> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public Core.Message.Message CreateStart()
|
||||
{
|
||||
return _factory(MessageType.Initialize, 0);
|
||||
}
|
||||
|
||||
public Core.Message.Message CreateStep(uint val)
|
||||
{
|
||||
return _factory(MessageType.Step, val);
|
||||
}
|
||||
|
||||
public Core.Message.Message CreateFinal()
|
||||
{
|
||||
return _factory(MessageType.Finalize, 0);
|
||||
}
|
||||
|
||||
public Core.Message.Message CreateClose()
|
||||
{
|
||||
return _factory(MessageType.Close, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using AmagnoVirtualPrinter.Agent.Core.Interfaces;
|
||||
using AmagnoVirtualPrinter.Logging;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Core;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Core.Message;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using NamedPipeWrapper;
|
||||
|
||||
using AmagnoVirtualPrinter.Agent.Core;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib
|
||||
{
|
||||
public class ProgressInfoBroker : IProgressInfo, IDisposable
|
||||
{
|
||||
[NotNull]
|
||||
private readonly IVirtualPrinterLogger<ProgressInfoBroker> _logger;
|
||||
|
||||
[NotNull]
|
||||
private readonly IMessageFactory _messageFactory;
|
||||
|
||||
[NotNull]
|
||||
private readonly IProgressInfoServer _progressInfoServer;
|
||||
|
||||
[NotNull]
|
||||
private readonly IProgressInfoProcessManager _progressInfoProcessManager;
|
||||
|
||||
public ProgressInfoBroker
|
||||
(
|
||||
[NotNull]IVirtualPrinterLogger<ProgressInfoBroker> logger,
|
||||
[NotNull]IMessageFactory messageFactory,
|
||||
[NotNull]IProgressInfoServerFactory progressInfoServerFactory,
|
||||
[NotNull]IProgressInfoProcessManager progressProcessManager
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageFactory = messageFactory;
|
||||
_progressInfoProcessManager = progressProcessManager;
|
||||
|
||||
_progressInfoServer = progressInfoServerFactory.Create();
|
||||
_progressInfoServer.ClientConnected += ServerOnClientConnected;
|
||||
_progressInfoServer.Start();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_progressInfoProcessManager.Stop();
|
||||
_progressInfoServer.Stop();
|
||||
}
|
||||
|
||||
public void Progress(IJob job, uint val)
|
||||
{
|
||||
StartProgressAgentIfNotRunning(job);
|
||||
_progressInfoServer.PushMessage(_messageFactory.CreateStep(val));
|
||||
}
|
||||
|
||||
public void Initialize(IJob job)
|
||||
{
|
||||
StartProgressAgentIfNotRunning(job);
|
||||
_progressInfoServer.PushMessage(_messageFactory.CreateStart());
|
||||
}
|
||||
|
||||
public void Finish(IJob job)
|
||||
{
|
||||
_progressInfoServer.PushMessage(_messageFactory.CreateFinal());
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void ServerOnClientConnected(NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection)
|
||||
{
|
||||
LogDebug("New Progress Client connected");
|
||||
}
|
||||
|
||||
private void StartProgressAgentIfNotRunning(IJob job)
|
||||
{
|
||||
if(!_progressInfoProcessManager.IsRunning())
|
||||
{
|
||||
_progressInfoProcessManager.Run(job);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogDebug(string message, params object[] args)
|
||||
{
|
||||
_logger.Debug(message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using AmagnoVirtualPrinter.Agent.Core.Interfaces;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces;
|
||||
using AmagnoVirtualPrinter.Utils;
|
||||
using AmagnoVirtualPrinter.Agent.Core;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ProgressInfoProcessManager : IProgressInfoProcessManager
|
||||
{
|
||||
private const string ProcessName = "VPDAgentProgress";
|
||||
|
||||
public bool IsRunning()
|
||||
{
|
||||
return Process.GetProcesses().Any(pList => pList.ProcessName.Contains(ProcessName));
|
||||
}
|
||||
|
||||
public void Run([NotNull]IJob job)
|
||||
{
|
||||
if (job == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(job));
|
||||
}
|
||||
|
||||
var path = Path.GetDirectoryName(typeof(ProgressInfoProcessManager).Assembly.Location);
|
||||
var file = Path.Combine(path, ProcessName + ".exe");
|
||||
new Shell().Execute(job.JobInfo, job.SessionInfo, file, null);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
var processes = Process.GetProcesses().Where(pList => pList.ProcessName.Contains(ProcessName));
|
||||
|
||||
foreach(var process in processes)
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using NamedPipeWrapper;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ProgressInfoServer : IProgressInfoServer
|
||||
{
|
||||
[NotNull]
|
||||
private readonly NamedPipeServer<Core.Message.Message> _server;
|
||||
|
||||
public ProgressInfoServer([NotNull] NamedPipeServer<Core.Message.Message> server)
|
||||
{
|
||||
_server = server;
|
||||
_server.ClientConnected += ServerOnClientConnected;
|
||||
}
|
||||
|
||||
public event ConnectionEventHandler<Core.Message.Message, Core.Message.Message> ClientConnected;
|
||||
|
||||
private void ServerOnClientConnected([CanBeNull] NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection) => ClientConnected?.Invoke(connection);
|
||||
|
||||
public void PushMessage([CanBeNull] Core.Message.Message message)
|
||||
{
|
||||
_server.PushMessage(message);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_server.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_server.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.IO.Pipes;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using AmagnoVirtualPrinter.ProgressInfo.Lib.Interfaces;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
using NamedPipeWrapper;
|
||||
|
||||
namespace AmagnoVirtualPrinter.ProgressInfo.Lib
|
||||
{
|
||||
public class ProgressInfoServerFactory : IProgressInfoServerFactory
|
||||
{
|
||||
private const string PipeName = "vdpagent";
|
||||
|
||||
[NotNull]
|
||||
private readonly Func<NamedPipeServer<Core.Message.Message>, IProgressInfoServer> _factorInfoServer;
|
||||
|
||||
public ProgressInfoServerFactory
|
||||
(
|
||||
[NotNull]Func<NamedPipeServer<Core.Message.Message>, IProgressInfoServer> factorInfoServer
|
||||
)
|
||||
{
|
||||
_factorInfoServer = factorInfoServer;
|
||||
}
|
||||
|
||||
public IProgressInfoServer Create()
|
||||
{
|
||||
var namedPipeServer = new NamedPipeServer<Core.Message.Message>(PipeName, GetPipeSecurity());
|
||||
|
||||
return _factorInfoServer(namedPipeServer);
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
private static PipeSecurity GetPipeSecurity()
|
||||
{
|
||||
var security = new PipeSecurity();
|
||||
|
||||
security.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
|
||||
security.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), PipeAccessRights.FullControl, AccessControlType.Allow));
|
||||
|
||||
return security;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("AmagnoVirtualPrinter.ProgressInfo.Lib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Amagno")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("d66f55e5-b3f7-4c61-a4f2-b55c4d412e01")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// indem Sie "*" wie unten gezeigt eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Loading…
Add table
Add a link
Reference in a new issue