Ejemplo n.º 1
0
        /// <summary>
        /// Removes one parameter from the parameter list
        /// </summary>
        /// <param name="parameterId">name of the parameter</param>
        /// <returns>true if successful, otherwise false</returns>
        public bool RemoveParameter(String parameterId)
        {
            bool returnValue = false;

            TParameter ParameterToRemove = Parameters.GetParameter(parameterId);

            if (ParameterToRemove != null)
            {
                Parameters.RemoveVariable(parameterId);
                returnValue = true;
            }

            return(returnValue);
        }
Ejemplo n.º 2
0
        private void readParameter(TMethod mem)
        {
            TParameter param = new TParameter();
            if (currentToken.token == ECodeToken.brBraceEnd)
            {
                return;
            }

            if (currentToken.token == ECodeToken.syComma)
            {
                getNextToken();
                return;
            }

            if (currentToken.token == ECodeToken.kwIn)
            {
                getNextToken();
            }

            if (currentToken.token == ECodeToken.brSmallBraceBegin)
            {
                param.attributes = readAttributes();
            }

            if (currentToken.token == ECodeToken.ltString)
            {
                param.type = readType();
                param.type.isResult = false;

                if (currentToken.token == ECodeToken.syPoint) //method(string name...)
                {
                    param.type.isArray = true;
                    param.paramArray = true;
                    getNextToken();
                    getNextToken();
                    getNextToken();
                }

                param.name = currentToken.value;
                mem.parameters.Add(param);
                getNextToken();
            }
        }
Ejemplo n.º 3
0
        private static void setTransformations()
        {
            //In c#-bindinds, types beginning with "HTML" will be renamed to "Html".
            //THe output generates still the "HTML" version, for example
            //c#: el is HtmlImageElement
            //js: el instanceof HTMLImageElement

            Transformations.renameType("EventListener", "Function");
            Transformations.generateElementConstructorForType("HTML", "Element"); //This will extract "hr" from HtmlHrElement and generates document.createElement('hr')
            Transformations.generateElementConstructorForType("SVG", "Element");

            //Extracting the tagName will sometimes not get the correct tagname. Here they can specified more detailed.
            Transformations.generateElementConstructorCorrectTagName("HTMLImageElement", "img");
            Transformations.generateElementConstructorCorrectTagName("HTMLAnchorElement", "a");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableCaptionElement", "caption");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableCellElement", "td");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableColElement", "col");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableRowElement", "tr");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableSectionElement", "tbody"); //TODO: It can be thead or tfoot, too!
            Transformations.generateElementConstructorCorrectTagName("HTMLDListElement", "dl");
            Transformations.generateElementConstructorCorrectTagName("HTMLOListElement", "ol");
            Transformations.generateElementConstructorCorrectTagName("HTMLUListElement", "ul");
            Transformations.generateElementConstructorCorrectTagName("HTMLDictionaryElement", "d");
            Transformations.generateElementConstructorCorrectTagName("HTMLParagraphElement", "p");
            Transformations.generateElementConstructorCorrectTagName("HTMLModElement", "tbody"); // TODO: Could be del or ins, but not mod. mod is an interface.

            //The Webkit IDL files have sometimes another return type for internal use. Here they can be corrected.
            Transformations.changeDelegateResultType("PositionCallback", "void");
            Transformations.changeDelegateResultType("PositionErrorCallback", "void");

            Transformations.renameType("Event", "DomEvent");

            var jsonMethod = new TMethod(null);
            jsonMethod.name = "JSON";
            jsonMethod.resultType = new TType() { name = "Object" };
            jsonMethod.parameters.Add(new TParameter() { name = "JSONString", type = new TType() { name = "String" } });
            Transformations.addMethodToType("Window", jsonMethod);

            var sendMethod = new TMethod(null);
            sendMethod.name = "send";
            sendMethod.resultType = new TType() { name = "void" };
            var Param = new TParameter() { name = "data", type = new TType() { name = "*" } };
            Param.attributes.Add(new TNameAttribute(){ name="Optional" });
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod = new TMethod(null);
            sendMethod.name = "sendArrayBuffer";
            sendMethod.aliasName = "send";
            sendMethod.resultType = new TType() { name = "void" };
            Param = new TParameter() { name = "data", type = new TType() { name = "ArrayBuffer" } };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod = new TMethod(null);
            sendMethod.name = "sendBlob";
            sendMethod.aliasName = "send";
            sendMethod.resultType = new TType() { name = "void" };
            Param = new TParameter() { name = "data", type = new TType() { name = "Blob" } };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod = new TMethod(null);
            sendMethod.name = "sendDocument";
            sendMethod.aliasName = "send";
            sendMethod.resultType = new TType() { name = "void" };
            Param = new TParameter() { name = "data", type = new TType() { name = "Document" } };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod = new TMethod(null);
            sendMethod.name = "sendString";
            sendMethod.aliasName = "send";
            sendMethod.resultType = new TType() { name = "void" };
            Param = new TParameter() { name = "data", type = new TType() { name = "String" } };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod = new TMethod(null);
            sendMethod.name = "sendFormData";
            sendMethod.aliasName = "send";
            sendMethod.resultType = new TType() { name = "void" };
            Param = new TParameter() { name = "data", type = new TType() { name = "FormData" } };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// function selection
        /// </summary>
        /// <param name="f">function name</param>
        /// <param name="ops">if ops[1] is nil, and f cannot be evaluated, return nil; otherwise if ops is not nil, print an error if f cannot be evaluated</param>
        /// <returns>void</returns>
        private TVariant FunctionSelector(String f, TVariant[] ops)
        {
            TVariant          ReturnValue = null;
            TRptUserFunctions rptUserFunctions;
            String            s;
            String            s2;

            System.Int32 start;
            System.Int32 length;
            String       logMessage;
            bool         FunctionFound;
            int          counter;

            f = f.ToLower();
            TLogging.SetContext("call to function " + f);
            TParameterList myParams = GetParameters();

            if ((f == "eq") || (f == "ne"))
            {
                // check if at least one of the parameters is a variable; otherwise give warning
                if ((ops[1].ToString().IndexOf('{') == -1) && (ops[2].ToString().IndexOf('{') == -1))
                {
                    TLogging.Log(
                        "Warning: comparison should contain at least one variable: " + f.ToString() + '(' + ops[1].ToString() + ',' + ops[2].ToString(
                            ) +
                        ')', TLoggingType.ToLogfile | TLoggingType.ToConsole);
                }
            }

            if ((f == "isnull") || (f == "exists") || (f == "or") || (f == "and") || (f == "iif") || (f == "assign"))
            {
                // need to replace the variables manually
                // either because we don't want them replaced at all (isnull or exists needs the variable name),
                // or because we don't want to evaluate the second parameter if the first one already defines the result (e.g. or)
            }
            else
            {
                for (counter = 1; counter <= ReportingConsts.MAX_FUNCTION_PARAMETER; counter += 1)
                {
                    ops[counter] = EvaluateOperand(ops[counter]);
                }
            }

            if (f == "eq")
            {
                ReturnValue = new TVariant(ops[1].CompareToI(ops[2]) == 0);
            }
            else if (f == "ne")
            {
                ReturnValue = new TVariant(ops[1].CompareToI(ops[2]) != 0);
            }
            else if (f == "lt")
            {
                ReturnValue = new TVariant(ops[1].CompareTo(ops[2]) < 0);
            }
            else if (f == "le")
            {
                ReturnValue = new TVariant(ops[1].CompareTo(ops[2]) <= 0);
            }
            else if (f == "gt")
            {
                ReturnValue = new TVariant(ops[1].CompareTo(ops[2]) > 0);
            }
            else if (f == "ge")
            {
                ReturnValue = new TVariant(ops[1].CompareTo(ops[2]) >= 0);
            }
            else if (f == "sub")
            {
                ReturnValue = new TVariant(ops[1].ToDecimal() - ops[2].ToDecimal());
            }
            else if (f == "adddays")
            {
                ReturnValue = new TVariant(ops[1].ToDate().AddDays(ops[2].ToDouble()));
            }
            else if (f == "add")
            {
                ReturnValue = new TVariant(ops[1].ToDecimal() + ops[2].ToDecimal());
            }
            else if (f == "additems")
            {
                length = ops[1].ToInt() + 1;

                decimal result = 0.0M;

                for (counter = 2; counter <= length; ++counter)
                {
                    result += ops[counter].ToDecimal();
                }

                ReturnValue = new TVariant(result);
            }
            else if (f == "mul")
            {
                ReturnValue = new TVariant(ops[1].ToDecimal() * ops[2].ToDecimal());
            }
            else if (f == "div")
            {
                if (ops[2].ToDecimal() == 0)
                {
                    ReturnValue = new TVariant(0.0);
                }
                else
                {
                    ReturnValue = new TVariant(ops[1].ToDecimal() / ops[2].ToDecimal());
                }
            }
            else if (f == "mod")
            {
                if (ops[2].ToDecimal() == 0)
                {
                    ReturnValue = new TVariant(0.0);
                }
                else
                {
                    ReturnValue = new TVariant(ops[1].ToInt64() % ops[2].ToInt64());
                }
            }
            else if (f == "floor")
            {
                ReturnValue = new TVariant(Math.Floor(ops[1].ToDecimal()));
            }
            else if (f == "round")
            {
                ReturnValue = new TVariant(Math.Round(ops[1].ToDecimal()));
            }
            else if (f == "not")
            {
                ReturnValue = new TVariant(!ops[1].ToBool());
            }
            else if (f == "iif")
            {
                // iif ( condition, value_if_true, value_if_false )
                ops[1] = EvaluateOperand(ops[1]);

                if (ops[1].ToBool() == true)
                {
                    ops[2]      = EvaluateOperand(ops[2]);
                    ReturnValue = new TVariant(ops[2]);
                }
                else
                {
                    ops[3]      = EvaluateOperand(ops[3]);
                    ReturnValue = new TVariant(ops[3]);
                }
            }
            else if (f == "or")
            {
                ops[1] = EvaluateOperand(ops[1]);

                if (ops[1].ToBool() == false)
                {
                    ops[2]      = EvaluateOperand(ops[2]);
                    ReturnValue = new TVariant(ops[2].ToBool());
                }
                else
                {
                    ReturnValue = new TVariant(true);
                }
            }
            else if (f == "and")
            {
                ops[1] = EvaluateOperand(ops[1]);

                if (ops[1].ToBool() == true)
                {
                    ops[2]      = EvaluateOperand(ops[2]);
                    ReturnValue = new TVariant(ops[2].ToBool());
                }
                else
                {
                    ReturnValue = new TVariant(false);
                }
            }
            else if (f == "log")
            {
                if (ops[2] != null)
                {
                    ReturnValue = new TVariant(ops[1].ToString() + " " + ops[2].ToString());
                }
                else
                {
                    if (myParams.Exists(ops[1].ToString()))
                    {
                        myParams.Debug(ops[1].ToString());
                        ReturnValue = new TVariant();
                    }
                    else
                    {
                        ReturnValue = ops[1];
                    }
                }

                if (!ReturnValue.IsNil())
                {
                    TLogging.Log(ReturnValue.ToString());
                }
            }
            else if (f == "length")
            {
                ReturnValue = new TVariant(ops[1].ToString().Length);
            }
            else if (StringHelper.IsSame(f, "ContainsCSV"))
            {
                ReturnValue = new TVariant(StringHelper.ContainsCSV(ops[1].ToString(), ops[2].ToString()));
            }
            else if (f == "replace")
            {
                ReturnValue = new TVariant(ops[1].ToString().Replace(ops[2].ToString(), ops[3].ToString()));
            }
            else if ((f == "substring") || (f == "substr"))
            {
                s      = ops[1].ToString();
                start  = ops[2].ToInt();
                length = ops[3].ToInt();

                if ((start < s.Length) && (start + length <= s.Length) && (length > 0))
                {
                    ReturnValue = new TVariant(s.Substring(start, length));
                }
                else
                {
                    ReturnValue = new TVariant("");
                    TLogging.Log("Text is not long enough or length is wrong: " + s + ' ' + start.ToString() + ' ' + length.ToString());
                }
            }
            else if ((f == "substringright") || (f == "substrright"))
            {
                s      = ops[1].ToString();
                length = ops[2].ToInt();
                start  = s.Length - length;

                if ((start < s.Length) && (start + length <= s.Length) && (length > 0))
                {
                    ReturnValue = new TVariant(s.Substring(start, length));
                }
                else
                {
                    ReturnValue = new TVariant("");
                    TLogging.Log("Text is not long enough or length is wrong: " + s + ' ' + start.ToString() + ' ' + length.ToString());
                }
            }
            else if ((f == "substringwithoutright") || (f == "substrwithoutright"))
            {
                s      = ops[1].ToString();
                length = s.Length - ops[2].ToInt();
                start  = 0;

                if ((start < s.Length) && (start + length <= s.Length) && (length > 0))
                {
                    ReturnValue = new TVariant(s.Substring(start, length));
                }
                else
                {
                    ReturnValue = new TVariant("");
                    TLogging.Log("Text is not long enough or length is wrong: " + s + ' ' + start.ToString() + ' ' + length.ToString());
                }
            }
            else if (f == "concatenate")
            {
                s = ops[1].ToString();

                s = s + ops[2].ToString();

                ReturnValue = new TVariant(s);
            }
            else if (f == "concatenateww")
            {
                s      = ops[1].ToString();
                length = ops[3].ToInt();

                s = s.PadRight(s.Length + length);

                s = s + ops[2].ToString();

                ReturnValue = new TVariant(s);
            }
            else if (f == "concatenatewithcomma")
            {
                s  = ops[1].ToString();
                s2 = ops[2].ToString();

                if ((s.Length > 0) &&
                    (s2.Length > 0))
                {
                    s = s + ", ";
                }

                s = s + s2;

                ReturnValue = new TVariant(s);
            }
            else if (f == "format")
            {
                ReturnValue = new TVariant(ops[1].ToFormattedString(ops[2].ToString()));
            }
            else if (f == "formattime")
            {
                String separator = ops[1].ToString();
                String hour      = ops[2].ToString();
                String min       = ops[3].ToString();
                String sec       = "";

                if ((ops.Length > 4) && (ops[4] != null))
                {
                    sec = ops[4].ToString();
                }

                if (hour.Length < 2)
                {
                    hour = "0" + hour;
                }

                if (min.Length < 2)
                {
                    min = "0" + min;
                }

                if ((sec.Length < 2) && (sec.Length > 0))
                {
                    sec = "0" + sec;
                }

                if (sec.Length > 0)
                {
                    ReturnValue = new TVariant(hour + separator + min + separator + sec);
                }
                else
                {
                    ReturnValue = new TVariant(hour + separator + min);
                }
            }
            else if (f == "assign")
            {
                string targetVariableName = ops[1].ToString();

                if (targetVariableName.StartsWith("{") && targetVariableName.EndsWith("}"))
                {
                    targetVariableName = targetVariableName.Substring(1, targetVariableName.Length - 2);
                }

                ops[2] = EvaluateOperand(ops[2]);

                if (myParams.Exists(targetVariableName))
                {
                    // we should overwrite the existing variable, not add on another level
                    TParameter origParameter = myParams.GetParameter(targetVariableName);
                    origParameter.value = ops[2];
                }
                else
                {
                    myParams.Add(targetVariableName, ops[2], -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }

//              TLogging.Log("Assign: " + targetVariableName + "=" + ops[2].ToString());
                ReturnValue = ops[2];
            }
            else if (f == "exists")
            {
                ReturnValue = new TVariant(myParams.Exists(ops[1].ToString(), column, Depth));
            }
            else if (f == "isnull")
            {
                ReturnValue =
                    new TVariant((!myParams.Exists(ops[1].ToString(), column,
                                                   Depth) || myParams.Get(ops[1].ToString(), column, Depth).IsZeroOrNull()));
            }
            else if (f == "template")
            {
                TRptCalculation         rptTemplate        = ReportStore.GetCalculation(CurrentReport, ops[1].ToString());
                TRptDataCalcCalculation rptTempCalculation = new TRptDataCalcCalculation(this);
                ReturnValue = rptTempCalculation.Calculate(rptTemplate, null).VariantValue;
            }
            else if (f == "columnexist")
            {
                String ColumnID    = ops[1].ToString();
                bool   ColumnExist = false;

                System.Data.DataTable TempTable = myParams.ToDataTable();
                int numColumns = TempTable.Columns.Count;

                foreach (System.Data.DataRow Row in TempTable.Rows)
                {
                    for (int Counter = 0; Counter < numColumns; ++Counter)
                    {
                        if (Row[Counter].ToString() == ColumnID)
                        {
                            ColumnExist = true;
                            break;
                        }
                    }

                    if (ColumnExist)
                    {
                        break;
                    }
                }

                ReturnValue = new TVariant(ColumnExist);
            }
            else if (f == "conditionrow")
            {
                ReturnValue = new TVariant(ops[1]);

                if (ReturnValue.ToBool() == false)
                {
                    // clear this row, we don't want to display it
                    // set all parameters of this row to NULL
                    myParams.Add("DONTDISPLAYROW", new TVariant(true));
                }
                else
                {
                    myParams.Add("DONTDISPLAYROW", new TVariant(false), -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }
            }
            else if (f == "column")
            {
                if ((ops[1].ToInt() >= 0) && (ops[1].ToInt() < CurrentColumns.Length))
                {
                    ReturnValue = new TVariant(CurrentColumns[ops[1].ToInt()]);
                }
                else
                {
                    TLogging.Log("referenced column does not exist: " + ops[1].ToString());
                    ReturnValue = new TVariant();
                }
            }
            else if (f == "HasColumns".ToLower())
            {
                ReturnValue = new TVariant(Results.HasColumns(this.LineId));
            }
            else if (f == "HasChildRows".ToLower())
            {
                ReturnValue = new TVariant(Results.HasChildRows(this.LineId));
            }
            else if (f == "CountChildRows".ToLower())
            {
                ReturnValue = new TVariant(Results.CountChildRows(this.LineId));
            }
            else if (f == "HasChildColumns".ToLower())
            {
                ReturnValue = new TVariant(Results.HasChildColumns(this.LineId));
            }
            else if (f == "invisible".ToLower())
            {
                // need to return true so that calculation happens.
                ReturnValue = new TVariant(true);
            }
            else if (f == "fatherColumn")
            {
                ReturnValue = GetParentValue(ParentRowId, ops[1].ToInt());
            }
            else if (f == "childColumn")
            {
                ReturnValue = GetChildValue(LineId, ops[1].ToInt());
            }
            else if (StringHelper.IsSame(f, "SecondLevelColumn"))
            {
                ReturnValue = Get2ndLevelValue(ParentRowId, ops[1].ToInt());
            }
            else if (StringHelper.IsSame(f, "FirstLevelColumn"))
            {
                ReturnValue = Get1stLevelValue(ParentRowId, ops[1].ToInt());
            }
            else if (StringHelper.IsSame(f, "GetShortCaption"))
            {
                ReturnValue = new TVariant(GetShortCaption(ops[1].ToInt()));
            }
            else if (StringHelper.IsSame(f, "GetCaption"))
            {
                ReturnValue = new TVariant(GetCaption(ops[1].ToInt()));
            }
            else if (StringHelper.IsSame(f, "getSumLower2Report"))
            {
                if (ops[3] == null)
                {
                    ReturnValue = new TVariant(GetSumLower2Report(ops[1].ToInt(), ops[2].ToInt(), true), "currency");
                }
                else
                {
                    ReturnValue = new TVariant(GetSumLower2Report(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToBool()), "currency");
                }
            }
            else if (StringHelper.IsSame(f, "getSumLowerReport"))
            {
                if (ops[3] == null)
                {
                    ReturnValue = new TVariant(GetSumLowerReport(ops[1].ToInt(), ops[2].ToInt(), true), "currency");
                }
                else
                {
                    ReturnValue = new TVariant(GetSumLowerReport(ops[1].ToInt(), ops[2].ToInt(), ops[3].ToBool()), "currency");
                }
            }
            else if (StringHelper.IsSame(f, "getSumLowerReportCredit"))
            {
                ReturnValue = new TVariant(GetSumLowerReportCredit(ops[1].ToInt(), ops[2].ToInt()), "currency");
            }
            else
            {
                FunctionFound = false;

                foreach (System.Type userFunctionsClass in FUserFunctions)
                {
                    if (!FunctionFound)
                    {
                        rptUserFunctions = (TRptUserFunctions)Activator.CreateInstance(userFunctionsClass);

                        if (rptUserFunctions.FunctionSelector(this, f, ops, out ReturnValue))
                        {
                            FunctionFound = true;
                            break;
                        }

                        rptUserFunctions = null;
                    }
                }

                if (!FunctionFound)
                {
                    TRptCalculation calculation = ReportStore.GetCalculation(CurrentReport, f);

                    if (calculation != null)
                    {
                        TRptDataCalcCalculation calc = new TRptDataCalcCalculation(this);
                        ReturnValue = calc.EvaluateCalculation(calculation, null, String.Empty, -1);
                    }
                    else if (ops[1] == null)
                    {
                        // don't print an error if ops[1] is null;
                        // just return f;
                        // this is needed e.g. for HasChildRows etc, called from TRptEvaluator.evaluateOperator
                        ReturnValue = null;
                    }
                    else
                    {
                        ReturnValue = new TVariant();
                        logMessage  = "unknown function " + f;

                        if (ops[1] != null)
                        {
                            logMessage = logMessage + ' ' + ops[1].ToString();
                        }

                        if (ops[2] != null)
                        {
                            logMessage = logMessage + ' ' + ops[2].ToString();
                        }

                        TLogging.Log(logMessage);
                    }
                }
            }

            TLogging.SetContext("");
            return(ReturnValue);
        }
Ejemplo n.º 5
0
        private static void setTransformations()
        {
            //In c#-bindinds, types beginning with "HTML" will be renamed to "Html".
            //THe output generates still the "HTML" version, for example
            //c#: el is HtmlImageElement
            //js: el instanceof HTMLImageElement

            Transformations.renameType("EventListener", "Function");
            Transformations.generateElementConstructorForType("HTML", "Element"); //This will extract "hr" from HtmlHrElement and generates document.createElement('hr')
            Transformations.generateElementConstructorForType("SVG", "Element");

            //Extracting the tagName will sometimes not get the correct tagname. Here they can specified more detailed.
            Transformations.generateElementConstructorCorrectTagName("HTMLImageElement", "img");
            Transformations.generateElementConstructorCorrectTagName("HTMLAnchorElement", "a");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableCaptionElement", "caption");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableCellElement", "td");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableColElement", "col");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableRowElement", "tr");
            Transformations.generateElementConstructorCorrectTagName("HTMLTableSectionElement", "tbody"); //TODO: It can be thead or tfoot, too!
            Transformations.generateElementConstructorCorrectTagName("HTMLDListElement", "dl");
            Transformations.generateElementConstructorCorrectTagName("HTMLOListElement", "ol");
            Transformations.generateElementConstructorCorrectTagName("HTMLUListElement", "ul");
            Transformations.generateElementConstructorCorrectTagName("HTMLDictionaryElement", "d");
            Transformations.generateElementConstructorCorrectTagName("HTMLParagraphElement", "p");
            Transformations.generateElementConstructorCorrectTagName("HTMLModElement", "tbody"); // TODO: Could be del or ins, but not mod. mod is an interface.

            //The Webkit IDL files have sometimes another return type for internal use. Here they can be corrected.
            Transformations.changeDelegateResultType("PositionCallback", "void");
            Transformations.changeDelegateResultType("PositionErrorCallback", "void");

            Transformations.renameType("Event", "DomEvent");

            var jsonMethod = new TMethod(null);

            jsonMethod.name       = "JSON";
            jsonMethod.resultType = new TType()
            {
                name = "Object"
            };
            jsonMethod.parameters.Add(new TParameter()
            {
                name = "JSONString", type = new TType()
                {
                    name = "String"
                }
            });
            Transformations.addMethodToType("Window", jsonMethod);

            var sendMethod = new TMethod(null);

            sendMethod.name       = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            var Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "*"
                }
            };

            Param.attributes.Add(new TNameAttribute()
            {
                name = "Optional"
            });
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod            = new TMethod(null);
            sendMethod.name       = "sendArrayBuffer";
            sendMethod.aliasName  = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "ArrayBuffer"
                }
            };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod            = new TMethod(null);
            sendMethod.name       = "sendBlob";
            sendMethod.aliasName  = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "Blob"
                }
            };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod            = new TMethod(null);
            sendMethod.name       = "sendDocument";
            sendMethod.aliasName  = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "Document"
                }
            };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod            = new TMethod(null);
            sendMethod.name       = "sendString";
            sendMethod.aliasName  = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "String"
                }
            };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);

            sendMethod            = new TMethod(null);
            sendMethod.name       = "sendFormData";
            sendMethod.aliasName  = "send";
            sendMethod.resultType = new TType()
            {
                name = "void"
            };
            Param = new TParameter()
            {
                name = "data", type = new TType()
                {
                    name = "FormData"
                }
            };
            sendMethod.parameters.Add(Param);
            Transformations.addMethodToType("XMLHttpRequest", sendMethod);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="masterRow"></param>
        /// <param name="condition"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public Boolean SavePrecalculation(int masterRow, String condition, String code)
        {
            Boolean ReturnValue;

            TVariant[]        precalculatedColumns;
            TVariant[]        precalculatedDescr = new TVariant[2];
            TVariant[]        header             = new TVariant[2];
            Boolean           display;
            Boolean           hideRow = false;
            Boolean           debit_credit_indicator;
            Boolean           param_hide_empty_lines = false;
            int               counter;
            String            values;
            TRptDataCalcValue rptDataCalcValue;
            List <TRptValue>  rptGrpValue;
            int               maxDisplayColumns;
            int               numberColumns;
            int               ColumnPartnerName = -1;
            int               ColumnPartnerKey  = -1;
            TResult           newRow;

            ReturnValue       = false;
            condition         = condition.ToLower();
            maxDisplayColumns = Results.GetMaxDisplayColumns();
            numberColumns     = maxDisplayColumns;

            while (Parameters.Exists("param_calculation", numberColumns, -1))
            {
                numberColumns = numberColumns + 1;
            }

            precalculatedColumns = new TVariant[numberColumns];

            for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
            {
                precalculatedColumns[counter] = new TVariant();
            }

            if (!Parameters.Exists("debit_credit_indicator", -1, Depth))
            {
                debit_credit_indicator = true;
            }
            else
            {
                debit_credit_indicator = Parameters.Get("debit_credit_indicator", -1, Depth).ToBool();
            }

            if (Parameters.Get("param_hide_empty_lines").ToString() == "true")
            {
                param_hide_empty_lines = true;
            }

            if (Depth > 0)
            {
                if (debit_credit_indicator)
                {
                    Parameters.Add("debit_credit_indicator", true, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }
                else
                {
                    Parameters.Add("debit_credit_indicator", false, -1, -1, null, null, ReportingConsts.CALCULATIONPARAMETERS);
                }

                values = Parameters.Get("ControlSource", ReportingConsts.ALLCOLUMNS, Depth).ToString();

                if (values == "calculation")
                {
                    // first calculate the invisible helper Columns
                    for (counter = maxDisplayColumns; counter <= numberColumns - 1; counter += 1)
                    {
                        column = counter;
                        precalculatedColumns[column] = Precalculate(precalculatedColumns);
                    }

                    // calculate the visible Columns
                    for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
                    {
                        column = counter;
                        precalculatedColumns[column] = Precalculate(precalculatedColumns);

                        if (param_hide_empty_lines)
                        {
                            // if this parameter is set, hide the row when all columns are empty, except
                            // of the column partner name and partner key.
                            TParameter CurrentParameter = Parameters.GetParameter("param_calculation", column, -1, eParameterFit.eExact);

                            if (CurrentParameter.value.ToString() == "Partner Name")
                            {
                                ColumnPartnerName = CurrentParameter.column;
                            }
                            else if (CurrentParameter.value.ToString() == "Partner Key")
                            {
                                ColumnPartnerKey = CurrentParameter.column;
                            }
                        }
                    }

                    if (param_hide_empty_lines)
                    {
                        hideRow = IsRowEmpty(ref precalculatedColumns, ColumnPartnerName, ColumnPartnerKey, 0, maxDisplayColumns - 1);
                    }
                }
                else
                {
                    // first calculate the invisible helper Columns
                    for (counter = maxDisplayColumns; counter <= numberColumns - 1; counter += 1)
                    {
                        CalculateColumnValue(counter, ref precalculatedColumns);
                    }

                    for (counter = 0; counter <= maxDisplayColumns - 1; counter += 1)
                    {
                        CalculateColumnValue(counter, ref precalculatedColumns);
                    }
                }

                rptGrpValue = (List <TRptValue>)Parameters.GetGrpValue("ControlSource",
                                                                       ReportingConsts.HEADERCOLUMN + 1,
                                                                       Depth,
                                                                       eParameterFit.eExact);

                if (rptGrpValue != null)
                {
                    Parameters.Add("headerVISIBLE", new TVariant(true), -1, Depth);
                    column           = ReportingConsts.HEADERCOLUMN + 1;
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    header[0]        = rptDataCalcValue.Calculate(rptGrpValue);
                }

                rptGrpValue = (List <TRptValue>)Parameters.GetGrpValue("ControlSource",
                                                                       ReportingConsts.HEADERCOLUMN + 2,
                                                                       Depth,
                                                                       eParameterFit.eExact);

                if (rptGrpValue != null)
                {
                    Parameters.Add("headerVISIBLE", new TVariant(true), -1, Depth);
                    column           = ReportingConsts.HEADERCOLUMN + 2;
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    header[1]        = rptDataCalcValue.Calculate(rptGrpValue);
                }

                for (counter = 0; counter <= 1; counter += 1)
                {
                    column      = counter - 10;
                    rptGrpValue = (List <TRptValue>)Parameters.GetGrpValue("ControlSource", column, Depth, eParameterFit.eExact);

                    if (rptGrpValue != null)
                    {
                        rptDataCalcValue            = new TRptDataCalcValue(this);
                        precalculatedDescr[counter] = rptDataCalcValue.Calculate(rptGrpValue);
                    }
                }

                debit_credit_indicator = Parameters.Get("debit_credit_indicator", column, Depth).ToBool();
                display = true;
                newRow  = Results.AddRow(masterRow,
                                         LineId,
                                         display,
                                         Depth,
                                         code,
                                         condition,
                                         debit_credit_indicator,
                                         header,
                                         precalculatedDescr,
                                         precalculatedColumns);
                ReturnValue = true;

                if (condition.Length != 0)
                {
                    column  = -1;
                    display = EvaluateCondition(condition);
                }

                if (Parameters.Exists("DONTDISPLAYROW") && (Parameters.Get("DONTDISPLAYROW").ToBool() == true))
                {
                    display = false;
                }

                if ((newRow != null) && ((!display) || hideRow))
                {
                    newRow.display = false;
                    ReturnValue    = false;
                }
            }

            return(ReturnValue);
        }