示例#1
0
        /**
         * Test.
         *
         * @throws Exception
         *             the exception
         */
        public void testSendReceiveBasicTest()
        {
            Console.WriteLine("Starting test 01 (Create, Send, Receive)");
            CMPMedica.MMCoreConnector.Factories.MMCoreSettingsFactory.ConnectionSettings.Settings.Add("MMCSRVC_MMCORE_HOST", "localhost");
            CMPMedica.MMCoreConnector.Factories.MMCoreSettingsFactory.ConnectionSettings.Settings.Add("MMCSRVC_MMCORE_PORT", "8088");
            services = MMCoreServicesFactory.Services;
            services.SetupServices();
            content = System.Text.ASCIIEncoding.ASCII.GetBytes(contentStr);
            sender  = readOrCreateMBAccount(boxType, type, value, applicationId);
            reimporCert();
            showAccount(sender);
            MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage mim = createTestIntMessage();
            string msgId = sendIntMessage(mim, MMCoreConnector.WRQueueManagement.mailBoxAccountType.MAILBOX_EHEALTH);

            Console.WriteLine("SENT MSG ID: " + msgId);
            verifyNoError(sender.id, msgId);
            System.Threading.Thread.Sleep(10000);
            HashSet <string> msgIds = receiveMessageIds(sender.id);

            if (msgIds.Contains(msgId))
            {
                Console.WriteLine("The MESSAGE:" + msgId + " is received");
            }
            else
            {
                throw new Exception("The MESSAGE:" + msgId + " is NOT received!");
            }
            fetchMessage(sender.id, msgId);
            deleteMessage(sender.id, msgId);
        }
        public void mmCoreMainTest()
        {
            Console.WriteLine("Starting test 01 (Create, Send, Receive)");
            //Set up connector settings. Host = localhost (where the mproxy/mmcore is installed) port =8088
            setUpConnector();
            //Content to be sent
            content = System.Text.ASCIIEncoding.ASCII.GetBytes(contentStr);

            initializeSenderPersonalData();
            initializeReceiverPersonalData();
            MMCoreConnector.WRAccount.person remoteSender   = verifyServerAccountExist(sender);
            MMCoreConnector.WRAccount.person remoteReceiver = verifyServerAccountExist(receiver);
            if (remoteSender == null)
            {
                remoteSender = createServerAccount(sender);
            }

            if (remoteReceiver == null)
            {
                remoteReceiver = createServerAccount(receiver);
            }
            updateLocalPassword(remoteReceiver, receiver.password);
            updateLocalPassword(remoteSender, sender.password);
            receiver = remoteReceiver;
            sender   = remoteSender;

            if (!verifyLocalAccountExist(sender))
            {
                createLocalAccount(sender);
                certify(sender);
            }
            if (!verifyLocalAccountExist(receiver))
            {
                createLocalAccount(receiver);
                certify(receiver);
            }

            MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage mim = createTestIntMessage();

            string msgId = sendIntMessage(mim, MMCoreConnector.WRQueueManagement.mailBoxAccountType.MAILBOX_MEDIBRIDGE_MMCORE);

            Console.WriteLine("SENT MSG ID: " + msgId);
            verifyNoError(sender.login, msgId);
            System.Threading.Thread.Sleep(10000);
            HashSet <string> msgIds = receiveMessageIds(receiver.login);

            if (msgIds.Contains(msgId))
            {
                Console.WriteLine("The MESSAGE:" + msgId + " is received");
            }
            else
            {
                throw new Exception("The MESSAGE:" + msgId + " is NOT received!");
            }
            fetchMessage(receiver.login, msgId);
            deleteMessage(receiver.login, msgId);
        }
        public static string sendIntMessage(MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage mim, MMCoreConnector.WRQueueManagement.mailBoxAccountType mbat)
        {
            string res = "";

            MMCoreConnector.WRQueueManagement.mproxyOperationStatus mos = services.MMCoreServiceQueueManagement.sendMessage(mim, mbat);
            if (mos.operationResult.Equals(MMCoreConnector.WRQueueManagement.mproxyOperationResult.MPROXY_RESULT_FAILED))
            {
                throw new Exception("SEND Failed!");
            }
            res = mos.operationOutputValue;
            return(res);
        }
 private void verifyNoError(string accountId, string msgId)
 {
     Console.WriteLine("CHECK for errors. SENT MSG ID: " + msgId);
     MMCoreConnector.WRQueueManagement.mproxyOperationStatusIMessage msintm = services.MMCoreServiceQueueManagement.getIMessageById(accountId, msgId, MMCoreConnector.WRQueueManagement.mailBoxType.SENTBOX);
     if (msintm.operationResult.Equals(MMCoreConnector.WRQueueManagement.mproxyOperationResult.MPROXY_RESULT_FAILED))
     {
         throw new Exception("Can't get the message: " + msgId + "   " + msintm.detailedInfo);
     }
     MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage      mim = msintm.value[0];
     MMCoreConnector.WRQueueManagement.mproxyIntegrationMessageError err = mim.error;
     if (err != null)
     {
         throw new Exception("The message has an error:" + err.mproxyError + "; " + err.rootCause);
     }
     else
     {
         Console.WriteLine("The MESSAGE is OK (NO ERROR)");
     }
 }
        private void fetchMessage(string accountId, string id)
        {
            MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage      mim   = null;
            MMCoreConnector.WRQueueManagement.mproxyOperationStatusIMessage mosim = services.MMCoreServiceQueueManagement.getIMessageById(accountId, id, MMCoreConnector.WRQueueManagement.mailBoxType.INBOX);
            if (mosim.operationResult.Equals(MMCoreConnector.WRQueueManagement.mproxyOperationResult.MPROXY_RESULT_FAILED))
            {
                throw new Exception("getIMessageById Failed! ERR " + mosim.operationResult);
            }
            MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage[] mims = mosim.value;
            mim = mims[0];

            if (mim != null)
            {
                MMCoreConnector.WRQueueManagement.mproxyAttachment[] ents = mim.mproxyAttachements;
                foreach (MMCoreConnector.WRQueueManagement.mproxyAttachment ent in ents)
                {
                    Console.WriteLine("ATT: " + ent.name);
                }
            }
        }
 private static MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage composeMessage()
 {
     MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage message = new MMCoreConnector.WRQueueManagement.mproxyIntegrationMessage();
     message.mproxyXMLMessage = "";
     return(message);
 }