public override VendScreen.Common.TaskManager.ITask NewTask(log4net.ILog log) { if (!this.Task.CommandsEnabled()) return null; var task = new VSSyncExportTask() {Config = this, Logger = log}; return task; }
protected override void OnStart(string[] args) { XmlConfigurator.Configure(); Log.Info("VSSync Export Service started"); config = Config.GetConfig(Log); this.sendErrorsThread = new Thread(this.SendErrors); //this.sendErrorsThread.IsBackground = true; this.sendErrorsThread.Start(); try { var tasks = config.GetTasks(); foreach (var task in tasks) { var taskBase = task as TaskBase; if (taskBase != null) { if (taskBase.Config.RunAtStart) { taskManager.AddIntervalTask(task, DateTime.Now.AddSeconds(1), 0, (DateTime?)null); } } var taskInterval = task as IInterval; if (taskInterval == null) continue; var interval = taskInterval.Interval*1000*60; var startDateTime = taskInterval.StartDateTime; taskManager.AddIntervalTask(task, startDateTime, interval, (DateTime?) null); var vsSyncExportTask = task as VSSyncExportTask; if (vsSyncExportTask != null) { vSSyncExportTask = vsSyncExportTask; } } } catch (Exception ex) { Log.Error("Service starting error:", ex); throw; } }