예제 #1
0
        public void ProjectWarning(AnalyseFile file, string refProject, string project, string toolNo)
        {
            file.warning.toolNo  = toolNo;
            file.warning.element = "project";
            file.warning.value1  = refProject;

            file.warning.value2 = project;
            file.warning.text   = "PROJECT mismatch";
        }
예제 #2
0
        public void MimeWarning(AnalyseFile file, bool inFile, string mime, string toolNo)
        {
            file.warning.toolNo = toolNo;

            if (inFile)
            {
                file.warning.element = "inFile";
                file.warning.value1  = file.inFile.mime;
            }
            file.warning.value2 = mime;
            file.warning.text   = "MIME mismatch";
        }
예제 #3
0
        public void ReadVeraPdf(string fileName, string outRootFolder, string inRootFolder)
        {
            Globals.toolCounter++;
            Console.WriteLine(Globals.toolCounter);
            AnalyseTool veraTool = new AnalyseTool();

            veraTool.buildInformation = new List <AnalyseTool.VeraRelease>();

            veraTool.batchSummary = new AnalyseTool.VeraSummary();
            veraTool.files        = new AnalyseTool.DcmFiles();
            veraTool.toolNo       = Globals.toolCounter.ToString();
            veraTool.toolId       = "103";
            veraTool.name         = "veraPDF";
            veraTool.version      = "";

            Console.WriteLine("Tool created");

            XPathNavigator    nav;
            XPathDocument     xDoc;
            XPathNodeIterator nodeIter;

            xDoc = new XPathDocument(fileName);

            nav = xDoc.CreateNavigator();

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable);

            nsmgr.AddNamespace("s", "");

            veraTool.version = nav.SelectSingleNode("//report/buildInformation/releaseDetails[@id='gui']/@version").ToString();

            nodeIter = nav.Select("//report/buildInformation/releaseDetails ", nsmgr);

            Console.WriteLine("Biuldinfomations: " + nodeIter.Count);

            while (nodeIter.MoveNext())
            {
                AnalyseTool.VeraRelease detail = new AnalyseTool.VeraRelease();
                detail.id        = nodeIter.Current.GetAttribute("id", nsmgr.DefaultNamespace);
                detail.version   = nodeIter.Current.GetAttribute("version", nsmgr.DefaultNamespace);
                detail.buildDate = nodeIter.Current.GetAttribute("buildDate", nsmgr.DefaultNamespace);

                veraTool.buildInformation.Add(detail);
            }

            AnalyseTool.VeraSummary summary = new AnalyseTool.VeraSummary();
            summary.totalJobs     = nav.SelectSingleNode("//report/batchSummary/@totalJobs").ToString();
            summary.failedToParse = nav.SelectSingleNode("//report/batchSummary/@failedToParse").ToString();
            summary.encrypted     = nav.SelectSingleNode("//report/batchSummary/@encrypted").ToString();

            Console.WriteLine("Val report");
            summary.validationReports              = new AnalyseTool.VeraSummary.VeraValReport();
            summary.validationReports.compliant    = nav.SelectSingleNode("//report/batchSummary/validationReports/@compliant").ToString();
            summary.validationReports.nonCompliant = nav.SelectSingleNode("//report/batchSummary/validationReports/@nonCompliant").ToString();
            summary.validationReports.failedJobs   = nav.SelectSingleNode("//report/batchSummary/validationReports/@failedJobs").ToString();
            summary.validationReports.total        = nav.SelectSingleNode("//report/batchSummary/validationReports").Value;

            Console.WriteLine("feature report");
            summary.featureReports            = new AnalyseTool.VeraSummary.FeatureReports();
            summary.featureReports.failedJobs = nav.SelectSingleNode("//report/batchSummary/featureReports/@failedJobs").ToString();
            summary.featureReports.total      = nav.SelectSingleNode("//report/batchSummary/featureReports").Value;

            Console.WriteLine("repair report");
            summary.repairReports            = new AnalyseTool.VeraSummary.ReparirReports();
            summary.repairReports.failedJobs = nav.SelectSingleNode("//report/batchSummary/repairReports/@failedJobs").ToString();
            summary.repairReports.total      = nav.SelectSingleNode("//report/batchSummary/repairReports").Value;

            summary.duration        = new AnalyseTool.VeraSummary.VeraDuration();
            summary.duration.start  = nav.SelectSingleNode("//report/batchSummary/duration/@start").ToString();
            summary.duration.finish = nav.SelectSingleNode("//report/batchSummary/duration/@finish").ToString();
            summary.duration.total  = nav.SelectSingleNode("//report/batchSummary/duration").Value;

            veraTool.batchSummary = summary;

            veraTool.outputPath = outRootFolder;

            Globals.extractionAnalyse.tools.Add(veraTool);
            Console.WriteLine("Tool added");


            nodeIter = nav.Select("//report/jobs/job", nsmgr);

            Console.WriteLine("File count: " + nodeIter.Count);

            XPathExpression getProfileName = nav.Compile("descendant::validationReport/profileName");

            int fileCount = 0;

            while (nodeIter.MoveNext())
            {
                string name = nodeIter.Current.SelectSingleNode("descendant::item/name").Value;
                Console.WriteLine("Filename: " + name);
                string fileId = LogReader.GetFileId(name, outRootFolder);
                Console.WriteLine("ID: " + fileId);

                AnalyseFile veraFile = LogReader.GetFile(fileId);

                if (String.IsNullOrEmpty(veraFile.id))
                {
                    newFile     = true;
                    veraFile.id = fileId;
                    Console.WriteLine("New file");
                }

                veraFile.valid = new AnalyseFile.Valid();

                veraFile.valid.toolId = veraTool.toolId;
                string isCompliant = nodeIter.Current.SelectSingleNode("descendant::validationReport/@isCompliant").Value;
                veraFile.valid.isValid = isCompliant;
                Console.WriteLine("Is compliant: " + isCompliant);

                veraFile.valid.passedRules  = nodeIter.Current.SelectSingleNode("descendant::validationReport/details/@passedRules").Value;
                veraFile.valid.failedRules  = nodeIter.Current.SelectSingleNode("descendant::validationReport/details/@failedRules").Value;
                veraFile.valid.passedChecks = nodeIter.Current.SelectSingleNode("descendant::validationReport/details/@passedChecks").Value;
                veraFile.valid.failedChecks = nodeIter.Current.SelectSingleNode("descendant::validationReport/details/@failedChecks").Value;

                string profName = nodeIter.Current.SelectSingleNode("descendant::validationReport/@profileName").Value;
                Console.WriteLine("profileName: " + profName);

                string profile  = profName.Split(' ')[0];
                string pdfAtype = "";
                if (profile.Contains("PDF"))
                {
                    veraFile.valid.type = profile.Split('-')[0];
                    pdfAtype            = profile.Split('-')[1];
                }

                Console.WriteLine("isCompliant: " + isCompliant);

                if (newFile)
                {
                    Globals.extractionAnalyse.files.Add(veraFile);
                }
                fileCount++;
                OnProgressUpdate?.Invoke(fileCount);
            }
        }
예제 #4
0
        public void ReadDroidFiles(string fileName, bool inFiles, string inRootFolder, string outRootFolder, bool incTableXml)
        {
            string isIn = "in";

            if (!inFiles)
            {
                isIn = "out";
            }

            Globals.toolCounter++;
            Console.WriteLine(Globals.toolCounter);
            AnalyseTool droidTool = new AnalyseTool
            {
                toolNo  = Globals.toolCounter.ToString(),
                toolId  = "102",
                name    = "Droid",
                version = "6.4",
                role    = "filetype",
                subrole = isIn
            };

            Console.WriteLine("Tool created");

            using (var reader = new StreamReader(fileName))
            {
                // Read all lines in file one at the time
                int fileCount = 0;

                string line = reader.ReadLine();
                while ((line = reader.ReadLine()) != null)
                {
                    string[] split = line.Split(',');

                    if (!split[8].Contains("File"))
                    {
                        Console.WriteLine(split[8].ToString());
                        continue;
                    }

                    //File droidFile = new File();
                    string filePath = split[3].Trim('"');

                    if (String.IsNullOrEmpty(filePath))
                    {
                        continue;
                    }

                    string fileId;
                    if (inFiles)
                    {
                        fileId = GetFileId(filePath, inRootFolder);
                    }
                    else
                    {
                        fileId = GetFileId(filePath, outRootFolder);
                    }

                    string readFileName = split[16].Trim('"');
                    if (!incTableXml && readFileName.Contains("table") && (readFileName.Contains(".xml") || readFileName.Contains(".xsd")))
                    {
                        continue;
                    }

                    AnalyseFile droidFile = GetFile(fileId);
                    fileCount++;

                    if (String.IsNullOrEmpty(droidFile.id))
                    {
                        newFile      = true;
                        droidFile.id = fileId;
                    }

                    if (inFiles)
                    {
                        droidFile.inFile.ext  = split[9].Trim('"');
                        droidFile.inFile.puid = split[14].Trim('"');

                        string readMime = split[15].Trim('"');
                        string fileMime = droidFile.inFile.mime;

                        if (String.IsNullOrEmpty(fileMime))
                        {
                            droidFile.inFile.mime = readMime;
                        }
                        else if (fileMime != readMime)
                        {
                            MimeWarning(droidFile, true, readMime, droidTool.toolNo);
                        }

                        droidFile.inFile.name    = readFileName;
                        droidFile.inFile.version = split[17].Trim('"');
                    }
                    else
                    {
                        droidFile.outFile.ext  = split[9].Trim('"');
                        droidFile.outFile.puid = split[14].Trim('"');

                        string readMime = split[15].Trim('"');
                        string fileMime = droidFile.outFile.mime;

                        if (String.IsNullOrEmpty(fileMime))
                        {
                            droidFile.outFile.mime = readMime;
                        }
                        else if (fileMime != readMime)
                        {
                            MimeWarning(droidFile, false, readMime, droidTool.toolNo);
                        }

                        droidFile.outFile.name    = readFileName;
                        droidFile.outFile.version = split[17].Trim('"');
                    }
                    OnProgressUpdate?.Invoke(fileCount);
                    if (newFile)
                    {
                        Globals.extractionAnalyse.files.Add(droidFile);
                    }
                }
            }
            Globals.extractionAnalyse.tools.Add(droidTool);
            Console.WriteLine("Tool added");
        }
예제 #5
0
        // Reading Decom Blob report and assigning values to objects
        public void ReadDcmBlbRpt(string fileName, string inRootFolder, string outRootFolder)
        {
            Globals.toolCounter++;
            Console.WriteLine(Globals.toolCounter);
            AnalyseTool dcmTool = new AnalyseTool();

            dcmTool.dcmTool = new AnalyseTool.DcmTool();
            dcmTool.files   = new AnalyseTool.DcmFiles();
            dcmTool.toolNo  = Globals.toolCounter.ToString();
            dcmTool.name    = "Decom";
            dcmTool.version = "1.3.0";

            Console.WriteLine("Tool created");

            string line;

            using (StreamReader reader = new StreamReader(fileName))
            {
                Console.WriteLine("Start read");
                int lineCount = 0;
                int fileCount = 0;
                // Read all lines in file one at the time
                while ((line = reader.ReadLine()) != null)
                {
                    // Skip empty lines
                    if (!string.IsNullOrEmpty(line))
                    {
                        if (lineCount == 0)
                        {
                            string[] splitter = { "was" };
                            dcmTool.dcmTool.name = line.Split(splitter, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim().TrimEnd('.');
                            lineCount++;
                            continue;
                        }

                        if (lineCount == 1)
                        {
                            string[] splitter = { "name" };
                            dcmTool.project = line.Split(splitter, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim().TrimEnd('.');
                            lineCount++;
                            continue;
                        }

                        if (line.Contains("IN_PROGRESS:"))
                        {
                            dcmTool.files.inProgress = line.Split(':')[1].Trim();
                            continue;
                        }
                        else if (line.Contains("FAILED:"))
                        {
                            dcmTool.files.failed = line.Split(':')[1].Trim();
                            continue;
                        }
                        else if (line.Contains("SUCCESSFUL:"))
                        {
                            dcmTool.files.success = line.Split(':')[1].Trim();
                            continue;
                        }
                        else if (line.Contains("IDLE:"))
                        {
                            dcmTool.files.idle = line.Split(':')[1].Trim();
                            continue;
                        }
                        else if (line.Contains("NOT_CONVERTED:"))
                        {
                            dcmTool.files.notConverted = line.Split(':')[1].Trim();
                            continue;
                        }

                        string[] firstSplit = line.Split(',');
                        string[] inputSplit = { "input file:", "input file content type:", "conversion output file:", "conversion status:", "conversion end date:" };

                        string inputPath = firstSplit[1].Split(inputSplit, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                        Console.WriteLine("input path: " + inputPath);
                        Console.WriteLine("In root folder: " + inRootFolder);

                        string      fileId = GetFileId(inputPath, inRootFolder);
                        AnalyseFile file   = GetFile(fileId);
                        Console.WriteLine("File created");
                        fileCount++;

                        string[] timeSplit = { "time:", "date:" };
                        string   startTime = firstSplit[0].Split(timeSplit, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                        Console.WriteLine("Start time: " + startTime);

                        file.start = TimeConv(startTime);

                        file.inFile.path = inputPath;
                        if (String.IsNullOrEmpty(file.id))
                        {
                            newFile = true;
                            file.id = fileId;
                        }
                        string readMime = firstSplit[2].Split(inputSplit, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                        string fileMime = file.inFile.mime;

                        if (String.IsNullOrEmpty(fileMime))
                        {
                            file.inFile.mime = readMime;
                        }
                        else if (fileMime != readMime)
                        {
                            MimeWarning(file, true, readMime, dcmTool.toolNo);
                        }

                        string[] outSplit = { "file:" };
                        if (String.IsNullOrEmpty(file.outFile.path))
                        {
                            file.outFile.path = firstSplit[3].Split(inputSplit, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                        }

                        if (String.IsNullOrEmpty(file.result.result))
                        {
                            file.result.result = firstSplit[4].Split(':')[1].Trim();
                        }

                        if (file.result.toolNo == 0)
                        {
                            file.result.toolNo = Globals.toolCounter;
                        }

                        string endDate = firstSplit[5].Split(timeSplit, 2, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
                        Console.WriteLine("End time: " + endDate);

                        if (String.IsNullOrEmpty(file.end))
                        {
                            file.end = TimeConv(endDate);
                        }

                        if (newFile)
                        {
                            Globals.extractionAnalyse.files.Add(file);
                        }
                        //Console.WriteLine("File added");

                        lineCount++;
                        OnProgressUpdate?.Invoke(fileCount);
                    }
                    lineCount++;
                    OnProgressUpdate?.Invoke(fileCount);
                }
            }

            dcmTool.files.files = Int32.Parse(dcmTool.files.inProgress) + Int32.Parse(dcmTool.files.failed) + Int32.Parse(dcmTool.files.success) +
                                  Int32.Parse(dcmTool.files.idle) + Int32.Parse(dcmTool.files.notConverted);
            Console.WriteLine("dcmFiles: " + dcmTool.files.files);

            dcmTool.inputPath.Add(inRootFolder);
            dcmTool.outputPath = outRootFolder;

            Globals.extractionAnalyse.tools.Add(dcmTool);
            Console.WriteLine("Tool added");
        }