Beispiel #1
0
        public void EventLogger_LoggingTest()
        {
            string    message       = "Error Message";
            Exception ex            = new Exception("Exception");
            string    messageFormat = "Message Format: message: {0}, exception: {1}";

            ILog log = new EventLogger("ServiceStack.Logging.Tests", "Application");

            Assert.IsNotNull(log);

            log.Debug(message);
            log.Debug(message, ex);
            log.DebugFormat(messageFormat, message, ex.Message);

            log.Error(message);
            log.Error(message, ex);
            log.ErrorFormat(messageFormat, message, ex.Message);

            log.Fatal(message);
            log.Fatal(message, ex);
            log.FatalFormat(messageFormat, message, ex.Message);

            log.Info(message);
            log.Info(message, ex);
            log.InfoFormat(messageFormat, message, ex.Message);

            log.Warn(message);
            log.Warn(message, ex);
            log.WarnFormat(messageFormat, message, ex.Message);
        }
        /// <summary>
        /// <c>parseDelimited</c>
        /// </summary>
        /// Converts motLegacy delimited data format to motLegacy tagged format and passes it to the gateway
        /// There are two formats in play.  One uses binary delimiters and one uses plain text, which is
        /// undocumented and appears to be used by Qs1.  FrameworksLTC uses the binary version
        /// <param name="v1Data">Indicates documented binary delimited format if true</param>
        public void Go(bool v1Data = false)
        {
            var retVal = PreParseQs1(Data);

            if (retVal != string.Empty)
            {
                Data   = retVal;
                v1Data = true;
            }

            retVal = PreParseByteStream(Data);
            if (retVal != string.Empty)
            {
                Data = retVal;
            }

            Data = NormalizeDelimiters(Data);

            var tc = new TableConverter();

            char[] fieldDelimiter  = { '~' };
            char[] recordDelimiter = { '^' };
            var    table           = string.Empty;

            // Unravel the delimited stream
            var items = Data.Split(recordDelimiter);

            string[] fields = null;

            foreach (var item in items)
            {
                try
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    fields = item.Split(fieldDelimiter);
                    table  = tc.Parse(fields, v1Data);
                    ParseTagged(table);
                }
                catch (Exception ex)
                {
                    EventLogger.Error(ex.Message);

                    if (fields != null)
                    {
                        foreach (var f in fields)
                        {
                            EventLogger.Debug($"ERROR: ParseDelimited Field: {f}");
                        }
                    }

                    EventLogger.Debug($"ERROR: ParseDelimited Record: {table}");

                    throw;
                }
            }
        }
Beispiel #3
0
        public string Parse(string data)
        {
            if (data == null)
            {
                throw new ArgumentNullException($"MotParser::Parse");
            }

            string responseMessage;

            try
            {
                using (var gatewaySocket = new MotSocket(GatewayAddress, GatewayPort))
                {
                    gatewaySocket._useASCII = this.UseAscii;

                    using (var p = new MotParser(gatewaySocket, data, _inputDataFormat, DebugMode, AllowZeroTQ, DefaultStoreLoc))
                    {
                        EventLogger.Debug(p.ResponseMessage);
                        responseMessage = p.ResponseMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                responseMessage = $"Parser failure, Message: {ex.Message}";
                EventLogger.Error(responseMessage);
                throw;
            }

            return(responseMessage);
        }
        private void WriteBlockToGateway(string inboundData)
        {
            if (string.IsNullOrEmpty(inboundData))
            {
                throw new ArgumentNullException($"inboundData data Null or Empty");
            }

            if (GatewaySocket == null)
            {
                throw new ArgumentNullException($"Invalid Socket Reference");
            }

            try
            {
                if (DebugMode)
                {
                    LogTaggedRecord(inboundData);
                }

                if (GatewaySocket.Write(inboundData) == false)
                {
                    throw new Exception("Parser recieved a 'failed' response from the gateway");
                }

                if (SendEof)
                {
                    GatewaySocket.Write("<EOF/>");
                }

                if (DebugMode)
                {
                    EventLogger.Debug(inboundData);
                }
            }
            catch (Exception ex)
            {
                EventLogger.Error($"Failed to write to gateway: {ex.Message}");
                throw;
            }
        }
Beispiel #5
0
        public void EventLoggerLogDebug()
        {
            ManualResetEvent handle = new ManualResetEvent(false);

            try
            {
                EventLogger logger = new EventLogger();

                logger.Log += (sender, args) =>
                {
                    Assert.AreEqual(EventLoggerEventType.Debug, args.EventType);
                    Assert.AreEqual("Debug", args.Message);
                    Assert.IsNull(args.Exception);
                    handle.Set();
                };

                logger.Debug("Debug");
                WaitHandle.WaitAll(new WaitHandle[] { handle });
            }
            finally
            {
                handle.Close();
            }
        }
        public void EventLoggerLogDebug()
        {
            ManualResetEvent handle = new ManualResetEvent(false);

            try
            {
                EventLogger logger = new EventLogger();

                logger.Log += (sender, args) =>
                {
                    Assert.AreEqual(EventLoggerEventType.Debug, args.EventType);
                    Assert.AreEqual("Debug", args.Message);
                    Assert.IsNull(args.Exception);
                    handle.Set();
                };

                logger.Debug("Debug");
                WaitHandle.WaitAll(new WaitHandle[] { handle });
            }
            finally
            {
                handle.Close();
            }
        }
        private void RunParser(InputDataFormat inputDataFormat, string inputStream)
        {
            try
            {
                switch (inputDataFormat)
                {
                case InputDataFormat.AutoDetect:
                    ParseByGuess(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Best Guess processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.XML:
                    ParseXml(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed XML processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.JSON:
                    ParseJson(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed JSON processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.Delimited:
                    ParseDelimited(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Delimited File processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.Tagged:
                    ParseTagged(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Tagged File processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.Parada:
                    ParseParada(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Parda file processng: {inputStream}");
                    }
                    break;

                case InputDataFormat.Dispill:
                    ParseDispill(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Dispill File Processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.HL7:
                    ParseHL7(inputStream);

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed HL7 File Processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.MTS:
                case InputDataFormat.psEDI:
                    ParseEdi(inputStream);
                    if (DebugMode)
                    {
                        EventLogger.Debug($"Completed Oasis File Processing: {inputStream}");
                    }
                    break;

                case InputDataFormat.Unknown:

                    if (DebugMode)
                    {
                        EventLogger.Debug($"Unknown File Type: {inputStream}");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                EventLogger.Error($"MotParser failed on input type {inputDataFormat.ToString()}\nError {ex.Message}");
                throw;
            }
        }
Beispiel #8
0
 /// <summary>
 /// Service Method when Service first starts
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     log.Debug("Syllabus Plus Scheduler Service started.");
     this.Scheduler = new Timer(new TimerCallback(ScheduleCallback),
                                state: null, dueTime: 0, period: (this.configSettings.SyncIntervalInMinutes * 60000));
 }
Beispiel #9
0
        public MainForm()
        {
            InitializeComponent();

            buffer = new Byte[512];

            audio = new RtAudio();

            //audio1 = new RtAudio();

            mixer = new RtStreamMixer();

            // Setup Test Logging
            EventLoggerManager.TraceLoggingEvent    += new LoggingEventHandler(EventLoggerManager_TraceLoggingEvent);
            EventLoggerManager.DebugLoggingEvent    += new LoggingEventHandler(EventLoggerManager_DebugLoggingEvent);
            EventLoggerManager.InfoLoggingEvent     += new LoggingEventHandler(EventLoggerManager_InfoLoggingEvent);
            EventLoggerManager.WarnLoggingEvent     += new LoggingEventHandler(EventLoggerManager_WarnLoggingEvent);
            EventLoggerManager.ErrorLoggingEvent    += new LoggingEventHandler(EventLoggerManager_ErrorLoggingEvent);
            EventLoggerManager.CriticalLoggingEvent += new LoggingEventHandler(EventLoggerManager_CriticalLoggingEvent);

            List <RtAudio.Api> compileApis = RtAudio.getCompiledApi();

            // List the currently compiled APIs.
            logger.Debug("Compiled Apis:");
            foreach (RtAudio.Api api in compileApis)
            {
                //Console.WriteLine("  {0}", api.ToString());
                logger.Debug(String.Format("  {0}", api.ToString()));
            } // end foreach

            // Enumerate Devices
            uint deviceCount = audio.getDeviceCount();

            //Console.WriteLine("Device Count: {0}", deviceCount);
            logger.Debug(String.Format("Device Count: {0}", deviceCount));

            //Console.WriteLine("Found Devices:");
            logger.Debug("Found Devices:");
            for (uint idx = 0; deviceCount > idx; idx++)
            {
                RtAudio.DeviceInfo info = audio.getDeviceInfo(idx);

                //Console.WriteLine("ID {1}: {0}:", info.name, idx);
                //Console.WriteLine("    InputChannels: {0}", info.inputChannels);
                //Console.WriteLine("    OutputChannels: {0}", info.outputChannels);
                //Console.WriteLine("    DuplexChannels: {0}", info.duplexChannels);

                logger.Debug(String.Format("ID {1}: {0}:", info.name, idx));
                logger.Debug(String.Format("    InputChannels: {0}", info.inputChannels));
                logger.Debug(String.Format("    OutputChannels: {0}", info.outputChannels));
                logger.Debug(String.Format("    DuplexChannels: {0}", info.duplexChannels));

                if (info.inputChannels > 0)
                {
                    inputCombo.Items.Add(info.name);
                    inputCombo.SelectedIndex = 0;
                } // end if

                if (info.outputChannels > 0)
                {
                    outputCombo.Items.Add(info.name);
                    outputCombo.SelectedIndex = 0;
                } // end if
            }     // end for
        }