Index: VerpakkingsDefinitie/UI/LogInScherm.pas =================================================================== diff -u -r550 -r551 --- VerpakkingsDefinitie/UI/LogInScherm.pas (.../LogInScherm.pas) (revision 550) +++ VerpakkingsDefinitie/UI/LogInScherm.pas (.../LogInScherm.pas) (revision 551) @@ -15,35 +15,106 @@ EditGebruikersnaam: TEdit; Label3: TLabel; EditWachtwoord: TEdit; - Panel1: TPanel; - - procedure Panel1Click(Sender: TObject); + PanelLogIn: TPanel; + procedure PanelLogInClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure EditGebruikersnaamChange(Sender: TObject); + procedure PanelLogInMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure PanelLogInMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure PanelButtonEnableChange(Sender: TPanel); private - { Private declarations } + procedure Login(); public { Public declarations } end; implementation uses - Main, - UserServerService, Agent; + Main, Util, + UserServerService, Agent, ApplicationContext; {$R *.dfm} -procedure TFormLogin.Panel1Click(Sender: TObject); +procedure TFormLogin.FormCreate(Sender: TObject); +begin + EditWachtwoord.PasswordChar := '*'; // Verberg paswoord + PanelLogIn.Enabled := false; + PanelButtonEnableChange(PanelLogIn); +end; + +procedure TFormLogin.PanelLogInClick(Sender: TObject); +begin + Login(); +end; + +// Indrukken van button simuleren op panel: http://www.festra.com/wwwboard/messages/1006.html +procedure TFormLogin.PanelLogInMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + (Sender as TPanel).BevelOuter := bvLowered; +end; + +procedure TFormLogin.PanelLogInMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + (Sender as TPanel).BevelOuter := bvRaised; +end; + +procedure TFormLogin.PanelButtonEnableChange(Sender: TPanel); +begin + if Sender.Enabled then + begin + Sender.ParentBackground := True; // Neem kleur van parent (default) + Sender.Font.Color := clWhite; + end + else + begin + Sender.ParentBackground := false; + // Neem kleur van parent en maak donkerder + Sender.Color := TColor(TUtilColorLightener.LightenColor(Vcl.Graphics.ColorToRGB(PanelLogIn.Parent.Brush.Color), 70)); + Sender.Font.Color := clGray; + end; + +end; + +procedure TFormLogin.EditGebruikersnaamChange(Sender: TObject); +begin + // We kijken enkel naar gebruikersnaam, want leeg ww zou geldig kunnen zijn + PanelLogIn.Enabled := EditGebruikersnaam.Text <> EmptyStr; + PanelButtonEnableChange(PanelLogIn); +end; + +procedure TFormLogin.Login(); var - Response: PxStatus; - fAgent: TAgent; + Agent: TAgent; + ErrorMessage: string; begin - fAgent := TAgent.Create(); - //Response := fAgent.GebruikerAanmelden(EditGebruikersnaam.Text,EditWachtwoord.Text); - Response := fAgent.GebruikerAanmelden('tve','tve1502'); - ShowMessage(Response.ToString); + Agent := nil; + try + Agent := TAgent.Create(); + Agent.GebruikerAanmelden(EditGebruikersnaam.Text, EditWachtwoord.Text, ApplicationContextObj.UserServerServiceContext); - // TODO controleren of login succesvol was en waarden invullen in ApplicationContext - //(self.Parent.Parent as TFormMain).NavigeerNaar(Main.FORMZOEKPRODUCTENID); + if ApplicationContextObj.UserServerServiceContext.IsOK then + begin + (self.Navigator as TFormMain).NavigeerNaar(Main.NAVZOEKPRODUCTEN); + end + else + begin + // Login gefaald + ErrorMessage := ApplicationContextObj.UserServerServiceContext.ErrorMessage; + if ApplicationContextObj.UserServerServiceContext.InternalErrorMessage <> '' then + begin + ErrorMessage := ErrorMessage + sLineBreak + ApplicationContextObj.UserServerServiceContext.InternalErrorMessage; + end; + + if MessageDlg(ErrorMessage, TMsgDlgType.mtInformation, [mbRetry, mbCancel], 0, mbCancel) = mrRetry then + begin + // Retry gedrukt + Login(); + end; + end; + finally + Agent.Free(); + end; end; end. Index: VerpakkingsDefinitie/WS/UserServerService.pas =================================================================== diff -u -r548 -r551 --- VerpakkingsDefinitie/WS/UserServerService.pas (.../UserServerService.pas) (revision 548) +++ VerpakkingsDefinitie/WS/UserServerService.pas (.../UserServerService.pas) (revision 551) @@ -4,9 +4,9 @@ // WSDL : http://cacheaccept2010:57772/csp/dev1/WS.Sys.Toegang.UserServer.CLS?WSDL=1 // >Import : http://cacheaccept2010:57772/csp/dev1/WS.Sys.Toegang.UserServer.CLS?WSDL=1>0 // Encoding : UTF-8 -// Codegen : [wfSkipUnusedTypes-, wfAllowOutParameters+] +// Codegen : [wfUnwindLiteralParameters-, wfOutputLiteralTypes+] // Version : 1.0 -// (2/08/2021 14:58:05 - - $Rev: 45757 $) +// (3/08/2021 12:55:09 - - $Rev: 45757 $) // ************************************************************************ // unit UserServerService; @@ -32,12 +32,105 @@ // !:string - "http://www.w3.org/2001/XMLSchema"[Gbl] // !:boolean - "http://www.w3.org/2001/XMLSchema"[Gbl] + LogInResponse = class; { "http://vhintra.vanhoecke.be"[GblElm] } + LogOutResponse = class; { "http://vhintra.vanhoecke.be"[GblElm] } + LogOut = class; { "http://vhintra.vanhoecke.be"[GblElm] } + LogIn = class; { "http://vhintra.vanhoecke.be"[GblElm] } pxStatus = class; { "http://vhintra.vanhoecke.be"[GblCplx] } pxLogIn = class; { "http://vhintra.vanhoecke.be"[GblCplx] } // ************************************************************************ // + // XML : LogInResponse, global, + // Namespace : http://vhintra.vanhoecke.be + // ************************************************************************ // + LogInResponse = class(TRemotable) + private + FLogInResult: pxStatus; + FpxLogIn: pxLogIn; + FpxLogIn_Specified: boolean; + procedure SetpxLogIn(Index: Integer; const ApxLogIn: pxLogIn); + function pxLogIn_Specified(Index: Integer): boolean; + public + destructor Destroy; override; + published + property LogInResult: pxStatus read FLogInResult write FLogInResult; + property pxLogIn: pxLogIn Index (IS_OPTN) read FpxLogIn write SetpxLogIn stored pxLogIn_Specified; + end; + + + + // ************************************************************************ // + // XML : LogOutResponse, global, + // Namespace : http://vhintra.vanhoecke.be + // ************************************************************************ // + LogOutResponse = class(TRemotable) + private + FLogOutResult: pxStatus; + public + destructor Destroy; override; + published + property LogOutResult: pxStatus read FLogOutResult write FLogOutResult; + end; + + + + // ************************************************************************ // + // XML : LogOut, global, + // Namespace : http://vhintra.vanhoecke.be + // ************************************************************************ // + LogOut = class(TRemotable) + private + FSessionKey: string; + FSessionKey_Specified: boolean; + procedure SetSessionKey(Index: Integer; const Astring: string); + function SessionKey_Specified(Index: Integer): boolean; + published + property SessionKey: string Index (IS_OPTN) read FSessionKey write SetSessionKey stored SessionKey_Specified; + end; + + + + // ************************************************************************ // + // XML : LogIn, global, + // Namespace : http://vhintra.vanhoecke.be + // ************************************************************************ // + LogIn = class(TRemotable) + private + FApplication_: string; + FApplication__Specified: boolean; + FGebruikersNaam: string; + FGebruikersNaam_Specified: boolean; + FWachtWoord: string; + FWachtWoord_Specified: boolean; + FDomein: string; + FDomein_Specified: boolean; + FpxLogIn: pxLogIn; + FpxLogIn_Specified: boolean; + procedure SetApplication_(Index: Integer; const Astring: string); + function Application__Specified(Index: Integer): boolean; + procedure SetGebruikersNaam(Index: Integer; const Astring: string); + function GebruikersNaam_Specified(Index: Integer): boolean; + procedure SetWachtWoord(Index: Integer; const Astring: string); + function WachtWoord_Specified(Index: Integer): boolean; + procedure SetDomein(Index: Integer; const Astring: string); + function Domein_Specified(Index: Integer): boolean; + procedure SetpxLogIn(Index: Integer; const ApxLogIn: pxLogIn); + function pxLogIn_Specified(Index: Integer): boolean; + public + destructor Destroy; override; + published + property Application_: string Index (IS_OPTN) read FApplication_ write SetApplication_ stored Application__Specified; + property GebruikersNaam: string Index (IS_OPTN) read FGebruikersNaam write SetGebruikersNaam stored GebruikersNaam_Specified; + property WachtWoord: string Index (IS_OPTN) read FWachtWoord write SetWachtWoord stored WachtWoord_Specified; + property Domein: string Index (IS_OPTN) read FDomein write SetDomein stored Domein_Specified; + property pxLogIn: pxLogIn Index (IS_OPTN) read FpxLogIn write SetpxLogIn stored pxLogIn_Specified; + end; + + + + // ************************************************************************ // // XML : pxStatus, global, // Namespace : http://vhintra.vanhoecke.be // ************************************************************************ // @@ -121,8 +214,8 @@ // ************************************************************************ // UserServerSoap = interface(IInvokable) ['{161BA6C5-717D-1FD5-0A06-6B43E6A58125}'] - function LogIn(const Application_: string; const GebruikersNaam: string; const WachtWoord: string; const Domein: string; var pxLogIn: pxLogIn): pxStatus; stdcall; - function LogOut(const SessionKey: string): pxStatus; stdcall; + function LogIn(const parameters: LogIn): LogInResponse; stdcall; + function LogOut(const parameters: LogOut): LogOutResponse; stdcall; end; function GetUserServerSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): UserServerSoap; @@ -168,6 +261,102 @@ end; +destructor LogInResponse.Destroy; +begin + SysUtils.FreeAndNil(FLogInResult); + SysUtils.FreeAndNil(FpxLogIn); + inherited Destroy; +end; + +procedure LogInResponse.SetpxLogIn(Index: Integer; const ApxLogIn: pxLogIn); +begin + FpxLogIn := ApxLogIn; + FpxLogIn_Specified := True; +end; + +function LogInResponse.pxLogIn_Specified(Index: Integer): boolean; +begin + Result := FpxLogIn_Specified; +end; + +destructor LogOutResponse.Destroy; +begin + SysUtils.FreeAndNil(FLogOutResult); + inherited Destroy; +end; + +procedure LogOut.SetSessionKey(Index: Integer; const Astring: string); +begin + FSessionKey := Astring; + FSessionKey_Specified := True; +end; + +function LogOut.SessionKey_Specified(Index: Integer): boolean; +begin + Result := FSessionKey_Specified; +end; + +destructor LogIn.Destroy; +begin + SysUtils.FreeAndNil(FpxLogIn); + inherited Destroy; +end; + +procedure LogIn.SetApplication_(Index: Integer; const Astring: string); +begin + FApplication_ := Astring; + FApplication__Specified := True; +end; + +function LogIn.Application__Specified(Index: Integer): boolean; +begin + Result := FApplication__Specified; +end; + +procedure LogIn.SetGebruikersNaam(Index: Integer; const Astring: string); +begin + FGebruikersNaam := Astring; + FGebruikersNaam_Specified := True; +end; + +function LogIn.GebruikersNaam_Specified(Index: Integer): boolean; +begin + Result := FGebruikersNaam_Specified; +end; + +procedure LogIn.SetWachtWoord(Index: Integer; const Astring: string); +begin + FWachtWoord := Astring; + FWachtWoord_Specified := True; +end; + +function LogIn.WachtWoord_Specified(Index: Integer): boolean; +begin + Result := FWachtWoord_Specified; +end; + +procedure LogIn.SetDomein(Index: Integer; const Astring: string); +begin + FDomein := Astring; + FDomein_Specified := True; +end; + +function LogIn.Domein_Specified(Index: Integer): boolean; +begin + Result := FDomein_Specified; +end; + +procedure LogIn.SetpxLogIn(Index: Integer; const ApxLogIn: pxLogIn); +begin + FpxLogIn := ApxLogIn; + FpxLogIn_Specified := True; +end; + +function LogIn.pxLogIn_Specified(Index: Integer): boolean; +begin + Result := FpxLogIn_Specified; +end; + procedure pxStatus.SetIsOK(Index: Integer; const ABoolean: Boolean); begin FIsOK := ABoolean; @@ -283,13 +472,12 @@ InvRegistry.RegisterInterface(TypeInfo(UserServerSoap), 'http://vhintra.vanhoecke.be', 'UTF-8'); InvRegistry.RegisterDefaultSOAPAction(TypeInfo(UserServerSoap), 'http://vhintra.vanhoecke.be/WS.Sys.Toegang.UserServer.%operationName%'); InvRegistry.RegisterInvokeOptions(TypeInfo(UserServerSoap), ioDocument); - { UserServerSoap.LogIn } - InvRegistry.RegisterMethodInfo(TypeInfo(UserServerSoap), 'LogIn', '', - '[ReturnName="LogInResult"]'); - InvRegistry.RegisterParamInfo(TypeInfo(UserServerSoap), 'LogIn', 'Application_', 'Application', ''); - { UserServerSoap.LogOut } - InvRegistry.RegisterMethodInfo(TypeInfo(UserServerSoap), 'LogOut', '', - '[ReturnName="LogOutResult"]'); + InvRegistry.RegisterInvokeOptions(TypeInfo(UserServerSoap), ioLiteral); + RemClassRegistry.RegisterXSClass(LogInResponse, 'http://vhintra.vanhoecke.be', 'LogInResponse'); + RemClassRegistry.RegisterXSClass(LogOutResponse, 'http://vhintra.vanhoecke.be', 'LogOutResponse'); + RemClassRegistry.RegisterXSClass(LogOut, 'http://vhintra.vanhoecke.be', 'LogOut'); + RemClassRegistry.RegisterXSClass(LogIn, 'http://vhintra.vanhoecke.be', 'LogIn'); + RemClassRegistry.RegisterExternalPropName(TypeInfo(LogIn), 'Application_', '[ExtName="Application"]'); RemClassRegistry.RegisterXSClass(pxStatus, 'http://vhintra.vanhoecke.be', 'pxStatus'); RemClassRegistry.RegisterExternalPropName(TypeInfo(pxStatus), 'Message_', '[ExtName="Message"]'); RemClassRegistry.RegisterXSClass(pxLogIn, 'http://vhintra.vanhoecke.be', 'pxLogIn'); Index: VerpakkingsDefinitie/UI/Subscherm.pas =================================================================== diff -u -r550 -r551 --- VerpakkingsDefinitie/UI/Subscherm.pas (.../Subscherm.pas) (revision 550) +++ VerpakkingsDefinitie/UI/Subscherm.pas (.../Subscherm.pas) (revision 551) @@ -8,28 +8,30 @@ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ActnList, Vcl.ImgList, Vcl.ExtCtrls, Soap.InvokeRegistry, Soap.Rio, Soap.SOAPHTTPClient, Data.DB, Datasnap.DBClient, Soap.SOAPConn, Agent, - ApplicationContext; + Main, ApplicationContext; type TFormSubscherm = class(TForm) private - fApplicationContext: TApplicationContext; + FNavigator: TFormMain; + FApplicationContext: TApplicationContext; + protected + property Navigator: TFormMain Read FNavigator write FNavigator; + property ApplicationContextObj: TApplicationContext Read FApplicationContext write FApplicationContext; public - property ApplicationContext: TApplicationContext Read fApplicationContext - write fApplicationContext; - - Constructor Create(AOwner: TComponent; var ApplicationContext: TApplicationContext); overload; + Constructor Create(AOwner: TComponent; Navigator: TFormMain; var ApplicationContext: TApplicationContext); overload; end; implementation -constructor TFormSubscherm.Create(AOwner: TComponent; var ApplicationContext: TApplicationContext); +constructor TFormSubscherm.Create(AOwner: TComponent; Navigator: TFormMain; var ApplicationContext: TApplicationContext); begin inherited Create(AOwner); - Self.ApplicationContext := ApplicationContext; + Self.Navigator := Navigator; + Self.ApplicationContextObj := ApplicationContext; - BorderStyle := bsNone; // Alle subschermen hebben geen border + BorderStyle := bsNone; // Subschermen hebben geen border end; end. Index: VerpakkingsDefinitie/UI/LogInScherm.dfm =================================================================== diff -u -r550 -r551 --- VerpakkingsDefinitie/UI/LogInScherm.dfm (.../LogInScherm.dfm) (revision 550) +++ VerpakkingsDefinitie/UI/LogInScherm.dfm (.../LogInScherm.dfm) (revision 551) @@ -13,6 +13,7 @@ Font.Style = [] OldCreateOrder = False Position = poScreenCenter + OnCreate = FormCreate DesignSize = ( 192 240) @@ -67,6 +68,7 @@ Height = 21 Anchors = [akTop] TabOrder = 0 + OnChange = EditGebruikersnaamChange end object EditWachtwoord: TEdit Left = 19 @@ -76,7 +78,7 @@ Anchors = [akTop] TabOrder = 1 end - object Panel1: TPanel + object PanelLogIn: TPanel Left = 53 Top = 205 Width = 92 @@ -94,6 +96,8 @@ ParentBiDiMode = False ParentFont = False TabOrder = 2 - OnClick = Panel1Click + OnClick = PanelLogInClick + OnMouseDown = PanelLogInMouseDown + OnMouseUp = PanelLogInMouseUp end end Index: VerpakkingsDefinitie/Main.pas =================================================================== diff -u -r550 -r551 --- VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 550) +++ VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 551) @@ -9,8 +9,9 @@ ApplicationContext; const - FORMLOGINID = 1; - FORMZOEKPRODUCTENID = 2; + NAVHOME = 0; + NAVLOGIN = 1; + NAVZOEKPRODUCTEN = 2; type TFormMain = class(TForm) @@ -38,36 +39,37 @@ procedure TFormMain.FormCreate(Sender: TObject); begin fAppContext := TApplicationContext.Create(); - // TODO Wat doet dit in de originele applicatie?: fUiContext.ImagesScherm := TImagesScherm.Create(self); - // TODO kijken of "VerwerkParamStrings;" nodig is - + { TODO -cMain: Wat doet dit in de originele applicatie?: fUiContext.ImagesScherm := TImagesScherm.Create(self); } + { TODO -cMain: Kijken of "VerwerkParamStrings;" nodig is } + { TODO -cNavigatie : + 'Scherm' cre�ren vanuit code. Tweede 'scherm' maken met twee secties (30%-70%). } PanelMain := TPanel.Create(Self); PanelMain.Parent := Self; PanelMain.Align := alClient; - Self.NavigeerNaar(FORMLOGINID); + Self.NavigeerNaar(NAVLOGIN); end; - // TODO afmeld optie toevoegen +// { TODO -cMain: afmeld optie toevoegen } procedure TFormMain.NavigeerNaar(schermId: Integer); begin Application.ProcessMessages; // Interrupts the execution of an application so that it can process the message queue. // Volgende subscherm laden in panel - begin - fHuidigScherm.Free; - case schermId of - FORMLOGINID: - fHuidigScherm := TFormLogin.Create(PanelMain, fAppContext); - FORMZOEKPRODUCTENID: - fHuidigScherm := TFormZoekProducten.Create(PanelMain, fAppContext); - end; - - fHuidigScherm.Parent := PanelMain; - fHuidigScherm.Align := alClient; - fHuidigScherm.Show; + fHuidigScherm.Free; + case schermId of + NAVHOME: + fHuidigScherm := TFormZoekProducten.Create(PanelMain, Self, fAppContext); + NAVLOGIN: + fHuidigScherm := TFormLogin.Create(PanelMain, Self, fAppContext); + NAVZOEKPRODUCTEN: + fHuidigScherm := TFormZoekProducten.Create(PanelMain, Self, fAppContext); end; + + fHuidigScherm.Parent := PanelMain; + fHuidigScherm.Align := alClient; + fHuidigScherm.Show; end; end. Index: VerpakkingsDefinitie/WS/Agent.pas =================================================================== diff -u -r548 -r551 --- VerpakkingsDefinitie/WS/Agent.pas (.../Agent.pas) (revision 548) +++ VerpakkingsDefinitie/WS/Agent.pas (.../Agent.pas) (revision 551) @@ -2,44 +2,91 @@ interface -uses UserServerService; +uses SysUtils, + ApplicationContext, UserServerService; +// Resource strings are stored as resources and linked into the executable or +// library so that they can be modified without recompiling the program. +resourcestring + USER_SERVER_URL = 'http://cacheaccept2010:57772/csp/dev1/WS.Sys.Toegang.UserServer.cls'; + APPLICATION_NAME = 'vhintra'; + DOMAIN_NAME = '1'; + type TAgent = class private - fServer: String; - fUserServerSoap: UserServerSoap; + FUserServerSoap: UserServerSoap; + procedure RegistreerLoginGegevens(UserServerServiceContext: TUserServerServiceContext; pxLogInObj: pxLogIn); + procedure RegistreerMislukteLogin(UserServerServiceContext: TUserServerServiceContext; pxStatusObj: pxStatus); public Constructor Create(); overload; - function GebruikerAanmelden(Gebruikersnaam: string; Wachtwoord: string) : PxStatus; + procedure GebruikerAanmelden(GebruikersNaam: string; Wachtwoord: string; + UserServerServiceContext: TUserServerServiceContext); end; implementation constructor TAgent.Create(); -var - fNamespace: string; - fUserServer: string; begin - fServer := 'cachedevut2010'; - fNamespace := 'dev1'; - if fServer = 'cache01' then - fNamespace := 'admin1'; - //fUserServer := 'http://' + fServer + ':57772/csp/' + fNamespace + '/WS.Halux.AAP.GebruikerService.cls'; - fUserServer := 'http://cacheaccept2010:57772/csp/dev1/WS.Sys.Toegang.UserServer.cls'; - fUserServerSoap := UserServerService.GetUserServerSoap(false, fUserServer, nil); + FUserServerSoap := UserServerService.GetUserServerSoap(false, USER_SERVER_URL, nil); end; -function TAgent.GebruikerAanmelden(Gebruikersnaam: string; Wachtwoord: string) : PxStatus; +procedure TAgent.GebruikerAanmelden(GebruikersNaam: string; Wachtwoord: string; + UserServerServiceContext: TUserServerServiceContext); var - fLogInObject: PxLogin; - fResponse: PxStatus; + LogInData: UserServerService.LogIn; + LogInResponseObj: UserServerService.LogInResponse; begin - fLogInObject := PxLogin.Create; - // By REF ingevuld wanneer pxStatus geen fout bevat - // LogIn(Application, GebruikersNaam, WachtWoord, Domein, pxLogIn) -> pxStatus - fResponse := fUserServerSoap.LogIn('vhintra', Gebruikersnaam, Wachtwoord, '1', fLogInObject); - Result := fResponse + LogInData := nil; + LogInResponseObj := nil; + try + // Request + LogInData := UserServerService.LogIn.Create(); + LogInData.Application_ := APPLICATION_NAME; + LogInData.GebruikersNaam := GebruikersNaam; + LogInData.Wachtwoord := Wachtwoord; + LogInData.Domein := DOMAIN_NAME; + LogInData.pxLogIn := nil; // Ongebruikt + + LogInResponseObj := FUserServerSoap.LogIn(LogInData); + + // Response + if LogInResponseObj.pxLogIn <> nil then + begin + // Gelukt + RegistreerLoginGegevens(UserServerServiceContext, LogInResponseObj.pxLogIn); + end + else + begin + // Mislukt + RegistreerMislukteLogin(UserServerServiceContext, LogInResponseObj.LogInResult); + end; + finally + LogInData.Free(); + LogInResponseObj.Free(); + end; end; +procedure TAgent.RegistreerLoginGegevens(UserServerServiceContext: TUserServerServiceContext; pxLogInObj: pxLogIn); +begin + // Andere velden juist zetten + UserServerServiceContext.IsOK := True; + UserServerServiceContext.ErrorMessage := ''; + UserServerServiceContext.InternalErrorMessage := ''; + + UserServerServiceContext.SessionKey := pxLogInObj.SessionKey; + UserServerServiceContext.GebruikersNaam := pxLogInObj.GebruikersNaam; +end; + +procedure TAgent.RegistreerMislukteLogin(UserServerServiceContext: TUserServerServiceContext; pxStatusObj: pxStatus); +begin + // Ander velden leegmaken + UserServerServiceContext.SessionKey := ''; + UserServerServiceContext.GebruikersNaam := ''; + + UserServerServiceContext.IsOK := pxStatusObj.IsOK; + UserServerServiceContext.ErrorMessage := pxStatusObj.Message_; + UserServerServiceContext.InternalErrorMessage := pxStatusObj.InternalMessage; +end; + end. Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r547 -r551 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 547) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 551) @@ -3,13 +3,45 @@ // Dit is een klasse bedoeld om data te delen over de applicatie heen. // Dit kan bijvoorbeeld usernaam, login token, computernaam, ... // Informatie die elk component/klasse kan gebruiken. +// Voor schaalbaarheid en isolatie worden interfaces gebruikt die deze klasse implementeert. interface +// SUB CONTEXTS: klassen die overeenkomen met bepaalde sub-context (bv. alles gerelateerd met authenticatie). + +// - UserServerService type + TUserServerServiceContext = class + private + FSessionKey: string; + FGebruikersNaam: string; + + FIsOK: Boolean; + FErrorMessage: string; + FInternalErrorMessage: string; + public + property SessionKey: string read FSessionKey write FSessionKey; + property GebruikersNaam: string read FGebruikersNaam write FGebruikersNaam; + property IsOK: Boolean read FIsOK write FIsOK; + property ErrorMessage: string read FErrorMessage write FErrorMessage; + property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; + end; + + // APPLICATION CONTEXT + // Application context bevat alle sub-contexts TApplicationContext = class + private + FUserServerServiceContext: TUserServerServiceContext; + public + constructor Create(); + property UserServerServiceContext: TUserServerServiceContext read FUserServerServiceContext write FUserServerServiceContext; end; implementation +constructor TApplicationContext.Create(); +begin + FUserServerServiceContext := TUserServerServiceContext.Create(); +end; + end. Index: VerpakkingsDefinitie/UI/Util.pas =================================================================== diff -u --- VerpakkingsDefinitie/UI/Util.pas (revision 0) +++ VerpakkingsDefinitie/UI/Util.pas (revision 551) @@ -0,0 +1,188 @@ +unit Util; + +interface + +uses System.Types, Vcl.Graphics; // Color lightener + +type + TUtilColorLightener = class + class function LightenColor(RGB: Cardinal; Percentage: Integer): Cardinal;static; + end; + +implementation + +// COLOR LIGHTENER +// https://stackoverflow.com/questions/39569710/how-to-lighten-or-darken-a-specified-tcolor-in-inno-setup-pascal-script +function GetRValue(RGB: Cardinal): Byte; +begin + Result := Byte(RGB); +end; + +function GetGValue(RGB: Cardinal): Byte; +begin + Result := Byte(RGB shr 8); +end; + +function GetBValue(RGB: Cardinal): Byte; +begin + Result := Byte(RGB shr 16); +end; + +function Max(A, B: Integer): Integer; +begin + if A > B then + Result := A + else + Result := B; +end; + +function Min(A, B: Integer): Integer; +begin + if A < B then + Result := A + else + Result := B; +end; + +const + HLSMAX = 240; + RGBMAX = 255; + HLSUndefined = (HLSMAX * 2 / 3); + +procedure ColorRGBToHLS(RGB: Cardinal; var Hue, Luminance, Saturation: Word); +var + H, L, S: Double; + R, G, B: Word; + cMax, cMin: Double; + Rdelta, Gdelta, Bdelta: Word; { intermediate value: % of spread from max } +begin + R := GetRValue(RGB); + G := GetGValue(RGB); + B := GetBValue(RGB); + + { calculate lightness } + cMax := Max(Max(R, G), B); + cMin := Min(Min(R, G), B); + L := (((cMax + cMin) * HLSMAX) + RGBMAX) / (2 * RGBMAX); + Luminance := Trunc(L); + if cMax = cMin then { r=g=b --> achromatic case } + begin + Hue := Trunc(HLSUndefined); + Saturation := 0; + end + else { chromatic case } + begin + { saturation } + if Luminance <= HLSMAX / 2 then + S := (((cMax - cMin) * HLSMAX) + ((cMax + cMin) / 2)) / (cMax + cMin) + else + S := (((cMax - cMin) * HLSMAX) + ((2 * RGBMAX - cMax - cMin) / 2)) / (2 * RGBMAX - cMax - cMin); + + { hue } + Rdelta := Trunc((((cMax - R) * (HLSMAX / 6)) + ((cMax - cMin) / 2)) / (cMax - cMin)); + Gdelta := Trunc((((cMax - G) * (HLSMAX / 6)) + ((cMax - cMin) / 2)) / (cMax - cMin)); + Bdelta := Trunc((((cMax - B) * (HLSMAX / 6)) + ((cMax - cMin) / 2)) / (cMax - cMin)); + + if (R = cMax) then + begin + H := Bdelta - Gdelta + end + else if (G = cMax) then + begin + H := (HLSMAX / 3) + Rdelta - Bdelta + end + else // B == cMax + begin + H := ((2 * HLSMAX) / 3) + Gdelta - Rdelta; + end; + + if (H < 0) then + H := H + HLSMAX; + if (H > HLSMAX) then + H := H - HLSMAX; + + Hue := Round(H); + Saturation := Trunc(S); + end; +end; + +function HueToRGB(Lum, Sat, Hue: Double): Integer; +var + ResultEx: Double; +begin + { range check: note values passed add/subtract thirds of range } + if (Hue < 0) then + Hue := Hue + HLSMAX; + + if (Hue > HLSMAX) then + Hue := Hue - HLSMAX; + + { return r,g, or b value from this tridrant } + if (Hue < (HLSMAX / 6)) then + ResultEx := Lum + (((Sat - Lum) * Hue + (HLSMAX / 12)) / (HLSMAX / 6)) + else if (Hue < (HLSMAX / 2)) then + ResultEx := Sat + else if (Hue < ((HLSMAX * 2) / 3)) then + ResultEx := Lum + (((Sat - Lum) * (((HLSMAX * 2) / 3) - Hue) + (HLSMAX / 12)) / (HLSMAX / 6)) + else + ResultEx := Lum; + Result := Round(ResultEx); +end; + +function RoundColor(Value: Double): Integer; +begin + if Value > 255 then + Result := 255 + else + Result := Round(Value); +end; + +function RGB(R, G, B: Byte): Cardinal; +begin + Result := (Cardinal(R) or (Cardinal(G) shl 8) or (Cardinal(B) shl 16)); +end; + +function ColorHLSToRGB(Hue, Luminance, Saturation: Word): Cardinal; +var + R, G, B: Double; { RGB component values } + Magic1, Magic2: Double; { calculated magic numbers (really!) } +begin + if (Saturation = 0) then + begin { achromatic case } + R := (Luminance * RGBMAX) / HLSMAX; + G := R; + B := R; + if (Hue <> HLSUndefined) then; { ERROR } + end + else + begin { chromatic case } + { set up magic numbers } + if (Luminance <= (HLSMAX / 2)) then + begin + Magic2 := (Luminance * (HLSMAX + Saturation) + (HLSMAX / 2)) / HLSMAX; + end + else + begin + Magic2 := Luminance + Saturation - ((Luminance * Saturation) + (HLSMAX / 2)) / HLSMAX; + end; + Magic1 := 2 * Luminance - Magic2; + + { get RGB, change units from HLSMAX to RGBMAX } + R := (HueToRGB(Magic1, Magic2, Hue + (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX; + G := (HueToRGB(Magic1, Magic2, Hue) * RGBMAX + (HLSMAX / 2)) / HLSMAX; + B := (HueToRGB(Magic1, Magic2, Hue - (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX; + end; + Result := RGB(RoundColor(R), RoundColor(G), RoundColor(B)); +end; + +class function TUtilColorLightener.LightenColor(RGB: Cardinal; Percentage: Integer): Cardinal; +var + H, S, L: Word; +begin + ColorRGBToHLS(RGB, H, L, S); + L := (Integer(L) * Percentage) div 100; + Result := ColorHLSToRGB(H, L, S); +end; + +// ----- COLOR LIGHTENER +end.