예제 #1
0
        //public Task Execute(IJobExecutionContext context)
        //{
        //    throw new NotImplementedException();
        //}

        public void execute(IJobList jobList, ILogger logger = null)
        {
            jobList.setLastRun(this);
            if (logger == null)
            {
                //logger = \OC::server.getLogger();
            }

            try
            {
                var jobStartTime = this.time.getTime();
                //logger.debug('Run '.get_class(this). ' job with ID '. this.getId(), ['app' => 'cron']);
                this.run(this.argument);
                var timeTaken = this.time.getTime() - jobStartTime;

                //logger.debug('Finished '.get_class(this). ' job with ID '. this.getId(). ' in '. timeTaken. ' seconds', ['app' => 'cron']);
                jobList.setExecutionTime(this, timeTaken);
            }
            catch (Exception e) {
                if (logger != null)
                {
                    //logger.logException(e, [
                    //                'app' => 'core',
                    //                'message' => 'Error while running background job (class: '.get_class(this). ', arguments: '.print_r(this.argument, true). ')'
                    //            ]);
                }
            }
        }