/** * Checks to see if the given EbXmlMessage is acknowledged asynchronously, and just returns * if not. Otherwise, constructs an EbXMLAcknowledgment addressed to the sender of "msg", * and calls the ConnectionManager to send it. * * @param EbXmlMessage to acknowledge */ private void doAsynchronousAck(EbXmlMessage msg) { if (msg == null) { return; } if (!msg.Header.DuplicateElimination) { return; } if (msg.Header.SyncReply) { return; } StringBuilder a = new StringBuilder(makeEbXmlAck(msg, false)); ConnectionManager cm = ConnectionManager.getInstance(); SDSconnection sds = cm.SdsConnection; string ods = msg.Header.FromPartyKey.Substring(0, msg.Header.FromPartyKey.IndexOf("-")); List <SdsTransmissionDetails> sdsdetails = sds.getTransmissionDetails(ACKSERVICE, ods, null, msg.Header.FromPartyKey); a.Replace("__CPA_ID__", sdsdetails[0].CPAid); EbXmlAcknowledgment ack = new EbXmlAcknowledgment(a.ToString()); ack.setHost(sdsdetails[0].Url); cm.send(ack, sdsdetails[0]); }
/** * Singleton constructor. */ private ConnectionManager() { getPasswordProvider(); requests = new Dictionary <string, Sendable>(); expiryHandlers = new Dictionary <string, IExpiredMessageHandler>(); handlers = new Dictionary <string, ISpineHandler>(); synchronousHandlers = new Dictionary <string, ISynchronousResponseHandler>(); itkTrunkHandler = new ITKTrunkHandler(); handlers.Add("urn:nhs:names:services:itk/COPC_IN000001GB01", itkTrunkHandler); handlers.Add("\"urn:nhs:names:services:itk/COPC_IN000001GB01\"", itkTrunkHandler); loadCertificate(); messageDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MESSAGE_DIRECTORY_REGVAL, ""); if (messageDirectory.Length == 0) { EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No message directory provided - only in-memory persistence available", EventLogEntryType.Warning); } // Make sure messageDirectory is terminated with a path delimiter, because we're going // to need to add message ids to it when we call depersist() to delete persisted messages // on expiry or explicit transmission result. // if (!messageDirectory.EndsWith("\\")) { messageDirectory = messageDirectory + "\\"; } myIp = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MY_IP_REGVAL, ""); if (myIp.Length == 0) { myIp = null; EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No local IP address provided - will use first non-localhost interface", EventLogEntryType.Warning); } expiredDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, EXPIRED_DIRECTORY_REGVAL, ""); if (expiredDirectory.Length == 0) { EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No expired message directory provided - administrative handling of unsent messages NOT available", EventLogEntryType.Warning); } sdsConnection = new SDSconnection(); try { retryCheckPeriod = Int64.Parse((string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, RETRY_TIMER_PERIOD_REGVAL, "")); } catch { } string nulldefault = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, USE_NULL_DEFAULT_SYNCHRONOUS_HANDLER_REGVAL, ""); if (nulldefault.ToLower().StartsWith("y")) { defaultSynchronousResponseHandler = new NullSynchronousResponseHandler(); } else { defaultSynchronousResponseHandler = new DefaultFileSaveSynchronousResponseHandler(); } defaultSpineHandler = new DefaultFileSaveSpineHandler(); persistDurations = loadReceivedPersistDurations(); if (retryCheckPeriod != 0) { retryProcessorTimer = new Timer(processRetries, null, retryCheckPeriod, retryCheckPeriod); } }
static void Main(string[] args) { ConnectionManager cm = ConnectionManager.getInstance(); SDSconnection c = cm.SdsConnection; cm.listen(); // cm.loadPersistedMessages(); // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:pdsquery:QUPA_IN000008UK02", "YES", null, null); // / List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:pdsquery:QUPA_IN020000UK31", "YEA", "631955299542", null); // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:mm:PORX_IN020101UK31", "YEA", "631955299542", null); /* string qstring = null; * using (StreamReader rdr = File.OpenText(@"c:\test\data\query.txt")) * { * qstring = rdr.ReadToEnd(); * } * // SpineHL7Message msg = new SpineHL7Message("QUPA_IN020000UK31", qstring); * //SpineHL7Message msg = new SpineHL7Message("PORX_IN020101UK31", qstring); * SpineHL7Message msg = new SpineHL7Message("QUPA_IN000008UK02", qstring); * SpineSOAPRequest req = new SpineSOAPRequest(sdsdetails[0], msg); * msg.ToAsid = sdsdetails[0].Asid[0]; * msg.MyAsid = c.MyAsid; * msg.IsQuery = true; * //EbXmlMessage eb = new EbXmlMessage(sdsdetails[0], msg, c); * * MemoryStream ms = new MemoryStream(); * req.write(ms); * //eb.write(ms); * ms.Seek(0, SeekOrigin.Begin); * StreamReader sr = new StreamReader(ms); * string s = sr.ReadToEnd(); * * cm.send(req, sdsdetails[0]); */ //cm.listen(); // while (true) ; // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:pdsquery:QUPA_IN000008UK02", "YES", null, null); // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:pdsquery:QUPA_IN040000UK32", "YES", null, null); // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:mm:PORX_IN132004UK30", "YES", null, null); List <SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:psis:REPC_IN150015UK05", "YES", null, null); // List<SdsTransmissionDetails> sdsdetails = c.getTransmissionDetails("urn:nhs:names:services:pdsquery:QUPA_IN000006UK02", "YES", null, null); int i = sdsdetails.Count; cm.listen(); string qstring = null; using (StreamReader rdr = File.OpenText(@"c:\test\data\REPC_IN150015UK05_mhstest.xml")) { qstring = rdr.ReadToEnd(); } SpineHL7Message msg = new SpineHL7Message("REPC_IN150015UK05", qstring); msg.ToAsid = sdsdetails[0].Asid[0]; msg.MyAsid = c.MyAsid; msg.AuthorRole = "S0080:G0450:R5080"; msg.AuthorUid = "687227875014"; msg.AuthorUrp = "012345678901"; EbXmlMessage eb = new EbXmlMessage(sdsdetails[0], msg); // eb.Attachments.Add(deattachment); MemoryStream ms = new MemoryStream(); eb.write(ms); ms.Seek(0, SeekOrigin.Begin); StreamReader sr = new StreamReader(ms); string s = sr.ReadToEnd(); cm.send(eb, sdsdetails[0]); }
/** * Singleton constructor. */ private ConnectionManager() { getPasswordProvider(); requests = new Dictionary<string, Sendable>(); expiryHandlers = new Dictionary<string, IExpiredMessageHandler>(); handlers = new Dictionary<string, ISpineHandler>(); synchronousHandlers = new Dictionary<string, ISynchronousResponseHandler>(); itkTrunkHandler = new ITKTrunkHandler(); handlers.Add("urn:nhs:names:services:itk/COPC_IN000001GB01", itkTrunkHandler); handlers.Add("\"urn:nhs:names:services:itk/COPC_IN000001GB01\"", itkTrunkHandler); loadCertificate(); messageDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MESSAGE_DIRECTORY_REGVAL, ""); if (messageDirectory.Length == 0) { EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No message directory provided - only in-memory persistence available", EventLogEntryType.Warning); } // Make sure messageDirectory is terminated with a path delimiter, because we're going // to need to add message ids to it when we call depersist() to delete persisted messages // on expiry or explicit transmission result. // if (!messageDirectory.EndsWith("\\")) messageDirectory = messageDirectory + "\\"; myIp = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MY_IP_REGVAL, ""); if (myIp.Length == 0) { myIp = null; EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No local IP address provided - will use first non-localhost interface", EventLogEntryType.Warning); } expiredDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, EXPIRED_DIRECTORY_REGVAL, ""); if (expiredDirectory.Length == 0) { EventLog logger = new EventLog("Application"); logger.Source = LOGSOURCE; logger.WriteEntry("No expired message directory provided - administrative handling of unsent messages NOT available", EventLogEntryType.Warning); } sdsConnection = new SDSconnection(); try { retryCheckPeriod = Int64.Parse((string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, RETRY_TIMER_PERIOD_REGVAL, "")); } catch { } string nulldefault = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, USE_NULL_DEFAULT_SYNCHRONOUS_HANDLER_REGVAL, ""); if (nulldefault.ToLower().StartsWith("y")) defaultSynchronousResponseHandler = new NullSynchronousResponseHandler(); else defaultSynchronousResponseHandler = new DefaultFileSaveSynchronousResponseHandler(); defaultSpineHandler = new DefaultFileSaveSpineHandler(); persistDurations = loadReceivedPersistDurations(); if (retryCheckPeriod != 0) retryProcessorTimer = new Timer(processRetries, null, retryCheckPeriod, retryCheckPeriod); }