예제 #1
0
파일: Report.cs 프로젝트: facchinm/SiRFLive
        private void writeResetSummaryXMLFile(string dir, ReportLayoutType rFormat)
        {
            frmResetTestReportPlots plots = new frmResetTestReportPlots();
            ZedGraphControl control = new ZedGraphControl();
            string path = dir + @"\SummaryReport.xml";
            switch (rFormat)
            {
                case ReportLayoutType.GroupBySWVersion:
                    path = dir + @"\PerSW_SummaryReport.xml";
                    break;

                case ReportLayoutType.GroupByResetType:
                    path = dir + @"\PerResetType_SummaryReport.xml";
                    break;
            }
            StreamWriter f = new StreamWriter(path);
            try
            {
                f.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                f.WriteLine("<reset>");
                int styleCt = 0;
                List<string> il = new List<string>();
                foreach (string str2 in this.reportDataHash.Keys)
                {
                    Header1DataClass class2 = (Header1DataClass) this.reportDataHash[str2];
                    f.WriteLine("\t<swVersion name=\"{0}\">", str2);
                    ArrayList list2 = new ArrayList();
                    foreach (string str3 in class2.Header2DataHash.Keys)
                    {
                        list2.Add(str3);
                    }
                    list2.Sort();
                    foreach (string str4 in list2)
                    {
                        plots.PaneTitle = str2 + "\r\n" + str4;
                        plots.CreateCharts();
                        GraphPane myPane = plots.AddPane("TTFF Resets", "Secs");
                        GraphPane pane2 = plots.AddPane("2-D Error", "Meters");
                        GraphPane pane3 = plots.AddPane("Verical Error", "Meters");
                        PerEnvReport report = (PerEnvReport) class2.Header2DataHash[str4];
                        if (this.ReportLayout == ReportLayoutType.GroupBySWVersion)
                        {
                            styleCt++;
                        }
                        else
                        {
                            styleCt = 1;
                        }
                        string item = str4 + styleCt.ToString() + ".jpg";
                        string str6 = "Style" + styleCt.ToString();
                        il.Add(item);
                        f.WriteLine("\t\t<environment name=\"{0}\" plotImage=\"{1}\"  showpicturestyle=\"{2}\">", str4, item, str6);
                        ArrayList list3 = new ArrayList();
                        foreach (string str7 in report.PerSiteData.Keys)
                        {
                            list3.Add(str7);
                        }
                        list3.Sort();
                        int num2 = 0;
                        foreach (string str8 in list3)
                        {
                            ReportElements elements = (ReportElements) report.PerSiteData[str8];
                            f.WriteLine("\t\t\t<site number=\"{0}\">", str8);
                            this.printResetSummary(f, elements.TTFFSamples.Samples, elements.NumberOfMisses, elements.NumberOfSVInFix);
                            this.printSampleData(f, elements.TTFFSamples, this._percentile, this._ttffLimit, Convert.ToDouble(this._timeoutVal), "TTFF", "sec");
                            this.printSampleData(f, elements.Position2DErrorSamples, this._percentile, this._hrErrLimit, -9999.0, "2-D Error", "m");
                            this.printSampleData(f, elements.VerticalErrorSamples, this._percentile, this._hrErrLimit, -9999.0, "Vertical Error", "m");
                            this.printSampleData(f, elements.CNOSamples, this._percentile, "", -9999.0, "CNO", "dbHz");
                            f.WriteLine("\t\t\t</site>");
                            if (rFormat == ReportLayoutType.GroupBySWVersion)
                            {
                                plots.AddCurve(myPane, elements.TTFFSamples, elements.TTFFSamples.Samples, str8);
                                plots.AddCurve(pane2, elements.Position2DErrorSamples, elements.Position2DErrorSamples.Samples, str8);
                                plots.AddCurve(pane3, elements.VerticalErrorSamples, elements.VerticalErrorSamples.Samples, str8);
                            }
                            num2++;
                        }
                        if (rFormat == ReportLayoutType.GroupBySWVersion)
                        {
                            plots.RefreshGraph();
                            plots.SaveGraphToFile(dir, item);
                            plots.PaneTitle = string.Empty;
                        }
                        f.WriteLine("\t\t</environment>");
                        myPane = null;
                        pane2 = null;
                        pane3 = null;
                    }
                    f.WriteLine("\t</swVersion>");
                }
                this.printTestSetup(f);
                if (rFormat == ReportLayoutType.GroupBySWVersion)
                {
                    this.modifyResetReportCSS(dir, styleCt);
                    this.printImageList(f, il);
                }
                f.WriteLine("</reset>");
                f.Close();
                this.reportDataHash.Clear();
                this.perRxSetupData.Clear();
                string outputFile = path.Replace(".xml", ".html");
                this.GenerateHTMLReport(path, outputFile, ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts\resetReport.xsl");
                plots.Dispose();
                control.Dispose();
            }
            catch (Exception exception)
            {
                this.perRxSetupData.Clear();
                this.perRxSetupData.Clear();
                plots.Dispose();
                control.Dispose();
                if (f != null)
                {
                    f.Close();
                }
                MessageBox.Show(exception.Message, "Report Generate Error");
            }
        }
예제 #2
0
파일: Report.cs 프로젝트: facchinm/SiRFLive
 public void Summary_Reset(string dir)
 {
     frmResetTestReportPlots plots = new frmResetTestReportPlots();
     new ZedGraphControl();
     Hashtable hashtable = new Hashtable();
     int index = 8;
     int num2 = index + 1;
     int num3 = num2 + 3;
     int num4 = num3 + 3;
     int num5 = num4 + 5;
     int num6 = 12;
     int num7 = (num6 + num5) + 1;
     double sample = 0.0;
     string path = dir + @"\summary_reset.xml";
     StreamWriter f = new StreamWriter(path);
     try
     {
         FileInfo[] files = new DirectoryInfo(dir).GetFiles("*.csv");
         if (files.Length != 0)
         {
             foreach (FileInfo info2 in files)
             {
                 Header1DataClass class2;
                 PerEnvReport report;
                 ReportElements elements;
                 StreamReader reader = info2.OpenText();
                 string name = info2.Name;
                 string pattern = @"_(com|COM|tcp|TCP|i2c|I2C)\d+_(reset)*(?<testName>\w+)_(?<cno>-?\d+\.*\d?)";
                 Regex regex = new Regex(pattern, RegexOptions.Compiled);
                 bool flag = regex.IsMatch(name);
                 string key = "Unknown";
                 string str5 = "Unknown";
                 if (flag)
                 {
                     key = regex.Match(name).Result("${cno}");
                     str5 = regex.Match(name).Result("${testName}");
                 }
                 string str6 = string.Empty;
                 string input = reader.ReadLine();
                 if (input != null)
                 {
                     pattern = @"SW Version=\s*(?<swVer>.*)";
                     Regex regex2 = new Regex(pattern, RegexOptions.Compiled);
                     if (regex2.IsMatch(input))
                     {
                         str6 = regex2.Match(input).Result("${swVer}");
                     }
                     else
                     {
                         str6 = "SW Version= Not detected";
                     }
                 }
                 else
                 {
                     str6 = "SW Version= Not detected";
                 }
                 if (hashtable.Contains(str6))
                 {
                     class2 = (Header1DataClass) hashtable[str6];
                 }
                 else
                 {
                     Header1DataClass class3 = new Header1DataClass();
                     hashtable.Add(str6, class3);
                     class2 = (Header1DataClass) hashtable[str6];
                 }
                 if (class2.Header2DataHash.Contains(str5))
                 {
                     report = (PerEnvReport) class2.Header2DataHash[str5];
                 }
                 else
                 {
                     PerEnvReport report2 = new PerEnvReport();
                     class2.Header2DataHash.Add(str5, report2);
                     report = (PerEnvReport) class2.Header2DataHash[str5];
                 }
                 if (report.PerSiteData.Contains(key))
                 {
                     elements = (ReportElements) report.PerSiteData[key];
                 }
                 else
                 {
                     ReportElements elements2 = new ReportElements();
                     report.PerSiteData.Add(key, elements2);
                     elements = (ReportElements) report.PerSiteData[key];
                 }
                 input = reader.ReadLine();
                 string str8 = "N/A";
                 Hashtable hashtable2 = new Hashtable();
                 int num9 = 0;
                 if (input != null)
                 {
                     string[] strArray = input.Split(new char[] { '=' });
                     if (strArray.Length > 1)
                     {
                         str8 = strArray[1];
                         if (this.perRxSetupData.ContainsKey(str8))
                         {
                             goto Label_0323;
                         }
                         if (strArray.Length > 1)
                         {
                             hashtable2.Add(strArray[0], strArray[1]);
                         }
                         while ((input = reader.ReadLine()) != null)
                         {
                             if (input == "End Summary")
                             {
                                 break;
                             }
                             if (input != string.Empty)
                             {
                                 strArray = input.Split(new char[] { '=' });
                                 if (strArray.Length > 1)
                                 {
                                     hashtable2.Add(strArray[0], strArray[1]);
                                 }
                                 num9++;
                             }
                         }
                         this.perRxSetupData.Add(str8, hashtable2);
                     }
                 }
                 goto Label_032F;
             Label_0315:
                 if (input == "End Summary")
                 {
                     goto Label_032F;
                 }
             Label_0323:
                 if ((input = reader.ReadLine()) != null)
                 {
                     goto Label_0315;
                 }
             Label_032F:
                 elements.RxName = str8;
                 input = reader.ReadLine();
                 for (input = reader.ReadLine(); input != null; input = reader.ReadLine())
                 {
                     string[] strArray2 = input.Split(new char[] { ',' });
                     double num10 = -9999.0;
                     if (strArray2.Length >= 5)
                     {
                         double num11 = Convert.ToDouble(strArray2[this._ttffReportType]);
                         double num12 = Convert.ToDouble(strArray2[index]);
                         double num13 = Convert.ToDouble(this._limitVal);
                         string[] strArray3 = this._hrErrLimit.Split(new char[] { ',' });
                         int num14 = -1;
                         try
                         {
                             num14 = Convert.ToInt32(strArray2[num7]);
                         }
                         catch
                         {
                         }
                         if (strArray3.Length > 0)
                         {
                             Convert.ToDouble(strArray3[strArray3.Length - 1]);
                         }
                         else
                         {
                             Convert.ToDouble(strArray3[0]);
                         }
                         if (num11 <= 0.0)
                         {
                             elements.NumberOfMisses++;
                         }
                         else if (num11 >= num13)
                         {
                             elements.NumberOfMisses++;
                         }
                         double num15 = Convert.ToDouble(strArray2[num3]);
                         if (num15 != -9999.0)
                         {
                             num10 = Math.Abs((double) (num15 - Convert.ToDouble(strArray2[num4])));
                         }
                         if ((num14 >= 0) && (num14 <= 3))
                         {
                             elements.NumberOfSVInFix++;
                         }
                         try
                         {
                             elements.TTFFSamples.InsertSample(num11);
                             elements.Position2DErrorSamples.InsertSample(num12);
                             elements.VerticalErrorSamples.InsertSample(num10);
                             report.PerEnvSamples.TTFFSamples.InsertSample(num11);
                             report.PerEnvSamples.Position2DErrorSamples.InsertSample(num12);
                             report.PerEnvSamples.VerticalErrorSamples.InsertSample(num10);
                             class2.ReportDataSamples.TTFFSamples.InsertSample(num11);
                             class2.ReportDataSamples.Position2DErrorSamples.InsertSample(num12);
                             class2.ReportDataSamples.VerticalErrorSamples.InsertSample(num10);
                             for (int i = 0; i < num6; i++)
                             {
                                 sample = Convert.ToDouble(strArray2[num5 + i]);
                                 if (sample != 0.0)
                                 {
                                     elements.CNOSamples.InsertSample(sample);
                                     report.PerEnvSamples.CNOSamples.InsertSample(sample);
                                     class2.ReportDataSamples.CNOSamples.InsertSample(sample);
                                 }
                             }
                         }
                         catch (FormatException exception)
                         {
                             exception.ToString();
                         }
                     }
                 }
                 reader.Close();
             }
             f.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
             f.WriteLine("<reset>");
             int styleCt = 0;
             List<string> il = new List<string>();
             foreach (string str9 in hashtable.Keys)
             {
                 Header1DataClass class4 = (Header1DataClass) hashtable[str9];
                 f.WriteLine("\t<swVersion name=\"{0}\">", str9);
                 foreach (string str10 in class4.Header2DataHash.Keys)
                 {
                     plots.PaneTitle = str9 + "\r\n" + str10;
                     plots.CreateCharts();
                     GraphPane myPane = plots.AddPane("TTFF Resets", "Secs");
                     GraphPane pane2 = plots.AddPane("2-D Error", "Meters");
                     GraphPane pane3 = plots.AddPane("Verical Error", "Meters");
                     PerEnvReport report3 = (PerEnvReport) class4.Header2DataHash[str10];
                     styleCt++;
                     string item = str10 + styleCt.ToString() + ".jpg";
                     string str12 = "Style" + styleCt.ToString();
                     il.Add(item);
                     f.WriteLine("\t\t<environment name=\"{0}\" plotImage=\"{1}\"  showpicturestyle=\"{2}\">", str10, item, str12);
                     ArrayList list2 = new ArrayList();
                     foreach (string str13 in report3.PerSiteData.Keys)
                     {
                         list2.Add(str13);
                     }
                     list2.Sort();
                     int num18 = 0;
                     foreach (string str14 in list2)
                     {
                         ReportElements elements3 = (ReportElements) report3.PerSiteData[str14];
                         f.WriteLine("\t\t\t<site number=\"{0}\">", str14);
                         this.printResetSummary(f, elements3.TTFFSamples.Samples, elements3.NumberOfMisses, elements3.NumberOfSVInFix);
                         this.printSampleData(f, elements3.TTFFSamples, this._percentile, this._ttffLimit, Convert.ToDouble(this._timeoutVal), "TTFF", "sec");
                         plots.AddCurve(myPane, elements3.TTFFSamples, elements3.TTFFSamples.Samples, str14);
                         this.printSampleData(f, elements3.Position2DErrorSamples, this._percentile, this._hrErrLimit, -9999.0, "2-D Error", "m");
                         plots.AddCurve(pane2, elements3.Position2DErrorSamples, elements3.Position2DErrorSamples.Samples, str14);
                         this.printSampleData(f, elements3.VerticalErrorSamples, this._percentile, this._hrErrLimit, -9999.0, "Vertical Error", "m");
                         plots.AddCurve(pane3, elements3.VerticalErrorSamples, elements3.VerticalErrorSamples.Samples, str14);
                         this.printSampleData(f, elements3.CNOSamples, this._percentile, "", -9999.0, "CNO", "dbHz");
                         f.WriteLine("\t\t\t</site>");
                         num18++;
                     }
                     plots.RefreshGraph();
                     plots.SaveGraphToFile(dir, item);
                     plots.PaneTitle = string.Empty;
                     f.WriteLine("\t\t</environment>");
                 }
                 f.WriteLine("\t</swVersion>");
             }
             this.modifyResetReportCSS(dir, styleCt);
             this.printTestSetup(f);
             this.printImageList(f, il);
             f.WriteLine("</reset>");
             f.Close();
             hashtable.Clear();
             this.perRxSetupData.Clear();
             string outputFile = dir + @"\summary_reset.html";
             this.GenerateHTMLReport(path, outputFile, ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts\resetReport.xsl");
         }
     }
     catch (Exception exception2)
     {
         this.perRxSetupData.Clear();
         hashtable.Clear();
         f.Close();
         MessageBox.Show(exception2.Message, "ERROR");
     }
 }