Executes the job.

@throws Controller_Jobs_Exception If an error occurs
354294
public function run()
	{
		$context = $this->_getContext();
		$config = $context->getConfig();

		$productManager = MShop_Product_Manager_Factory::createManager( $context );
		$productListManager = $productManager->getSubManager( 'list' );
		$listTypeId = $this->_getProductListTypeId( $productListManager, 'suggestion' );

		$baseProductManager = MShop_Factory::createManager( $context, 'order/base/product' );
		$search = $baseProductManager->createSearch();
		$config->set( 'aggregatekey', 'mshop/order/manager/base/product/default/aggregateAllProductsInOrders' );

		$totalsCnt = $baseProductManager->aggregate( $search, 'order.base.product.productid' );

		$search = $baseProductManager->createSearch();
		$context->getConfig()->set( 'aggregatekey', 'mshop/order/manager/base/product/default/countAll' );
		$ordersCnt = $baseProductManager->aggregate( $search, 'order.base.product.baseid' );
		$totalOrders = $ordersCnt[0];

		$minSupport = $config->get( 'controller/jobs/product/suggestions/minsupport', 0.1 );

		$filteredBySupport = array();
		foreach( $totalsCnt as $id => $totalCnt )
		{
			if( $minSupport <= ( $sup = ( $totalCnt / $totalOrders ) ) ) {
				$filteredBySupport[$id] = $sup;
			}
		}

		$minConfidence = $config->get( 'controller/jobs/product/suggestions/minconfidence', 0.3 );
		$maxSuggestions = $config->get( 'controller/jobs/product/suggestions/maxsuggestions', 10 );

		foreach( $filteredBySupport as $id => $sup )
		{
			$prodList = array();

			$search = $baseProductManager->createSearch();
			$search->setConditions( $search->compare( '==', 'order.base.product.productid', $id ) );
			$this->_getContext()->getConfig()->set( 'aggregatekey', 'mshop/order/manager/base/product/default/aggregateProductsInOrders' );
			$relativeCnt = $baseProductManager->aggregate($search, 'order.base.product.productid');

			unset( $relativeCnt[$id] );

			foreach( $relativeCnt as $relId => $relCnt ) {
				if ( $minSupport <= ( $relCnt / $totalOrders ) )
				{
					if( $minConfidence <= ( $conf = ( $relCnt / $totalsCnt[$id] ) ) ) {
						$prodList[ $relId ] = $conf;
					}
				}
			}

			arsort( $prodList );

			$prodList = array_slice( $prodList, 0, $maxSuggestions, true );

			$this->_removeProductSuggestions( $id, $listTypeId, $productListManager );
			$this->_createProductListSuggestions( $id, array_keys( $prodList ), $listTypeId, $productListManager );
		}
	}
951953
public function handle()
    {
        $exception = $this->getException();

        Log::logger('ErrorHandler')->error($exception->getMessage(), [
            'exception' => get_class($exception),
            'file' => sprintf(
                "%s on line %d",
                $exception->getFile(),
                $exception->getLine()
            )
        ]);

        $template = new Template();

        $template = $template->initialize();
        $view = 'errors/500.html.twig';
        $code = 500;
        if (
            ($exception instanceof ControllerNotFoundException) ||
            ($exception instanceof ActionNotFoundException)
        ) {
            $view = 'errors/404.html.twig';
            $code = 404;
        }

        $data = ['exception' => $exception];
        $html = $template->parse($view)
            ->process($data);

        $this->app->response->setStatusCode($code)
            ->setContent($html);

        $this->app->response->send();
    }
1277323
public function execute()
    {
        $this->response = curl_exec($this->curlHandle);

        $this->checkForErrors();

        list($this->responseHeaders, $this->responseBody) = explode("\r\n\r\n", $this->response, 2);
    }
295344
protected function job(): void
    {
        $corporation = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($corporation->isCachedLoad()) return;

        CorporationInfo::firstOrNew([
            'corporation_id' => $this->getCorporationId(),
        ])->fill([
            'name'            => $corporation->name,
            'ticker'          => $corporation->ticker,
            'member_count'    => $corporation->member_count,
            'ceo_id'          => $corporation->ceo_id,
            'alliance_id'     => $corporation->alliance_id ?? null,
            'description'     => $corporation->description ?? null,
            'tax_rate'        => $corporation->tax_rate,
            'date_founded'    => property_exists($corporation, 'date_founded') ?
                carbon($corporation->date_founded) : null,
            'creator_id'      => $corporation->creator_id,
            'url'             => $corporation->url ?? null,
            'faction_id'      => $corporation->faction_id ?? null,
            'home_station_id' => $corporation->home_station_id ?? null,
            'shares'          => $corporation->shares ?? null,
        ])->save();
    }
343933
public function execute() {
		$this->out(__d('cake_notify', 'Clear notifications in progress...'), 1, Shell::NORMAL);
		if ($this->Notification->clearNotifications()) {
			$this->out('<success>' . __d('cake_notify', 'Notifications clear successfully.') . '</success>', 1, Shell::NORMAL);
		} else {
			$this->out('<error>' . __d('cake_notify', 'Notifications clear unsuccessfully.') . '</error>');
		}
	}
858506
protected function job(): void
    {
        while (true) {

            $industry_jobs = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($industry_jobs->isCachedLoad()) return;

            collect($industry_jobs)->each(function ($job) {

                CorporationIndustryJob::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'job_id'         => $job->job_id,
                ])->fill([
                    'installer_id'           => $job->installer_id,
                    'facility_id'            => $job->facility_id,
                    'location_id'            => $job->location_id,
                    'activity_id'            => $job->activity_id,
                    'blueprint_id'           => $job->blueprint_id,
                    'blueprint_type_id'      => $job->blueprint_type_id,
                    'blueprint_location_id'  => $job->blueprint_location_id,
                    'output_location_id'     => $job->output_location_id,
                    'runs'                   => $job->runs,
                    'cost'                   => $job->cost ?? null,
                    'licensed_runs'          => $job->licensed_runs ?? null,
                    'probability'            => $job->probability ?? null,
                    'product_type_id'        => $job->product_type_id ?? null,
                    'status'                 => $job->status,
                    'duration'               => $job->duration,
                    'start_date'             => carbon($job->start_date),
                    'end_date'               => carbon($job->end_date),
                    'pause_date'             => property_exists($job, 'pause_date') ?
                        carbon($job->pause_date) : null,
                    'completed_date'         => property_exists($job, 'completed_date') ?
                        carbon($job->completed_date) : null,
                    'completed_character_id' => $job->completed_character_id ?? null,
                    'successful_runs'        => $job->successful_runs ?? null,
                ])->save();
            });

            if (! $this->nextPage($industry_jobs->pages))
                return;
        }
    }
961796
public function run()
    {
        $this->config->setParams($this->buildParams($this->config));

        $parentId = $this->getParentId();

        $request = $this->firstPage($this->config);
        while ($request !== false) {
            $response = $this->download($request);

            $responseHash = sha1(serialize($response));
            if ($responseHash == $this->lastResponseHash) {
                $this->logger->debug(sprintf(
                    "Job '%s' finished when last response matched the previous!",
                    $this->getJobId()
                ));
                $this->scroller->reset();
                break;
            } else {
                $data = $this->runResponseModules($response, $this->config);
                $data = $this->filterResponse($this->config, $data);
                $this->parse($data, $parentId);

                $this->lastResponseHash = $responseHash;
            }

            $request = $this->nextPage($this->config, $response, $data);
        }
    }
85862
public function execute() {
        global $CFG, $DB;

        $timenow = time();

        // Cleanup read and unread notifications.
        if (!empty($CFG->messagingdeleteallnotificationsdelay)) {
            $notificationdeletetime = $timenow - $CFG->messagingdeleteallnotificationsdelay;
            $params = array('notificationdeletetime' => $notificationdeletetime);
            $DB->delete_records_select('notifications', 'timecreated < :notificationdeletetime', $params);
        }

        // Cleanup read notifications.
        if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
            $notificationdeletetime = $timenow - $CFG->messagingdeletereadnotificationsdelay;
            $params = array('notificationdeletetime' => $notificationdeletetime);
            $DB->delete_records_select('notifications', 'timeread < :notificationdeletetime', $params);
        }
    }
1085448
public function handle()
	{
		$counter = JobsFacade::run();

		if ($counter === false) {
			$this->error('Job executor needs to cool down for '.(JobsFacade::remainingCoolDown() * 60)
                .' seconds! No jobs executed.');
		} else {
			$this->info('Done. Jobs executed: '.$counter.'/'.JobsFacade::count());
		}			
	}
351561
protected function job(): void
    {
        $members = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($members->isCachedLoad()) return;

        collect($members)->each(function ($member_id) {

            CorporationMember::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'character_id'   => $member_id,
            ])->save();

        });

        // Remove expelled members
        CorporationMember::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('character_id', collect($members))
            ->delete();
    }
649417
public function run()
    {
        Model::unguard();

        $this->call(RolesTableSeeder::class);
        $this->call(UserTableSeeder::class);

        Model::reguard();
    }
308947
public function run() {
        $this->_hookManager->runBeforeSystem();

        $urlArray = explode('/', $this->_url);
        //Deletes last element if empty
        $lastElement = end($urlArray);
        if ($lastElement == '') {
            array_pop($urlArray);
        }
        reset($urlArray);

        // If present take the first element as the controller
        $tmpController = isset($urlArray[0]) ? array_shift($urlArray) : 'index';
        $action = null;

        //Prepare the GET params in order to pass them to the Controller
        $myGet = $_GET;
        if(isset($myGet['url'])){
            unset($myGet['url']);
        }

        if ($this->applyStaticRouting($tmpController)) {
            $this->_hookManager->runBefore(); // Runs before controller hooks
            include(ROOT . DS . $tmpController);
            $this->_hookManager->runAfter(); // Runs after controller hooks
        } elseif ($this->applyRouting($tmpController, $action, $urlArray)) {
            ($action === null) ? $action = 'index' : $action;
            $tmpController = '\\pff\\controllers\\'.$tmpController;
            $controller = new $tmpController($tmpController, $this, $action, array_merge($urlArray,$myGet));
        } elseif (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . ucfirst($tmpController) . '_Controller.php')) {
            $action = isset($urlArray[0]) ? array_shift($urlArray) : 'index';
            $controllerClassName = '\\pff\\controllers\\'.ucfirst($tmpController) . '_Controller';
            $controller          = new $controllerClassName($tmpController, $this, $action, array_merge($urlArray,$myGet));
        } else {
            throw new RoutingException('Cannot find a valid controller.', 404);
        }

        if (isset($controller)) {
            $this->_action = $action;
            $this->_moduleManager->setController($controller); // We have a controller, let the modules know about it
            ob_start();
            $this->_hookManager->runBefore(); // Runs before controller hooks
            if ((int)method_exists($controller, $this->_action)) {
                call_user_func_array(array($controller, "beforeAction"), $urlArray);
                call_user_func(array($controller, "beforeFilter"));
                call_user_func_array(array($controller, $this->_action), $urlArray);
                call_user_func(array($controller, "afterFilter"));
                call_user_func_array(array($controller, "afterAction"), $urlArray);
                $this->_hookManager->runAfter(); // Runs after controller hooks
                ob_end_flush();
            } else {
                throw new RoutingException('Not a valid action: ' . $action, 404);
            }
        }
    }
653483
public function handle()
    {
        // Figure out the stub directory
        $this->stubs = __DIR__.'/../../stubs/generate';
        if (!is_dir($this->stubs)) {
            throw new Exception('Could not find stubs dir');
        }

        // Generate
        $this->generateModel();
        $this->generateView();
        $this->generateController();
    }
218914
protected function job(): void
    {
        $labels = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($labels->isCachedLoad()) return;

        collect($labels)->each(function ($label) {

            CorporationContactLabel::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'label_id'       => $label->label_id,
            ])->fill([
                'label_name' => $label->label_name,
            ])->save();
        });

        CorporationContactLabel::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('label_id', collect($labels)->pluck('label_id')->flatten()->all())
            ->delete();
    }
936353
protected function job(): void
    {
        $titles = $this->retrieve([
            'corporation_id' => $this->getCorporationId(),
        ]);

        if ($titles->isCachedLoad()) return;

        collect($titles)->each(function ($title) {

            CorporationTitle::firstOrNew([
                'corporation_id' => $this->getCorporationId(),
                'title_id'       => $title->title_id,
            ])->fill([
                'name' => $title->name ?? sprintf('Untitled %d', (int) sqrt($title->title_id - 1)),
            ])->save();

            collect($this->types)->each(function ($type) use ($title) {

                if (! property_exists($title, $type))
                    return;

                collect($title->{$type})->each(function ($name) use ($title, $type) {

                    CorporationTitleRole::firstOrCreate([
                        'corporation_id' => $this->getCorporationId(),
                        'title_id'       => $title->title_id,
                        'type'           => $type,
                        'role'           => $name,
                    ]);
                });

                CorporationTitleRole::where('corporation_id', $this->getCorporationId())
                    ->where('title_id', $title->title_id)
                    ->where('type', $type)
                    ->whereNotIn('role', collect($title->{$type})->flatten()->all())
                    ->delete();

            });

            $this->known_titles->push($title->title_id);

        });

        CorporationTitle::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('title_id', $this->known_titles->flatten()->all())
            ->delete();
    }
427240
public function run()
    {
        Scripts::initializeClassLoader($this);
        Scripts::initializeSignalSlot($this);
        Scripts::initializePackageManagement($this);

        $this->activeRequestHandler = $this->resolveRequestHandler();
        $this->activeRequestHandler->handleRequest();
    }
465288
public function run()
    {
        // Get and instantiate the reporter class, load files
        $reporterClass = self::$console->getReporterClass();
        $this->reporter = new $reporterClass(self::$console);

        $this->reporter->beforeRun();
        foreach ($this->suites as $suite) {
            $this->runSuite($suite);
        }
        $this->reporter->afterRun();

        if (self::$console->options['watch']) {
            $this->watch();
        }
    }