Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r561 -r563 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 561) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 563) @@ -9,11 +9,12 @@ uses ObserverPattern, - System.Generics.Collections; + System.Generics.Collections, + OptiServerService; // SUB CONTEXTS: klassen die overeenkomen met bepaalde sub-context (bv. alles gerelateerd met authenticatie). -// - UserServerService +// - User type TUserContext = class(TSubject) private @@ -32,6 +33,7 @@ property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; + // - Product Selection TProductInformatie = class private FProductNr: Integer; @@ -51,7 +53,6 @@ TProductsContext = class(TSubject) private - FSessionKey: string; FProducten: TList; FIsOK: Boolean; @@ -67,17 +68,22 @@ property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; + // - Product Detail + // TProductDetailInformatie = class() + // end; + TProductDetailContext = class(TSubject) private - FSessionKey: string; FGeselecteerdProduct: TProductInformatie; + FProductDetailInformatie: OptiServerService.pxBoxData; FIsOK: Boolean; FErrorMessage: string; FInternalErrorMessage: string; public procedure NotifyChanged(); property GeselecteerdProduct: TProductInformatie read FGeselecteerdProduct write FGeselecteerdProduct; + property ProductDetailInformatie: OptiServerService.pxBoxData read FProductDetailInformatie write FProductDetailInformatie; property IsOK: Boolean read FIsOK write FIsOK; property ErrorMessage: string read FErrorMessage write FErrorMessage; Index: VerpakkingsDefinitie/WS/OptiServerService.pas =================================================================== diff -u -r562 -r563 --- VerpakkingsDefinitie/WS/OptiServerService.pas (.../OptiServerService.pas) (revision 562) +++ VerpakkingsDefinitie/WS/OptiServerService.pas (.../OptiServerService.pas) (revision 563) @@ -1,3 +1,4 @@ +// AANGEPASTE VERSIE VAN GEGENEREERD // ************************************************************************ // // The types declared in this file were generated from data read from the // WSDL File described below: Index: VerpakkingsDefinitie/WS/SelectService.pas =================================================================== diff -u -r560 -r563 --- VerpakkingsDefinitie/WS/SelectService.pas (.../SelectService.pas) (revision 560) +++ VerpakkingsDefinitie/WS/SelectService.pas (.../SelectService.pas) (revision 563) @@ -1,3 +1,4 @@ +// AANGEPASTE VERSIE VAN GEGENEREERD // ************************************************************************ // // The types declared in this file were generated from data read from the // WSDL File described below: Index: VerpakkingsDefinitie/WS/ProductsAgent.pas =================================================================== diff -u -r562 -r563 --- VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 562) +++ VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 563) @@ -18,15 +18,20 @@ FSelectServerSoap: SelectService.ProdSelectServerSoap; FOptiBoxServerSoap: OptiServerService.OptiBoxServerSoap; function GeefBruikbareLijnenUitXMLDataSet(DataSetXml: string): TStringList; - procedure RegistreerZoekResultaten(ProductsContext: TProductsContext; DataSet: string); + procedure RegistreerZoekResultaten(ProductsContext: TProductsContext; DataSet: string); overload; procedure RegistreerMislukteOpzoeking(ProductsContext: TProductsContext; pxStatusObj: SelectService.pxStatus); overload; - procedure RegistreerMislukteOpzoeking(ProductsContext: TProductsContext; pxStatusObj: OptiServerService.pxStatus); overload; - function GetBoxDataIDsViaProduct(ProductNr: Integer; UserContext: TUserContext): GetBoxDataIDsViaProductResponse; + procedure RegistreerZoekResultaten(ProductDetailContext: TProductDetailContext; + pxBoxDataObj: OptiServerService.pxBoxData); overload; + procedure RegistreerMislukteOpzoeking(ProductDetailContext: TProductDetailContext; + pxStatusObj: OptiServerService.pxStatus); overload; + function GetBoxDataIDsViaProduct(ProductNr: Integer; UserContext: TUserContext; + ProductDetailContext: TProductDetailContext): string; public Constructor Create(); procedure ZoekOpMetKortTekst(Zoek: string; KLNr: string; At: string; UserContext: TUserContext; ProductsContext: TProductsContext); - procedure ZoekProductDataMetProductNr(ProductNr: Integer; UserContext: TUserContext; ProductsContext: TProductsContext); + procedure ZoekProductDataMetProductNr(ProductNr: Integer; UserContext: TUserContext; + ProductDetailContext: TProductDetailContext); end; implementation @@ -164,9 +169,16 @@ ProductsContext.NotifyChanged(); end; -function TProductsAgent.GetBoxDataIDsViaProduct(ProductNr: Integer; UserContext: TUserContext): GetBoxDataIDsViaProductResponse; +function TProductsAgent.GetBoxDataIDsViaProduct(ProductNr: Integer; UserContext: TUserContext; + ProductDetailContext: TProductDetailContext): string; var ZoekData: OptiServerService.GetBoxDataIDsViaProduct; + GetBoxDataIDsViaProductResponseObj: OptiServerService.GetBoxDataIDsViaProductResponse; + TempStr: string; + Lijn: string; + Lijnen: TStringList; + LijnenBoxDataID: TStringList; + XMLDoc: IXMLDocument; begin ZoekData := nil; try @@ -175,71 +187,99 @@ ZoekData.SessionKey := UserContext.SessionKey; ZoekData.ProductNr := ProductNr; - Result := FOptiBoxServerSoap.GetBoxDataIDsViaProduct(ZoekData); + GetBoxDataIDsViaProductResponseObj := FOptiBoxServerSoap.GetBoxDataIDsViaProduct(ZoekData); + + // Response + if GetBoxDataIDsViaProductResponseObj.GetBoxDataIDsViaProductResult <> nil then + // Mislukt + RegistreerMislukteOpzoeking(ProductDetailContext, GetBoxDataIDsViaProductResponseObj.GetBoxDataIDsViaProductResult); + + // Bruikbare informatie uit antwoord halen + + // Producten inladen + LijnenBoxDataID := TStringList.Create; + Lijnen := GeefBruikbareLijnenUitXMLDataSet(GetBoxDataIDsViaProductResponseObj.varDataSet); + try + // 'GetBoxDataIDsViaObjTypeAndRef' element overlopen en mappen naar een instantie. + for Lijn in Lijnen do + begin + LijnenBoxDataID.Add(Lijn); + if ContainsStr(Lijn, '') then + begin + // Er zit een volledig item in de lijst + TempStr := LijnenBoxDataID.Text; + XMLDoc := LoadXMLData(TempStr); // XML document van maken + // Elementen uit XML laden. + Result := XMLDoc.DocumentElement.ChildValues['ID']; + end; + end; + finally + Lijnen.Free(); + LijnenBoxDataID.Free(); + end; finally ZoekData.Free(); end; end; procedure TProductsAgent.ZoekProductDataMetProductNr(ProductNr: Integer; UserContext: TUserContext; - ProductsContext: TProductsContext); + ProductDetailContext: TProductDetailContext); var - GetBoxDataIDsViaProductResponseObj: OptiServerService.GetBoxDataIDsViaProductResponse; - TempStr: string; - Lijn: string; - Lijnen: TStringList; - LijnenBoxDataID: TStringList; - XMLDoc: IXMLDocument; + ZoekData: OptiServerService.GetBoxDataViaId; BoxDataID: string; + GetBoxDataViaIDResponseObj: GetBoxDataViaIDResponse; begin - GetBoxDataIDsViaProductResponseObj := GetBoxDataIDsViaProduct(ProductNr, UserContext); + BoxDataID := GetBoxDataIDsViaProduct(ProductNr, UserContext, ProductDetailContext); + // Controleren dat er resultaat was + if BoxDataID = '' then + raise Exception.Create('Er is geen Box ID gevonden.'); + // Request + // Met ID, box data opvragen + ZoekData := nil; + try + ZoekData := OptiServerService.GetBoxDataViaId.Create(); + ZoekData.SessionKey := UserContext.SessionKey; + ZoekData.BoxDataID := BoxDataID; - // Response - if GetBoxDataIDsViaProductResponseObj.GetBoxDataIDsViaProductResult <> nil then - // Mislukt - RegistreerMislukteOpzoeking(ProductsContext, GetBoxDataIDsViaProductResponseObj.GetBoxDataIDsViaProductResult); + GetBoxDataViaIDResponseObj := FOptiBoxServerSoap.GetBoxDataViaId(ZoekData); - // Bruikbare informatie uit antwoord halen - - // Producten inladen - LijnenBoxDataID := TStringList.Create; - Lijnen := GeefBruikbareLijnenUitXMLDataSet(GetBoxDataIDsViaProductResponseObj.varDataSet); - try - // 'GetBoxDataIDsViaObjTypeAndRef' element overlopen en mappen naar een instantie. - for Lijn in Lijnen do + // Response + if GetBoxDataViaIDResponseObj.GetBoxDataViaIDResult = nil then begin - LijnenBoxDataID.Add(Lijn); - if ContainsStr(Lijn, '') then - begin - // Er zit een volledig item in de lijst - TempStr := LijnenBoxDataID.Text; - XMLDoc := LoadXMLData(TempStr); // XML document van maken - // Elementen uit XML laden. - BoxDataID := XMLDoc.DocumentElement.ChildValues['ID']; - end; + // Gelukt + RegistreerZoekResultaten(ProductDetailContext, GetBoxDataViaIDResponseObj.varBoxData); + end + else + begin + // Mislukt + RegistreerMislukteOpzoeking(ProductDetailContext, GetBoxDataViaIDResponseObj.GetBoxDataViaIDResult); end; finally - Lijnen.Free(); - LijnenBoxDataID.Free(); + ZoekData.Free(); end; +end; - // Controleren dat er resultaat was - if BoxDataID = '' then - raise Exception.Create('Er is geen Box ID gevonden.'); +procedure TProductsAgent.RegistreerZoekResultaten(ProductDetailContext: TProductDetailContext; + pxBoxDataObj: OptiServerService.pxBoxData); +begin + // Andere velden juist zetten + ProductDetailContext.IsOK := True; + ProductDetailContext.ErrorMessage := ''; + ProductDetailContext.InternalErrorMessage := ''; - // Met ID box data opvragen - + ProductDetailContext.ProductDetailInformatie := pxBoxDataObj; end; -procedure TProductsAgent.RegistreerMislukteOpzoeking(ProductsContext: TProductsContext; pxStatusObj: OptiServerService.pxStatus); +procedure TProductsAgent.RegistreerMislukteOpzoeking(ProductDetailContext: TProductDetailContext; + pxStatusObj: OptiServerService.pxStatus); begin - { TODO : ProductDetail leegmaken } + ProductDetailContext.ProductDetailInformatie := nil; - ProductsContext.IsOK := pxStatusObj.IsOK; - ProductsContext.ErrorMessage := pxStatusObj.Message_; - ProductsContext.InternalErrorMessage := pxStatusObj.InternalMessage; + ProductDetailContext.IsOK := pxStatusObj.IsOK; + ProductDetailContext.ErrorMessage := pxStatusObj.Message_; + ProductDetailContext.InternalErrorMessage := pxStatusObj.InternalMessage; - ProductsContext.NotifyChanged(); + ProductDetailContext.NotifyChanged(); end; end. Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.pas =================================================================== diff -u -r562 -r563 --- VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 562) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 563) @@ -76,7 +76,7 @@ exit; ApplicationContext.ProductDetailContext.GeselecteerdProduct := Item.Data; FProductsAgent.ZoekProductDataMetProductNr(TProductInformatie(Item.Data).ProductNr, self.ApplicationContext.UserContext, - self.ApplicationContext.ProductsContext); + self.ApplicationContext.ProductDetailContext); ApplicationContext.ProductDetailContext.NotifyChanged();