Exemple #1
0
        private void addLogsCollectionFileMenuItem_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog {
                Filter      = "All files (*.*)|*.*|Log definition files (*.xml)|*.xml",
                FilterIndex = 2
            };
            var result = openFileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try {
                    var serializer = new XmlSerializer(typeof(LogSourceDefinition));
                    using (var fileStream = new FileStream(openFileDialog.FileName, FileMode.Open)) {
                        LogSourceDefinition logDefinition = null;
                        logDefinition = (LogSourceDefinition)serializer.Deserialize(fileStream);
                        _logSourceListController.AddLogSourceDefinition(logDefinition);
                        displayStartAnalysisPrompt();
                    }
                }
                catch (Exception exc) {
                    MessageBox.Show($"File {openFileDialog.FileName} is not a valid log source definition file. {exc.Message}.",
                                    "Invalid log source definition file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
Exemple #2
0
        public AnalysisResultsForm(AnalysisArgs analysisArgs, LogSourceDefinition logSources, string renderersConfigFile)
        {
            InitializeComponent();

            _logSourceListController = new LogSourceTreeViewController <TreeView>(logFilesList);

            AnalysisArgs = analysisArgs;
            LogSources   = logSources;

            Analyzers      = buildAnalyzers(analysisArgs);
            AnalyzerChains = buildAnalyzerChains(analysisArgs);

            populateLists();
            formCaptionTextbox.Text = this.Text;
            FormState = FormStateEnum.Ready;

            var renderersBuilder = new RenderersBuilder(renderersConfigFile);
            var renderers        = renderersBuilder.BuildRenderers();

            foreach (var r in renderers)
            {
                _rendererList.Add(r.AnalyzerType, r);
            }

            runAnalysisThread();
        }
Exemple #3
0
        private LogSourceDefinition buildLogSourceDefinition(bool selectedOnly)
        {
            var logSourceDefinition = new LogSourceDefinition();

            foreach (TreeNode node in ListView.Nodes)
            {
                if (selectedOnly && !node.Checked)
                {
                    continue;
                }

                if (isFileNode(node))
                {
                    logSourceDefinition.SourceFiles.Add(node.Text);
                }
                else if (isFolderNode(node))
                {
                    logSourceDefinition.SourceFolders.Add(node.Text);
                    foreach (TreeNode fileNode in node.Nodes)
                    {
                        if (selectedOnly && !fileNode.Checked)
                        {
                            continue;
                        }

                        logSourceDefinition.SourceFiles.Add(fileNode.Text);
                    }
                }
            }
            return(logSourceDefinition);
        }
Exemple #4
0
        private void serializeLogSourceDefinition(LogSourceDefinition logSourceDefinition, string filename)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(LogSourceDefinition));
            StreamWriter  writer     = new StreamWriter(filename);

            serializer.Serialize(writer, logSourceDefinition);
            writer.Close();
        }
Exemple #5
0
        private void createLogDefinitionFile(Func <LogSourceDefinition> buildLogSourceDefinitionFunc)
        {
            var openFileDialog = new OpenFileDialog {
                CheckFileExists = false,
                FileName        = "New Log Definition.xml"
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                LogSourceDefinition logSourceDefinition = buildLogSourceDefinitionFunc();
                serializeLogSourceDefinition(logSourceDefinition, openFileDialog.FileName);
            }
        }
Exemple #6
0
        //[TestMethod]
        public void itShouldSerialize()
        {
            var logSourceDef = new LogSourceDefinition();

            logSourceDef.SourceFiles.Add(@"c:\file1.log");
            logSourceDef.SourceFiles.Add(@"c:\file2.log");

            logSourceDef.SourceFolders.Add(@"c:\folder1");
            logSourceDef.SourceFolders.Add(@"c:\folder2");

            // Insert code to set properties and fields of the object.
            XmlSerializer mySerializer = new
                                         XmlSerializer(typeof(LogSourceDefinition));
            // To write to a file, create a StreamWriter object.
            StreamWriter myWriter = new StreamWriter("myFileName.xml");

            mySerializer.Serialize(myWriter, logSourceDef);
            myWriter.Close();
        }
Exemple #7
0
 internal override void AddLogSourceDefinition(LogSourceDefinition logSourceDefinition)
 {
     logSourceDefinition.SourceFiles.ForEach(f => AddFile(f));
     logSourceDefinition.SourceFolders.ForEach(f => AddFolder(f, true));
 }
Exemple #8
0
 internal abstract void AddLogSourceDefinition(LogSourceDefinition logDefinition);