Reusable Component S_185RMQ - Message Object

LANSA

Reusable Component S_185RMQ - Message Object
* ===================================================================;
*;
* Component : S_185RMQ;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Reuable display of a single message queue ;
*;
* Disclaimer : The following material is supplied as sample material;
* only. No warranty concerning this material or its use;
* in any way whatsoever is expressed or implied.;
*;
* ===================================================================;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(331) LAYOUTMANAGER(#ATLM_1) LEFT(0) TABPOSITION(1) TOP(0) VISIBLE(False) VISUALSTYLE(#VS_PANEL) WIDTH(354);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1) MARGINLEFT(2) MARGINRIGHT(2) MARGINTOP(2);
DEFINE_COM CLASS(#S_185QUE.Visual) NAME(#S_185QUE) DISPLAYPOSITION(1) HEIGHT(19) LEFT(2) PARENT(#COM_OWNER) TABPOSITION(1) TOP(2) VISUALSTYLE(#VS_NORM) WIDTH(346);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_1) ATTACHMENT(Top) MANAGE(#S_185QUE) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_PANL) NAME(#PANL_1) DISPLAYPOSITION(2) HEIGHT(73) LAYOUTMANAGER(#FWLM_1) LEFT(2) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(232) VISUALSTYLE(#VS_NORM) WIDTH(346);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_2) ATTACHMENT(Bottom) MANAGE(#PANL_1) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_FWLM) NAME(#FWLM_1) FLOWOPERATION(Spread) FLOWOPERATIONHOR(Decrease) FLOWOPERATIONVER(Spread) SPACING(0) SPACINGITEMS(4);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#REFRESH) CAPTION('Refresh') DISPLAYPOSITION(1) HINT('Refresh or load details from the message queue now') LEFT(5) PARENT(#PANL_1) TABPOSITION(1) TOP(8) WIDTH(89);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_1) MANAGE(#REFRESH) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#RESET_BUTTON) CAPTION('Reset Alarm') DISPLAYPOSITION(2) ENABLED(False) HINT('Reset the alarm ') LEFT(98) PARENT(#PANL_1) TABPOSITION(2) TOP(8);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_2) MANAGE(#RESET_BUTTON) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#REPLY_BUTTON) CAPTION('Reply') DISPLAYPOSITION(3) ENABLED(False) LEFT(182) PARENT(#PANL_1) TABPOSITION(3) TOP(8);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_3) MANAGE(#REPLY_BUTTON) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_TIMR) NAME(#REFRESH_CLOCK) INTERVAL(0);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STATUS_BAR) DISPLAYPOSITION(3) HEIGHT(22) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(305) WIDTH(350);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_5) ATTACHMENT(Bottom) MANAGE(#STATUS_BAR) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_TIMR) NAME(#ALARM_CLOCK) INTERVAL(0);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#MSG_LIST) COLUMNHEADERS(False) DISPLAYPOSITION(4) FULLROWSELECT(True) HEIGHT(189) LEFT(2) PARENT(#COM_OWNER) SELECTIONSTYLE(Single) TABPOSITION(4) TOP(43) WIDTH(346);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Center) MANAGE(#MSG_LIST) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) DISPLAYPOSITION(1) PARENT(#MSG_LIST) SOURCE(#SYSVAR$AV) WIDTH(300);
DEFINE_COM CLASS(#PRIM_CMBX) NAME(#TIME_LIST) COMBOBOXSTYLE(DropDownList) DISPLAYPOSITION(5) HEIGHT(22) LEFT(2) PARENT(#COM_OWNER) TABPOSITION(5) TOP(21) VALUE('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoO') WIDTH(346);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_6) ATTACHMENT(Top) MANAGE(#TIME_LIST) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_CBCL) NAME(#CBCL_1) DISPLAYPOSITION(1) PARENT(#TIME_LIST) SOURCE(#STD_TEXTS) WIDTH(20);
DEFINE_COM CLASS(#PRIM_CBCL) NAME(#CBCL_2) PARENT(#TIME_LIST) SOURCE(#STD_NUM) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#STD_NUM) NAME(#REFRESH_TIME);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) PARENT(#MSG_LIST) SOURCE(#S_185MSGN) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#REMOVE_BUTTON) CAPTION('Remove') DISPLAYPOSITION(4) ENABLED(False) LEFT(266) PARENT(#PANL_1) TABPOSITION(4) TOP(8);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_4) MANAGE(#REMOVE_BUTTON) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#REMOVE_ALL) CAPTION('Remove All') DISPLAYPOSITION(5) LEFT(182) PARENT(#PANL_1) TABPOSITION(5) TOP(40);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_5) MANAGE(#REMOVE_ALL) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#REMOVE_OLD) CAPTION('Remove Old') DISPLAYPOSITION(6) LEFT(266) PARENT(#PANL_1) TABPOSITION(6) TOP(40);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_6) MANAGE(#REMOVE_OLD) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_7) MANAGE(#REPLY_BUTTON) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) PARENT(#MSG_LIST) SOURCE(#S_185RTNT) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#S_185RRY) NAME(#REPLYFORM);
;
Def_Cond *ReplyMsg '#S_185RTNT = ''05''';
;
* Store details of associated iSeries server SSN;
;
Define #ServerSSN RefFld(#Std_Obj);
define_pty ServerSSN Set(SetSSN);
;
* ===============================================================================;
* Handle setting of server SSN name ;
* ===============================================================================;
;
PtyROUTINE SetSSN;
Define_Map *input #Std_Obj #Pty_001;
Change #ServerSSN #Pty_001.Value;
EndRoutine;
;
* ===============================================================================;
* Instance Creation;
* ===============================================================================;
;
EVTROUTINE HANDLING(#Com_Owner.CreateInstance) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
Change #S_185que QSYSOPR;
Execute AddRefresh ( ' Refreshing every 10 seconds ' 10000);
Execute AddRefresh ( ' Refreshing every 20 seconds ' 20000);
Execute AddRefresh ( ' Refreshing every 30 seconds ' 30000);
Execute AddRefresh ( ' Refreshing every minute' 60000);
Execute AddRefresh ( ' Refreshing every 2 minutes' 120000);
Execute AddRefresh ( ' Refreshing every 3 minutes' 180000);
Execute AddRefresh ( ' Refreshing every 5 minutes' 300000);
Execute AddRefresh ( ' Refreshing every 10 minutes' 600000);
Execute AddRefresh ( ' Refreshing every 20 minutes' 1200000);
Execute AddRefresh ( ' Refreshing every 30 minutes' 1800000);
Execute AddRefresh ( ' Refreshing every hour' 3600000) ;
Execute AddRefresh ( ' Refreshing every 2 hours' 7200000);
Get_Entry 4 #Time_List;
Set #Time_List.CurrentItem Focus(True);
Set #Refresh_Time Value(60000) ;
EndRoutine;
;
* ===============================================================================;
* Set up refresh times;
* ===============================================================================;
;
Subroutine AddRefresh ((#Std_TextS *Received)(#Std_Num *Received));
Add_Entry #Time_List;
EndRoutine;
;
* ===============================================================================;
* Handle change of the refresh timing ;
* ===============================================================================;
;
EVTROUTINE HANDLING(#Time_List.ItemGotFocus) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
;
Set #Refresh_Time Value(#Std_Num);
Set #Refresh_Clock Interval(#Refresh_Time) ;
Set #Alarm_Clock Interval(0);
Set #Reset_Button Enabled(False);
;
ENDROUTINE;
;
* ===============================================================================;
* Handle tick of the refresh timer;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REFRESH_CLOCK.Tick) ;
;
Invoke #Com_Owner.RefreshQueue;
;
ENDROUTINE;
;
* ===============================================================================;
* Handle tick of the alarm timer;
* ===============================================================================;
;
EVTROUTINE HANDLING(#Alarm_CLOCK.Tick);
;
Use OV_Sound_Alarm (E);
;
ENDROUTINE;
;
* ===============================================================================;
* Handle request to close;
* ===============================================================================;
;
MthRoutine uClose;
;
Delete From_File(SetOMQ) With_Key(#S_185SesI);
;
Set #Refresh_Clock Interval(0);
Set #Alarm_Clock Interval(0);
Set #Com_Owner Visible(False);
;
EndRoutine;
;
* ===============================================================================;
* Handle request to (re)open;
* ===============================================================================;
;
MthRoutine uOpen;
;
Set (#Refresh_Clock #Alarm_Clock) Interval(0);
Set #Com_Owner Visible(True);
Invoke #Com_Owner.RefreshQueue;
Set #Refresh_Clock Interval(#Refresh_Time);
;
EndRoutine;
;
* ===============================================================================;
* Handle fresh of message queue details;
* ===============================================================================;
;
MthRoutine RefreshQueue;
Define_com #Std_Num #Save_Timer;
Define #EntCount RefFld(#std_Num);
Define #AlmCount RefFld(#std_Num);
;
* Save the timer time and then stop the timer ;
;
Set #Save_Timer Value(#Refresh_Clock.Interval) ;
;
Set #Refresh_Clock Interval(0);
Set #Alarm_Clock Interval(0);
Set (#Reset_Button #Remove_Button #Reply_Button) Enabled(False);
;
* Indicate staring to refresh;
;
Message 'Refesh in progress' Type(*Status);
;
* Clear the message queue list ;
;
Clr_List #Msg_List;
;
* Now use the iSeries RPC to fresh the messages and give back the assigned session id ;
;
Exchange Fields(#S_185Que #S_185SesI);
;
USE BUILTIN(CALL_SERVER_FUNCTION) WITH_ARGS(#SERVERSSN SET185B Y Y) TO_GET(#S_RETCDA2);
;
* Read the messages and add them to the visible list, take care to track those that require ;
* replies because these involve a special icon and the use of the alarm ;
;
Change (#EntCount #AlmCount) 0;
;
SELECT FIELDS(#S_185LVL1 #S_185MSGN #S_185RTNT #S_185SEV) FROM_FILE(SETOMQ) with_Key(#S_185SesI);
Change #EntCount '#EntCount + 1';
Change #SysVar$av #S_185LVL1;
Add_Entry #Msg_List;
* Handle a message that requires a reply;
If *ReplyMsg;
Set #Msg_List.CurrentItem Image(#S_185IQU) ;
Change #AlmCount '#AlmCount + 1';
Else;
* Handle a high severity message;
If '#S_185SEV >= 30';
Set #Msg_List.CurrentItem Image(#S_185IWN);
* Handle other messages;
Else;
Set #Msg_List.CurrentItem Image(#S_185IIN);
Endif;
Endif;
;
EndSelect;
;
* Ensure last item is visible;
;
If '#EntCount > 0';
Get_Entry #EntCount #Msg_List;
Set #Msg_List.CurrentItem EnsureVisible(True);
Endif;
;
* Start the alarm ringing if required;
;
If '#AlmCount > 0';
Set #Alarm_Clock Interval(3000);
Set #Reset_Button Enabled(True);
Endif;
;
* Restart the refresh timer with the save time;
;
Set #Refresh_Clock Interval(#Save_Timer.Value);
;
EndRoutine;
;
* ===============================================================================;
* Handle reset of alarm by turning it off;
* ===============================================================================;
;
EVTROUTINE HANDLING(#RESET_BUTTON.Click);
Set #Alarm_Clock Interval(0);
Set #Reset_Button Enabled(False);
ENDROUTINE;
;
* ===============================================================================;
* Handle manual refresh request;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REFRESH.Click) ;
Invoke #Com_Owner.RefreshQueue;
ENDROUTINE;
;
* ===============================================================================;
* Handle manual refresh request;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REMOVE_BUTTON.Click) ;
Exchange Fields(#S_185Que #S_185SesI #S_185MsgN);
USE BUILTIN(CALL_SERVER_FUNCTION) WITH_ARGS(#SERVERSSN SET185C Y N) TO_GET(#S_RETCDA2);
Invoke #Com_Owner.RefreshQueue;
ENDROUTINE;
;
* ===============================================================================;
* Message (de)selected;
* ===============================================================================;
;
EVTROUTINE HANDLING(#MSG_LIST.ItemLostSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
Set (#Remove_Button #Reply_Button) Enabled(False);
ENDROUTINE;
;
* ===============================================================================;
* Message selected;
* ===============================================================================;
;
EVTROUTINE HANDLING(#MSG_LIST.ItemGotSelection) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS);
Set #Remove_Button Enabled(True);
Set #Reply_Button Enabled(*ReplyMsg);
ENDROUTINE;
;
* ===============================================================================;
* Remove All;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REMOVE_ALL.Click) ;
Exchange Fields(#S_185Que #S_185SesI);
USE BUILTIN(CALL_SERVER_FUNCTION) WITH_ARGS(#SERVERSSN SET185E Y N) TO_GET(#S_RETCDA2);
Invoke #Com_Owner.RefreshQueue;
ENDROUTINE;
;
* ===============================================================================;
* Remove Old;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REMOVE_OLD.Click) ;
Exchange Fields(#S_185Que #S_185SesI);
USE BUILTIN(CALL_SERVER_FUNCTION) WITH_ARGS(#SERVERSSN SET185F Y N) TO_GET(#S_RETCDA2);
Invoke #Com_Owner.RefreshQueue;
ENDROUTINE;
;
* ===============================================================================;
* Reply;
* ===============================================================================;
;
EVTROUTINE HANDLING(#REPLY_BUTTON.Click);
;
Define_com #Std_Num #Save_Timer;
Define_com #Std_Num #Save_Alarm;
;
* Save timer values and stop the clocks;
;
Set #Save_Timer Value(#Refresh_Clock.Interval);
Set #Save_Alarm Value(#Alarm_Clock.Interval);
Set (#Refresh_Clock #Alarm_Clock) Interval(0);
;
* Show the form to get the reply;
;
Set #ReplyForm uMessage(#SysVar$av) ;
;
Invoke #ReplyForm.uGetReply;
;
* If a valid reply has been specified;
;
If '#ReplyForm.uReply *ne *Blanks';
Change #S_185Lvl1 #ReplyForm.uReply ;
Exchange Fields(#S_185Que #S_185SesI #S_185MsgN #S_185Lvl1);
USE BUILTIN(CALL_SERVER_FUNCTION) WITH_ARGS(#SERVERSSN SET185D Y N) TO_GET(#S_RETCDA2);
Endif;
;
* Restart the clocks;
;
Set #Refresh_Clock Interval(#Save_Timer.Value);
Set #Alarm_Clock Interval(#Save_Alarm.Value);
;
ENDROUTINE;
;
END_COM