public RExporterResult GetChartPDFTest(DataSet ds, string sChartName, int id_map) { RExporterResult result = new RExporterResult(); string rowData = string.Format("{0}\\input.csv", Environment.CurrentDirectory); string sJPGPath = string.Format("{0}\\chart.pdf", Environment.CurrentDirectory); string sTestDunnResult = string.Format("{0}\\dunnTest.txt", Environment.CurrentDirectory); string sTestKwResult = string.Format("{0}\\KwTest.txt", Environment.CurrentDirectory); exportToCSV(ds, rowData); executeR(string.Format("{0}\\DunnTest.R", Environment.CurrentDirectory), rowData, sTestDunnResult); result.DunnTest = File.ReadAllLines(sTestDunnResult); executeR(@".\KwTest.R", rowData, sTestKwResult); result.KwTest = File.ReadAllLines(sTestKwResult); int df = result.GetKwTestDF(); double kw = result.GetKwchiSquared(); string testResult = result.GetKwchiDescription(); //formatKwTest(df, kw); string sScriptFile = setChartExporter(id_map); executeR(sScriptFile, rowData, sJPGPath, sChartName, testResult); result.ChartPath = sJPGPath; return(result); }
private void ExportRobotDataPDF() { SQL.ConnectionString = @"data source=WR-7-BASE-74\SQLEXPRESS;initial catalog=DoktoratRobot;Integrated Security=SSPI;"; MapItem[] mapList = SQL.DataProviderExport.GetExportMapList(); string sTempInputDir = string.Format("{0}\\TempInput", Environment.CurrentDirectory); string sOutputDir = string.Format("{0}\\Output", Environment.CurrentDirectory); foreach (var map in mapList) { ConfigItem[] itemConfigList = SQL.DataProviderExport.GetExportConfigList(map); DataSet ds; List <string> pdfsFile = new List <string>(); List <string> dunnTest = new List <string>(); List <string> kwTest = new List <string>(); List <string> LatexImageDescriptions = new List <string>(); StringBuilder sLatexFile = new StringBuilder(); double[] prawodpodobienstwMinimalnea = new double[] { 0, 3.8415, 5.9915, 7.8147, 9.4877, 11.0705, 12.5916 }; double alfa = 0.05; string sCombineNamePDF = "Robots " + map.MapName + ".pdf"; string sCombineNameTex = "Robots " + map.MapName + ".tex"; sCombineNamePDF = sCombineNamePDF.Replace(" ", "_"); //usuniecie spacje w nazwie pliku wynikowym pdf sCombineNameTex = sCombineNameTex.Replace(" ", "_"); //usuniecie spcaji w nazwie poliku wynikowego tex if (Directory.Exists(sTempInputDir)) { Directory.Delete(sTempInputDir, true); Directory.CreateDirectory(sTempInputDir); } else { Directory.CreateDirectory(sTempInputDir); } if (!Directory.Exists(sOutputDir)) { Directory.CreateDirectory(sOutputDir); } for (int i = 0; i < itemConfigList.Length; i++) { string sOutputPdfFile = string.Format("{0}\\{1}.pdf", sTempInputDir, i.ToString()); string sChartTitel = string.Format("{0}", itemConfigList[i].Name); // ""; //Gdy zajedzie potrzeba to nadamy w tym mijscy nazwy wykresu string sLatexImageDescriptions = string.Format("Eksperymenty Roboty: Mapa {0} Konfiguracja: {1}", map.MapName, itemConfigList[i].Name); ds = SQL.DataProviderExport.GetExportResult(itemConfigList[i].ConfigID); ds = removeUnnecessaryData(ds, map.ID_Map); RExporter r = new RExporter(); RExporterResult chartAndTestResult = r.GetChartPDFTest(ds, sChartTitel, map.ID_Map); RExporterResultItem[] testResult = chartAndTestResult.GetDunnTestResult(); SQL.DataProviderExport.InsertDunnStatistic(map, itemConfigList[i], testResult); File.Move(chartAndTestResult.ChartPath, sOutputPdfFile); pdfsFile.Add(sOutputPdfFile); int df = chartAndTestResult.GetKwTestDF(); double kw = chartAndTestResult.GetKwchiSquared(); string outLatex = formatLatexFile(sChartTitel, string.Format("06_experimental_results/robot/img/{0}", sCombineNamePDF), i, alfa, prawodpodobienstwMinimalnea[df], df, kw, map.MapName); sLatexFile.Append(outLatex); } concatAndAddContent(pdfsFile, string.Format("{0}\\{1}", sOutputDir, sCombineNamePDF)); File.AppendAllText(string.Format("{0}\\{1}", sOutputDir, sCombineNameTex), sLatexFile.ToString()); } // MessageBox.Show(this, "Excel file created , you can find the file"); }