Exemplo n.º 1
0
        private String ReceiveMessage(String msgId)
        {
            //check if it exits (not realy needed but demonstrates the usage of the get msg list and it gives us the msg type)
            GetMessagesListRequestType selectReq = new GetMessagesListRequestType();

            selectReq.Source = GetMessagesListRequestTypeSource.INBOX;
            GetMessageListResponseType listRsp = consult.getMessagesList(selectReq);

            Assert.AreEqual("100", listRsp.Status.Code);

            ContentInfoTypeContentType?msgType = null;

            foreach (GetMessageListResponseTypeMessage msg in listRsp.Message)
            {
                if (msg.MessageId == msgId)
                {
                    msgType = msg.ContentInfo.ContentType;
                }
            }

            Assert.IsNotNull(msgType);

            //Now that we know it exists and we know if it news or a document we can move on and get it.
            MessageRequestType fetchReq = new MessageRequestType();

            fetchReq.Source    = MessageRequestTypeSource.INBOX;
            fetchReq.MessageId = msgId;

            GetFullMessageResponseType fetchRsp = consult.getFullMessage(fetchReq);

            Assert.AreEqual("100", fetchRsp.Status.Code);

            switch (msgType.Value)
            {
            case ContentInfoTypeContentType.NEWS:
                NewsType news = (NewsType)fetchRsp.Message.ContentContext.Content.Item;
                return(Encoding.UTF8.GetString(news.Item));

            case ContentInfoTypeContentType.DOCUMENT:
                DocumentType doc = (DocumentType)fetchRsp.Message.ContentContext.Content.Item;
                return(Encoding.UTF8.GetString(doc.Item));

            default:
                Assert.Fail();
                return(null);
            }
        }
Exemplo n.º 2
0
        private void CleanupMsgBox()
        {
            GetMessagesListRequestType selectReq = new GetMessagesListRequestType();

            selectReq.Source = GetMessagesListRequestTypeSource.INBOX;
            GetMessageListResponseType listRsp = consult.getMessagesList(selectReq);

            List <String> msgIds = new List <string>();

            foreach (GetMessageListResponseTypeMessage msg in listRsp.Message)
            {
                msgIds.Add(msg.MessageId);
            }

            MoveMessageRequestType mvReq = new MoveMessageRequestType();

            mvReq.MessageId   = msgIds.ToArray();
            mvReq.Source      = MoveMessageRequestTypeSource.INBOX;
            mvReq.Destination = MoveMessageRequestTypeDestination.BININBOX;
            Egelke.EHealth.Client.EhBox.ResponseType mvRsp = consult.moveMessage(mvReq);

            Assert.AreEqual("100", mvRsp.Status.Code);
        }