Ejemplo n.º 1
0
        private object SetScheduler(dynamic parameters)
        {
            ServiceTimer timer  = this.Bind <ServiceTimer>();
            int          result = _clientManagerRepository.SetScheduler(timer);

            return(Response.AsJson(result));
        }
Ejemplo n.º 2
0
        private object DisableScheduler(dynamic parameters)
        {
            ServiceTimer timer  = this.Bind <ServiceTimer>();
            int          result = this._clientManagerRepository.DisableScheduler(parameters.ServiceId, parameters.ClientId);

            return(Response.AsJson(result));
        }
Ejemplo n.º 3
0
        public static ServiceTimer GetScheduler(short serviceId, string apiKey)
        {
            Client       referenceClient = GetClient(apiKey);
            ServiceTimer scheduler       = WebOperations.WebGet <ServiceTimer>(WebOperations.WebMethod.GET_SCHEDULER_BY_CLIENTID_AND_SERVICEID, apiKey, referenceClient.Id, serviceId);

            return(scheduler ?? FileOperations.GetLocalScheduler(serviceId) as ServiceTimer);
        }
Ejemplo n.º 4
0
 private void InitializeTimer(double timeInterval)
 {
     if (timeInterval > 0)
     {
         ServiceTimer.Dispose();
         ServiceTimer          = new Timer();
         ServiceTimer.Enabled  = true;
         ServiceTimer.Elapsed += new ElapsedEventHandler(timer1_Tick);
         ServiceTimer.Interval = 10000;
     }
 }
Ejemplo n.º 5
0
        internal static IServiceTimer GetLocalScheduler(short serviceId)
        {
            IServiceTimer svcTimer = new ServiceTimer();


            switch (serviceId)
            {
            default:
                svcTimer.Day    = 0;
                svcTimer.Hour   = 0;
                svcTimer.Minute = 0;
                svcTimer.Second = 40;
                break;
                //case Names.MonitorService:
                //    svcTimer.Day = Properties.Settings.Default.SCH_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.SCH_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.SCH_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.SCH_SECOND;
                //    break;
                //case Names.EndpointTracker:
                //    svcTimer.Day = Properties.Settings.Default.EPTSCH_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.EPTSCH_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.EPTSCH_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.EPTSCH_SECOND;
                //    break;
                //case Names.CSTTracker:
                //    svcTimer.Day = Properties.Settings.Default.EPTSCH_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.EPTSCH_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.EPTSCH_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.EPTSCH_SECOND;
                //    break;
                //case Names.NancyGateway:
                //    svcTimer.Day = Properties.Settings.Default.NGW_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.NGW_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.NGW_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.NGW_SECOND;
                //    break;
                //case Names.PostOffice:
                //    svcTimer.Day = Properties.Settings.Default.MQH_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.MQH_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.MQH_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.MQH_SECOND;
                //    break;
                //case Names.WebConfBackup:
                //    svcTimer.Day = Properties.Settings.Default.WCFGBCK_DAY;
                //    svcTimer.Hour = Properties.Settings.Default.WCFGBCK_HOUR;
                //    svcTimer.Minute = Properties.Settings.Default.WCFGBCK_MINUTE;
                //    svcTimer.Second = Properties.Settings.Default.WCFGBCK_SECOND;
                //    break;
            }
            return(svcTimer);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor from the ApiService.
        /// </summary>
        /// <exception cref="ArgumentNullException">When the <paramref name="api"/> is null.</exception>
        /// <exception cref="ArgumentException">When the <paramref name="checkIntervalInSeconds"/> is lower than one second.</exception>
        /// <param name="api">The api used to query information.</param>
        /// <param name="checkIntervalInSeconds"></param>
        protected ApiService(ITwitchAPI api, int checkIntervalInSeconds)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }

            if (checkIntervalInSeconds < 1)
            {
                throw new ArgumentException("The interval must be 1 second or more.", nameof(checkIntervalInSeconds));
            }

            _api          = api;
            _serviceTimer = new ServiceTimer(OnServiceTimerTick, checkIntervalInSeconds);
        }
Ejemplo n.º 7
0
        internal static IServiceTimer GetLocalScheduler(short serviceId)
        {
            IServiceTimer svcTimer = new ServiceTimer();


            switch (serviceId)
            {
            default:
                svcTimer.Day    = 0;
                svcTimer.Hour   = 0;
                svcTimer.Minute = 0;
                svcTimer.Second = 40;
                break;
            }
            return(svcTimer);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// The method that will be executed when the service is stopped.  This method
        /// disposes of the <see cref="ServiceTimer"/>. The <see cref="OnStop"/>
        /// abstract method will also be called if the service requires additional functionality
        /// on stopping. This method will catch and log any exceptions that occur on stopping.
        /// </summary>
        public void Stop()
        {
            try
            {
                Log.Info("Stopping periodic service.");
                if (ServiceTimer != null)
                {
                    ServiceTimer.Dispose();
                }

                OnStop();
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("An error occured while stopping the service: \n{0}", ex);
            }
        }
Ejemplo n.º 9
0
 public void Stop()
 {
     try
     {
         if (Server == null)
         {
             return;
         }
         Server.Dispose();
         IsStarted = false;
         ServiceTimer.Stop();
     }
     catch (Exception exception)
     {
         VirtualAssistant.Instance.Logger.Error(exception);
     }
 }
Ejemplo n.º 10
0
 public void Start()
 {
     try
     {
         var portString = VirtualAssistant.Instance.SettingsManager["Channel"]["Port-Number"].Value;
         int portNumber;
         if (!int.TryParse(portString, out portNumber))
         {
             return;
         }
         var baseAddress = $"http://localhost:{portNumber}/";
         Server    = WebApp.Start <ServerConfiguration>(baseAddress);
         IsStarted = true;
         ServiceTimer.Start();
     }
     catch (Exception exception)
     {
         VirtualAssistant.Instance.Logger.Error(exception);
     }
 }
Ejemplo n.º 11
0
        private void DoWork(object sender, ElapsedEventArgs e)
        {
            try
            {
                log.Info("Start logic");

                ServiceTimer.Interval = 60 * 60 * 1000;
                GoIPDynDnsClient.Program.MainLogic(log);
            }
            catch (Exception x)
            {
                log.Error("Exception" + e);
            }
            finally
            {
                if (null != ServiceTimer)
                {
                    ServiceTimer.Start(); // re - enable the timer
                }
            }
        }
Ejemplo n.º 12
0
        public async Task <ActionResult <IEnumerable <ServiceTimerViewModel> > > CreateServiceTimer(int aircraftId,
                                                                                                    ServiceTimer timer)
        {
            if (timer == null)
            {
                return(BadRequest());
            }
            if (timer.ServiceTimerId == 0) // default
            {
                var maxId = await dbcontext.ServiceTimer.MaxAsync(t => t.ServiceTimerId);

                timer.ServiceTimerId = maxId + 1;
            }
            var aircraft = dbcontext.Aircraft
                           .Where(a => a.AircraftId == aircraftId)
                           .Include(a => a.ServiceTimer)
                           .FirstOrDefault();

            if (aircraft == null)
            {
                return(NotFound());
            }
            await dbcontext.ServiceTimer.AddAsync(timer);

            await dbcontext.SaveChangesAsync();

            var result = new ServiceTimerViewModel
            {
                ServiceTimerId  = timer.ServiceTimerId,
                AircraftId      = timer.AircraftId,
                Status          = timer.Status,
                NextServiceDate = timer.NextServiceDate
            };

            return(CreatedAtAction("GetServiceTimersOfAircraftList", new { aircraftId = timer.AircraftId }, result));
        }
Ejemplo n.º 13
0
 public void Stop()
 {
     ServiceTimer.Stop();
     ServiceTimer.Elapsed -= ServiceTimer_Elapsed;
     Log.Instance.Info("Core.Bitcon.Service service is Stopped");
 }
Ejemplo n.º 14
0
 protected override void OnStop()
 {
     ServiceTimer.Enabled = false;
     ServiceTimer.Dispose();
     ServiceTimer = null;
 }
Ejemplo n.º 15
0
        private object GetScheduler(dynamic parameters)
        {
            ServiceTimer timer = this._clientManagerRepository.GetScheduler(parameters.ClientId, parameters.ServiceId);

            return(Response.AsJson(timer));
        }
Ejemplo n.º 16
0
        public static ServiceTimer GetScheduler(short serviceId, int clientId, string apiKey)
        {
            ServiceTimer scheduler = WebOperations.WebGet <ServiceTimer>(WebOperations.WebMethod.GET_SCHEDULER_BY_CLIENTID_AND_SERVICEID, apiKey, clientId, serviceId);

            return(scheduler ?? FileOperations.GetLocalScheduler(serviceId) as ServiceTimer); // (scheduler'i return et null mu??) Local Scheduler'i return et
        }
Ejemplo n.º 17
0
 private void ServiceTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ServiceTimer.Stop();
     Executor.ExecuteAction(CoreServiceRepository.DataProcessingApiRequest);
     ServiceTimer.Start();
 }