コード例 #1
0
        /// <summary>
        /// Получить запрос из очереди СМЭВ
        /// </summary>
        /// <returns>полученный запрос</returns>
        public override IRequest RecieveRequest()
        {
            var messageType = new MessageTypeSelector()
            {
                Id = ReferenceName
            };

            var signedMessage =
                CryptoProNetHelper.SignSmevObject(messageType, ReferenceName, DefaultNamespace, SerialNumber);

            var request = SmevService.GetRequest(messageType, signedMessage);

            if (request == null)
            {
                return(null);
            }

            var message = SmevTestMessage.Create(request, out var ftpAttachments);

            if (ftpAttachments != null)
            {
                message.Attachments = RecieveFtpAttachments(ftpAttachments, message.MessageId).ToList <IAttachment>();
            }

            OnRequestRecieved(new RequestRecievedEventArgs()
            {
                Request = message
            });

            return(message);
        }
コード例 #2
0
        /// <summary>
        /// Получить ответ из очереди СМЭВ
        /// </summary>
        /// <returns>ответ на запрос, отказ или статус запроса</returns>
        public override IMessage RecieveResponse()
        {
            var messageType = new MessageTypeSelector()
            {
                Id = ReferenceName
            };

            var signedMessage =
                CryptoProNetHelper.SignSmevObject(messageType, ReferenceName, DefaultNamespace, SerialNumber);

            var response = SmevService.GetResponse(messageType, signedMessage);

            if (response == null)
            {
                return(null);
            }

            var message = SmevTestMessage.Create(response);

            switch (message)
            {
            case IResponse responseMessage:

                OnResponseRecieved(new ResponseRecievedEventArgs()
                {
                    Response = responseMessage
                });

                return(responseMessage);

            case IReject reject:

                OnErrorRecieved(new ErrorRecievedEventArgs()
                {
                    ErrorMessage = new ErrorStatus()
                    {
                        MessageId    = reject.MessageId,
                        Status       = Status.Запрос_отклонен,
                        ErrorMessage = reject.RejectionMessage
                    }
                });
                return(reject);

            case IStatusFault statusFault:

                OnErrorRecieved(new ErrorRecievedEventArgs()
                {
                    ErrorMessage = new ErrorStatus()
                    {
                        MessageId    = statusFault.MessageId,
                        Status       = Status.Ошибка_при_отправке,
                        ErrorMessage = statusFault.SmevFaultDescription
                    }
                });

                return(statusFault);
            }

            return(null);
        }