// Testen van de BL.PPS.TBX.WPZaag #include %occInclude #Include BL.Sys.Proxy #define QuitIfError(%context,%st) Write:%st'=$$$pxStatusOK %context, " --- Msg:", %st.Message, ", IMsg:", %st.InternalMessage, ! hang:%st'=$$$pxStatusOK (3) quit:%st'=$$$pxStatusOK #define QuitWithStatusIfError(%context,%st) Write:%st'=$$$pxStatusOK %context, " --- Msg:", %st.Message, ", IMsg:", %st.InternalMessage, ! quit:%st'=$$$pxStatusOK %st #define WriteError(%context,%st) Write:%st'=$$$pxStatusOK %context, " --- Msg:", %st.Message, ", IMsg:", %st.InternalMessage, ! #define BatchID 915 //1=Per Lade, 2=Per Plaat, 3=Per Sequentie #define BulkPerXXX 3 InitBatch() { Kill ^KTO(6332) Merge ^KTO(6332)=^|"JRNL-ADMIN1"|KTO(6332) Kill ^KTO1 Merge ^KTO1=^|"JRNL-ADMIN1"|KTO1 Kill ^KTO2 Merge ^KTO2=^|"JRNL-ADMIN1"|KTO2 Kill ^KTO3 Merge ^KTO3=^|"JRNL-ADMIN1"|KTO3 Kill ^HATBX Merge ^HATBX=^|"JRNL-ADMIN1"|HATBX Do ^PV2 quit } ; WSTestOne kill do WSTestStartBatch(5) quit ; WSTestAll kill do ##class(DS.PPS.Params.WPZaagParams).SetDefaultValues() do WSTestGetBatchIDs() do WSTestStartBatch(5) do WSTestStartBatchWithURL() do WSTestStartBatchWithCheckGezaagdeLengte() do WSTestStartBatchWithSkip() do WSTestGetLijst() do WSTestGetLijstWithChange() do WSTestReprint() do WSTestRedoZaag() quit ; WSTestGetBatchIDs() { kill Write "WSTestGetBatchIDs", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.GetBatchIDs("test",.qry) $$$QuitIfError("Na WSTestGetBatchIDs",st) For set Stqry=qry.Next() Quit:Stqry'=1 Do . Write "BatchID: ", $get(qry.Data("BatchID")),! Write "WSTestGetBatchIDs done", ! quit } ; WSTestStartBatchWithURL() { Write "WSTestStartBatchWithURL", ! kill do WSTestStartBatch(1) kill ws Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.GetDetailInfo("test",.url) $$$QuitIfError("Na GetDetailInfo",st) Write "URL=",url,! Write "WSTestStartBatchWithURL done", ! quit } ; WSTestStartBatchWithSkip() { Write "WSTestStartBatchWithSkip", ! kill do WSTestStartBatch(1) kill ws Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.SetStatusSkipped("test") $$$QuitIfError("Na SetStatusSkipped",st) kill ws, st, pxWPZaagInfo Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.StartNextAction("test",.pxWPZaagInfo) $$$QuitIfError("Na WSTestStartBatchWithSkip --> StartNextAction",st) Do WriteWPZaagInfo(pxWPZaagInfo) Write "WSTestStartBatchWithSkip done", ! quit } ; WSTestStartBatchWithCheckGezaagdeLengte() { Write "WSTestStartBatchWithCheckGezaagdeLengte", ! kill do WSTestStartBatch(1) kill ws, st, pxWPZaagInfo Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.StartNextAction("test",.pxWPZaagInfo) $$$QuitIfError("Na StartNextAction",st) kill ws Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set pxWPZaagInfo.AskBodemLengte = 1 Set pxWPZaagInfo.AskRugLengte = 1 Set st = ws.CheckGezaagdeLengte("test", pxWPZaagInfo) $$$QuitIfError("Na CheckGezaagdeLengte",st) Write "WSTestStartBatchWithCheckGezaagdeLengte done", ! quit } WSTestStartBatch(MaxCount) { kill Write "WSTestFullCompleteBatch", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.StartBatch("test",$$$BatchID,.pxWPZaagInfo) $$$QuitIfError("Na ws.StartBatch",st) Do WriteWPZaagInfo(pxWPZaagInfo) Set StopCount = 0 for quit:((pxWPZaagInfo.Type="EOB")||(pxWPZaagInfo.Type="EOL")||(StopCount>MaxCount)) do . Set StopCount = StopCount+1 . if pxWPZaagInfo.Type = "BulkInfo" do . . // BL heeft nood aan info hoe de Bulk moet gesorteerd worden, de info moet aangeleverd worden . . Set info = ##class(BL.PPS.TBX.WPZaag.pxBulkSortInfo).%New() . . Set info.SortType = $$$BulkPerXXX //1=Per Lade, 2=Per Plaat, 3=Per Sequentie . . do info.ActionSequence.Insert("B+R") . . do info.ActionSequence.Insert("B") . . do info.ActionSequence.Insert("R") . . do info.ActionSequence.Insert("RLI") . . do info.ActionSequence.Insert("RRE") . . do info.ActionSequence.Insert("RMID") . . do info.ActionSequence.Insert("RBA") . . do info.ActionSequence.Insert("BM") . . do info.ActionSequence.Insert("Frz") . . Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() . . Write " SetSortInfo", ! . . Set st = ws.SetSortInfo("test",info) . . $$$QuitIfError("Na SetSortInfo",st) . . kill ws, st, pxWPZaagInfo . . Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() . . Set st = ws.StartNextAction("test",.pxWPZaagInfo) . . Write " StartNextAction", ! . . Do WriteWPZaagInfo(pxWPZaagInfo) . kill ws, st, pxWPZaagInfo . Write "WSTestStartBatch --> SetLastOneDone", ! . Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() . Set st = ws.SetStatusDone("test") . $$$QuitIfError("Na ws.WSTestStartBatch --> SetStatusDone",st) . kill ws, st, pxWPZaagInfo . Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() . Set st = ws.StartNextAction("test",.pxWPZaagInfo) . $$$QuitIfError("Na ws.WSTestStartBatch --> StartNextAction",st) . Do WriteWPZaagInfo(pxWPZaagInfo) Write "WSTestFullCompleteBatch done", ! quit } ; WSTestGetLijst() { kill Write "WSTestGetLijst", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.StartBatch("test",$$$BatchID,.pxWPZaagInfo) $$$QuitIfError("Na ws.StartBatch",st) Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.GetLijst("test",.pxWPLijst) $$$QuitIfError("Na WSTestGetLijst",st) Write "BatchID", pxWPLijst.BatchID, ! For set St=pxWPLijst.DsLijst.Next() Quit:St'=1 Do . Write $get(pxWPLijst.DsLijst.Data("QueueID")),*9,$get(pxWPLijst.DsLijst.Data("BatchID")),*9 . Write $get(pxWPLijst.DsLijst.Data("PRNr")),*9,$get(pxWPLijst.DsLijst.Data("Actie")),*9 . Write $get(pxWPLijst.DsLijst.Data("Status")),*9,$get(pxWPLijst.DsLijst.Data("Redo")),*9 . Write $get(pxWPLijst.DsLijst.Data("Reprint")), ! Write "WSTestGetLijst done", ! quit } WSTestGetLijstWithChange() { kill Write "WSTestGetLijstWithChange", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.StartBatch("test",$$$BatchID,.pxWPZaagInfo) $$$QuitIfError("Na ws.StartBatch",st) kill Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.GetLijst("test",.pxWPLijst) $$$QuitIfError("Na GetLijst",st) // Redo-list opbouwen (gebeurt normaal aan de echte client zijde, hier een simulatie om te kunnen testen) Set pxRedo = ##class(BL.PPS.TBX.WPZaag.pxWPZaagRedo).%New() Set idx = 0 For set St=pxWPLijst.DsLijst.Next() Quit:St'=1 Do . Set idx = idx + 1 . Write $get(pxWPLijst.DsLijst.Data("QueueID")),*9,$get(pxWPLijst.DsLijst.Data("BatchID")),*9 . Write $get(pxWPLijst.DsLijst.Data("PRNr")),*9,$get(pxWPLijst.DsLijst.Data("Actie")),*9 . Write $get(pxWPLijst.DsLijst.Data("Status")), ! . if ((idx=2)||(idx=3)||(idx=6)||(idx=7)||(idx=10)||(idx=11)) do . . Set dtl = ##class(BL.PPS.TBX.WPZaag.pxWPZaagRedoDtl).%New() . . Set dtl.QueueID = $get(pxWPLijst.DsLijst.Data("QueueID")) . . Set dtl.Actie =$get(pxWPLijst.DsLijst.Data("Actie")) . . if ((idx=2)||(idx=6)||(idx=7)) do . . . Set dtl.Redo = "1" . . if ((idx=3)||(idx=6)||(idx=10)||(idx=11)) do . . . Set dtl.Reprint = "1" . . Write "Redo:", dtl.QueueID, " / ", dtl.Actie, " / ", dtl.Redo, " / ", dtl.Reprint, ! . . do pxRedo.Detail.Insert(dtl) // Redo uitvoeren Write "ExecuteRedoList", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.ExecuteRedoList("test",.pxRedo) $$$QuitIfError("Na ExecuteRedoList",st) kill Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.GetLijst("test",.pxWPLijst) $$$QuitIfError("Na GetLijst(2)",st) Set idx = 0 For set St=pxWPLijst.DsLijst.Next() Quit:St'=1 Do . Set idx = idx + 1 . Write $get(pxWPLijst.DsLijst.Data("QueueID")),*9,$get(pxWPLijst.DsLijst.Data("BatchID")),*9 . Write $get(pxWPLijst.DsLijst.Data("PRNr")),*9,$get(pxWPLijst.DsLijst.Data("Actie")),*9 . Write $get(pxWPLijst.DsLijst.Data("Status")), ! Write "WSTestGetLijstWithChange done", ! quit } WSTestReprint() { kill Write "WSTestReprint (eerst StartBatch, om te positioneren)", ! kill do WSTestStartBatch(2) kill Write "WSTestReprint - eigenlijke reprint", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.Reprint("test") $$$QuitIfError("Na WSTestReprint",st) Write "WSTestReprint done", ! quit } WSTestRedoZaag() { Write "WSTestRedoZaag (eerst StartBatch, om te positioneren)", ! kill do WSTestStartBatch(2) kill Write "WSTestRedoZaag - eigenlijke redo", ! Set ws = ##class(Intra.PPS.TBX.WPZaag).%New() Set st = ws.RedoZaag("test",1,1,1) $$$QuitIfError("Na WSTestRedoZaag",st) Write "WSTestRedoZaag done", ! quit } WriteWPZaagInfo(pxWPZaagInfo){ Write "pxWPZaagInfo", ! Write "Type : ", pxWPZaagInfo.Type, ! Write "ActionTxtCount:", pxWPZaagInfo.ActionTxt.Count(),! For i=1:1:pxWPZaagInfo.ActionTxt.Count() do . Write $C(9), pxWPZaagInfo.ActionTxt.GetAt(i), $S(i=pxWPZaagInfo.CurrentActionIdx:" <--",1:""), ! Write "Laatste ? : ", pxWPZaagInfo.IsLaatsteAction, ! Write "KortTekst : ", pxWPZaagInfo.KortTekst, ! Write "ErrorStatus : ", pxWPZaagInfo.ErrorStatus, ! Write "Opmerking : ", pxWPZaagInfo.Opmerking, ! Write "Draagkracht : ", pxWPZaagInfo.Draagkracht, ! Write "BodemKleur :", pxWPZaagInfo.BodemKleur, ! Write "BodemHoogte :", pxWPZaagInfo.BodemHoogte, ! Write "BodemLengte :", pxWPZaagInfo.BodemLengte, ! Write "BodemCntInSequence :", pxWPZaagInfo.BodemCntInSequence, ! Write "BodemLengthInSequence :", pxWPZaagInfo.BodemLengthInSequence, ! Write "BodemAantalPlaten :", pxWPZaagInfo.BodemAantalPlaten, ! Write "RugKleur :", pxWPZaagInfo.RugKleur, ! Write "RugHoogte :", pxWPZaagInfo.RugHoogte, " ", pxWPZaagInfo.RugHoogteCode, ! Write "RugLengte :", pxWPZaagInfo.RugLengte, ! Write "RugCntInSequence :", pxWPZaagInfo.RugCntInSequence, ! Write "RugLengthInSequence :", pxWPZaagInfo.RugLengthInSequence, ! Write "RugAantalPlaten :", pxWPZaagInfo.RugAantalPlaten, ! Write "BluMotion :", pxWPZaagInfo.BluMotion, ! Write "BGColorBodem :", pxWPZaagInfo.BGColorBodem, ! Write "BGColorRug :", pxWPZaagInfo.BGColorRug, ! Write "BGColorOpmerking :", pxWPZaagInfo.BGColorOpmerking, ! quit } ; WriteWPZaagStatus() { Set BatchID = $$$BatchID &sql(DECLARE crQ CURSOR FOR SELECT ID as QueueID, Product->KortTekst As PRNr, WPZaag_WPStatus As WPStatus INTO :QueueID, :PRNr, :WPStatus FROM PPS.TBX_Queue WHERE BatchID= :BatchID) &sql(OPEN crQ) Write "SQLCODE Na Open:", SQLCODE, ! If SQLCODE'<0 Do . For &sql(FETCH crQ) Quit:(SQLCODE) Do . . Write QueueID, " ", WPStatus, " ", PRNr, ! . . Set q=##class(DS.PPS.TBX.Queue).%OpenId(QueueID) . . For i=1:1:$LL(q.WPZaag.arrActionStatus) do . . . Write $c(9), $List($List(q.WPZaag.arrActionStatus,i),1), " ", $List($List(q.WPZaag.arrActionStatus,i),2), ! . . //Write QueueID, ! . &sql(CLOSE crQ) quit } ListBuildInSql SET a=$LISTBUILD("Red","Blue","Green") &sql(Declare crLB1 CURSOR FOR SELECT top 1 $LISTLENGTH(:a),$LIST(:a,:i) INTO :b,:plain FROM PPS.TBX_Queue) for i=1:1:$LL(a) do . &sql(OPEN crLB1) . Write "SQLCODE Na Open:", SQLCODE, ! . If SQLCODE'<0 Do . . For &sql(FETCH crLB1) Quit:(SQLCODE) Do . . . Write "* b:", b, " Plain:", plain, ! . . &sql(CLOSE crLB1) &sql(SELECT $LISTLENGTH(:a),$LIST(:a,-1) INTO :b,:plain FROM BKH.Renewals_Data) IF SQLCODE'=0 { WRITE !,"error code ",SQLCODE QUIT } Write "b:", b, " Plain:", plain, ! &sql(SELECT $LIST(:a,:b,-1) INTO :encoded FROM BKH.Renewals_Data) IF SQLCODE'=0 { WRITE !,"error code ",SQLCODE } ELSE { WRITE !,"The final element as a string: ",plain WRITE !,"The final element as an encoded string: " ZZDUMP encoded }