protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
 {
     var ins=baseRecorder.OnFieldMatchPublic(context, source, ref match);
     if (ins == NextInstruction.Return)
         context.FieldBuffer[context.SourceHeaderInfo["__full_text"]] = source;
     return ins;
 }
 protected override NextInstruction OnBeforeProcessRecordInput(RecorderContext context)
 {
     if (context.HeaderInfo != null) return base.OnBeforeProcessRecordInput(context);
     Exception error = null;
     var ins = GetHeaderInfo(context, ref error);
     return (ins & NextInstruction.Continue) != NextInstruction.Continue ? ins : base.OnBeforeProcessRecordInput(context);
 }
        public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
        {
            var rec = context.InputRecord as TextRecord;
            if (rec == null || rec.RecordText == null)
                return RecordInputType.Unknown;

            return RecordInputType.Record;
        }
 public TerminalRemoteFileSystemInfo(RecorderContext context, string fullName, string name)
 {
     Context = context;
     this.fullName = fullName;
     this.name = name;
     exists = new ObjectValue<int>(-1);
     directory = new ObjectValue<RecorderFileSystemInfo>();
 }
        public override NextInstruction GetHeaderInfo(RecorderContext context, ref Exception error)
        {
            var ins = base.GetHeaderInfo(context, ref error);

            if ((ins & NextInstruction.Do) == NextInstruction.Do)
            {
                context.FieldMappingIndexLookup = CreateFieldMappingIndexLookup(context.HeaderInfo, context, GetFieldMappingsFields());
            }

            return ins;
        }
 public override NextInstruction GetHeaderInfo(RecorderContext context, ref Exception error)
 {
     if (MappingInfos == null) return NextInstruction.Do;
     foreach (var mappingInfo in MappingInfos)
     {
         context.SourceHeaderInfo = MimicMappingInfo(mappingInfo.Mappings);
         context.HeaderInfo = RecordFields2Info(MappingInfos, context.SourceHeaderInfo);
         break;
     }
     return NextInstruction.Do;
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            if (!match.Success) return NextInstruction.Skip;
            var groupCollection = match.Groups;

            foreach (var key in RegSplitForValue.GetGroupNames())
            {
                int tmp;
                if (int.TryParse(key, out tmp)) continue;
                if (context.SourceHeaderInfo.ContainsKey(key))
                    context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;
            }
            return NextInstruction.Return;
        }
 public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
 {
     var ctx = context as TerminalRecorderContext;
     if (ctx == null)
     {
         error = new Exception("Context is not TerminalRecorderContext or null");
         return RecordInputType.Error;
     }
     var line = context.InputRecord.ToString();
     if (line == ctx.Keyword)
     {
         if (ctx.WaitBegin)
         {
             ctx.Keyword = "END" + ctx.Keyword.Substring(5);
             ctx.WaitBegin = false;
             return RecordInputType.Comment;
         }
         return RecordInputType.EndOfStream;
     }
     if (ctx.WaitBegin)
         return RecordInputType.Comment;
     if (line.StartsWith("0;"))
     {
         var index = line.IndexOf(';', 2);
         if (++index < line.Length)
         {
             context.InputRecord.SetValue(line.Substring(index));
             return RecordInputType.Record;
         }
         error = new Exception("Unexpected record line. No Record order after 0;");
     }
     else
     {
         var regErr = new Regex("^[0-9]+;[0-9]+;.", RegexOptions.Compiled);
         var sb = new StringBuilder();
         do
         {
             var m = regErr.Match(line);
             sb.Append(m.Success ? line.Substring(m.Length) : line);
             if (context.ReadRecord(ref error) <= 0)
                 break;
             line = context.InputRecord.ToString();
             if (line == ctx.Keyword)
                 break;
         } while (true);
         context.InputRecord.SetValue(sb.ToString());
     }
     return RecordInputType.Error;
 }
 public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
 {
     var rec = context.InputRecord as TextRecord;
     if (rec == null || rec.RecordText == null)
         return RecordInputType.Unknown;
     if (rec.RecordText.Length == 0)
         return RecordInputType.Comment;
     if (context.InputRecord.ToString().StartsWith("#"))
     {
         if (context.InputRecord.ToString().StartsWith("#Fields: "))
             return RecordInputType.Header;
         return RecordInputType.Comment;
     }
     return RecordInputType.Record;
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            if (!match.Success) return NextInstruction.Skip;
            var groupCollection = match.Groups;

            foreach (var key in RegSplitForAll.GetGroupNames())
            {
                try
                {
                    int tmp;
                    if (int.TryParse(key, out tmp)) continue;
                    int fieldBufferKey;
                    if (context.SourceHeaderInfo.TryGetValue(key, out fieldBufferKey))
                        context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;
                }
                catch (Exception exception)
                {
                    Console.Out.WriteLine(exception.Message);
                }
            }
            return NextInstruction.Return;
        }
 protected override RecorderFileSystemInfo CreateFileSystemInfo(RecorderContext context, string fullName)
 {
     return new TerminalRemoteFileSystemInfo(context, fullName, FileSystemHelper.FileNameOf(fullName, context.DirectorySeparatorChar));
 }
 protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
 {
     while (match.Success)
     {
         if (context.SourceHeaderInfo.ContainsKey(match.Groups[1].Value))
             context.FieldBuffer[context.SourceHeaderInfo[match.Groups[1].Value]] = match.Groups[2].Value;
         match = match.NextMatch();
     }
     return NextInstruction.Return;
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            if (!match.Success) return NextInstruction.Skip;
            var groupCollection = match.Groups;

            foreach (var key in RegSplitForAll.GetGroupNames())
            {
                int tmp;
                if (int.TryParse(key, out tmp)) continue;
                if (!context.SourceHeaderInfo.ContainsKey(key)) continue;
                if (groupCollection[key].Value.Length > 0)
                    context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;
            }

            match = match.NextMatch();

            while (match.Success)
            {
                if (context.SourceHeaderInfo.ContainsKey(match.Groups["x"].Value))
                    context.FieldBuffer[context.SourceHeaderInfo[match.Groups["x"].Value]] = match.Groups["y"].Value;
                match = match.NextMatch();
            }

            context.FieldBuffer[context.SourceHeaderInfo["Description"]] = source;
            return NextInstruction.Return;
        }
 protected override string GetHeaderText(RecorderContext context)
 {
     return string.Empty;
 }
 protected override string GetHeaderText(RecorderContext context)
 {
     return baseRecorder.GetHeaderTextPublic(context);
 }
 protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
 {
     try
     {
             if (!match.Success) return NextInstruction.Skip;
             var datetime = false;
             while (match.Success)
             {
                 if (!datetime) context.FieldBuffer[context.SourceHeaderInfo["Datetime"]] = match.Groups["Datetime"].Value;
                 datetime = true;
                 if (context.SourceHeaderInfo.ContainsKey(match.Groups[1].Value))
                     context.FieldBuffer[context.SourceHeaderInfo[match.Groups[1].Value]] = match.Groups[2].Value;
                 match = match.NextMatch();
             }
             context.FieldBuffer[context.SourceHeaderInfo["Description"]] = source;
         return NextInstruction.Return;
     }
     catch (Exception e)
     {
         Console.WriteLine("Error while processing veribranch record: " + e);
         return NextInstruction.Abort;
     }
 }
 protected override RecorderFileSystemInfo CreateDirectoryInfo(RecorderContext context, string absoluteName)
 {
     return new TerminalRemoteFileSystemInfo(context, absoluteName, FileSystemHelper.FileNameOf(absoluteName, context.DirectorySeparatorChar)) { Context = context as TerminalRecorderContext };
 }
 protected override NextInstruction OnBeforeSetData(RecorderContext context)
 {
     var ins = base.OnBeforeSetData(context);
     if (ins != NextInstruction.Do)
         return ins;
     if (string.IsNullOrEmpty(context.Record.ComputerName))
         context.Record.ComputerName = remoteHost;
     if (string.IsNullOrEmpty(context.Record.CustomStr10))
         context.Record.CustomStr10 = IisType;
     return NextInstruction.Do;
 }
 protected override NextInstruction OnBeforeSetData(RecorderContext context)
 {
     context.Record.Description = context.InputRecord.ToString();
     return base.OnBeforeSetData(context);
 }
 protected override string GetHeaderText(RecorderContext context)
 {
     return context.InputRecord.ToString().Substring(8);
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            var matchState = 0;
            while (match.Success)
            {
                var groupCollection = match.Groups;
                if (matchState == 0)
                {
                    foreach (var key in RegSplitForAll.GetGroupNames())
                    {
                            int tmp;
                            matchState = 1;
                            if (int.TryParse(key, out tmp)) continue;
                            int fieldBufferKey;
                            if (context.SourceHeaderInfo.TryGetValue(key, out fieldBufferKey))
                            context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;

                    }
                    match = match.NextMatch();
                }
                else
                {
                    if (context.SourceHeaderInfo.ContainsKey(match.Groups[4].Value))
                    context.FieldBuffer[context.SourceHeaderInfo[match.Groups[4].Value]] = match.Groups[5].Value;
                    match = match.NextMatch();
                }

            }

            return NextInstruction.Return;
        }
 public override NextInstruction GetHeaderInfo(RecorderContext context, ref Exception error)
 {
     return baseRecorder.GetHeaderInfo(context, ref error);
 }
 protected override NextInstruction OnBeforeSetData(RecorderContext context)
 {
     var ins = base.OnBeforeSetData(context);
     if ((ins & NextInstruction.Continue) != NextInstruction.Continue)
         return ins;
     context.OffsetInStream++;
     return NextInstruction.Do;
 }
        protected override NextInstruction OnProcessInputTextRecord(RecorderContext _context, string[] fields, ref Exception error)
        {
            var context = _context as RadiusUnifiedRecorderContext;
            var lineRecord = context.InputRecord.ToString();

            if (context.State == 0)
            {
                var matchState0 = _state0.Match(lineRecord);
                if (matchState0.Success)
                {
                    context.LastBuffer.AppendLine(lineRecord);
                    context.State = 1;
                }
            }
            else if(context.State==1)
            {
                var matchState0 = _state0.Match(lineRecord);

                if (matchState0.Success)
                {
                    context.InputRecord.SetValue(context.LastBuffer.ToString());
                    context.LastBuffer.Remove(0, context.LastBuffer.Length);
                    context.LastBuffer.AppendLine(lineRecord);
                    return NextInstruction.Do;
                }
                context.LastBuffer.AppendLine(lineRecord);
            }
            return NextInstruction.Skip;
        }
 public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
 {
     if (context.InputRecord == null || string.IsNullOrEmpty(context.InputRecord.ToString()))
         return RecordInputType.Comment;
     return RecordInputType.Record;
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            if (!match.Success) return NextInstruction.Skip;
            var groupCollection = match.Groups;

            var keys = new List<string> { "DATE_TIME", "HOST_IP", "HOST_PORT", "DEST_IP" };

            foreach (var key in keys)
            {
                if (context.SourceHeaderInfo.ContainsKey(key))
                    context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;
            }

            if (!string.IsNullOrEmpty(groupCollection["TRANSPORT_IP"].Value))
                context.FieldBuffer[context.SourceHeaderInfo["USER_IP"]] = groupCollection["TRANSPORT_IP"].Value;

            if (!string.IsNullOrEmpty(groupCollection["NETWORK_CONNECT_IP"].Value))
                context.FieldBuffer[context.SourceHeaderInfo["USER_IP"]] = groupCollection["NETWORK_CONNECT_IP"].Value;

            context.FieldBuffer[context.SourceHeaderInfo["SOURCE"]] = context.Recorder.RemoteHost;
            context.FieldBuffer[context.SourceHeaderInfo["WHOLE_ACTION"]] = match.Groups[1].Value;
            context.FieldBuffer[context.SourceHeaderInfo["DESCRIPTION"]] = source;

            return NextInstruction.Return;
        }
 public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
 {
     return context.InputRecord == null
                ? RecordInputType.Unknown
                : (context.InputRecord.ToString().Length == 0 ? RecordInputType.Comment : RecordInputType.Record);
 }
        protected override NextInstruction OnFieldMatch(RecorderContext context, string source, ref Match match)
        {
            try
            {
                if (string.IsNullOrEmpty(_lastBuffer.ToString()))
                {
                    _lastBuffer.Append(source.TrimEnd());
                    return NextInstruction.Abort;
                }

                var getDatetime = source.Split(',');
                if (getDatetime == null || getDatetime.Count() <= 0) return NextInstruction.Skip;
                DateTime date;
                var isdatetime = DateTime.TryParse(string.Format(getDatetime[0], DateFormat), out date);

                if (!string.IsNullOrEmpty(_lastBuffer.ToString()) && !isdatetime)
                {
                    _lastBuffer.Append("\n" + source.TrimEnd());
                    return NextInstruction.Abort;
                }

                if (string.IsNullOrEmpty(_lastBuffer.ToString()) || !isdatetime)
                {
                    return NextInstruction.Skip;
                }

                var regmatch = RegSplitForValue.Match(_lastBuffer.ToString());

                if (!regmatch.Success) return NextInstruction.Skip;
                var groupCollection = regmatch.Groups;

                foreach (var key in RegSplitForValue.GetGroupNames())
                {
                    int tmp;
                    if (int.TryParse(key, out tmp)) continue;
                    if (!context.SourceHeaderInfo.ContainsKey(key)) continue;
                    if (groupCollection[key].Value.Length > 0)
                        context.FieldBuffer[context.SourceHeaderInfo[key]] = groupCollection[key].Value;
                }
                context.FieldBuffer[context.SourceHeaderInfo["Description"]] = _lastBuffer.ToString();
                _lastBuffer = new StringBuilder();
                _lastBuffer.Append(source.TrimEnd());

                return NextInstruction.Return;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while processing veribranch record: " + e);
                return NextInstruction.Abort;
            }
        }
 protected override NextInstruction OnBeforeSetData(RecorderContext context)
 {
     var ins = base.OnBeforeSetData(context);
     if ((ins & NextInstruction.Continue) != NextInstruction.Continue)
         return ins;
     context.Record.ComputerName = Environment.MachineName;
     return NextInstruction.Do;
 }
 public override RecordInputType InputTextType(RecorderContext context, ref Exception error)
 {
     return baseRecorder.InputTextType(context, ref error);
 }