Ejemplo n.º 1
0
        public static void GetCleanerJobFiles(string jobId, ref List <string> filesHit, ref List <string> filesSkipped)
        {
            var logger = Common.GetLogger(NLog.LogLevel.Off);
            var batch  = FilecuumCleanerConfig.GetConfig(false);

            filesHit     = new List <string>();
            filesSkipped = new List <string>();

            RunCleanerJob(batch, jobId, logger, true, ref filesHit, ref filesSkipped);
        }
Ejemplo n.º 2
0
        public static int TestCleanerJob(string jobId)
        {
            var logger = Common.GetLogger();
            var batch  = FilecuumCleanerConfig.GetConfig(false);

            var filesHit     = new List <string>();
            var filesSkipped = new List <string>();

            return(RunCleanerJob(batch, jobId, logger, true, ref filesHit, ref filesSkipped));
        }
Ejemplo n.º 3
0
        public static int RunCleanerBatch(SchedulerClient schedulerClient = null)
        {
            var batchConfig = FilecuumCleanerConfig.GetConfig(false);

            var logger = Common.GetLogger();

            // check if the job exsists
            if (batchConfig == null || batchConfig.FilecuumCleanerJobs == null)
            {
                logger.Info(
                    String.Format(
                        "No cleanerjobs found in config file. This could be an issue when the site has just restarted. Next run should go better."));

                return(-1);
            }

            logger.Info(String.Format("Starting batch: {0} jobs enabled", batchConfig.FilecuumCleanerJobs.Count(job => job.Enabled == true)));

            int totalCnt = 0;

            foreach (var cleanerJob in batchConfig.FilecuumCleanerJobs)
            {
                if (schedulerClient != null)
                {
                    schedulerClient.Progressing();
                }

                int cnt = 0;
                // check if this job is allowed to start
                // is it enabled?
                if (!cleanerJob.Enabled)
                {
                    logger.Info(String.Format("Job: {0} is currently disabled.", cleanerJob.Name));
                    continue;
                }

                // we're allowed to start
                logger.Info(String.Format("Starting job: {0}", cleanerJob.Name));
                cnt = RunCleanerJob(cleanerJob.Id);
                logger.Info(String.Format("Finished job: {0}. files deleted {1}", cleanerJob.Name, cnt));
                totalCnt += cnt;
            }

            logger.Info(String.Format("Finished batch. Files deleted: {0}.", totalCnt));

            return(totalCnt);
        }