示例#1
0
        public Task StartAsync(CancellationToken token)
        {
            BasePath    = ServiceContext.Instance().Get("BasePath");
            ServiceName = ServiceContext.Instance().Get("ServiceName");
            ServiceExe  = ServiceContext.Instance().GetService(ServiceName, "Exe");
            ServiceArg  = ServiceContext.Instance().GetService(ServiceName, "Arg");
            IsPolling   = ServiceContext.Instance().GetService(ServiceName, "Type") == "Polling";

            ServiceArg = ServiceArg.Replace(@"%EXEDIR%", BasePath);

            IsElapsing = false;

            if (IsPolling)
            {
                var interval = int.Parse(ServiceContext.Instance().GetService(ServiceName, "Interval"));
                Timer          = new System.Timers.Timer(interval);
                Timer.Elapsed += Pooling;
                Timer.Start();
            }
            else
            {
                RunningProcess = Setup();
                RunningProcess.Start();

                var interval = 1000;
                Timer          = new System.Timers.Timer(interval);
                Timer.Elapsed += HealthCheck;
                Timer.Start();
            }

            return(Task.CompletedTask);
        }
        public EplanEventListener()
        {
            onUserPreCloseProject
            .SetEvent("Eplan.EplApi.OnUserPreCloseProject");
            onUserPreCloseProject.EplanEvent +=
                new EventHandlerFunction(OnUserPreCloseProject);

            onPostOpenProject.SetEvent("Eplan.EplApi.OnPostOpenProject");
            onPostOpenProject.EplanEvent +=
                new EventHandlerFunction(OnPostOpenProject);

            onMainEnd.SetEvent("Eplan.EplApi.OnMainEnd");
            onMainEnd.EplanEvent +=
                new EventHandlerFunction(OnMainEnd);

            onMainStart.SetEvent("Eplan.EplApi.OnMainStart");
            onMainStart.EplanEvent +=
                new EventHandlerFunction(OnMainStart);

            onNotifyPageChanged.SetEvent("NotifyPageOpened");
            onNotifyPageChanged.EplanEvent +=
                new EventHandlerFunction(OnNotifyPageChanged);

            IEplanHelper         eplanHelper         = new EplanHelper();
            IModuleConfiguration moduleConfiguration =
                new ModuleConfiguration();
            IRunningProcess runningProcess =
                new RunningProcess(Process.GetCurrentProcess());

            idleTimeModule = new IdleTimeModule.IdleTimeModule(
                eplanHelper, moduleConfiguration, runningProcess);
        }
        /// <summary>
        /// 获取所有进程
        /// </summary>
        public ObservableCollection <RunningProcess> GetProcessNow()
        {
            bool judge;
            int  j;

            ObservableCollection <RunningProcess> processes = new ObservableCollection <RunningProcess>();
            var details = ProcessDiagnosticInfo.GetForProcesses().OrderByDescending(x => x.ExecutableFileName);

            foreach (var detail in details)
            {
                if (detail.Parent != null)
                {
                    if ((!detail.ExecutableFileName.Equals("winlogon.exe")) && (!detail.ExecutableFileName.Equals("System")) && (!detail.ExecutableFileName.Equals("svchost.exe")) && (!detail.Parent.ExecutableFileName.Equals("svchost.exe") && (!detail.Parent.ExecutableFileName.Equals("wininit.exe"))))
                    {
                        for (j = 0, judge = false; j < processes.Count; j++)
                        {
                            if (processes[j].id == detail.Parent.ProcessId)
                            {
                                judge = true;
                            }
                        }
                        if (judge == false)
                        {
                            var temp2 = new RunningProcess(detail.ExecutableFileName, detail.ProcessId, detail.Parent.ExecutableFileName, detail.Parent.ProcessId);
                            processes.Add(temp2);
                        }
                    }
                }
            }
            return(processes);
        }
示例#4
0
 private void HealthCheck(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (RunningProcess.HasExited && !IsElapsing)
     {
         IsElapsing     = true;
         RunningProcess = Setup();
         RunningProcess.Start();
         IsElapsing = false;
     }
 }
示例#5
0
        public bool IsAlive(RunningProcess aProcess, int timeOutInMilliseconds)
        {
            var nktProcess = NktProcessFrom(aProcess);

            if (nktProcess == null)
            {
                return(false);
            }
            return(nktProcess.get_IsActive(timeOutInMilliseconds));
        }
        public bool OnInit()
        {
            IEplanHelper         eplanHelper         = new EplanHelper();
            IModuleConfiguration moduleConfiguration =
                new ModuleConfiguration();
            IRunningProcess runningProcess =
                new RunningProcess(Process.GetCurrentProcess());

            idleTimeModule = new IdleTimeModule(eplanHelper,
                                                moduleConfiguration, runningProcess);
            idleTimeModule.Start(OriginalAssemblyPath);
            return(true);
        }
示例#7
0
        public Task StopAsync(CancellationToken token)
        {
            Timer.Stop();
            Timer.Elapsed -= Pooling;
            Timer.Elapsed -= HealthCheck;

            RunningProcess.WaitForExit(10000);
            if (!RunningProcess.HasExited)
            {
                RunningProcess.Kill();
            }

            return(Task.CompletedTask);
        }
示例#8
0
        public async Task <IEnumerable <RunningProcess> > GetRunningProcesses(string connectionString)
        {
            using var connection = new SqlConnection(connectionString);

            var command = new SqlCommand(StoredProcedureExtensions.GetRunningProcesses(), connection)
            {
                CommandType = CommandType.Text
            };

            connection.Open();

            using var dataReader = await command.ExecuteReaderAsync();

            var runningProcesses = await RunningProcess.FromDataReader(dataReader);

            return(runningProcesses);
        }
示例#9
0
 public void Dispose()
 {
     Timer?.Dispose();
     RunningProcess.Dispose();
 }
 void IReceiveOptions.ReceiveFrom(OptionSet options)
 {
     RunningProcess.ReceiveFrom(options);
     DumpedProcess.ReceiveFrom(options);
 }
示例#11
0
 public void ProcessRightClick()
 {
     _selectedProcesses.Where(p => !p.IsRunning()).DefaultIfEmpty(RunningProcess.None()).First().IfNotRunning(proc => _view.DisplayToHookOnStartContextMenu());
 }
示例#12
0
 public IEnumerable <IRunningProcess> RunningProcesses()
 {
     return(RunningProcess.From(_manager.Processes().CollectAll(), this));
 }
示例#13
0
 private IRunningProcess CreateConsoleProcessFrom(NktProcess aProcess)
 {
     return(RunningProcess.From(aProcess, this));
 }