public LoggingServiceThreadList(ChildProcessTrackerWrapper childProcessTracker, ProcessWrapperFactory processFactory, IJobConfig jobConfig)
     : base(jobConfig)
 {
     _childProcessTracker = childProcessTracker;
     _processFactory      = processFactory;
     _jobConfig           = jobConfig;
 }
Example #2
0
        public static StartupConfiguration GetStartupConfiguration(IServerEnvironmentPreparer serverEnvironmentPreparer)
        {
            var writer = new Writer();

            var childProcessTracker = new ChildProcessTrackerWrapper();
            var processFactory      = new ProcessWrapperFactory();

            return(new StartupConfiguration
            {
                ServerEnvironmentPreparer = serverEnvironmentPreparer,
                IpcClient = new IpcClientImpl(new NamedPipeClientStreamWrapper(".", Guid.NewGuid().ToString(), System.IO.Pipes.PipeDirection.InOut)),
                AssemblyLoader = new AssemblyLoader(),
                Directory = new DirectoryWrapper(),
                ResourceCatalogFactory = new ResourceCatalogFactory(),
                WebServerConfiguration = new WebServerConfiguration(writer, new FileWrapper()),
                Writer = writer,
                StartWebServer = new StartWebServer(writer, WebServerStartup.Start),
                SecurityIdentityFactory = new SecurityIdentityFactoryForWindows(),
                QueueWorkerMonitor = new QueueWorkerMonitor(processFactory, new QueueWorkerConfigLoader(), TriggersCatalog.Instance, childProcessTracker),
                LoggingServiceMonitor = new LoggingServiceMonitorWithRestart(childProcessTracker, processFactory),
                HangfireServerMonitor = new HangfireServerMonitorWithRestart(childProcessTracker, processFactory),
                WebSocketPool = new WebSocketPool(),
                LoggerFactory = new ExecutionLogger.ExecutionLoggerFactory(),
                SystemInformationHelper = new GetSystemInformationHelper()
            });
        }
Example #3
0
        public void ProcessWrapperFactory_WithProcessStartInfo_WrapsProcessWithSameStartupInfo()
        {
            var processWrapperFactory = new ProcessWrapperFactory();
            var processStartInfo      = new ProcessStartInfo();

            var process = processWrapperFactory.BuildProcessWrapper(processStartInfo);

            Assert.AreSame(processStartInfo, process.StartInfo);
        }
Example #4
0
        /// <summary>
        ///     Prints the file.
        /// </summary>
        /// <param name="processTimeout">The timespan to wait for the process to finish</param>
        /// <returns>true, if printing was successful</returns>
        public bool Print(TimeSpan processTimeout)
        {
            if (CommandType == PrintType.Unprintable)
            {
                throw new InvalidOperationException("File is not printable");
            }

            var printerHelper = new PrinterHelper();

            if (CommandType == PrintType.Print && Printer != printerHelper.GetDefaultPrinter())
            {
                throw new InvalidOperationException("The default printer needs to be set in order to print this file");
            }

            var p = ProcessWrapperFactory.BuildProcessWrapper(new ProcessStartInfo());

            var verb = SupportsPrintTo()
                ? "printto"
                : "print";

            var command   = GetCommand(verb);
            var arguments = SupportsPrintTo()
                ? command.GetReplacedCommandArgs(Filename, Printer)
                : command.GetReplacedCommandArgs(Filename);

            p.StartInfo.FileName  = command.Command;
            p.StartInfo.Arguments = arguments;

            Logger.Debug($"Launching {verb} for \"{Filename}\": {command.Command} {arguments}");

            try
            {
                p.Start();
                p.WaitForExit(processTimeout);

                if (!p.HasExited)
                {
                    Logger.Warn("Process was not finishing after {0} seconds, killing it now...", processTimeout.TotalSeconds);
                    p.Kill();
                }
                else
                {
                    Successful = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Exception during printing"
                             + "\r\nType: " + ex.GetType()
                             + "\r\nMessage: " + ex.Message
                             );
                return(false);
            }

            return(Successful);
        }
        /// <summary>
        ///     Prints the file.
        /// </summary>
        /// <param name="processTimeout">The timespan to wait for the process to finish</param>
        /// <returns>true, if printing was successful</returns>
        public bool Print(TimeSpan processTimeout)
        {
            if (CommandType == PrintType.Unprintable)
            {
                throw new InvalidOperationException("File is not printable");
            }

            var printerHelper = new PrinterHelper();

            if (CommandType == PrintType.Print && Printer != printerHelper.GetDefaultPrinter())
            {
                throw new InvalidOperationException("The default printer needs to be set in order to print this file");
            }

            var p = ProcessWrapperFactory.BuildProcessWrapper(new ProcessStartInfo(Filename));

            if (SupportsPrintTo())
            {
                Logger.Debug("Launch PrintTo for \"" + Filename + "\"");
                p.StartInfo.Verb      = "Printto";
                p.StartInfo.Arguments = "\"" + Printer + "\"";
            }
            else
            {
                Logger.Debug("Launch Print for \"" + Filename + "\"");
                p.StartInfo.Verb = "Print";
            }

            try
            {
                p.Start();
                p.WaitForExit(processTimeout);

                if (!p.HasExited)
                {
                    Logger.Warn("Process was not finishing after {0} seconds, killing it now...", processTimeout.TotalSeconds);
                    p.Kill();
                }
                else
                {
                    Successful = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Exception during printing"
                             + "\r\nType: " + ex.GetType()
                             + "\r\nMessage: " + ex.Message
                             );
                return(false);
            }

            return(Successful);
        }
Example #6
0
        public void ProcessWrapperFactory_GetNewProcessWrapper_Returns_New_Instance_Of_ProcessWrapper()
        {
            // Arrange
            var sut = new ProcessWrapperFactory();

            // Act
            IProcessWrapper processWrapper = sut.GetNewProcessWrapper();

            // Assert
            Assert.IsNotNull(processWrapper);
            Assert.IsInstanceOfType(processWrapper, typeof(ProcessWrapper));
        }
Example #7
0
        public void ProcessWrapperFactory_GetNewProcessWrapper_Returns_Unique_Instance_Of_ProcessWrapper()
        {
            // Arrange
            var sut = new ProcessWrapperFactory();

            // Act
            IProcessWrapper processWrapper1 = sut.GetNewProcessWrapper();
            IProcessWrapper processWrapper2 = sut.GetNewProcessWrapper();

            // Assert
            Assert.IsNotNull(processWrapper1);
            Assert.IsNotNull(processWrapper2);
            Assert.AreNotSame(processWrapper1, processWrapper2);
        }
 public LanDiscoveryManager()
 {
     comparator_m            = new LanMachineIdentityComparator();
     processWrapperFactory_m = new ProcessWrapperFactory();
     networkInterfaceProxy_m = new NetworkInterfaceProxy();
 } // end method
 public LoggingServiceMonitorWithRestart(ChildProcessTrackerWrapper childProcessTracker, ProcessWrapperFactory processFactory)
 {
     _childProcessTracker = childProcessTracker;
     _processFactory      = processFactory;
 }