/** * 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 static MMCoreConnector.WRMailBoxAccount.mailBoxAccount readOrCreateMBAccount(string boxType, string type, string value, string applicationId) { MMCoreConnector.WRMailBoxAccount.mailBoxAccount res = null; Console.WriteLine("createLocalAccount. Type : " + type + " Value: " + value + " AppID:" + applicationId); string accId = generateMailBoxAccountId(boxType, type, value, applicationId); MMCoreConnector.WRMailBoxAccount.mproxyOperationStatusAccount mosa = null; MMCoreConnector.WRMailBoxAccount.mproxyOperationStatus mos = null; mosa = services.MMCoreServiceMailBoxAccount.readById(accId); if (mosa.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { res = mosa.value[0]; Console.WriteLine("readOrCreateMBAccount : account FOUND " + res); } else { Console.WriteLine("createLocalAccount : Account NOT FOUND. Creating..."); mos = services.MMCoreServiceMailBoxAccount.createMailBox(boxType, type, value, applicationId); Console.WriteLine("createLocalAccount : " + value + " RES: " + mos.operationResult + " INFO: " + mos.detailedInfo); if (mos.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { Console.WriteLine("readOrCreateMBAccount : account was creted "); } else { throw new Exception("Can't create the account. " + mosa.detailedInfo); } mosa = services.MMCoreServiceMailBoxAccount.readById(accId); res = mosa.value[0]; } return(res); }
public static void importCert(MMCoreConnector.WRMailBoxAccount.mailBoxAccount boxId, string fileLocation, string pinCode) { MMCoreConnector.WRMailBoxAccount.mailBoxAccount res; string id = boxId.id; MMCoreConnector.WRMailBoxAccount.mproxyOperationStatusAccount mosa = null; mosa = services.MMCoreServiceMailBoxAccount.readById(id); if (mosa.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { res = mosa.value[0]; Console.WriteLine("importCert : account FOUND " + res); } else { throw new Exception("Can't read the account. " + id); } res.pinCode = (pinCode); boxId.pinCode = (pinCode); updateAccount(res); services.MMCoreServiceCertification.deleteKeyStore(id); services.MMCoreServiceCertification.createEmptyKeyStore(id, pinCode); MMCoreConnector.WRCertification.mproxyOperationStatus cres = services.MMCoreServiceCertification.importPKCS12KeyStore(id, pinCode, fileLocation); if (!cres.operationResult.Equals(MMCoreConnector.WRCertification.mproxyOperationResult.MPROXY_RESULT_OK)) { throw new Exception("Can't import: " + id); } }
public static void updateAccount(MMCoreConnector.WRMailBoxAccount.mailBoxAccount mba) { MMCoreConnector.WRMailBoxAccount.mproxyOperationStatus mr = services.MMCoreServiceMailBoxAccount.update(mba); if (!mr.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { throw new Exception("Can't update the account. " + mr.detailedInfo); } }
public void showAccount(MMCoreConnector.WRMailBoxAccount.mailBoxAccount account) { Console.WriteLine("Account : " + account.id); MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties[] mbaps = account.properties; foreach (MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties mbap in mbaps) { Console.WriteLine("Account prop ID : " + mbap.propertyId + " VAL: " + mbap.value); } }
private void setUpAcceptanceEnv(MMCoreConnector.WRMailBoxAccount.mailBoxAccount mba) { Console.WriteLine("Setting EH's acceptance env for " + mba); setMailBoxAccountProperty(mba, "MBAP_EHEALTH_ENV", "acceptance"); updateAccount(mba); MMCoreConnector.WRMailBoxAccount.mproxyOperationStatusAccount mosa = services.MMCoreServiceMailBoxAccount.readById(mba.id); if (mosa.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { MMCoreConnector.WRMailBoxAccount.mailBoxAccount res = mosa.value[0]; showAccount(res); } }
public static void setMailBoxAccountProperty(MMCoreConnector.WRMailBoxAccount.mailBoxAccount mba, string key, string value) { MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties[] mbaps = mba.properties; foreach (MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties mbap in mbaps) { if (mbap.propertyId != null && mbap.propertyId.Equals(key)) { mbap.value = (value); return; } } MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties mbapp = new MMCoreConnector.WRMailBoxAccount.mailBoxAccountProperties(); Array.Resize(ref mbaps, mbaps.Length + 1); mbaps[mbaps.Length] = mbapp; mbapp.propertyId = key; mbapp.value = (value); }
private static void updateLocalAccountPassword(MMCoreConnector.WRAccount.person person) { MMCoreConnector.WRMailBoxAccount.mailBoxAccount accountLoc = null; MMCoreConnector.WRMailBoxAccount.mproxyOperationStatusAccount mosp = services.MMCoreServiceMailBoxAccount.readById(person.login); Console.WriteLine("verifyLocalAccountExist : " + person.login + " IS: " + mosp.operationResult); if (mosp.operationResult.Equals(MMCoreConnector.WRMailBoxAccount.mproxyOperationResult.MPROXY_RESULT_OK)) { if (mosp.detailedInfo.Equals("Successfully read")) { accountLoc = mosp.value[0]; Console.WriteLine("updateLocalAccountPassword : "******" FOUND!"); } } else { Console.WriteLine("updateLocalAccountPassword : "******" NOT FOUND..."); } accountLoc.password = person.password; services.MMCoreServiceMailBoxAccount.update(accountLoc); }