예제 #1
0
        private bool ExportToCSVFile(string AFilename)
        {
            bool ExportOnlyLowestLevel = false;

            // Add the parameter export_only_lowest_level to the Parameters if you don't want to export the
            // higher levels. In some reports (Supporting Churches Report or Partner Contact Report) the csv
            // output looks much nicer if it doesn't contain the unnecessary higher levels.
            if (FParameterList.Exists("csv_export_only_lowest_level"))
            {
                ExportOnlyLowestLevel = FParameterList.Get("csv_export_only_lowest_level").ToBool();
            }

            return(FResultList.WriteCSV(FParameterList, AFilename, ExportOnlyLowestLevel));
        }
예제 #2
0
        /// <summary>
        /// calculate the report and save the result and returned parameters to file
        /// </summary>
        public static void CalculateReport(string AReportParameterXmlFile, TParameterList ASpecificParameters, int ALedgerNumber = -1)
        {
            // important: otherwise month names are in different language, etc
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB", false);

            TReportGeneratorUIConnector ReportGenerator = new TReportGeneratorUIConnector();
            TParameterList Parameters    = new TParameterList();
            string         resultFile    = AReportParameterXmlFile.Replace(".xml", ".Results.xml");
            string         parameterFile = AReportParameterXmlFile.Replace(".xml", ".Parameters.xml");

            Parameters.Load(AReportParameterXmlFile);

            if (ALedgerNumber != -1)
            {
                Parameters.Add("param_ledger_number_i", ALedgerNumber);
            }

            Parameters.Add(ASpecificParameters);

            ReportGenerator.Start(Parameters.ToDataTable());

            while (ReportGenerator.AsyncExecProgressServerSide.ProgressState == TAsyncExecProgressState.Aeps_Executing)
            {
                Thread.Sleep(500);
            }

            Assert.IsTrue(ReportGenerator.GetSuccess(), "Report did not run successfully");
            TResultList Results = new TResultList();

            Results.LoadFromDataTable(ReportGenerator.GetResult());
            Parameters.LoadFromDataTable(ReportGenerator.GetParameter());

            if (!Parameters.Exists("ControlSource", ReportingConsts.HEADERPAGELEFT1, -1, eParameterFit.eBestFit))
            {
                Parameters.Add("ControlSource", new TVariant("Left1"), ReportingConsts.HEADERPAGELEFT1);
            }

            if (!Parameters.Exists("ControlSource", ReportingConsts.HEADERPAGELEFT2, -1, eParameterFit.eBestFit))
            {
                Parameters.Add("ControlSource", new TVariant("Left2"), ReportingConsts.HEADERPAGELEFT2);
            }

            Parameters.Save(parameterFile, false);
            Results.WriteCSV(Parameters, resultFile, ",", false, false);
        }
예제 #3
0
        /// <summary>
        /// calculate the report and save the result and returned parameters to file
        /// </summary>
        public static void CalculateReport(string AReportParameterXmlFile, TParameterList ASpecificParameters, int ALedgerNumber = -1)
        {
            // important: otherwise month names are in different language, etc
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB", false);

            TReportGeneratorUIConnector ReportGenerator = new TReportGeneratorUIConnector();
            TParameterList Parameters = new TParameterList();

            if (AReportParameterXmlFile.IndexOf(".Test.xml") == -1)
            {
                throw new Exception("invalid report name, should end with .Test.xml");
            }

            string resultFile    = AReportParameterXmlFile.Replace(".Test.xml", ".Results.csv");
            string parameterFile = AReportParameterXmlFile.Replace(".Test.xml", ".Parameters.xml");

            Parameters.Load(AReportParameterXmlFile);

            if (ALedgerNumber != -1)
            {
                Parameters.Add("param_ledger_number_i", ALedgerNumber);
            }

            Parameters.Add(ASpecificParameters);

            ReportGenerator.Start(Parameters.ToDataTable());

            while (!ReportGenerator.Progress.JobFinished)
            {
                Thread.Sleep(500);
            }

            Assert.IsTrue(ReportGenerator.GetSuccess(), "Report did not run successfully");
            TResultList Results = new TResultList();

            Results.LoadFromDataTable(ReportGenerator.GetResult());
            Parameters.LoadFromDataTable(ReportGenerator.GetParameter());

            Parameters.Sort();
            Parameters.Save(parameterFile, false);
            Results.WriteCSV(Parameters, resultFile, ",");
        }
예제 #4
0
        /// <summary>
        /// export the full result to a CSV file
        ///
        /// </summary>
        /// <returns>void</returns>
        public void ExportToCSV()
        {
            System.Diagnostics.Process csvProcess;

            if (dlgSaveCSVFile.FileName.Length == 0)
            {
                dlgSaveCSVFile.FileName = this.ReportName + '.' + dlgSaveCSVFile.DefaultExt;
            }

            if (dlgSaveCSVFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                bool ExportOnlyLowestLevel = false;

                // Add the parameter export_only_lowest_level to the Parameters if you don't want to export the
                // higher levels. In some reports (Supporting Churches Report or Partner Contact Report) the csv
                // output looks much nicer if it doesn't contain the unnecessary higher levels.
                if (Parameters.Exists("csv_export_only_lowest_level"))
                {
                    ExportOnlyLowestLevel = Parameters.Get("csv_export_only_lowest_level").ToBool();
                }

                if (Results.WriteCSV(Parameters, dlgSaveCSVFile.FileName, ExportOnlyLowestLevel))
                {
                    try
                    {
                        csvProcess = new System.Diagnostics.Process();
                        csvProcess.EnableRaisingEvents = false;
                        csvProcess.StartInfo.FileName  = dlgSaveCSVFile.FileName;
                        csvProcess.Start();
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    MessageBox.Show(Results.ErrorStatus, Catalog.GetString("Failed to save file"), MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }