Skip to content

Commit a8e7db3

Browse files
committed
error handling
1 parent 6f5f14a commit a8e7db3

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

Samples/OpenConnectUnit1.pas

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,19 @@ implementation
6767
{$R *.dfm}
6868

6969
procedure TMainForm.FormCreate(Sender: TObject);
70+
var
71+
configurationFilename : String;
7072
begin
7173
Suppliers:= TOpenConnectBusinessList.Create;
72-
Configuration := TMemIniFile.Create(ExtractFilePath(ExtractFileDir(ExtractFileDir(Application.ExeName)))+'configuration.ini');
74+
75+
if (Pos('Samples\Win32',Application.ExeName)>0) or (Pos('Samples\Win64',Application.ExeName)>0) then
76+
configurationFilename := ExtractFilePath(ExtractFileDir(ExtractFileDir(Application.ExeName)))
77+
else
78+
configurationFilename := ExtractFilePath(Application.ExeName);
79+
80+
configurationFilename := configurationFilename + 'configuration.ini';
81+
82+
Configuration := TMemIniFile.Create(configurationFilename);
7383
Editable := false;
7484

7585
Left := 50;

intf.OpenConnect.pas

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
License OpenConnect-for-Delphi
33
4-
Copyright (C) 2021 Landrix Software GmbH & Co. KG
4+
Copyright (C) 2022 Landrix Software GmbH & Co. KG
55
Sven Harazim, info@landrix.de
66
77
This program is free software: you can redistribute it and/or modify
@@ -24,7 +24,8 @@ interface
2424

2525
uses
2626
System.SysUtils, System.Classes,System.StrUtils,Vcl.Controls,
27-
System.Contnrs,Vcl.Dialogs,Vcl.Forms,System.IOUTils, System.Generics.Collections
27+
System.Contnrs,Vcl.Dialogs,Vcl.Forms,System.IOUTils,
28+
System.Generics.Collections, System.UITypes
2829
;
2930

3031
type
@@ -113,6 +114,7 @@ TOpenConnectHelper = class(TObject)
113114
public
114115
class function GetSupplierList(_ResultList : TOpenConnectBusinessList) : Boolean;
115116
class function CheckConnectivitiy(_LoginOptions : TOpenConnectLoginOptions; out _Connectivity : TOpenConnectConnectivityOptions) : Boolean;
117+
class function GetErrorCodeAsString(_ErrorNumber : Integer) : String;
116118
end;
117119

118120
implementation
@@ -271,6 +273,23 @@ function TOpenConnectBusinessList.Duplicate : TOpenConnectBusinessList;
271273

272274
{ TOpenConnectHelper }
273275

276+
class function TOpenConnectHelper.GetErrorCodeAsString(
277+
_ErrorNumber: Integer): String;
278+
begin
279+
case _ErrorNumber of
280+
1 : Result := 'Fehler bei der Authentifizierung der anfragenden Software.';
281+
2 : Result := 'Der angefragte Prozess existiert nicht im SHK Connect Server.';
282+
3 : Result := 'Das angefragte Unternehmen existiert nicht im SHK Connect Server.';
283+
4 : Result := 'Fehler bei der Authentifizierung des Anwenders beim Unternehmen.';
284+
5 : Result := 'Angefragte Branche existiert nicht.';
285+
6 : Result := 'Angefragte PLZ aus der Umkreissuche existiert nicht.';
286+
7 : Result := 'Fehler bei der Kommunikation mit dem angefragten Unternehmen.';
287+
9 : Result := 'Fehlerhafte Anfrage (z.B. Pflichtfelder in der Anfrage fehlen)';
288+
10 : Result := 'Testantwort';
289+
else Result := 'Es ist kein Fehler aufgetreten.';
290+
end;
291+
end;
292+
274293
class function TOpenConnectHelper.GetSupplierList(_ResultList: TOpenConnectBusinessList): Boolean;
275294
var
276295
bl_gb : GetBranchenListe;
@@ -309,8 +328,8 @@ class function TOpenConnectHelper.GetSupplierList(_ResultList: TOpenConnectBusin
309328
businessItm := _ResultList.GetItemByBusiness(bl_br.ID,SHKCONNECT_SERVICE_ARGE,true);
310329
businessItm.Description := bl_br.Name_;
311330
end;
312-
end;// else
313-
//WideMessageDialog(SHKCONNECT_SERVICE_ARGE+SHKCONNECT_SERVICE_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
331+
end else
332+
MessageDlg(SHKCONNECT_SERVICE_ARGE+SHKCONNECT_SERVICE_PROC_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
314333

315334
bl_resp.Free;
316335
bl_b := nil;
@@ -336,8 +355,8 @@ class function TOpenConnectHelper.GetSupplierList(_ResultList: TOpenConnectBusin
336355
businessItm := _ResultList.GetItemByBusiness(bl_br.ID,SHKCONNECT_SERVICE_SHKGH,true);
337356
businessItm.Description := bl_br.Name_;
338357
end;
339-
end;// else
340-
//WideMessageDialog(SHKCONNECT_SERVICE_SHKGH+SHKCONNECT_SERVICE_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
358+
end else
359+
MessageDlg(SHKCONNECT_SERVICE_SHKGH+SHKCONNECT_SERVICE_PROC_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
341360

342361
bl_resp.Free;
343362
bl_b := nil;
@@ -363,8 +382,8 @@ class function TOpenConnectHelper.GetSupplierList(_ResultList: TOpenConnectBusin
363382
businessItm := _ResultList.GetItemByBusiness(bl_br.ID,SHKCONNECT_SERVICE_OC,true);
364383
businessItm.Description := bl_br.Name_;
365384
end;
366-
end;// else
367-
//WideMessageDialog(SHKCONNECT_SERVICE_SHKGH+SHKCONNECT_SERVICE_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
385+
end else
386+
MessageDlg(SHKCONNECT_SERVICE_OC+SHKCONNECT_SERVICE_PROC_BL+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
368387

369388
bl_resp.Free;
370389
bl_b := nil;
@@ -404,8 +423,8 @@ class function TOpenConnectHelper.GetSupplierList(_ResultList: TOpenConnectBusin
404423
supplierItm.UsernameRequired := aa_u.Benutzername_erforderlich;
405424
supplierItm.PasswordRequired := aa_u.Passwort_erforderlich;
406425
end;
407-
end;// else
408-
//WideMessageDialog(SHKCONNECT_SERVICE_ARGE+SHKCONNECT_SERVICE_AA+#10+bl_resp.Status.Meldung, mtError, [mbOK], 0);
426+
end else
427+
MessageDlg(_ResultList[i].ServiceURL+SHKCONNECT_SERVICE_PROC_AA+#10+aa_resp.Status.Meldung, mtError, [mbOK], 0);
409428

410429
aa_resp.Free;
411430
aa_b := nil;
@@ -441,7 +460,7 @@ class function TOpenConnectHelper.CheckConnectivitiy(_LoginOptions: TOpenConnect
441460
exit;
442461
if _LoginOptions.SupplierID = 0 then
443462
exit;
444-
463+
445464
aia_gb := GetIndividuelleAuskunft.Create;
446465
try
447466
try
@@ -499,8 +518,7 @@ class function TOpenConnectHelper.CheckConnectivitiy(_LoginOptions: TOpenConnect
499518
end;
500519
Result := true;
501520
end else
502-
//WideMessageDialog(_LoginOptions.ServiceURL+SHKCONNECT_SERVICE_PROC_AIA+#10+aia_resp.Status.Meldung, mtError, [mbOK], 0);
503-
521+
MessageDlg(_LoginOptions.ServiceURL+SHKCONNECT_SERVICE_PROC_AIA+#10+aia_resp.Status.Meldung, mtError, [mbOK], 0);
504522

505523
aia_resp.Free;
506524
aia_b := nil;

0 commit comments

Comments
 (0)