Exemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            // log
            ErrorLogger.Log(ErrorLogger.LogType.OUTBOUND_SERVICE_STARTING, DateTime.Now.ToString());

            // get all configuration data
            List <Configuration> configs = ConfigurationDAO.GetApplications();

            // get the master configuration
            Configuration masterConfig = ConfigurationDAO.GetAllConfigurations();

            // gets the outgoing webservice configuration only
            List <Configuration> applications = ConfigurationUtility.GetIncomingWebservice(configs);

            applications.ForEach(delegate(Configuration appConfig) {
                OutboundHandler outboundHandler = new OutboundHandler();
                string appName = appConfig.application.name;

                // set the app name
                outboundHandler.setApplicationName(appName);

                // set the master config
                outboundHandler.setMasterConfiguration(masterConfig);

                // set the static worker
                outboundHandler.setProcessingWorker(OutboundHandlerDAO.handleProcessingForOutboundHandler);

                // add to queue and run
                ThreadPool.QueueUserWorkItem(new WaitCallback(startOutboundProcessing), outboundHandler);
            });
        }
Exemplo n.º 2
0
        private void startOutboundProcessing(object state)
        {
            OutboundHandler outboundHandler = (OutboundHandler)state;

            try
            {
                outboundHandler.Begin();
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex, "startOutboundProcessing(object state)", outboundHandler.getApplicationName());
            }
        }
Exemplo n.º 3
0
        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);
            }
        }