示例#1
0
        public ValidationResultsPackage ValidateBlocking(ProcessedDataPackage metaData)
        {
            lock (runningLock)
            {
                if (IsRunning)
                {
                    throw new Exception("Validator already running");
                }

                IsRunning = true;
                ValidationResultsPackage vr = new ValidationResultsPackage();
                ValidateData(metaData, vr);
                return(vr);
            }
        }
示例#2
0
        internal void SetResults(ProcessedDataPackage package, int index)
        {
            lastRenderTimestamp = 0;
            if (package == null)
            {
                //  Clear();
                return;
            }

            lock (setResultsLock)
            {
                this.currentResultsIndex = index;

                if (lastPackageHashNumber != package.GetHashCode())
                {
                    this.currentResults        = null;
                    this.package               = package;
                    this.lastPackageHashNumber = package.GetHashCode();

                    if (package.ContainsKey(typeof(BrokenSourceData)) != false &&
                        String.IsNullOrEmpty(((BrokenSourceData)package[typeof(BrokenSourceData)]).PageSource) == false &&
                        ((BrokenSourceData)package[typeof(BrokenSourceData)]).InjectionBreaks != null)
                    {
                        BrokenSourceData brokenSourceData = ((BrokenSourceData)package[typeof(BrokenSourceData)]);

                        SourcePiece[] sp = new SourcePiece[brokenSourceData.InjectionBreaks.Count];
                        int           i  = 0;
                        foreach (SourcePiece s in brokenSourceData.InjectionBreaks)
                        {
                            sp[i] = s;
                            i++;
                        }
                        this.currentResults = sp;
                        SetBuffer(brokenSourceData.PageSource);
                    }
                    if (package.ContainsKey(typeof(RenderData)) != false)
                    {
                        RenderData rd = (RenderData)package[typeof(RenderData)];
                        foreach (RenderedSegment rs in rd.Values)
                        {
                            lastRenderTimestamp = Math.Max(lastRenderTimestamp, rs.EndTime);
                        }
                    }
                }

                RedrawResultsNextPrev();
            }
        }
示例#3
0
        public override ValidationResults <String> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <String> results = new ValidationResults <String>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            if (data == null || data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            foreach (DownloadState ds in data)
            {
                try{
                    Uri u = new Uri(ds.URL);
                    if (results.Contains(u.Host.Trim().ToLower()) == false)
                    {
                        results.Add(u.Host);
                    }
                }
                catch
                {
                }
            }

            results.ResultsExplenation = message;

            int c = 0;

            for (int xx = 0; xx < grades.Length; xx++)
            {
                if (grades[xx] < results.Count)
                {
                    c++;
                }
                else
                {
                    break;
                }
            }
            results.Score -= c * 10;

            return(results);
        }
示例#4
0
        public void Validate(ProcessedDataPackage metaData)
        {
            lock (runningLock)
            {
                if (IsRunning)
                {
                    throw new Exception("Validator already running");
                }

                IsRunning = true;

                new Thread(delegate(){
                    this.ValidateData(metaData, null);
                }).Start();
            }
        }
示例#5
0
        public override ValidationResults <SourceValidationOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <SourceValidationOccurance> results = new ValidationResults <SourceValidationOccurance>();

            results.Score = -1;

            PageSourceData data = package.GetData <PageSourceData>();

            if (data == null || String.IsNullOrEmpty(data.PageSource))
            {
                return(results);
            }

            MatchCollection mc = style.Matches(data.PageSource);
            int             i  = 0;

            foreach (Match m in mc)
            {
                String ma = m.ToString();
                results.Add(new SourceValidationOccurance(data, m.Index, m.Length));
                i++;
            }

            if (results.Count == 0)
            {
                results.Score = 100;
            }
            else if (results.Count <= 6)
            {
                results.Score = 85;
            }
            else if (results.Count <= 10)
            {
                results.Score = 75;
            }
            else if (results.Count <= 15)
            {
                results.Score = 65;
            }
            else
            {
                results.Score = 0;
            }


            return(results);
        }
示例#6
0
        public override ValidationResults <SourceValidationOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <SourceValidationOccurance> results = new ValidationResults <SourceValidationOccurance>();

            results.Score = -1;

            PageSourceData data = package.GetData <PageSourceData>();

            if (data == null || String.IsNullOrEmpty(data.PageSource))
            {
                return(results);
            }

            String buffer = data.PageSource;

            var res = Regex.Match(buffer, "(?<=__VIEWSTATE\" value=\")(?<val>.*?)(?=\")").Groups["val"];

            if (res.Success == false)
            {
                results.Score = 100;
                return(results);
            }

            SourceValidationOccurance occurrence = new SourceValidationOccurance(data, res.Index, res.Length);

            results.Add(occurrence);

            if (res.Length > errorThreshold)
            {
                results.Score = 45;
            }
            else if (res.Length > warningThreshold)
            {
                results.Score = 65;
            }
            else if (res.Length > barelyPassedThreshold)
            {
                results.Score = 85;
            }
            else
            {
                results.Score = 100;
            }

            return(results);
        }
        public override PerformanceData GetProcessedData(ProcessedDataPackage state)
        {
            PerformanceDumpFilesInfo pdfi = new PerformanceDumpFilesInfo(state);

            PerformanceData performanceData = new PerformanceData();

            Stream s = pdfi.Open(FileAccess.Read);

            if (s == null)
            {
                return(performanceData);
            }

            StreamReader source = new StreamReader(s);

            performanceData.PerformanceDumpFilename = pdfi.GetFilename();

            String buffer = source.ReadToEnd();

            source.Close();
            source.Dispose();

            MatchCollection matchs = performance_Dump_Pattern.Matches(buffer);
            Match           match  = null;

            for (int i = 0; i < matchs.Count; i++)
            {
                match = matchs[i];

                if (match.Success)
                {
                    performanceData.AddLast(GetNewPerformanceState(
                                                state,
                                                performanceData,
                                                match.Groups[1].Value,
                                                match.Groups[2].Value,
                                                match.Groups[3].Value,
                                                match.Groups[4].Value,
                                                match.Groups[5].Value));
                }
            }
            FixAvg(performanceData);

            return(performanceData);
        }
示例#8
0
文件: Entry.cs 项目: jerkyboy/msfast
        public Entry(DownloadState ds, ProcessedDataPackage package)
        {
            this.PageRef = "page_" + package.CollectionID;

            this.StartedDateTime = Converter.EpochToDateTime(ds.ConnectionStartTime);

            this.Cache    = new Cache(ds, package);
            this.Request  = new Request(ds, package);
            this.Response = new Response(ds, package);
            this.Timings  = new Timings(ds, package);

            this.Time = this.Timings.Connect +
                        this.Timings.Blocked +
                        this.Timings.DNS +
                        this.Timings.Send +
                        this.Timings.Receive +
                        this.Timings.Wait;
        }
示例#9
0
        public override bool IsDataExists(ProcessedDataPackage state)
        {
            DownloadDumpFilesInfo ddfi = new DownloadDumpFilesInfo(state);

            if (ddfi.Exist() == false)
            {
                return(false);
            }

            try{
                FileInfo fi = new FileInfo(ddfi.GetFullPath());
                return(fi.Exists && fi.Length > 0);
            }
            catch
            {
            }
            return(false);
        }
示例#10
0
        public bool SaveProcessedDataPackage(Stream msfFilestream, ProcessedDataPackage pacakge)
        {
            GZipStream gzipStream = null;

            try
            {
                gzipStream = new GZipStream(msfFilestream, CompressionMode.Compress, true);

                return(Compress(gzipStream, pacakge));
            }
            finally
            {
                if (gzipStream != null)
                {
                    gzipStream.Close();
                    gzipStream.Dispose();
                }
            }
        }
示例#11
0
        private void SetTestRunning(bool p)
        {
            this.currentPackage = null;

            isRunning = p;
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new testRunning(this.SetTestRunning), new object[] { p });
                return;
            }

            ShowTestStatusPanel();

            this.pageGraphBtn.Enabled         = false;
            this.validationResultsBtn.Enabled = false;
            this.graphViewPanel.SetResults(null, null);
            this.validationResultsViewPanel.SetResults(null);

            this.abortCollectingDataBtn.Enabled = p;

            if (isRunning)
            {
                this.saveCollectionBtn.Enabled       = false;
                this.loadCollectionBtn.Enabled       = (this.browser == null);
                this.startCollectingDataBtn.Enabled  = false;
                this.configCollectingDataBtn.Enabled = false;
            }
            else if (browser != null && browser.State == BrowserStatus.Ready)
            {
                this.loadCollectionBtn.Enabled       = true;
                this.startCollectingDataBtn.Enabled  = true;
                this.configCollectingDataBtn.Enabled = true;
            }
            else
            {
                this.saveCollectionBtn.Enabled       = false;
                this.loadCollectionBtn.Enabled       = (this.browser == null);
                this.startCollectingDataBtn.Enabled  = false;
                this.configCollectingDataBtn.Enabled = false;
            }
        }
示例#12
0
        public override PageSourceData GetProcessedData(ProcessedDataPackage state)
        {
            SourceDumpFilesInfo sdfi = new SourceDumpFilesInfo(state);
            Stream sourceStream      = sdfi.Open(FileAccess.Read);

            PageSourceData sourceData = new PageSourceData();

            if (sourceStream == null)
            {
                return(sourceData);
            }

            StreamReader source = new StreamReader(sourceStream);

            sourceData.SourceFilename = sdfi.GetFilename();
            sourceData.PageSource     = source.ReadToEnd();
            source.Close();
            source.Dispose();

            return(sourceData);
        }
示例#13
0
        public override ValidationResults <DownloadStateOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <DownloadStateOccurance> results = new ValidationResults <DownloadStateOccurance>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            if (data == null || data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            foreach (DownloadState ds in data)
            {
                if (regex.IsMatch(ds.URL) == false)
                {
                    results.Add(new DownloadStateOccurance(ds));
                }
            }

            results.Score -= Math.Min(results.Count, 4) * 10;

            if (results.Count > 0)
            {
                if (results.Count == 1)
                {
                    results.ResultsExplenation = message_single;
                }
                else
                {
                    results.ResultsExplenation = String.Format(message_more, results.Count);
                }
            }

            return(results);
        }
示例#14
0
        public override ScreenshotsData GetProcessedData(ProcessedDataPackage state)
        {
            ScreenshotsDumpFilesInfo pdfi = new ScreenshotsDumpFilesInfo(state);

            FileInfo[] fi = pdfi.GetFiles();

            ScreenshotsData sd = new ScreenshotsData();

            if (fi == null || fi.Length == 0)
            {
                return(sd);
            }

            foreach (FileInfo f in fi)
            {
                sd.Add(new Screenshot(f.FullName));
            }

            sd.FilenameStructure = ScreenshotsDumpFilesInfo.ScreenShotsFilePattern;

            return(sd);
        }
示例#15
0
文件: Log.cs 项目: jerkyboy/msfast
        private Entry[] Get_Entries(ProcessedDataPackage package)
        {
            if (package.ContainsKey(typeof(DownloadData)) == false)
            {
                return(null);
            }

            DownloadData r = (DownloadData)package[typeof(DownloadData)];

            if (r == null)
            {
                return(null);
            }

            LinkedList <Entry> entry = new LinkedList <Entry>();

            foreach (DownloadState ds in r)
            {
                entry.AddLast(new Entry(ds, package));
            }
            return(new List <Entry>(entry).ToArray());
        }
示例#16
0
        private HARCache GenerateHAR(ProcessedDataPackage package)
        {
            HARImportExportsManager i  = new HARImportExportsManager();
            MemoryStream            ms = new MemoryStream();

            try
            {
                if (i.SaveProcessedDataPackage(ms, package))
                {
                    HARCache c = new HARCache();
                    c.HARJSONObject = String.Format(HAR_VAR, Encoding.UTF8.GetString(ms.ToArray()));
                    return(c);
                }
            }
            catch {
            }
            finally{
                ms.Close();
                ms.Dispose();
            }

            return(null);
        }
示例#17
0
        public override ValidationResults <DownloadStateOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <DownloadStateOccurance> results = new ValidationResults <DownloadStateOccurance>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            ResponseHeaderDumpFilesInfo rbdfi = new ResponseHeaderDumpFilesInfo(package);


            if (data == null ||
                data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            String       headerBuffer = null;
            StreamReader sr           = null;

            DateTime now = DateTime.Now.AddDays(2);

            Stream stream = null;

            foreach (DownloadState ds in data)
            {
                try
                {
                    stream = rbdfi.Open(FileAccess.Read, ds.FileGUID);

                    if (stream != null)
                    {
                        sr = new StreamReader(stream);

                        if (sr != null)
                        {
                            headerBuffer = sr.ReadToEnd();
                            sr.Close();
                            sr.Dispose();

                            if (regexContentType.IsMatch(headerBuffer) == false)
                            {
                                continue;
                            }

                            if (regexContentEncoding.IsMatch(headerBuffer) == false)
                            {
                                results.Add(new DownloadStateOccurance(ds));
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            results.Score -= Math.Min(results.Count, 4) * 10;

            if (results.Count > 0)
            {
                if (results.Count == 1)
                {
                    results.ResultsExplenation = message_single;
                }
                else
                {
                    results.ResultsExplenation = String.Format(message_more, results.Count);
                }
            }

            return(results);
        }
示例#18
0
        private bool Compress(Stream outstream, ProcessedDataPackage package)
        {
            if (package == null)
            {
                return(false);
            }

            ProcessedDataPackageDumpFilesInfo pdpdfi = new ProcessedDataPackageDumpFilesInfo(package);

            String collectFrom = pdpdfi.GetFolderNameAndCheckIfValid();

            if (String.IsNullOrEmpty(collectFrom) || Directory.Exists(collectFrom) == false)
            {
                return(false);
            }

            DirectoryInfo di = new DirectoryInfo(collectFrom);

            FileInfo[] compressThis = di.GetFiles();

            byte[] tmpBuffer2 = new byte[14];
            byte[] tmpBuffer3 = new byte[4096];

            int read = 0;

            Stream instream = null;

            if (WriteString(outstream, "MSFAST0001" + package.CollectionID + String.Format(DumpFileInfo.DUMP_FOLDER_PATTERN, package.CollectionID)) == false)
            {
                return(false);
            }

            foreach (FileInfo compress in compressThis)
            {
                instream = compress.Open(FileMode.Open, FileAccess.Read);

                if (WriteString(outstream, compress.Name) == false)
                {
                    return(false);
                }
                if (WriteInt(outstream, (int)compress.Length) == false)
                {
                    return(false);
                }

                while ((read = instream.Read(tmpBuffer3, 0, tmpBuffer3.Length)) != 0)
                {
                    outstream.Write(tmpBuffer3, 0, read);
                }

                instream.Close();
                instream.Dispose();

                outstream.WriteByte(0);
                outstream.WriteByte(0);
            }

            outstream.Flush();
            outstream.Close();
            outstream.Dispose();

            return(true);
        }
        public override ValidationResults <DownloadStateOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <DownloadStateOccurance> results = new ValidationResults <DownloadStateOccurance>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            ResponseHeaderDumpFilesInfo rbdfi = new ResponseHeaderDumpFilesInfo(package);

            if (data == null ||
                data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            String       headerBuffer = null;
            StreamReader sr           = null;
            Match        m            = null;

            DateTime now = DateTime.Now.AddDays(2);

            Stream stream = null;

            foreach (DownloadState ds in data)
            {
                try
                {
                    stream = rbdfi.Open(FileAccess.Read, ds.FileGUID);

                    if (stream != null)
                    {
                        sr = new StreamReader(stream);

                        if (sr != null)
                        {
                            headerBuffer = sr.ReadToEnd();
                            sr.Close();
                            sr.Dispose();

                            m = regex.Match(headerBuffer);

                            if (m.Success == false || m.Groups.Count <= 1 || String.IsNullOrEmpty(m.Groups[1].ToString()))
                            {
                                DownloadStateOccurance dso = new DownloadStateOccurance(ds);
                                dso.Comment = "(no expires)";
                                results.Add(dso);
                            }
                            else
                            {
                                try
                                {
                                    if (m.Groups[1].ToString() == "-1")
                                    {
                                        DownloadStateOccurance dso = new DownloadStateOccurance(ds);
                                        dso.Comment = "(-1)";
                                        results.Add(dso);
                                    }
                                    else
                                    {
                                        DateTime dt = DateTime.Parse(m.Groups[1].ToString());

                                        if (dt < now)
                                        {
                                            DownloadStateOccurance dso = new DownloadStateOccurance(ds);
                                            dso.Comment = String.Format("({0})", dt.Date);
                                            results.Add(dso);
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            results.Score -= Math.Min(results.Count, 4) * 10;

            if (results.Count > 0)
            {
                if (results.Count == 1)
                {
                    results.ResultsExplenation = message_single;
                }
                else
                {
                    results.ResultsExplenation = String.Format(message_more, results.Count);
                }
            }

            return(results);
        }
示例#20
0
        static void Main(string[] args)
        {
            String p = @"C:\Data\Development\MySpace\Performance\Tracker\Reports.Performance\bin\Debug\";
            ProcessedDataPackage package1 = null;

            try
            {
                package1 = ProcessedDataCollector.CollectAll(p, 53595);
            }
            catch (DirectoryNotFoundException)
            {
                System.Console.Error.Write("Invalid input folder!");
                return;
            }



            return;



            CommandLineArguments cla = new CommandLineArguments(args);

            if (cla.IsValid() == false)
            {
                CommandLineArguments.PrintUsage(System.Console.Error);
                return;
            }

            String outfolder = Directory.GetCurrentDirectory().ToString().Replace("\\", "/");
            String confolder = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Program)).Location) + "\\conf\\";

            if (String.IsNullOrEmpty(confolder) ||
                String.IsNullOrEmpty(outfolder) ||
                Directory.Exists(confolder) == false ||
                Directory.Exists(outfolder) == false ||
                File.Exists(confolder + "DefaultPageValidation.xml") == false)
            {
                System.Console.Error.Write("Invalid Configuration!");
                return;
            }

            ProcessedDataPackage package = null;

            try
            {
                package = ProcessedDataCollector.CollectAll(cla.Path, cla.CollectionId);
            }
            catch (DirectoryNotFoundException)
            {
                System.Console.Error.Write("Invalid input folder!");
                return;
            }

            if (package == null || package.Count == 0)
            {
                System.Console.Error.Write("Error while processing data!");
                return;
            }

            ValidationRunner vr = new ValidationRunner();

            vr.LoadFromFile(confolder + "DefaultPageValidation.xml");

            ValidationResultsPackage rsults = vr.ValidateBlocking(package);


            if (rsults == null || rsults.Count == 0)
            {
                System.Console.Error.Write("Error while validating results!");
                return;
            }

            if ("xml".Equals(cla.SaveType))
            {
                SavePackage(new XMLImportExportManager(), package, outfolder);
            }
            else if ("msf".Equals(cla.SaveType))
            {
                SavePackage(new MSFImportExportsManager(), package, outfolder);
            }
            else if ("har".Equals(cla.SaveType))
            {
                SavePackage(new HARImportExportsManager(), package, outfolder);
            }

            SaveValidation(rsults, outfolder);
        }
示例#21
0
        private void ShowOutcome(String graphResults, ValidationResultsPackage validationResults, ProcessedDataPackage package)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new showOutcome(this.ShowOutcome), new object[] { graphResults, validationResults, package });
                return;
            }

            this.currentPackage = package;

            if (String.IsNullOrEmpty(graphResults) == false)
            {
                this.saveCollectionBtn.Enabled = true;
                ShowGraphPanel();
            }
            else if (validationResults != null && validationResults.Count > 0)
            {
                this.saveCollectionBtn.Enabled = true;
                ShowValidationResultsPanel();
            }
            else
            {
                MessageBox.Show("No results found!");
            }

            this.pageGraphBtn.Enabled         = String.IsNullOrEmpty(graphResults) == false;
            this.validationResultsBtn.Enabled = (validationResults != null && validationResults.Count > 0);

            this.graphViewPanel.SetResults(graphResults, package);
            this.validationResultsViewPanel.SetResults(validationResults);
        }
示例#22
0
        public override ValidationResults <DownloadStateOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <DownloadStateOccurance> results = new ValidationResults <DownloadStateOccurance>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            ResponseBodyDumpFilesInfo rbdfi = new ResponseBodyDumpFilesInfo(package);

            if (data == null ||
                data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            String          bodyBuffer = null;
            StreamReader    sr         = null;
            MatchCollection m          = null;

            int count = 0;

            Stream stream = null;


            foreach (DownloadState ds in data)
            {
                if (ds.URLType != URLType.CSS)
                {
                    continue;
                }

                try
                {
                    stream = rbdfi.Open(FileAccess.Read, ds.FileGUID);

                    if (stream != null)
                    {
                        sr = new StreamReader(stream);

                        if (sr != null)
                        {
                            bodyBuffer = sr.ReadToEnd();
                            sr.Close();
                            sr.Dispose();

                            m = regex.Matches(bodyBuffer);

                            if (m.Count > 0)
                            {
                                count += m.Count;
                                results.Add(new DownloadStateOccurance(ds));
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            results.ResultsExplenation = String.Format(message, count);

            int c = 0;

            for (int xx = 0; xx < grades.Length; xx++)
            {
                if (grades[xx] < count)
                {
                    c++;
                }
                else
                {
                    break;
                }
            }
            results.Score -= c * 10;

            return(results);
        }
示例#23
0
 public JavascriptOutputReader(ProcessedDataPackage package)
 {
     this.package = package;
 }
示例#24
0
        public override ValidationResults <DownloadStateOccurance> ValidateData(ProcessedDataPackage package)
        {
            ValidationResults <DownloadStateOccurance> results = new ValidationResults <DownloadStateOccurance>();

            results.Score = -1;

            DownloadData data = package.GetData <DownloadData>();

            if (data == null || data.Count == 0)
            {
                return(results);
            }

            results.Score = 100;

            List <DownloadState> list = GetAllDownloadsFor(URLType.JS, data);

            String expl = "";

            if (list.Count > 0)
            {
                foreach (DownloadState ds in list)
                {
                    DownloadStateOccurance downloadDataValidatorOccurance = new DownloadStateOccurance(ds);
                    results.Add(downloadDataValidatorOccurance);
                }
                expl += String.Format(js_message, list.Count);

                int m = 0;

                for (int i = 0; i < js_grades.Length; i++)
                {
                    if (js_grades[i] < list.Count)
                    {
                        m++;
                    }
                    else
                    {
                        break;
                    }
                }
                results.Score -= m * 10;
            }



            list = GetAllDownloadsFor(URLType.CSS, data);

            if (list.Count > 0)
            {
                foreach (DownloadState ds in list)
                {
                    DownloadStateOccurance downloadDataValidatorOccurance = new DownloadStateOccurance(ds);
                    results.Add(downloadDataValidatorOccurance);
                }

                expl += String.Format(css_message, list.Count);

                int m = 0;

                for (int i = 0; i < css_grades.Length; i++)
                {
                    if (css_grades[i] < list.Count)
                    {
                        m++;
                    }
                    else
                    {
                        break;
                    }
                }
                results.Score -= m * 10;
            }



            results.ResultsExplenation = expl;

            return(results);
        }
示例#25
0
文件: Trace.cs 项目: jerkyboy/msfast
 public Trace(ProcessedDataPackage pacakge)
 {
     Log = new Log(pacakge);
 }
示例#26
0
 public Cache(DownloadState ds, ProcessedDataPackage package)
 {
 }
示例#27
0
 public IValidationResults Validate(ProcessedDataPackage package)
 {
     return(this.ValidateData(package));
 }
示例#28
0
        private void ProcessResults(ProcessedDataPackage package)
        {
            IConfigGetter getter = ConfigProvider.Instance.GetConfigGetter("MSFast.Global");

            if (getter == null)
            {
                SetTestRunning(false);
                SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
            }

            #region Collected Data

            String graphResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_GRAPH))
            {
                if (package.ContainsKey(typeof(DownloadData)) != false ||
                    package.ContainsKey(typeof(RenderData)) != false ||
                    package.ContainsKey(typeof(PerformanceData)) != false)
                {
                    SerializedResultsFilesInfo srfi = new SerializedResultsFilesInfo(package);

                    if (String.IsNullOrEmpty(srfi.GetFolderNameAndCheckIfValid()))
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.InvalidConfiguration, -1);
                        return;
                    }

                    package.ThumbnailsRoot = "file://" + srfi.GetFolderNameAndCheckIfValid();

                    XmlDocument x = package.Serialize();

                    if (x == null)
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }

                    try
                    {
                        x.Save(srfi.GetFullPath());
                        graphResults = srfi.GetFullPath();
                    }
                    catch
                    {
                        SetTestRunning(false);
                        SetTestStatus(TestEventType.TestEnded, false, PageDataCollectorErrors.Unknown, -1);
                        return;
                    }
                }
            }
            #endregion

            #region Validation

            ValidationResultsPackage validationResults = null;

            if (getter.GetBoolean(MSFastGlobalConfigKeys.PAGE_VALIDATION))
            {
                if (validationRunner == null)
                {
                    CreateValidationRunner();
                }

                if (validationRunner != null)
                {
                    validationResults = validationRunner.ValidateBlocking(package);
                }
            }

            #endregion

            SetTestRunning(false);
            SetTestStatus(TestEventType.TestEnded, true);

            ShowOutcome(graphResults, validationResults, package);
        }
示例#29
0
        public override DownloadData GetProcessedData(ProcessedDataPackage state)
        {
            DownloadDumpFilesInfo ddfi = new DownloadDumpFilesInfo(state);

            Stream file = ddfi.Open(FileAccess.Read);

            DownloadData processedData = new DownloadData();

            if (file == null)
            {
                return(processedData);
            }

            StreamReader source = new StreamReader(file);
            String       buffer = source.ReadToEnd();

            source.Close();
            source.Dispose();

            if (buffer == null)
            {
                return(null);
            }

            processedData.DownloadDataDumpFilename = ddfi.GetFilename();

            DownloadState downloadState = null;


            MatchCollection matchs = null;

            matchs = download_Dump_Pattern.Matches(buffer);

            Match   match = null;
            URLType type  = URLType.Unknown;

            processedData.TotalFiles = matchs.Count;

            for (int i = 0; i < matchs.Count; i++)
            {
                match = matchs[i];

                try
                {
                    downloadState                            = new DownloadState();
                    downloadState.FileGUID                   = match.Groups[1].ToString();
                    downloadState.ConnectionStartTime        = Math.Max(-1, long.Parse(match.Groups[2].ToString()));
                    downloadState.SendingRequestStartTime    = Math.Max(-1, long.Parse(match.Groups[3].ToString()));
                    downloadState.SendingRequestEndTime      = Math.Max(-1, long.Parse(match.Groups[4].ToString()));
                    downloadState.ReceivingResponseStartTime = Math.Max(-1, long.Parse(match.Groups[5].ToString()));
                    downloadState.ReceivingResponseEndTime   = Math.Max(-1, long.Parse(match.Groups[6].ToString()));
                    downloadState.ConnectionEndTime          = Math.Max(-1, long.Parse(match.Groups[7].ToString()));
                    downloadState.TotalSent                  = Math.Max(-1, int.Parse(match.Groups[8].ToString()));
                    downloadState.TotalReceived              = Math.Max(-1, int.Parse(match.Groups[9].ToString()));

                    processedData.TotalDataReceived += downloadState.TotalReceived;
                    processedData.TotalDataSent     += downloadState.TotalSent;

                    if (state != null)
                    {
                        if (downloadState.ConnectionStartTime > 0)
                        {
                            state.CollectionStartTime = Math.Min(state.CollectionStartTime, downloadState.ConnectionStartTime);
                        }
                        state.CollectionEndTime = Math.Max(state.CollectionEndTime, downloadState.ConnectionEndTime);
                    }

                    downloadState.URL = match.Groups[10].ToString();

                    processedData.AddLast(downloadState);

                    type = GetURLType(downloadState.URL);

                    downloadState.URLType = type;

                    if (type == URLType.CSS)
                    {
                        processedData.TotalCSS++;
                        processedData.TotalCSSWeight += downloadState.TotalReceived;
                    }
                    else if (type == URLType.Image)
                    {
                        processedData.TotalImages++;
                        processedData.TotalImagesWeight += downloadState.TotalReceived;
                    }
                    else if (type == URLType.JS)
                    {
                        processedData.TotalJS++;
                        processedData.TotalJSWeight += downloadState.TotalReceived;
                    }
                }
                catch
                {
                }
            }

            return(processedData);
        }
示例#30
0
 public abstract T ValidateData(ProcessedDataPackage package);