/// <summary>
        /// Create new project
        /// </summary>
        /// <param name="fileName">Log file name</param>
        /// <param name="logStream">Log file stream</param>
        /// <param name="projectName">Project name</param>
        /// <param name="patternDef">Analyzing pattern</param>
        /// <param name="enc">Log file encoding</param>
        /// <returns>Created project</returns>
        public FlatProject CreateProject(string fileName, Stream logStream, string projectName, PatternDefinition patternDef, Encoding enc)
        {
            log.In(logStream, projectName, patternDef);

            if (patternDef == null)
            {
                patternDef = PatternDefinition.CreateDefault();
            }

            currentProject                   = new FlatProject();
            currentProject.ProjectName       = projectName;
            currentProject.PatternDefinition = patternDef;

            string tempDir = CreateTempDirectory();

            currentProject.WorkingDirectory = tempDir;

            string logFileName = CreateDatabaseFilePath(currentProject);

            using (IntermediateLogWriter imLogWriter = new IntermediateLogWriter(logFileName, patternDef))
            {
                imLogWriter.Write(fileName, logStream, enc);
            }

            reader = new IntermediateLogReader(logFileName, currentProject.PatternDefinition);

            log.Out(currentProject);
            return(currentProject);
        }
Example #2
0
 public FlatProject()
 {
     PatternDefinition       = new PatternDefinition();
     RangeCriteria           = new SearchCriteria();
     ColumnsSearchCriteria   = new SearchCriteria();
     HighlightDefinitionList = new HighlightDefinitionList();
 }
Example #3
0
        /// <summary>
        /// Create new pattern definition and generate UUID to Pattern ID field.
        /// </summary>
        /// <returns>New pattern definition</returns>
        public static PatternDefinition CreateNew()
        {
            PatternDefinition pattern = CreateDefault();

            pattern.ID = Guid.NewGuid().ToString();

            return(pattern);
        }
        /// <summary>
        /// Create new project
        /// </summary>
        /// <param name="logFileName">Log file name</param>
        /// <param name="projectName">Project name</param>
        /// <param name="patternDef">Analyzing pattern</param>
        /// <param name="enc">Log file encoding</param>
        /// <returns>Created project</returns>
        public FlatProject CreateProject(String logFileName, string projectName, PatternDefinition patternDef, Encoding enc)
        {
            log.In(logFileName, projectName, patternDef);

            using (FileStream readStream = new FileStream(logFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)){
                FlatProject ret = CreateProject(logFileName, readStream, projectName, patternDef, enc);
                log.Out(ret);
                return(ret);
            }
        }
        /// <summary>
        /// Import log file to database
        /// </summary>
        /// <param name="fileName">Log file name</param>
        /// <param name="logStream">Log file stream</param>
        /// <param name="enc">Log file encoding</param>
        public void ImportLog(string fileName, Stream logStream, Encoding enc)
        {
            log.In(fileName, logStream, enc);

            PatternDefinition patternDef  = currentProject.PatternDefinition;
            string            logFileName = CreateDatabaseFilePath(currentProject);

            using (IntermediateLogWriter imLogWriter = new IntermediateLogWriter(logFileName, patternDef))
            {
                imLogWriter.Write(fileName, logStream, enc);
            }

            log.Out();
        }
Example #6
0
        /// <summary>
        /// Deep copy source pattern definition
        /// </summary>
        /// <param name="source">Copy source</param>
        /// <returns>Deep copied instance</returns>
        public static PatternDefinition Copy(PatternDefinition source)
        {
            PatternDefinition dest = new PatternDefinition();

            dest.ID                = Guid.NewGuid().ToString();
            dest.PatternName       = source.PatternName + " copy";
            dest.RegularExpression = source.RegularExpression;

            foreach (ColumnDefinition col in source.ColumnDefinitionList)
            {
                dest.ColumnDefinitionList.Add(ColumnDefinition.Copy(col));
            }

            return(dest);
        }
Example #7
0
        /// <summary>
        /// Create default pattern deinition.
        /// </summary>
        /// <returns>New default pattern definition</returns>
        public static PatternDefinition CreateDefault()
        {
            PatternDefinition patternDef = new PatternDefinition();

            patternDef.ID                = "default";
            patternDef.PatternName       = "New";
            patternDef.RegularExpression = "(.*)";

            ColumnDefinition colDef = new ColumnDefinition();

            colDef.Order           = 0;
            colDef.Hashable        = false;
            colDef.IsDateTimeField = false;
            colDef.ColumnName      = "Message";

            patternDef.ColumnDefinitionList.Add(colDef);

            return(patternDef);
        }