コード例 #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
ファイル: ServiceBase.cs プロジェクト: nsdown/ServiceOnset
        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
ファイル: ServiceFactory.cs プロジェクト: nsdown/ServiceOnset
        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
ファイル: ServiceBase.cs プロジェクト: PHPPlay/ServiceOnset
        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");
            }
        }
コード例 #9
0
        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
ファイル: ServiceBase.cs プロジェクト: org-itbiz/ServiceOnset
        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));
 }