protected override void OnStop()
        {
            base.OnStop();

            _jobManager.Stop();
            SLogger.Info(InstallServiceName + " Service was stopped by " + SystemReader.GetWindowsUsername() + ".");
        }
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            log4net.Config.XmlConfigurator.Configure();
            ConfigurationManager.RefreshSection("appSettings");

            _jobManager.Start();
            SLogger.Info(InstallServiceName + " Service was started by " + SystemReader.GetWindowsUsername() + ".");
        }
        public void Execute(IJobExecutionContext context)
        {
            JobFriendlyName = string.IsNullOrWhiteSpace(JobFriendlyName) ? Guid.NewGuid().ToString() : JobFriendlyName;

            ConfigurationManager.RefreshSection("appSettings");
            try
            {
                SLogger.Info(string.Format("Job {0} starts executing at {1}. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));

                //Check if the job is marked as disabled in the config
                if (!string.IsNullOrWhiteSpace(ConfigReader.DisableJobsByFriendlyName) && ConfigReader.DisableJobsByFriendlyName.Split(';').Any(j => j.Trim().Equals(JobFriendlyName, StringComparison.InvariantCultureIgnoreCase)))
                {
                    SLogger.Info(string.Format("Job {0} has been marked as disabled in the config file, therefore it does not execute this time.", JobFriendlyName));
                }
                else
                {
                    SLogger.Info(string.Format("Job {0} is executing...", JobFriendlyName));
                    InnerExcute(context);
                }
                SLogger.Info(string.Format("Job {0} finishes executing at {1}. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));
            }
            catch (Exception ex)
            {
                SLogger.Error(ex);
                SLogger.Info(string.Format("Job {0} stops executing at {1} due to internal errors. Currently logged in as {2}.", JobFriendlyName, DateTime.Now, SystemReader.GetWindowsUsername()));
            }
        }