当前位置: 首页>>代码示例>>C#>>正文


C# Report.WriteReport方法代码示例

本文整理汇总了C#中Report.WriteReport方法的典型用法代码示例。如果您正苦于以下问题:C# Report.WriteReport方法的具体用法?C# Report.WriteReport怎么用?C# Report.WriteReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Report的用法示例。


在下文中一共展示了Report.WriteReport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareFiles

        public Report CompareFiles(Log log, CsvFile csvBase, string sReportPath, ref Options options)
        {
            int iInvalids = 0;

            Report rep = new Report(sReportPath);
            log.WriteLine("Comparing \"{0}\" to \"{1}\"", _fileName, csvBase.ToString());

            rep.BaseFile = csvBase.ToString();
            rep.CompareFile = _fileName;

            Curve reference = new Curve();
            Curve compareCurve = new Curve();
            TubeReport tubeReport = new TubeReport();
            TubeSize size = null;
            Tube tube = new Tube(size);
            IOptions tubeOptions = new Options1(_dRangeDelta, Axes.X);

            foreach (KeyValuePair<string, List<double>> res in csvBase.Results)
            {
                if (!this.Results.ContainsKey(res.Key))
                    log.WriteLine(LogLevel.Warning, "{0} not found in \"{1}\", skipping checks.", res.Key, this._fileName);
                else
                {
                    compareCurve = new Curve(res.Key, this.XAxis.ToArray<double>(), this.Results[res.Key].ToArray<double>());

                    if (res.Value.Count == 0)
                    {
                        log.Error("{0} has no y-Values! Maybe error during parsing? Skipping", res.Key);
                        continue;
                    }
                    reference = new Curve("Reference ", csvBase.XAxis.ToArray(), csvBase.Results[res.Key].ToArray());
                    if (!reference.ImportSuccessful)
                    {
                        log.Error("Error in the calculation of the tubes. Skipping {0}", res.Key);
                        rep.Chart.Add(new Chart() { Title = res.Key, Errors = 1 });
                        continue;
                    }

                    if (reference.X.Length < compareCurve.X.Length)
                        log.WriteLine(LogLevel.Warning, "The resolution of the base x-axis is smaller than the compare x-axis. The better the base resolution is, the better the validation result will be!");
                    else
                        log.WriteLine(LogLevel.Debug, "The resolution of the base x-axis is good.");

                    size = new TubeSize(reference, true);
                    size.Calculate(_dRangeDelta, Axes.X, Relativity.Relative);
                    tube = new Tube(size);
                    tubeReport = tube.Calculate(reference);
                    tube.Validate(compareCurve);

                    if (tubeReport.Valid == Validity.Valid)
                        log.WriteLine(res.Key + " is valid");
                    else
                    {
                        log.WriteLine(LogLevel.Warning, "{0} is invalid! {1} errors have been found during validation.", res.Key,
                            (null != tube.Report.Errors && null != tube.Report.Errors.X) ? tube.Report.Errors.X.Length : 0);
                        iInvalids++;
                        Environment.ExitCode = 1;
                    }
                }
                if (null != tube.Report)//No charts for missing reports
                    PrepareCharts(reference, compareCurve, tube.Report.Errors, rep, tubeReport, res, options.UseBitmapPlots);
            }
            rep.Tolerance = _dRangeDelta;

            string sResult = "na";

            if (rep.TotalErrors == 0)
                sResult = "passed";
            else
                sResult = "failed";

            if (options.ComparisonFlag)
                using (TextWriter writer = File.CreateText(string.Format("{0}{1}compare_{2}.log", Path.GetDirectoryName(_fileName), Path.DirectorySeparatorChar, sResult)))
                {
                    //Content needs to be defined
                    writer.WriteLine("CSV Compare Version {0} ({1})", Info.AssemblyVersion, Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture);
                    writer.WriteLine("Comparison result file for {0}", _fileName);
                    writer.WriteLine(". Time:        {0:o}", DateTime.Now);
                    writer.WriteLine(". Operation:   {0}", options.Mode);
                    writer.WriteLine(". Tolerance:   {0}", options.Tolerance);
                    writer.WriteLine(". Result:      {0}", sResult);

                    if (rep.TotalErrors > 0)
                    {
                        Chart pairMax = rep.Chart.Aggregate((l, r) => l.DeltaError > r.DeltaError ? l : r);
                        writer.WriteLine(". Biggest error: {0}=>{1}", pairMax.Title, pairMax.DeltaError);
                        writer.WriteLine(". Failed values:");

                        foreach (Chart c in (from r in rep.Chart where r.DeltaError > 0 select r).OrderByDescending(er => er.DeltaError))
                            writer.WriteLine("{0}=>{1}", c.Title, c.DeltaError);
                    }
                }

            rep.WriteReport(log, (!string.IsNullOrEmpty(options.ReportDir)) ? options.ReportDir : string.Empty, options);
            GC.Collect();//immediately forget big charts and data
            return rep;
        }
开发者ID:harmanpa,项目名称:csv-compare,代码行数:97,代码来源:CsvFile.cs


注:本文中的Report.WriteReport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。