Commit aaffc371 by Cam Hayes

fixed issue with error not displaying when unable to connect to database

parent 5aaae14f
...@@ -109,6 +109,7 @@ procedure TAuthService.Login(AUser, APassword: string; ASuccess: TOnLoginSuccess ...@@ -109,6 +109,7 @@ procedure TAuthService.Login(AUser, APassword: string; ASuccess: TOnLoginSuccess
end; end;
begin begin
console.log('login');
if (AUser = '') or (APassword = '') then if (AUser = '') or (APassword = '') then
begin begin
AError('Please enter a username and a password'); AError('Please enter a username and a password');
......
...@@ -107,11 +107,10 @@ begin ...@@ -107,11 +107,10 @@ begin
LoadConfig(@ConfigLoaded); LoadConfig(@ConfigLoaded);
end; end;
procedure TDMConnection.SetClientConfig(Callback: TVersionCheckCallback); procedure TDMConnection.SetClientConfig(Callback: TVersionCheckCallback);
begin begin
XDataWebClient1.Connection := AuthConnection; XDataWebClient1.Connection := AuthConnection;
console.log('ClientConfig');
XDataWebClient1.RawInvoke('IAuthService.VerifyVersion', [clientVersion], XDataWebClient1.RawInvoke('IAuthService.VerifyVersion', [clientVersion],
procedure(Response: TXDataClientResponse) procedure(Response: TXDataClientResponse)
var var
...@@ -119,6 +118,7 @@ begin ...@@ -119,6 +118,7 @@ begin
error: string; error: string;
begin begin
jsonResult := TJSObject(Response.Result); jsonResult := TJSObject(Response.Result);
console.log(jsonResult);
if jsonResult.HasOwnProperty('error') then if jsonResult.HasOwnProperty('error') then
error := string(jsonResult['error']) error := string(jsonResult['error'])
...@@ -129,6 +129,10 @@ begin ...@@ -129,6 +129,10 @@ begin
Callback(False, error) Callback(False, error)
else else
Callback(True, ''); Callback(True, '');
end,
procedure(Error: TXDataClientError)
begin
Callback(False, Error.ErrorMessage);
end); end);
end; end;
......
...@@ -343,6 +343,7 @@ begin ...@@ -343,6 +343,7 @@ begin
xdwdsShipTo.Open; xdwdsShipTo.Open;
console.log(xdwdsShipTo.RecordCount); console.log(xdwdsShipTo.RecordCount);
console.log(notification['ADDRESS']);
console.log(xdwdsShipTo.FieldByName('state').AsString); console.log(xdwdsShipTo.FieldByName('state').AsString);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString; edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString;
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString; edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString;
......
...@@ -112,6 +112,7 @@ object FViewCustomers: TFViewCustomers ...@@ -112,6 +112,7 @@ object FViewCustomers: TFViewCustomers
Header.ListItemElementClassName = 'page-item' Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link' Header.ListLinkElementClassName = 'page-link'
WordWrap = True WordWrap = True
OnClickCell = wdbtcCustomersClickCell
OnDblClickCell = wdbtcCustomersDblClickCell OnDblClickCell = wdbtcCustomersDblClickCell
Columns = < Columns = <
item item
......
...@@ -38,6 +38,7 @@ type ...@@ -38,6 +38,7 @@ type
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer); procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure edtFilterChange(Sender: TObject); procedure edtFilterChange(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject); procedure wcbPageSizeChange(Sender: TObject);
procedure wdbtcCustomersClickCell(Sender: TObject; ACol, ARow: Integer);
private private
{ Private declarations } { Private declarations }
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
...@@ -170,6 +171,12 @@ begin ...@@ -170,6 +171,12 @@ begin
getCustomers(GenerateSearchOptions()); getCustomers(GenerateSearchOptions());
end; end;
procedure TFViewCustomers.wdbtcCustomersClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
console.log(xdwdsCustomersSHORT_NAME.AsString);
end;
procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol, procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol,
ARow: Integer); ARow: Integer);
begin begin
......
...@@ -89,27 +89,28 @@ begin ...@@ -89,27 +89,28 @@ begin
end end
else else
begin begin
asm // asm
var dlg = document.createElement("dialog"); // var dlg = document.createElement("dialog");
dlg.classList.add("shadow", "rounded", "border", "p-4"); // dlg.classList.add("shadow", "rounded", "border", "p-4");
dlg.style.maxWidth = "500px"; // dlg.style.maxWidth = "500px";
dlg.style.width = "90%"; // dlg.style.width = "90%";
dlg.style.fontFamily = "system-ui, sans-serif"; // dlg.style.fontFamily = "system-ui, sans-serif";
//
dlg.innerHTML = // dlg.innerHTML =
"<h5 class='fw-bold mb-3 text-danger'>kgOrders web app</h5>" + // "<h5 class='fw-bold mb-3 text-danger'>kgOrders web app</h5>" +
"<p class='mb-3' style='white-space: pre-wrap;'>" + ErrorMessage + "</p>" + // "<p class='mb-3' style='white-space: pre-wrap;'>" + ErrorMessage + "</p>" +
"<div class='text-end'>" + // "<div class='text-end'>" +
"<button id='refreshBtn' class='btn btn-primary'>Reload</button></div>"; // "<button id='refreshBtn' class='btn btn-primary'>Reload</button></div>";
//
document.body.appendChild(dlg); // document.body.appendChild(dlg);
dlg.showModal(); // dlg.showModal();
//
document.getElementById("refreshBtn").addEventListener("click", function () { // document.getElementById("refreshBtn").addEventListener("click", function () {
var base = location.origin + location.pathname; // var base = location.origin + location.pathname;
location.replace(base + "?ver=" + ClientVer + "&r=" + Date.now() + location.hash); // location.replace(base + "?ver=" + ClientVer + "&r=" + Date.now() + location.hash);
}); // });
end; // end;
ShowMessage( 'Error connecting to kgOrdersServer' + sLineBreak + 'Please contact EM Systems support' );
end; end;
end); end);
end, end,
......
...@@ -99,9 +99,9 @@ ...@@ -99,9 +99,9 @@
<VerInfo_MajorVer>0</VerInfo_MajorVer> <VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer> <VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_Release>8</VerInfo_Release> <VerInfo_Release>8</VerInfo_Release>
<TMSWebBrowser>1</TMSWebBrowser>
<TMSUseJSDebugger>2</TMSUseJSDebugger> <TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebSingleInstance>1</TMSWebSingleInstance> <TMSWebSingleInstance>1</TMSWebSingleInstance>
<TMSWebBrowser>5</TMSWebBrowser>
<TMSWebOutputPath>..\kgOrdersServer\bin\static</TMSWebOutputPath> <TMSWebOutputPath>..\kgOrdersServer\bin\static</TMSWebOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''"> <PropertyGroup Condition="'$(Cfg_2)'!=''">
......
...@@ -55,17 +55,15 @@ begin ...@@ -55,17 +55,15 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log( 1, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message ); Logger.Log( 1, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message );
raise EXDataHttpException.Create(500, 'Error Connecting to database! Please try again later or contact a system admin!'); raise; //EXDataHttpException.Create(500, 'Error Connecting to database! Please try again later or contact a system admin!');
end; end;
end; end;
end; end;
procedure TAuthDatabase.DataModuleDestroy(Sender: TObject); procedure TAuthDatabase.DataModuleDestroy(Sender: TObject);
begin begin
ucKG.Connected := false; ucKG.Connected := false;
Logger.Log( 5, 'TAuthDatabase.DataModuleDestroy' ); Logger.Log( 5, 'TAuthDatabase.DataModuleDestroy' );
end; end;
end. end.
...@@ -51,11 +51,16 @@ begin ...@@ -51,11 +51,16 @@ begin
try try
Logger.Log(4, 'TAuthService.AfterConstruction'); Logger.Log(4, 'TAuthService.AfterConstruction');
authDB := TAuthDatabase.Create(nil); authDB := TAuthDatabase.Create(nil);
if not authDB.ucKG.Connected then
begin
Logger.Log(1, 'Unable to connect to the database: A KGOrders Server Error has occured!');
raise EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
end;
except except
on E: Exception do on E: Exception do
begin begin
Logger.Log(1, 'Error creating the Auth database: ' + E.Message); Logger.Log(1, 'Error creating the Auth database: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!'); raise; //EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
end; end;
end; end;
end; end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment