예제 #1
0
        public ServiceBase(IServiceStartInfo startInfo)
        {
            this.StartInfo = startInfo;
            this.Log       = new Logger(startInfo.Name, startInfo.EnableLog);

            this.InnerThread = new Thread(new ThreadStart(this.ThreadProc));
            this.InnerThread.IsBackground = true;
            this.IsRunning = false;
        }
예제 #2
0
        public ServiceBase(IServiceStartInfo startInfo)
        {
            this.StartInfo = startInfo;
            this.Log = new Logger(startInfo.Name, startInfo.EnableLog);

            this.InnerThread = new Thread(new ThreadStart(this.ThreadProc));
            this.InnerThread.IsBackground = true;

            this.IsRunning = false;
        }
예제 #3
0
        public LaunchService(IServiceStartInfo startInfo)
            : base(startInfo)
        {
            this.InnerProcess = new Process();
            this.InnerProcess.StartInfo.UseShellExecute = startInfo.UseShellExecute;

            this.InnerProcess.StartInfo.FileName = startInfo.Command;
            this.InnerProcess.StartInfo.Arguments = startInfo.Arguments;
            this.InnerProcess.StartInfo.WorkingDirectory = startInfo.WorkingDirectory;
            this.Log.Info("InnerProcess is created");

            this.ResolveProcessBeforeStart(this.InnerProcess);
        }
예제 #4
0
        public IntervalService(IServiceStartInfo startInfo)
            : base(startInfo)
        {
            this.InnerProcess = new Process();
            this.InnerProcess.StartInfo.UseShellExecute = startInfo.UseShellExecute;

            this.InnerProcess.StartInfo.FileName         = startInfo.Command;
            this.InnerProcess.StartInfo.Arguments        = startInfo.Arguments;
            this.InnerProcess.StartInfo.WorkingDirectory = startInfo.WorkingDirectory;
            this.Log.Info("InnerProcess is created");

            this.ResolveProcessBeforeStart(this.InnerProcess);
        }
예제 #5
0
        public IService Create(IServiceStartInfo startInfo)
        {
            switch (startInfo.RunMode)
            {
                case ServiceRunMode.Daemon:
                    return new DaemonService(startInfo) as IService;
                case ServiceRunMode.Launch:
                    return new LaunchService(startInfo) as IService;
                case ServiceRunMode.Interval:
                    return new IntervalService(startInfo) as IService;

                default:
                    throw new ArgumentOutOfRangeException("runMode");
            }
        }
예제 #6
0
        public IService Create(IServiceStartInfo startInfo)
        {
            switch (startInfo.RunMode)
            {
            case ServiceRunMode.Launch:
                return(new LaunchService(startInfo) as IService);

            case ServiceRunMode.Interval:
                return(new IntervalService(startInfo) as IService);

            case ServiceRunMode.Daemon:
            default:
                return(new DaemonService(startInfo) as IService);
            }
        }
예제 #7
0
        public ServiceBase(IServiceStartInfo startInfo)
        {
            this.StartInfo = startInfo;
            this.Log       = new Logger(startInfo.Name, startInfo.EnableLog);

            this.InnerThread = new Thread(new ThreadStart(this.ThreadProc));
            this.InnerThread.IsBackground = true;
            this.IsRunning = false;

            if (startInfo.KillExistingProcess)
            {
                Process.GetProcesses().Where(p => this.TryMatchProcess(p, startInfo.Command))
                .ToList()
                .ForEach(p => this.TryKillProcess(p));
            }
        }
예제 #8
0
        public IService Create(IServiceStartInfo startInfo)
        {
            switch (startInfo.RunMode)
            {
            case ServiceRunMode.Daemon:
                return(new DaemonService(startInfo) as IService);

            case ServiceRunMode.Launch:
                return(new LaunchService(startInfo) as IService);

            case ServiceRunMode.Interval:
                return(new IntervalService(startInfo) as IService);

            default:
                throw new ArgumentOutOfRangeException("runMode");
            }
        }
        public bool StartCaptureService(IServiceStartInfo startinfo)
        {
            if (!CaptureServiceInfo.IsCompatibleWithRunningOS)
            {
                return(false);
            }

            try
            {
                TryKillPresentMon();
                SubscribeToPresentMonCapturedProcesses();

                Process process = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName               = startinfo.FileName,
                        Arguments              = startinfo.Arguments,
                        UseShellExecute        = startinfo.UseShellExecute,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        RedirectStandardInput  = true, // is it a MUST??
                        CreateNoWindow         = startinfo.CreateNoWindow,
                        Verb = "runas",
                    }
                };

                process.EnableRaisingEvents = true;
                process.OutputDataReceived += (sender, e) => _outputDataStream.OnNext(e.Data);
                process.ErrorDataReceived  += (sender, e) => _outputErrorStream.OnNext(e.Data);

                process.Start();
                _outputDataStream.OnNext("Capture service started...");
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                _logger.LogInformation("PresentMon successfully started");
                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to Start CaptureService");
                return(false);
            }
        }
예제 #10
0
 public IntervalService(IServiceStartInfo startInfo)
     : base(startInfo)
 {
     this.InnerProcess = CreateProcess();
 }
예제 #11
0
 public LaunchService(IServiceStartInfo startInfo)
     : base(startInfo)
 {
     this.InnerProcess = CreateProcess();
 }
예제 #12
0
        public ServiceBase(IServiceStartInfo startInfo)
        {
            this.StartInfo = startInfo;
            this.Log = new Logger(startInfo.Name, startInfo.EnableLog);

            this.InnerThread = new Thread(new ThreadStart(this.ThreadProc));
            this.InnerThread.IsBackground = true;
            this.IsRunning = false;

            if (startInfo.KillExistingProcess)
            {
                Process.GetProcesses().Where(p => this.TryMatchProcess(p, startInfo.Command))
                    .ToList()
                    .ForEach(p => this.TryKillProcess(p));
            }
        }
예제 #13
0
 public bool StartCaptureService(IServiceStartInfo startInfo)
 {
     return(_presentMonCaptureService.StartCaptureService(startInfo));
 }