Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
            parameters.Save("testDebug.json");
            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");

            // this test only works with english culture settings
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB", false);
            parameters.Add("IntegerList", "300,400");
            parameters.Save("test.json");
            parameters.Load(Path.GetFullPath("test.json"));
            Assert.AreEqual("eString:300,400", parameters.Get(
                                "IntegerList").EncodeToString(), "integers separated by comma should be treated as string");
            parameters.Save("test2.json");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="child"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        protected TVariant Get1stLevelValue(int child, int col)
        {
            TVariant ReturnValue;
            int      master;
            decimal  masterval;
            int      masterlevel;

            ReturnValue = new TVariant();
            master      = child;
            masterval   = CurrentColumns[col].ToDecimal();
            masterlevel = Depth;

            while (masterlevel > 1)
            {
                child = master;
                GetParentLine(child, col, ref master, ref masterval, ref masterlevel);
            }

            if ((masterlevel == 1) && (masterval != 0))
            {
                ReturnValue = new TVariant(masterval);
            }

            return(ReturnValue);
        }
Ejemplo n.º 4
0
        private void ReplaceFunctionVariables(ref TVariant v)
        {
            String   s;
            TVariant testS;

            TVariant[] ops = new TVariant[ReportingConsts.MAX_FUNCTION_PARAMETER + 1 - 0 + 1];
            Int32      counter;

            if (v.TypeVariant == eVariantTypes.eString)
            {
                s = v.ToString().Trim();
                s = s.Replace("{{lineId}}", StringHelper.IntToStr(LineId));
                s = s.Replace("{{column}}", StringHelper.IntToStr(column));
                s = s.Replace("{{level}}", StringHelper.IntToStr(Depth));

                // make sure that e.g. HasChildRows is evaluated
                for (counter = 1; counter <= ReportingConsts.MAX_FUNCTION_PARAMETER; counter += 1)
                {
                    ops[counter] = null;
                }

                testS = FunctionSelector(s, ops);

                if (testS != null)
                {
                    s = testS.ToString();
                }

                TRptFormatQuery query = new TRptFormatQuery(s, null, Parameters, column, Depth);
                query.ReplaceVariables();

                v = query.VariantValue;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="s"></param>
        /// <param name="withQuotes"></param>
        /// <returns></returns>
        public TVariant ReplaceVariables(String s, Boolean withQuotes)
        {
            TVariant ReturnValue;

            // find all variables given in
            // name translates into "value"
            // name is changed to value
            // #name# is changed to "value" (date)
            // if the variable should be retrieved with getParameter("variablename", 1,1,true) => use GLOBAL:variablename
            // var
            // todo: Integer;  need to make it work for postgresql as well
            ReturnValue = new TVariant(s);
            ReturnValue = ReplaceVariablesPattern(ReturnValue, "{{", "}}", "", "", new TConvertProc(Id));

            ReturnValue = ReplaceVariablesPattern(ReturnValue, "{#", "#}", "", "", new TConvertProc(FormatDate));

            if (withQuotes)
            {
                ReturnValue = ReplaceVariablesPattern(ReturnValue, "{", "}", "'", "'", new TConvertProc(Id));
            }
            else
            {
                ReturnValue = ReplaceVariablesPattern(ReturnValue, "{", "}", "", "", new TConvertProc(Id));
            }

            return(ReturnValue);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="copy"></param>
 public TParameter(TParameter copy)
 {
     name   = copy.name;
     value  = copy.value;
     column = copy.column;
     level  = copy.level;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets called in regular intervals from a Timer in Class TTimedProcessing.
        /// </summary>
        /// <param name="ADBAccessObj">Instantiated DB Access object with opened DB connection.</param>
        /// <param name="ARunManually">this is true if the process was called manually from the server admin console</param>
        public static void Process(TDataBase ADBAccessObj, bool ARunManually)
        {
            // only check once a day (or as specified in config file), if not manually called
            if (!ARunManually)
            {
                DateTime LastRun =
                    TVariant.DecodeFromString(


                        TSystemDefaults.GetSystemDefault(
                            PROCESSDATACHECK_LAST_RUN,
                            new TVariant(DateTime.MinValue).EncodeToString())).ToDate();

                if (LastRun.AddDays(TAppSettingsManager.GetInt16("DataChecks.RunEveryXDays", 1)) > DateTime.Now)
                {
                    // do not run the data check more than once a day or a week (depending on configuration setting), too many emails
                    TLogging.LogAtLevel(1, "TProcessDataChecks.Process: not running, since last run was at " + LastRun.ToString());
                    return;
                }
            }

            Errors_SinceDate = DateTime.Today.AddDays(-1 * SENDREPORTFORDAYS_TOUSERS);

            TLogging.LogAtLevel(1, "TProcessDataChecks.Process: Checking Modules");
            CheckModule(ADBAccessObj, "DataCheck.MPartner.");

            TSystemDefaults.SetSystemDefault(PROCESSDATACHECK_LAST_RUN, new TVariant(DateTime.Now).EncodeToString());
        }
        private void grdCommitmentStatusChoices_ReadControls(TRptCalculator ACalc, TReportActionEnum AReportAction)
        {
            // TODO
            //   The reason that the status choices listbox is not
            //   filled in with saved data is that Parameter.Save()
            //   and Parameter.Load() do not use
            //   TVariant.EncodeToString() and
            //   TVariant.DecodeFromString() when storing a saved set
            //   of parameters. Composites survive fine over the
            //   remoting interface, though. I (binki) am allowed to
            //   change the behavior of TParameterList.Save() and
            //   TParameterList.Load() _if_ I change the
            //   XmlReports/Settings/.../standard.xml files to support
            //   DecodeFromString().
            TVariant param_grdCommitmentStatusChoices = new TVariant();

            foreach (DataRow ARow in FCommitmentStatusTable.Rows)
            {
                if ((bool)ARow["Selection"])
                {
                    param_grdCommitmentStatusChoices.Add(new TVariant((String)ARow[PmCommitmentStatusTable.GetCodeDBName()]), "", false);
                }
            }

            ACalc.AddParameter("param_commitment_status_choices", param_grdCommitmentStatusChoices);
        }
        /// <summary>
        /// Insert the values of the detail data row if we have "Detail" as report level.
        /// The detail row contains for each partner the room bookings.
        /// </summary>
        /// <param name="ANumColumns">Number of columns the report has</param>
        /// <param name="AChildRow">Index of the child row</param>
        /// <param name="ARoomName">The room name of which to add the details to the table</param>
        /// <param name="ASituation">The current report situation</param>
        /// <returns>true</returns>
        private bool InsertDetailDataRow(int ANumColumns, ref int AChildRow, string ARoomName, ref TRptSituation ASituation)
        {
            foreach (DataRow DetailRow in FAccommodationDetailTable.Rows)
            {
                if (DetailRow["RoomName"].ToString() != ARoomName)
                {
                    continue;
                }

                TVariant[] Header      = new TVariant[ANumColumns];
                TVariant[] Description =
                {
                    new TVariant(), new TVariant()
                };
                TVariant[] Columns = new TVariant[ANumColumns];

                for (int Counter = 0; Counter < ANumColumns; ++Counter)
                {
                    Columns[Counter] = new TVariant(DetailRow[Counter].ToString());
                    Header[Counter]  = new TVariant();
                }

                ASituation.GetResults().AddRow(0, AChildRow++, true, 2, "", "", false,
                                               Header, Description, Columns);
            }

            return(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Common procedure to add a parameter, expects the value as a variant
        /// </summary>
        public void Add(String parameterId, TVariant value, int column, int depth, System.Object pRptElement, System.Object pRptGroup, int paramType)
        {
            Int32 subreport;

            if (parameterId != "CurrentSubReport")
            {
                subreport = GetOrDefault("CurrentSubReport", -1, new TVariant(-1)).ToInt();
            }
            else
            {
                subreport = -1;
                paramType = ReportingConsts.CALCULATIONPARAMETERS;
            }

            // find if there is already an element in the list with the exact same column/level combination
            foreach (TParameter element in Fparameters)
            {
                if ((element.name == parameterId) && (element.level == depth) && (element.column == column) && (element.subreport == subreport))
                {
                    element.value       = value;
                    element.pRptElement = pRptElement;
                    element.pRptGroup   = pRptGroup;
                    return;
                }
            }

            // else add a new element
            TParameter element2 = new TParameter(parameterId, value, column, depth, subreport, pRptElement, pRptGroup, paramType);

            Fparameters.Add(element2);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// save a generic CSV string to an Excel file
        /// </summary>
        public static bool CSV2ExcelStream(string ACSVData, MemoryStream AStream, string ASeparator = ",", string ATableName = "data")
        {
            try
            {
                ExcelPackage pck = new ExcelPackage();

                ExcelWorksheet worksheet = pck.Workbook.Worksheets.Add(ATableName);

                Int32 rowCounter = 1;
                Int16 colCounter = 1;

                // we don't have headers for the columns

                List <String> Lines       = ACSVData.Split(Environment.NewLine).ToList();
                Int32         LineCounter = 0;

                while (LineCounter < Lines.Count)
                {
                    string line = Lines[LineCounter];

                    while (line.Trim().Length > 0)
                    {
                        string value = StringHelper.GetNextCSV(ref line, Lines, ref LineCounter, ASeparator);

                        TVariant v = new TVariant(value);
                        if (v.TypeVariant == eVariantTypes.eDecimal)
                        {
                            worksheet.Cells[rowCounter, colCounter].Value = v.ToDecimal();
                        }
                        else if (v.TypeVariant == eVariantTypes.eInteger)
                        {
                            worksheet.Cells[rowCounter, colCounter].Value = v.ToInt32();
                        }
                        else if (v.TypeVariant == eVariantTypes.eDateTime)
                        {
                            worksheet.Cells[rowCounter, colCounter].Value = v.ToDate();
                        }
                        else
                        {
                            worksheet.Cells[rowCounter, colCounter].Value = value;
                        }
                        colCounter++;
                    }

                    LineCounter++;
                    rowCounter++;
                    colCounter = 1;
                }

                pck.SaveAs(AStream);

                return(true);
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
                return(false);
            }
        }
 /// <summary>
 /// Set the given DateTime control to be blank instead of
 /// DateTime.Now if the value is not specified.
 /// </summary>
 private void SetdtpControlManual(Ict.Petra.Client.CommonControls.TtxtPetraDate AControl,
                                  TVariant AValue)
 {
     if (AValue.IsZeroOrNull())
     {
         AControl.Date = null;
     }
 }
Ejemplo n.º 13
0
            public void New()
            {
                Console.WriteLine("Create");
                TVariant arg = TVariant.Zero;

                fileSystem.ExecuteTextCommand("create", ref arg);
                GetLastError(arg);
            }
Ejemplo n.º 14
0
        /// <summary>
        /// get a session variable, not decoded yet
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static TVariant GetVariant(string name)
        {
            if ((FSessionValues != null) && FSessionValues.Keys.Contains(name))
            {
                return(TVariant.DecodeFromString(FSessionValues[name]));
            }

            return(new TVariant((object)null));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// get a session variable
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static object GetVariable(string name)
        {
            if ((FSessionValues != null) && FSessionValues.Keys.Contains(name))
            {
                return(TVariant.DecodeFromString(FSessionValues[name]).ToObject());
            }

            return(null);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="precalculatedColumns"></param>
        /// <returns></returns>
        public TVariant Precalculate(TVariant[] precalculatedColumns)
        {
            String strCalculation;
            TRptDataCalcCalculation rptDataCalcCalculation;
            TRptCalculation         rptCalculation;

            TVariant ReturnValue = new TVariant();

            // calculation is used for display in the GUI, formula is used for adding ledgers
            if ((!GetParameters().Exists("param_calculation", column, Depth)))
            {
                return(ReturnValue);
            }

            if (GetParameters().Exists("param_formula", column, Depth))
            {
                strCalculation = GetParameters().Get("param_formula", column, Depth).ToString();
            }
            else
            {
                strCalculation = GetParameters().Get("param_calculation", column, Depth).ToString();
            }

            rptCalculation = ReportStore.GetCalculation(CurrentReport, strCalculation);

            if (rptCalculation == null)
            {
                ReturnValue = EvaluateFunctionCalculation(strCalculation, precalculatedColumns);
            }
            else
            {
                rptDataCalcCalculation = new TRptDataCalcCalculation(this);

                if (!rptDataCalcCalculation.EvaluateCalculationFunction(rptCalculation.rptGrpQuery, ref precalculatedColumns, ref ReturnValue))
                {
                    ReturnValue = rptDataCalcCalculation.EvaluateCalculationAll(rptCalculation,
                                                                                null,
                                                                                rptCalculation.rptGrpTemplate,
                                                                                rptCalculation.rptGrpQuery).VariantValue;

                    if (ReturnValue.IsZeroOrNull())
                    {
                        ReturnValue.ApplyFormatString(rptCalculation.strReturnsFormat);
                        return(ReturnValue);
                    }

                    // Removed some code from here due to Bug 3081 Reports crash if data contains the word SELECT
                    // Even if there were a case for running SQL at this point, it wouldn't work anyway due
                    // to the "" parameter in the call to DatabaseConnection.SelectDT().
                }

                ReturnValue.ApplyFormatString(rptCalculation.strReturnsFormat);
            }

            return(ReturnValue);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// constructor
 /// </summary>
 public TParameter(String pname,
                   TVariant pvalue,
                   int pcolumn,
                   int plevel)
 {
     name   = pname;
     value  = pvalue;
     column = pcolumn;
     level  = plevel;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// returns true if the value is zero or null
        /// </summary>
        public bool IsZeroOrNull()
        {
            if (IsVariant)
            {
                return(FVariantValue.IsZeroOrNull());
            }
            TVariant v = new TVariant(this.FSQLStmt);

            return(v.IsZeroOrNull());
        }
Ejemplo n.º 19
0
        /// <summary>
        /// add an odbc parameter, and replace the placeholders
        /// </summary>
        public void AddOdbcParameters(string APrefix, string AName, string APostfix, TVariant AValue)
        {
            if (IsVariant)
            {
                this.FSQLStmt = this.FVariantValue.ToString();
            }

            int pos            = 0;
            int parampos       = 0;
            int parameterIndex = 0;

            int wherePos = this.FSQLStmt.ToUpper().IndexOf(" WHERE ");

            pos = this.FSQLStmt.IndexOf(APrefix + AName + APostfix, pos);

            if (pos == -1)
            {
                return;
            }

            if (wherePos > pos)
            {
                TLogging.Log(this.FSQLStmt);
                throw new Exception("AddOdbcParameters: do not replace table names with odbc parameters");
            }

            while ((pos = this.FSQLStmt.IndexOf(APrefix + AName + APostfix, pos)) != -1)
            {
                while ((parampos != -1) && (parampos <= pos))
                {
                    parampos = this.FSQLStmt.IndexOf("PARAMETER?", parampos + 1);

                    if ((parampos != -1) && (parampos <= pos))
                    {
                        parameterIndex++;
                    }
                }
                pos++;
                parampos = pos;

                if (APrefix == "{")
                {
                    // force a string. needed for example for cost centre codes
                    AValue = new TVariant(AValue.ToString(), true);
                }

                this.FOdbcParameters.Insert(parameterIndex, AValue.ToOdbcParameter(AName));

                // we have added now a parameter, so this needs to be counted.
                // this is important if there are multiple occurances for the same parameter
                parameterIndex++;
            }

            this.FSQLStmt = this.FSQLStmt.Replace(APrefix + AName + APostfix, "PARAMETER?");
        }
Ejemplo n.º 20
0
            public bool Remove(Item item)
            {
                Console.WriteLine("Remove " + item.FullName);
                TVariant arg = TVariant.Zero;

                fileSystem.ExecuteTextCommand(
                    String.Format("{0} {1}", "remove", item.FullName),
                    ref arg);
                GetLastError(arg);
                return((bool)arg);
            }
Ejemplo n.º 21
0
 public bool Add(Item item)
 {
     Console.WriteLine("Add " + item.HDDPath);
     Console.WriteLine("As " + item.FullName);
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar(
         String.Format("{0} {1};{2}", "add", item.HDDPath, item.Directory),
         ref arg);
     GetLastError(arg);
     return arg.AsBool();
 }
Ejemplo n.º 22
0
 public bool Extract(Item item, string newFileName)
 {
     Console.WriteLine("Extract " + item.FullName);
     Console.WriteLine("To " + newFileName);
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar(
         String.Format("{0} {1};{2}", "extract", item.FullName, newFileName),
         ref arg);
     GetLastError(arg);
     return arg.AsBool();
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Read the parameters from a text file (xml format);
        /// used for loading settings
        /// </summary>
        /// <param name="filename">relative or absolute filename
        /// </param>
        /// <returns>void</returns>
        public void Load(String filename)
        {
            XmlNode    startNode;
            XmlNode    node;
            TXMLParser myDoc;
            String     level;
            String     column;
            int        levelNr;
            int        columnNr;
            int        subreport;

            myDoc = new TXMLParser(filename, false);
            try
            {
                startNode = myDoc.GetDocument().DocumentElement;

                if (startNode.Name.ToLower() == "parameters")
                {
                    node = startNode.FirstChild;

                    while (node != null)
                    {
                        if (node.Name == "Parameter")
                        {
                            column    = TXMLParser.GetAttribute(node, "column");
                            level     = TXMLParser.GetAttribute(node, "level");
                            subreport = TXMLParser.GetIntAttribute(node, "subreport");
                            columnNr  = -1;
                            levelNr   = -1;

                            if (column.Length != 0)
                            {
                                columnNr = (int)StringHelper.StrToInt(column);
                            }

                            if (level.Length != 0)
                            {
                                levelNr = (int)StringHelper.StrToInt(level);
                            }

                            Add(TXMLParser.GetAttribute(node, "id"),
                                TVariant.DecodeFromString(TXMLParser.GetAttribute(node, "value")),
                                columnNr, levelNr, subreport);
                        }

                        node = node.NextSibling;
                    }
                }
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
        }
Ejemplo n.º 24
0
            public bool Open(string filename)
            {
                Console.WriteLine("Open " + filename);
                TVariant arg = TVariant.Zero;

                fileSystem.ExecuteTextCommand(
                    String.Format("{0} {1}", "open", filename),
                    ref arg);
                GetLastError(arg);
                return((bool)arg);
            }
Ejemplo n.º 25
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="copy"></param>
 public TParameter(TParameter copy)
 {
     name             = copy.name;
     value            = copy.value;
     column           = copy.column;
     level            = copy.level;
     subreport        = copy.subreport;
     this.pRptElement = copy.pRptElement;
     this.pRptGroup   = copy.pRptGroup;
     this.paramType   = copy.paramType;
 }
Ejemplo n.º 26
0
            public bool Extract(Item item, string newFilename)
            {
                Console.WriteLine("Extract " + item.FullName);
                Console.WriteLine("To " + newFilename);
                TVariant arg = TVariant.Zero;

                fileSystem.ExecuteTextCommand(
                    String.Format("{0} {1};{2}", "extract", item.FullName, newFilename),
                    ref arg);
                GetLastError(arg);
                return((bool)arg);
            }
Ejemplo n.º 27
0
            public bool Add(Item item)
            {
                Console.WriteLine("Add " + item.HDDPath);
                Console.WriteLine("As " + item.FullName);
                TVariant arg = TVariant.Zero;

                fileSystem.ExecuteTextCommand(
                    String.Format("{0} {1};{2}", "add", item.HDDPath, item.Directory),
                    ref arg);
                GetLastError(arg);
                return((bool)arg);
            }
Ejemplo n.º 28
0
        /// <summary>
        /// For development and testing purposes this Method can either execute actions that
        /// are set up by the program 'PetraMultiStart' (indicated by 'RunAutoTests=true' on
        /// the command line) OR open a screen with parameters that
        /// come either from the .config file or Command Line (indicated by 'TestAction="xxx"').
        /// The 'Test Action' will not be run if the Control Key is pressed.
        /// </summary>
        /// <remarks>
        /// sample action: TestAction="Namespace=Ict.Petra.Client.MPartner.Gui,ActionOpenScreen=TFrmPartnerEdit2,PartnerKey=0043005002,InitiallySelectedTabPage=petpDetails"
        ///</remarks>
        private void RunTestAction()
        {
            string DisconnectTimeFromCommandLine = TAppSettingsManager.GetValue("DisconnectTime");

#if TODORemoting
            if (TAppSettingsManager.GetBoolean("RunAutoTests", false) == true)
            {
                // We need to manually 'fix up' the value of DisconnectTime that we get from .NET when we request
                // the commandline parameters as an array because .NET removes quotation marks in two places where
                // they were present on the command line. Those two quotation marks need to be there as the call to
                // TVariant.DecodeFromString() will not succeed if they aren't there in their proper places!
                DisconnectTimeFromCommandLine = DisconnectTimeFromCommandLine.Substring(
                    0, DisconnectTimeFromCommandLine.IndexOf(':') + 1) +
                                                "\"" + DisconnectTimeFromCommandLine.Substring(
                    DisconnectTimeFromCommandLine.IndexOf(':') + 1) + "\"";

                TestRunner = new PetraClient_AutomatedAppTest.TAutomatedAppTest(
                    TAppSettingsManager.GetValue("AutoTestConfigFile"),
                    TAppSettingsManager.GetValue("AutoTestParameters"),
                    TVariant.DecodeFromString(DisconnectTimeFromCommandLine).ToDate(),
                    TConnectionManagementBase.GConnectionManagement.ClientName);

                TestRunner.TestForm = this;
                TestRunner.ClientID = TConnectionManagementBase.GConnectionManagement.ClientID;
                TestRunner.Start(this);
            }
            else
#endif

            if (System.Windows.Forms.Form.ModifierKeys != Keys.Control)
            {
                string testAction = TAppSettingsManager.GetValue("TestAction", false);

                if (testAction != TAppSettingsManager.UNDEFINEDVALUE)
                {
                    XmlDocument temp           = new XmlDocument();
                    XmlNode     testActionNode = temp.CreateElement("testAction");
                    temp.AppendChild(testActionNode);

                    testAction = testAction.Trim(new char[] { '"' });

                    while (testAction.Length > 0)
                    {
                        string[]     pair = StringHelper.GetNextCSV(ref testAction, ",").Split(new char[] { '=' });
                        XmlAttribute attr = temp.CreateAttribute(pair[0]);
                        attr.Value = pair[1];
                        testActionNode.Attributes.Append(attr);
                    }

                    TLstTasks.ExecuteAction(testActionNode, null);
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Read the parameters from a text file (json format);
        /// used for loading settings
        /// </summary>
        /// <param name="filename">relative or absolute filename
        /// </param>
        /// <returns>void</returns>
        public void Load(String filename)
        {
            String jsonString;

            if (!System.IO.File.Exists(filename))
            {
                throw new Exception("file " + filename + " could not be found.");
            }

            using (StreamReader sr = new StreamReader(filename))
            {
                jsonString = sr.ReadToEnd();
            }

            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Object[]             list       = (Object[])serializer.DeserializeObject(jsonString);

                foreach (Dictionary <string, object> param in list)
                {
                    string   name = String.Empty;
                    int      columnNr = -1, levelNr = -1;
                    TVariant value = new TVariant();
                    foreach (KeyValuePair <string, object> entry in param)
                    {
                        if (entry.Key == "name")
                        {
                            name = entry.Value.ToString();
                        }
                        else if (entry.Key == "column")
                        {
                            columnNr = Convert.ToInt32(entry.Value);
                        }
                        else if (entry.Key == "level")
                        {
                            levelNr = Convert.ToInt32(entry.Value);
                        }
                        else if (entry.Key == "value")
                        {
                            value = TVariant.DecodeFromString(entry.Value.ToString());
                        }
                    }

                    Add(name, value, columnNr, levelNr);
                }
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Common procedure to retrieve a parameter or a default value; will return a TVariant object
        ///
        /// </summary>
        /// <returns>void</returns>
        public TVariant GetOrDefault(String parameterId, int column, TVariant ADefault)
        {
            TVariant ReturnValue;

            ReturnValue = Get(parameterId, column, -1, eParameterFit.eBestFit);

            if (ReturnValue.IsNil())
            {
                ReturnValue = ADefault;
            }

            return(ReturnValue);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// add more to the variant
        /// </summary>
        public void Add(TVariant v, string format = "")
        {
            if (FSQLStmt == string.Empty)
            {
                FSQLStmt = "TVariant";
            }
            else if (!IsVariant)
            {
                this.FVariantValue = new TVariant(this.FSQLStmt);
                FSQLStmt           = "TVariant";
            }

            this.FVariantValue.Add(v, format);
        }
Ejemplo n.º 32
0
 private void GetLastError(TVariant arg)
 {
     if ((bool)arg)
     {
         LastError = "";
         return;
     }
     LastError = MarshalUtils.MarshalString((pnt, length) =>
     {
         fileSystem.ExecuteTextCommandEx("last_error", pnt, out length);
         return(length);
     });
     Console.WriteLine(LastError);
 }
Ejemplo n.º 33
0
 public void New()
 {
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar("create", ref arg);
     GetLastError(arg);
 }
Ejemplo n.º 34
0
 public void Close()
 {
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar("close", ref arg);
     GetLastError(arg);
 }
Ejemplo n.º 35
0
 private void GetLastError(TVariant arg)
 {
     if ((bool)arg)
     {
         LastError = "";
         return;
     }
     LastError = MarshalUtils.MarshalString((pnt, length) =>
     {
         fileSystem.ExecuteTextCommandEx("last_error", pnt, out length);
         return length;
     });
     Console.WriteLine(LastError);
 }
Ejemplo n.º 36
0
 private void GetLastError(TVariant arg)
 {
     if (arg.AsBool()) {
         LastError = "";
         return;
     }
     LastError = MarshalUtils.MarshalString((pnt, length) => {
         FileSystem.ExecCmdStr("last_error", pnt, out length);
         return length;
     });
     Console.WriteLine(LastError);
 }
Ejemplo n.º 37
0
 public bool Save(string fileName)
 {
     if (Path.HasExtension(fileName))
         fileName = Path.ChangeExtension(fileName, ".dcp");
     else
         fileName += ".dcp";
     Console.WriteLine("Save as " + fileName);
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar(
         String.Format("{0} {1}", "save", fileName),
         ref arg);
     GetLastError(arg);
     return arg.AsBool();
 }
Ejemplo n.º 38
0
 public bool Remove(Item item)
 {
     Console.WriteLine("Remove " + item.FullName);
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar(
         String.Format("{0} {1}", "remove", item.FullName),
         ref arg);
     GetLastError(arg);
     return arg.AsBool();
 }
Ejemplo n.º 39
0
 public bool Open(string fileName)
 {
     Console.WriteLine("Open " + fileName);
     TVariant arg = new TVariant();
     FileSystem.ExecCmdVar(
         String.Format("{0} {1}", "open", fileName),
         ref arg);
     GetLastError(arg);
     return arg.AsBool();
 }