public bool ProcessVisit(string visitKey, byte[] ups, byte[] hrs, int startIndex, int length, ref StringBuilder data)
        {
            string processGUID = GetAssignedProcess(visitKey);

            using (ChannelFactory <IPatternsProcessorMessages> factory = CreateChannelFactory(processGUID))
            {
                IPatternsProcessorMessages channel = factory.CreateChannel();
                try
                {
                    ResultsEngineResponse response = channel.EngineProcessData(visitKey, ups, hrs, startIndex, length);
                    if (response.ResponseCode != EngineResponseCode.Success)
                    {
                        throw new Exception(response.ErrorMessage);
                    }

                    data = response.ResultsData;
                    return(response.MoreData);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    CloseChannel((ICommunicationObject)channel);
                }
            }
        }
        private StatusEngineResponse ExecuteGetStatus(string processGUID)
        {
            using (ChannelFactory <IPatternsProcessorMessages> factory = CreateChannelFactory(processGUID))
            {
                IPatternsProcessorMessages channel = factory.CreateChannel();
                try
                {
                    StatusEngineResponse response = channel.GetStatus();
                    if (response.ResponseCode != EngineResponseCode.Success)
                    {
                        throw new Exception(response.ErrorMessage);
                    }

                    return(response);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    CloseChannel((ICommunicationObject)channel);
                }
            }
        }
        private bool ExecuteRemoveEpisode(string visitKey, string processGUID)
        {
            using (ChannelFactory <IPatternsProcessorMessages> factory = CreateChannelFactory(processGUID))
            {
                IPatternsProcessorMessages channel = factory.CreateChannel();
                try
                {
                    EngineResponseBase response = channel.RemoveEpisode(visitKey);
                    if (response.ResponseCode != EngineResponseCode.Success)
                    {
                        throw new Exception(response.ErrorMessage);
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
                finally
                {
                    CloseChannel((ICommunicationObject)channel);
                }
            }
        }
 private void ExecuteTerminateProcess(string processGUID)
 {
     using (ChannelFactory <IPatternsProcessorMessages> factory = CreateChannelFactory(processGUID))
     {
         IPatternsProcessorMessages channel = factory.CreateChannel();
         try
         {
             channel.TerminateProcess();
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             CloseChannel((ICommunicationObject)channel);
         }
     }
 }