示例#1
0
 public PcfMessage(MQMessage message)
 {
     _list  = new List <PcfParameter>();
     _mqCfh = new Mqcfh(message);
     for (var i = 0; i < _mqCfh.ParameterCount; i++)
     {
         AddParameter(PcfParameter.NextParameter(message));
     }
 }
示例#2
0
 private void Initialize(int type, int command, int msgSeqNumber, bool last)
 {
     _list  = new List <PcfParameter>();
     _mqCfh = new Mqcfh
     {
         CompCode     = 0,
         Reason       = 0,
         Command      = command,
         Type         = type,
         MsgSeqNumber = msgSeqNumber
     };
     Cmdtype        = type;
     _mqCfh.Control = last ? 1 : 0;
 }
示例#3
0
        protected MQMessage[] Send(int command, PcfParameter[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var oo            = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_INQUIRE;
            var responseQueue = _qMgr.AccessQueue("SYSTEM.DEFAULT.MODEL.QUEUE", oo);

            var cmdMessage = new MQMessage {
                ReplyToQueueName = responseQueue.Name,
                MessageType      = MQC.MQMT_REQUEST,
                Feedback         = MQC.MQFB_NONE,
                Format           = MQC.MQFMT_ADMIN,
                Report           = MQC.MQRO_NONE
            };

            PCFAgentResponseTracker tracker;

            if (_qMgr.Platform == MQC.MQPL_ZOS)
            {
                tracker = new PCFAgentResponseTracker390();
                Mqcfh.Write(cmdMessage, command, parameters.Length, Cmqcfc.MqcftCommandXr, Cmqcfc.MqcfhVersion3);
            }
            else
            {
                tracker = new PCFAgentResponseTrackerNon390();
                Mqcfh.Write(cmdMessage, command, parameters.Length, Cmqcfc.MqcftCommand, Cmqcfc.MqcfhVersion1);
            }

            foreach (var p in parameters)
            {
                p.Write(cmdMessage);
            }

            var aqo      = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
            var cmdQueue = _qMgr.AccessQueue(_qMgr.CommandInputQueueName, aqo);

            var pmo = new MQPutMessageOptions {
                Options = MQC.MQPMO_NEW_MSG_ID
            };

            cmdQueue.Put(cmdMessage, pmo);

            var gmo = new MQGetMessageOptions {
                Options      = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT,
                WaitInterval = _waitInterval,
                MatchOptions = MQC.MQMO_MATCH_CORREL_ID
            };
            var list = new List <MQMessage>();

            while (true)
            {
                var response = new MQMessage {
                    CorrelationId = cmdMessage.MessageId
                };
                responseQueue.Get(response, gmo);

                list.Add(response);
                if (tracker.IsLast(response))
                {
                    break;
                }
            }
            cmdQueue.Close();
            responseQueue.Close();
            return(list.ToArray());
        }