Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev - System Notification in the Event of Data Interface Errors [jp-0002] #183

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/Console/Commands/ImportNonGovPledgeHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ protected function UpdateNonGovPledgeHistory($in_year)
$filter = '(yearcd eq '. $in_year .')';

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_NON_GOV_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_NON_GOV_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);

if ($response->successful()) {

$row_count = json_decode($response->body())->{'@odata.count'};

Expand Down Expand Up @@ -220,6 +222,15 @@ protected function UpdateNonGovPledgeHistory($in_year)

}

} else {

$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

throw new Exception( $response->status() . ' - ' . $response->body() );

}

// } catch (\Exception $ex) {

// // write to log message
Expand Down
32 changes: 24 additions & 8 deletions app/Console/Commands/ImportPledgeHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ protected function UpdatePledgeHistoryVendor()
{

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_VNDR_BI_ENDPOINT') .'?$count=true&$top=1');
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_VNDR_BI_ENDPOINT') .'?$count=true&$top=1');

if ($response->successful()) {
$row_count = json_decode($response->body())->{'@odata.count'};

if ($row_count > 0) {
// Truncate Pledge History table when records returned from BI
PledgeHistoryVendor::truncate();
Expand Down Expand Up @@ -252,6 +253,14 @@ protected function UpdatePledgeHistoryVendor()

}

} else {

$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

throw new Exception( $response->status() . ' - ' . $response->body() );
}

// } catch (\Exception $ex) {

// $this->status = 'Error';
Expand All @@ -272,10 +281,11 @@ protected function UpdatePledgeHistory($in_year)
$filter = '(yearcd eq '. $in_year .')';

// try {
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);
$response = Http::withHeaders(['Content-Type' => 'application/json'])
->withBasicAuth(env('ODS_USERNAME'),env('ODS_TOKEN'))
->get(env('ODS_INBOUND_REPORT_PLEDGE_HISTORY_BI_ENDPOINT') .'?$count=true&$top=1&$filter='.$filter);

if ($response->successful()) {
$row_count = json_decode($response->body())->{'@odata.count'};

$size = 10000;
Expand Down Expand Up @@ -373,10 +383,16 @@ protected function UpdatePledgeHistory($in_year)
$this->status = 'Error';
$this->LogMessage( $response->status() . ' - ' . $response->body() );

}
throw new Exception( $response->status() . ' - ' . $response->body() );

}
}

} else {

throw new Exception( $response->status() . ' - ' . $response->body() );
}

// } catch (\Exception $ex) {

// // write to log message
Expand Down
2 changes: 1 addition & 1 deletion app/MicrosoftGraph/SendEmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function send()
protected function sendMailUsingSMPTServer()
{

$this->subject = "PECSF [". App::environment() . "] -- The Process ('" . $this->job_id . " - ". $this->job_name . ")' was failed to complete.";
$this->subject = "PECSF [". App::environment() . "] -- The Process (" . $this->job_id . " - ". $this->job_name . ") was failed to complete.";

$this->body = "<p>";
$this->body .= "Process ID : " . $this->job_id . "</br>";
Expand Down