private object SetScheduler(dynamic parameters) { ServiceTimer timer = this.Bind <ServiceTimer>(); int result = _clientManagerRepository.SetScheduler(timer); return(Response.AsJson(result)); }
private object DisableScheduler(dynamic parameters) { ServiceTimer timer = this.Bind <ServiceTimer>(); int result = this._clientManagerRepository.DisableScheduler(parameters.ServiceId, parameters.ClientId); return(Response.AsJson(result)); }
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); }
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; } }
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); }
/// <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); }
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); }
/// <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); } }
public void Stop() { try { if (Server == null) { return; } Server.Dispose(); IsStarted = false; ServiceTimer.Stop(); } catch (Exception exception) { VirtualAssistant.Instance.Logger.Error(exception); } }
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); } }
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 } } }
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)); }
public void Stop() { ServiceTimer.Stop(); ServiceTimer.Elapsed -= ServiceTimer_Elapsed; Log.Instance.Info("Core.Bitcon.Service service is Stopped"); }
protected override void OnStop() { ServiceTimer.Enabled = false; ServiceTimer.Dispose(); ServiceTimer = null; }
private object GetScheduler(dynamic parameters) { ServiceTimer timer = this._clientManagerRepository.GetScheduler(parameters.ClientId, parameters.ServiceId); return(Response.AsJson(timer)); }
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 }
private void ServiceTimer_Elapsed(object sender, ElapsedEventArgs e) { ServiceTimer.Stop(); Executor.ExecuteAction(CoreServiceRepository.DataProcessingApiRequest); ServiceTimer.Start(); }