/// <inheritdoc /> public MotParser(MotSocket outSocket, string inputStream, InputDataFormat inputDataFormat, bool debugMode = false, bool allowZeroTQ = false, string defaultStoreLoc = null, bool autoTruncate = false, bool sendEof = false) : base(inputStream) { GatewaySocket = outSocket ?? throw new ArgumentNullException($@"NULL Socket passed to MotParser"); if (GatewaySocket.Disposed) { throw new ArgumentNullException($"Disposed Socket passed to MotParser"); } SendEof = sendEof; DebugMode = debugMode; AutoTruncate = autoTruncate; AllowZeroTQ = allowZeroTQ; DefaultStoreLoc = defaultStoreLoc; try { RunParser(inputDataFormat, inputStream); } catch { EventLogger.Error($"MotParser failed on input type {inputDataFormat} and data: {inputStream}"); throw; } }
/// <inheritdoc /> // ReSharper disable once UnusedParameter.Local public MotParser(string inputStream, InputDataFormat inputDataFormat, bool autoTruncate = false, bool sendEof = false, bool debugMode = false) : base(inputStream) { try { GatewaySocket = new MotSocket("localhost", 24042); RunParser(inputDataFormat, inputStream); } catch { EventLogger.Error("MotParser failed on input type {0} and data: {1}", inputDataFormat.ToString(), inputStream); throw; } }
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; } }
public string Parse(string data, InputDataFormat inputDataFormat) { _inputDataFormat = inputDataFormat; return(Parse(data)); }