Beispiel #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Error::$exitIfError = true;
     Request::$cookieFileName = __DIR__ . '/../../../storage/framework/cookies/cookie_';
     $login = DB::table('config')->where('name', '=', 'login')->select('value')->get();
     try {
         User::getInstance($login[0]->value)->getShortInfo();
     } catch (\Exception $e) {
         $password = DB::table('config')->where('name', '=', 'password')->select('value')->get();
         User::getInstance($login[0]->value)->Auth($login[0]->value, $password[0]->value);
         User::getInstance($login[0]->value)->getShortInfo();
     }
     $jobs = DB::table('job')->get();
     foreach ($jobs as $job) {
         $conditions = json_decode($job->conditions);
         if (User::getInstance($login[0]->value)->energy > $conditions->energy) {
             $vcJob = new VCJob($login[0]->value);
             $vcJob->companyId = $job->company_id;
             $vcJob->worker = true;
             try {
                 $statistic = $vcJob->doWork($conditions->energy);
                 DB::table('log')->insert(['section' => 'job', 'type' => 'success', 'message' => 'Work is done', 'data' => json_encode($statistic)]);
             } catch (\Exception $e) {
                 DB::table('log')->insert(['section' => 'job', 'type' => 'error', 'message' => 'Work failed', 'data' => ['code' => $e->getCode(), 'message' => $e->getMessage()]]);
             }
         }
     }
 }
Beispiel #2
0
 public function __construct()
 {
     Error::$exitIfError = true;
     Request::$cookieFileName = __DIR__ . '/../../../storage/framework/cookies/cookie_';
 }