/// <summary>
        /// Creates an instance of the PaletteInsightAgent and starts it.
        /// </summary>
        /// <param name="hostControl">Service HostControl object</param>
        /// <returns>Indicator that service succesfully started</returns>
        public bool Start(Topshelf.HostControl hostControl)
        {
            // Request additional time from the service host due to how much initialization has to take place.
            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            // Initialize and start service.
            try
            {
                agent = new PaletteInsightAgent.PaletteInsightAgent();
                // move starting the agent here, so exceptions get properly logged not only on construction,
                // but on start  also
                agent.Start();

                // check the isRunning flag as this place stopped the execution numerous times
                // without logging that the IsRunning() call returned false
                var isRunning = agent.IsRunning();
                if (!isRunning)
                {
                    Log.Error("The agent seems to be not running: IsRunning() returned false right after .Start()");
                }

                return(isRunning);
            }
            catch (Exception e)
            {
                Log.Fatal(e, "Exception is: {0}", e);
                return(false);
            }
        }
示例#2
0
 public static void StartTimer(Topshelf.HostControl hctrl)
 {
     if ((ParentProcesses != null) && _timer == null)
     {
         _timer = new System.Threading.Timer(
             new System.Threading.TimerCallback(TimerTask), hctrl, 1000, 2000);
     }
 }
        public void StartAndStopTest()
        {
            Topshelf.HostControl hostControl = null;
            NugetService         service     = new NugetService();

            service.Start(hostControl);
            service.Stop(hostControl);
        }
 /// <summary>
 /// Stops the PaletteInsightAgent service.
 /// </summary>
 /// <param name="hostControl">Service HostControl object</param>
 /// <returns>Indicator that service succesfully stopped</returns>
 public bool Stop(Topshelf.HostControl hostControl)
 {
     if (agent != null)
     {
         agent.Stop();
         agent.Dispose();
     }
     return(true);
 }
示例#5
0
 public bool Stop(Topshelf.HostControl hostControl)
 {
     try
     {
         Server.Shutdown();
     }
     catch (Exception ex)
     {
         log.Error("Quartz调度器关闭报错", ex);
     }
     return(true);
 }
示例#6
0
        public static void StartTimer(Topshelf.HostControl hctrl)
        {
            bool startTimer = false;

            if (_timer == null && (ParentProcesses != null))
            {
                startTimer = true;
            }
            if (_timer == null && _idleSpan > 0 && _parentPort > 0)
            {
                startTimer = true;
            }

            if (startTimer)
            {
                _timer = new System.Threading.Timer(
                    new System.Threading.TimerCallback(TimerTask), hctrl, 1000, 2000);
            }
        }
示例#7
0
        public bool Start(Topshelf.HostControl hostControl)
        {
            try
            {
                // 添加测试作业, 如果需要调试,请确保配置的这个Id没有部署成服务
                var jobDetail = JobBuilder
                                .Create <PDFViewer.PDFToSWFAndSnap>()
                                .WithIdentity("TimeoutNoticeJob")
                                .Build();

                Server.Scheduler.AddJob(jobDetail, true);
                Server.Scheduler.TriggerJob(jobDetail.Key);

                Server.Start();
            }
            catch (Exception ex)
            {
                log.Error("Quartz调度器启动报错", ex);
            }
            return(true);
        }