private static List <MessageHeaderInstance> getSingleMessageHeaderInstance(MessageHeaderInstance messageHeaderInstance) { List <MessageHeaderInstance> messageHeaderInstances = new List <MessageHeaderInstance>(); SysDataAccessCredential dac = DAOUtility.GetSysCredentials(); DataAccess das = new DataAccess(); using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac))) { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandType = System.Data.CommandType.Text; command.CommandText = das.GET_SINGLE_MESSAGE_HEADER_INSTANCE; command.Parameters.AddWithValue(MessageHeaderInstanceDAO.AT_ID, messageHeaderInstance.id); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { messageHeaderInstances.Add(new MessageHeaderInstance(reader)); } } } catch (Exception e) { ErrorLogger.LogError(e, "getSingleMessageHeaderInstance(MessageHeaderInstance MessageHeaderInstance)", messageHeaderInstance.id.ToString()); } } return(messageHeaderInstances); }
private static bool deleteMessageHeaderInstance(MessageHeaderInstance messageHeaderInstance) { SysDataAccessCredential dac = DAOUtility.GetSysCredentials(); DataAccess das = new DataAccess(); using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac))) { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandType = System.Data.CommandType.Text; command.CommandText = das.DELETE_MESSAGE_HEADER_INSTANCE; command.Parameters.AddWithValue(MessageHeaderInstanceDAO.AT_ID, messageHeaderInstance.id); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { messageHeaderInstance.id = DAOUtility.GetData <int>(reader, MessageHeaderInstanceDAO.ID); } } } catch (Exception e) { ErrorLogger.LogError(e, "DeleteMessageHeaderInstance()", messageHeaderInstance.id.ToString()); } } return(true); }
public static void TestBrokerUpdates() { List <Application> applications = ApplicationDAO.Get(); applications.ForEach(delegate(Application application) { if (application.name != "RSERVER") { return; } List <MessageBucket> brokerInformation = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(application); //List<Broker> brokerInformation //= BrokerDAO.GetProcessedMessageHeaderInstancesByApplication(application); brokerInformation.ForEach(delegate(MessageBucket broker) { // get the message header and message MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance; Message message = broker.message; // update the table to processed MessageBucketDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true); //BrokerDAO.ReprocessMessage(messageHeaderInstance.messageControlId); }); }); }
public static bool UpdateProcessedFlagAndMessageLog(MessageHeaderInstance messageHeaderInstance, Message message, bool isReprocess = false) { SysDataAccessCredential dac = DAOUtility.GetSysCredentials(); DataAccess das = new DataAccess(); // set the flag which determines the reprocess bool isProcessed = false; using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac))) { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = das.UPDATE_MESSAGE_HEADER_INSTANCE_PROCESS; command.Parameters.AddWithValue(MessageBucketDAO.AT_ID, messageHeaderInstance.id); command.Parameters.AddWithValue(MessageBucketDAO.AT_MESSAGE_ID, message.id); command.Parameters.AddWithValue(MessageBucketDAO.AT_ISREPROCESS, isReprocess); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { isProcessed = DAOUtility.GetData <bool>(reader, MessageBucketDAO.ID); } } } catch (Exception e) { ErrorLogger.LogError(e, "MessageHeaderInstance messageHeaderInstance, Message message", messageHeaderInstance.id.ToString() + "|" + message.id.ToString()); ErrorLogger.LogError(new Exception("Message UpdateProcessedFlagAndMessageLog Retry"), "MessageHeaderInstance messageHeaderInstance, Message message", messageHeaderInstance.id.ToString() + "|" + message.id.ToString()); isProcessed = UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, isReprocess); } } return(isProcessed); }
private static MessageHeaderInstance updateMessageHeaderInstanceToProcessed(MessageHeaderInstance messageHeaderInstance, Message message, bool isReprocess = false) { SysDataAccessCredential dac = DAOUtility.GetSysCredentials(); DataAccess das = new DataAccess(); using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac))) { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = das.UPDATE_MESSAGE_HEADER_INSTANCE_PROCESS; command.Parameters.AddWithValue(MessageHeaderInstanceDAO.AT_ID, messageHeaderInstance.id); command.Parameters.AddWithValue(MessageHeaderInstanceDAO.AT_MESSAGE_ID, message.id); command.Parameters.AddWithValue(MessageHeaderInstanceDAO.AT_ISREPROCESS, isReprocess); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { messageHeaderInstance.id = DAOUtility.GetData <int>(reader, MessageHeaderInstanceDAO.ID); } } } catch (Exception e) { ErrorLogger.LogError(e, "updateMessageHeaderInstanceToProcessed()", messageHeaderInstance.id.ToString()); } } return(messageHeaderInstance); }
public static void handleProcessingForOutboundHandler(Configuration masterConfig, OutboundHandler outboundHandler) { // to control some basic CPU handling settings Config outboundConfig = new Config(); // load each of the configurations into their own objects List <Application> applications = masterConfig.applications; List <Communication> communications = masterConfig.communications; List <WebserviceObject> webserviceObjects = masterConfig.webserviceObjects; List <WebserviceInstance> webserviceInstances = masterConfig.webserviceInstances; List <WebservicePropertySet> webserviceProperties = masterConfig.webservicePropertySets; List <MessageGroup> messageGroups = masterConfig.messageGroups; List <MessageGroupInstance> messageGroupInstances = masterConfig.messageGroupInstances; // continue to read the table while (true) { applications.ForEach(delegate(Application app) { if (app.name == outboundHandler.getApplicationName()) { // get the unprocessed message count for the application List <MessageBucket> brokerInformation = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(app); // set the MOD from config file. var options = new ParallelOptions { MaxDegreeOfParallelism = outboundConfig.MaxDegreeOfParallelism }; // parallel For each Parallel.ForEach(brokerInformation, options, broker => { // get the message header and message MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance; Message message = broker.message; // srub the input of bad stuff string hl7Scrubbed = HL7MessageUtility.scrubHL7MessageForParse(message.hl7Raw); // make the hl7 message HL7Message hl7Message = HL7MessageDAO.getMessage(hl7Scrubbed); // locally retrieve the communication object from memory Communication communication = ConfigurationUtility.GetIncomingWebserviceCommunication(app, communications); // locally retrieve the webservice instance object from memory WebserviceInstance webserviceInstance = ConfigurationUtility.GetIncomingWebserviceInstance(communication, webserviceInstances); // locally retrieve the web service objects from memory List <WebserviceObject> wsObjects = ConfigurationUtility.GetIncomingWebserviceObjects(webserviceInstance, webserviceObjects); // determine the message type Generic.MessageType messageType = HL7MessageUtility.getMessageType(hl7Message, hl7Scrubbed); switch (messageType) { // to handle a new message add message type then its own handler case Generic.MessageType.ADT: break; case Generic.MessageType.ORM: handleProcessingForORM(wsObjects, webserviceProperties, hl7Message, messageGroupInstances, messageGroups, app, message); break; case Generic.MessageType.ORU: handleProcessingForORU(wsObjects, webserviceProperties, hl7Message, messageGroupInstances, messageGroups, app, message); break; case Generic.MessageType.SIU: break; case Generic.MessageType.UNKNOWN: break; default: break; } // update the table to processed MessageBucketDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true); // update broker stats handleBrokerStatUpdate(message, communication); }); } }); // provide blocking if there is no data to process. Thread.Sleep(1000); } }
public static bool Delete(MessageHeaderInstance messageHeaderInstance) { return(deleteMessageHeaderInstance(messageHeaderInstance)); }
public static MessageHeaderInstance ReprocessMessage(MessageHeaderInstance messageHeaderInstance, Message message) { return(updateMessageHeaderInstanceToProcessed(messageHeaderInstance, message, true)); }
public static MessageHeaderInstance PostUpdate(MessageHeaderInstance messageHeaderInstance, Message message) { return(updateMessageHeaderInstanceToProcessed(messageHeaderInstance, message)); }
public static List <MessageHeaderInstance> Get(MessageHeaderInstance messageHeaderInstance) { return(getSingleMessageHeaderInstance(messageHeaderInstance)); }
public static void TestConfigLoad() { Configuration masterConfig = ConfigurationDAO.GetAllConfigurations(); List <Application> applications = masterConfig.applications; List <Communication> communications = masterConfig.communications; List <WebserviceObject> webserviceObjects = masterConfig.webserviceObjects; List <WebserviceInstance> webserviceInstances = masterConfig.webserviceInstances; List <WebservicePropertySet> webserviceProperties = masterConfig.webservicePropertySets; List <MessageGroup> messageGroups = masterConfig.messageGroups; applications.ForEach(delegate(Application app) { if (app.name != RSERVER) { return; } // get the unprocessed message count for the application List <MessageBucket> brokerInformation = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(app); brokerInformation.ForEach(delegate(MessageBucket broker) { // get the message header and message MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance; Message message = broker.message; // locally retrieve the communication object from memory Communication communication = ConfigurationUtility.GetIncomingWebserviceCommunication(app, communications); // locally retrieve the webservice instance object from memory WebserviceInstance webserviceInstance = ConfigurationUtility.GetIncomingWebserviceInstance(communication, webserviceInstances); // locally retrieve the web service objects from memory List <WebserviceObject> wsObjects = ConfigurationUtility.GetIncomingWebserviceObjects(webserviceInstance, webserviceObjects); // for each object - for each property set for that object - handle accordingly wsObjects.ForEach(delegate(WebserviceObject wsObject) { Console.WriteLine("OBJECT:" + wsObject.name); List <WebservicePropertySet> wsProperties = ConfigurationUtility.GetIncomingWebservicePropertySets(wsObject, webserviceProperties); wsProperties.ForEach(delegate(WebservicePropertySet wsProperty) { Console.WriteLine("Property:" + wsProperty.name); List <MessageGroup> msGroups = ConfigurationUtility.GetIncomingWebserviceMessageGroup(wsProperty, messageGroups); Console.WriteLine("Group Count:" + msGroups.Count); }); }); // update the table to processed // BrokerDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true); }); }); }