Beispiel #1
0
        public void TestGeneralParametersProcessing()
        {
            TParameterList parameters = new TParameterList();

            TVariant value = new TVariant();

            value.ApplyFormatString("Currency");
            Assert.AreEqual("0", value.ToFormattedString(), "null value for currency should be 0");
            value = new TVariant(value.ToFormattedString());
            parameters.Add("amountdue", value, -1, 2, null, null, ReportingConsts.CALCULATIONPARAMETERS);
            parameters.Save("testDebug.csv", true);
            Assert.AreEqual(true, parameters.Exists("amountdue", -1, 1, eParameterFit.eBestFitEvenLowerLevel), "can find added parameter");
            Assert.AreEqual("0", parameters.Get("amountdue", -1, 2,
                    eParameterFit.eBestFit).ToFormattedString(), "currency parameter is stored not correctly");
            //Assert.AreEqual("0", parameters.Get("amountdue", -1, 1, eParameterFit.eBestFit).ToFormattedString(), "currency parameter is stored not correctly");
            Assert.AreEqual("0", parameters.Get("amountdue", -1, 1,
                    eParameterFit.eBestFitEvenLowerLevel).ToFormattedString(), "currency parameter cannot be accessed from level up");

            parameters.Add("IntegerList", "300,400");
            parameters.Save("test.csv", false);
            parameters.Load(Path.GetFullPath("test.csv"));
            Assert.AreEqual("eString:300,400", parameters.Get(
                    "IntegerList").EncodeToString(), "integers separated by comma should be treated as string");
            parameters.Save("test2.csv", true);
        }
Beispiel #2
0
        /// <summary>
        /// Save the currently selected options and parameters to a file;
        /// this will automatically make this setting the most recent
        /// </summary>
        /// <returns>null if something went wrong (eg. overwrite a system settings file);
        /// otherwise a collection with the recently used settings, including the settings just saved
        /// </returns>
        public StringCollection SaveSettings(String ASettingsName, TParameterList AParameters)
        {
            if (IsSystemSettings(ASettingsName))
            {
                // cannot store/modify system settings, they are only provided by ICT
                // they can be saved as another setting
                return null;
            }

            if (!System.IO.Directory.Exists(FUserSettingsDirectory + FReportName))
            {
                System.IO.Directory.CreateDirectory(FUserSettingsDirectory + FReportName);
            }

            AParameters.Save(FUserSettingsDirectory + FReportName + System.IO.Path.DirectorySeparatorChar + ASettingsName + ".xml");
            return UpdateRecentlyUsedSettings(ASettingsName);
        }
        /// <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.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());

            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);
        }