/**
  * @param array            $input
  * @param OrganizationData $organization
  * @return bool
  */
 public function update(array $input, OrganizationData $organization)
 {
     try {
         $this->repo->update($input, $organization);
         $this->log->info('Organization Recipient Country Budget  Updated', ['for ' => $organization['recipient_organization_budget']]);
         $this->log->activity("organization.recipient_organization_budget_updated", ['name' => $this->auth->user()->organization->name]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['OrganizationRecipientOrganizationBudget' => $input]);
     }
     return false;
 }
 /**
  * @param $input
  * @param $organization
  * @return bool
  */
 public function update(array $input, OrganizationData $organization)
 {
     try {
         $this->repo->update($input, $organization);
         $this->log->info('Document Link Updated', ['for' => $organization->document_link]);
         $this->log->activity("organization.document_link_updated", ['name' => $this->auth->user()->organization->name]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['OrganizationDocumentLink' => $input]);
     }
     return false;
 }
 /**
  * update Recipient Country
  * @param array    $input
  * @param Activity $activity
  * @return bool
  */
 public function update(array $input, Activity $activity)
 {
     try {
         $this->recipientCountryRepo->update($input, $activity);
         $this->log->info('Recipient Country  Updated!', ['for ' => $activity->recipient_country]);
         $this->log->activity("activity.recipient_country_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['RecipientCountry' => $input]);
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * updates Activity Title
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->iatiTitleRepo->update($activityDetails, $activity);
         $this->log->info('Activity Title Updated!', ['for ' => $activity['narrative']]);
         $this->log->activity("activity.title_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['Title' => $activityDetails]);
     }
     return false;
 }
 /**
  * @param array    $input
  * @param Activity $activity
  * @return bool
  * @internal param $organization
  */
 public function update(array $input, Activity $activity)
 {
     try {
         $this->iatiIdentifierRepo->update($input, $activity);
         $this->log->info('Activity Iati Identifier updates', ['for ' => $activity['activity_identifier']]);
         $this->log->activity("activity.iati_identifier_updated", ['identifier' => $input['activity_identifier'], 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['IatiIdentifier' => $input]);
     }
     return false;
 }
 /**
  * updates Activity recipient region
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->recipientRegionRepo->update($activityDetails, $activity);
         $this->log->info('Activity Recipient Region Updated!', ['for ' => $activity->recipient_region]);
         $this->log->activity("activity.recipient_region_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['recipientRegion' => $activityDetails]);
     }
     return false;
 }
Exemplo n.º 7
0
 /**
  * update activity Status
  * @param array    $input
  * @param Activity $activity
  * @return bool
  */
 public function update(array $input, Activity $activity)
 {
     try {
         $this->activityStatusRepo->update($input, $activity);
         $this->log->info('Activity Status  Updated!', ['for ' => $activity['activity_status']]);
         $this->log->activity("activity.activity_status_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['ActivityStatus' => $input]);
     }
     return false;
 }
 /**
  * updates Activity Contact Info
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->contactInfoRepo->update($activityDetails, $activity);
         $this->log->info('Activity Contact Info Updated!', ['for ' => $activity['contact_info']]);
         $this->log->activity("activity.contact_info_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['ContactInfo' => $activityDetails]);
     }
     return false;
 }
 /**
  * updates Activity Participating Organization
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->participatingOrgRepo->update($activityDetails, $activity);
         $this->log->info('Activity Participating Organization updated!', ['for' => $activity->participating_organization]);
         $this->log->activity("activity.participating_organization", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['ParticipatingOrganization' => $activityDetails]);
     }
     return false;
 }
Exemplo n.º 10
0
 /**
  * updates Activity Sector
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->sectorRepo->update($activityDetails, $activity);
         $this->logger->info('Activity Sector updated!', ['for' => $activity->sector]);
         $this->logger->activity("activity.sector_updated", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->logger->error($exception, ['sector' => $activityDetails]);
     }
     return false;
 }
 /**
  * @param $input
  * @param $organization
  * @return bool
  */
 public function update(array $input, OrganizationData $organization)
 {
     try {
         $this->repo->update($input, $organization);
         $this->log->info('Organization Total Budget Updated', ['for ' => $organization['total_budget']]);
         $this->log->activity("organization.total_budget_updated", ['name' => $organization->organization->name]);
         return true;
     } catch (Exception $exception) {
         $this->log->error($exception, ['OrganizationTotalBudget' => $input]);
     }
     return false;
 }
 /**
  * updates Activity Country Budget Items
  * @param array    $activityDetails
  * @param Activity $activity
  * @return bool
  */
 public function update(array $activityDetails, Activity $activity)
 {
     try {
         $this->database->beginTransaction();
         $this->CountryBudgetItemRepo->update($activityDetails, $activity);
         $this->database->commit();
         $this->logger->info('Activity Country Budget Items updated!', ['for' => $activity->country_budget_items]);
         $this->logger->activity("activity.country_budget_items", ['activity_id' => $activity->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->database->rollback();
         $this->logger->error($exception, ['countryBudgetItems' => $activityDetails]);
     }
     return false;
 }
Exemplo n.º 13
0
 /**
  * Called when the crawl has ended.
  */
 public function finishedCrawling()
 {
     $this->log->info('link checker summary');
     collect($this->urlsGroupedByStatusCode)->each(function ($urls, $statusCode) {
         if ($this->isSuccessOrRedirect($statusCode)) {
             return;
         }
         $count = count($urls);
         if ($statusCode == static::UNRESPONSIVE_HOST) {
             $this->log->warning("{$count} url(s) did have unresponsive host(s)");
             return;
         }
         $this->log->warning("Crawled {$count} url(s) with statuscode {$statusCode}");
     });
 }
Exemplo n.º 14
0
 /**
  * Save Page Text
  * @param      $contractID
  * @param      $page_no
  * @param      $text
  * @param bool $log
  * @return bool
  */
 public function saveText($contractID, $page_no, $text, $log = true)
 {
     $page_detail = ['contract_id' => $contractID, 'page_no' => $page_no, 'text' => $text];
     try {
         $this->pages->updateOrCreate($page_detail);
         if ($log) {
             $this->logger->activity('contract.log.save_page', ['page' => $page_no], $contractID);
         }
         $this->logger->info("Page text updated", ['Contract id' => $contractID, 'Page id ' => $page_no]);
         return true;
     } catch (Exception $e) {
         $this->logger->error($e->getMessage());
         return false;
     }
 }
 /**
  * Upload Pdf to s3 and create contracts
  *
  * @param $key
  */
 public function uploadPdfToS3AndCreateContracts($key)
 {
     $contracts = $this->getJsonData($key);
     foreach ($contracts as $contract) {
         $this->updateContractJsonByID($key, $contract->id, ['create_status' => static::CREATE_PROCESSING], 2);
         try {
             $this->storage->disk('s3')->put($contract->file, $this->filesystem->get($this->getFilePath($key, $contract->file)));
         } catch (Exception $e) {
             $this->logger->error(sprintf('File could not be uploaded : %s', $e->getMessage()));
             continue;
         }
         $data = ['file' => $contract->file, 'filehash' => $contract->filehash, 'user_id' => $contract->user_id, 'metadata' => $contract->metadata];
         try {
             $con = $this->contract->save($data);
             $this->logger->activity('contract.log.save', ['contract' => $con->id], $con->id, $con->user_id);
             $this->updateContractJsonByID($key, $contract->id, ['create_status' => static::CREATE_COMPLETED], 2);
             if ($con) {
                 $this->queue->push('App\\Nrgi\\Services\\Queue\\ProcessDocumentQueue', ['contract_id' => $con->id]);
             }
             $this->logger->info('Contract successfully created.', ['Contract Title' => $con->title]);
         } catch (Exception $e) {
             $this->logger->error($e->getMessage());
             if ($this->storage->disk('s3')->exists($contract->file)) {
                 $this->storage->disk('s3')->delete($contract->file);
             }
             $this->updateContractJsonByID($key, $contract->id, ['create_remarks' => trans('contract.save_fail'), 'create_status' => static::CREATE_FAILED], 2);
         }
         $this->deleteFile($key, $contract->file);
     }
 }
Exemplo n.º 16
0
 /**
  * Configures a given package by name.
  *
  * Use this when you want to run something
  * like 'composer update'.
  *
  * @param $packageName
  * @return mixed
  */
 public function configurePackage($packageName)
 {
     $packagePath = $this->resolvePackagePath($packageName);
     $this->log->info('Attempting to configure package', ['package' => $packageName]);
     $this->composer->setWorkingPath($packagePath);
     $this->composer->updatePackageDependencies($this->preparePackageOptions($packageName));
 }
Exemplo n.º 17
0
 /**
  * Text send to RC
  *
  * @param $contract_id
  * @return bool
  */
 public function copyTextToRC($contract_id)
 {
     $tasks = $this->task->getAll($contract_id);
     foreach ($tasks as $task) {
         $this->page->saveText($contract_id, $task->page_no, $task->assignments->assignment->answer, false);
     }
     $contract = $this->contract->find($contract_id);
     $contract->mturk_status = Contract::MTURK_COMPLETE;
     $this->logger->info('Contract text updated from MTurk', ['Contract id' => $contract_id]);
     $this->logger->activity('mturk.log.sent_to_rc', null, $contract_id);
     return $contract->save();
 }
 /**
  * deletes element which has been clicked.
  * @param $organization
  * @param $element
  * @return bool
  */
 public function deleteElement($organization, $element)
 {
     try {
         $this->repo->deleteELement($organization, $element);
         $this->logger->info(sprintf('Organization element %s has been deleted.', $element), ['for ' => $organization->id]);
         $this->logger->activity("organization.organization_element_deleted", ['element' => $element, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
         return true;
     } catch (Exception $exception) {
         $this->logger->error($exception);
     }
     return false;
 }
Exemplo n.º 19
0
 /**
  * Remove all the sector details from every transactions of the activity.
  * @param $activityId
  * @return bool
  */
 public function removeTransactionSector($activityId)
 {
     try {
         $transactions = $this->transactionRepo->getTransactionData($activityId);
         $this->activityRepo->removeTransactionSector($transactions);
         $this->logger->info('Sector has been removed from Transaction level', ['for ' => $activityId]);
         $this->logger->activity("activity.transaction_sector_removed");
         return true;
     } catch (Exception $exception) {
         $this->logger->error($exception);
     }
     return false;
 }
 /**
  * @param $contractId
  * @param $message
  * @param $type
  * @param $annotationStatus
  * @return bool
  */
 public function comment($contractId, $message, $annotationStatus)
 {
     $this->database->beginTransaction();
     $status = $this->updateStatus($annotationStatus, $contractId);
     if ($status) {
         try {
             $this->comment->save($contractId, $message, "annotation", $annotationStatus);
             $this->logger->info('Comment successfully added.', ['Contract id' => $contractId, 'type' => 'annotation', 'status' => $status]);
             $this->database->commit();
             return true;
         } catch (Exception $e) {
             $this->database->rollback();
             $this->logger->error($e->getMessage());
         }
     }
     return false;
 }
Exemplo n.º 21
0
 /**
  * Attempts to update Composer.
  *
  * Returns true if Composer was updated, false if not.
  *
  * @return bool
  * @throws ComposerException
  */
 public function selfUpdate()
 {
     $beforeVersion = $this->getVersion();
     $process = $this->getProcess();
     $processCommand = trim($this->findComposer() . ' self-update');
     $process->setCommandLine($processCommand);
     $this->log->info('Running Composer command', ['command' => $processCommand]);
     $process->run();
     if ($process->isSuccessful() == false) {
         $composerError = remove_ansi($process->getErrorOutput());
         $this->log->error('Composer self update process failure', ['composer' => $composerError]);
         throw new ComposerException('There was an error updating Composer');
     }
     $afterVersion = $this->getVersion();
     if ($beforeVersion == $afterVersion) {
         return false;
     }
     return true;
 }
 /**
  * Update Contract word file
  *
  * @param $contract_id
  * @return string
  */
 public function updateWordFile($contract_id)
 {
     $text = [];
     if ($contract = $this->contract->findContractWithPages($contract_id)) {
         foreach ($contract->pages->sortBy('page_no') as $key => $page) {
             $text[] = $page->text;
         }
     }
     list($filename, $ext) = explode('.', $contract->file);
     $wordFileName = $filename . '.txt';
     try {
         $file_path = $this->word->create($text, $wordFileName);
         $this->storage->disk('s3')->put(sprintf('%s/%s', $contract_id, $wordFileName), $this->filesystem->get($file_path));
         $this->filesystem->delete($file_path);
         $this->logger->info('Word file updated', ['Contract id' => $contract_id]);
         return true;
     } catch (Exception $e) {
         $this->logger->error('Word file could not  be update : ' . $e->getMessage(), ['Contract id' => $contract_id]);
         return false;
     }
 }
Exemplo n.º 23
0
 /**
  * Clear views manually.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function views()
 {
     Artisan::call('view:clear');
     $this->log->info(trans('cms::utilities.views.success') . trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()]));
     return $this->notifySuccess(trans('cms::utilities.views.success'));
 }
Exemplo n.º 24
0
 /**
  * Handle the event.
  *
  * @param  UserSignedUp  $event
  * @return void
  */
 public function handle(UserSignedUp $event)
 {
     $this->log->info('pre-signup', ['context' => $event->user->email, 'timestamp' => date('Y-m-d H:i:s')]);
 }
 /**
  * Upload Pdfs to S3
  *
  * @param $id
  * @return void
  */
 public function uploadPdfsToS3($id)
 {
     $client = S3Client::factory(['key' => env('AWS_KEY'), 'secret' => env('AWS_SECRET'), 'region' => env('AWS_REGION')]);
     $client->uploadDirectory(sprintf('%s/%s/pages/', $this->getWriteDirectory(), $id), env('AWS_BUCKET'), $id);
     $this->logger->info(sprintf("Pdf uploaded to S3 {%s}", env('AWS_BUCKET')));
 }