Пример #1
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);
        }
Пример #2
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;
 }
Пример #3
0
        /// <summary>
        /// Common procedure to retrieve a parameter of any type; will return a TVariant object
        /// </summary>
        /// <returns>void</returns>
        public TVariant Get(String parameterId, int column, int depth, eParameterFit exact)
        {
            TParameter element = GetParameter(parameterId, column, depth, exact);

            if (element != null)
            {
                return(element.value);
            }

            return(new TVariant());
        }
Пример #4
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;
 }
Пример #5
0
        /// <summary>
        /// Common procedure to add a parameter, expects the value as a variant
        /// </summary>
        public void Add(String parameterId, TVariant value, int column = -1, int depth = -1)
        {
            // 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.value = value;
                    return;
                }
            }

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

            Fparameters.Add(element2);
        }
Пример #6
0
        /// <summary>
        /// remove variable completely from list, all occurrences
        /// </summary>
        /// <param name="AParameterId"></param>
        public void RemoveVariable(String AParameterId)
        {
            TParameter toDelete = null;

            do
            {
                if (toDelete != null)
                {
                    Fparameters.Remove(toDelete);
                    toDelete = null;
                }

                foreach (TParameter element in Fparameters)
                {
                    if (StringHelper.IsSame(element.name, AParameterId))
                    {
                        toDelete = element;
                    }
                }
            } while (toDelete != null);
        }
Пример #7
0
        /// <summary>
        /// compare two objects for sorting
        /// </summary>
        int IComparable.CompareTo(Object B)
        {
            TParameter a = this;
            TParameter b = (TParameter)B;

            if (a.name == b.name)
            {
                if (a.level == b.level)
                {
                    if (a.column == b.column)
                    {
                        return(0);
                    }

                    return(a.column > b.column ? 1 : -1);
                }

                return(a.level > b.level ? 1 : -1);
            }

            return(a.name.CompareTo(b.name));
        }
Пример #8
0
        /// <summary>
        /// Common procedure to retrieve a parameter of any type; will return a TParameter object
        ///
        /// </summary>
        /// <returns>void</returns>
        public TParameter GetParameter(String parameterId, int column, int depth, eParameterFit exact)
        {
            int subreport = -1;

            TParameter ReturnValue   = null;
            TParameter columnFit     = null;
            TParameter commonFit     = null;
            TParameter allColumnFit  = null;
            TParameter bestLevelFit  = null;
            TParameter lowerLevelFit = null;
            TParameter anyFit        = null;
            int        closestLevel  = -1;
            int        lowerLevel    = 20;

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

/* Perhaps I'll get more speed if I remove this..
 *          // just to be careful: if curly brackets were used by accident in the xml file, remove them
 *          if (parameterId[0] == '{')
 *          {
 *              TLogging.Log(
 *                  "deprecated: " + parameterId +
 *                  "; make sure your report xml file is correct, you might be using a variable with brackets in a function call to exists or isnull");
 *              parameterId = parameterId.Substring(1, parameterId.Length - 2);
 *
 *              if ((parameterId[0] == '{') || (parameterId[0] == '#'))
 *              {
 *                  parameterId = parameterId.Substring(1, parameterId.Length - 2);
 *              }
 *          }
 */
            foreach (TParameter element in Fparameters)
            {
                if (((element.subreport == subreport) || (element.subreport == -1)) && StringHelper.IsSame(element.name, parameterId))
                {
                    // is there an exact match?
                    if ((element.level == depth) && (element.column == column))
                    {
                        return(element);
                    }

                    // there is a global match
                    if (((element.level == -1) || (element.level == -2)) && (element.column == -1))
                    {
                        commonFit = element;
                    }

                    // there is a match for all data columns (ALLCOLUMNS)
                    if ((element.level == depth) && (element.column == ReportingConsts.ALLCOLUMNS))
                    {
                        allColumnFit = element;
                    }

                    // has the exact column and is valid for all lines (1) or (2)
                    if (((element.level == -1) || (element.level == -2)) && (element.column == column))
                    {
                        columnFit = element;
                    }

                    // has the exact column or an column = 1 and the next line above
                    if (((element.column == -1) || (element.column == column)) && (element.level > closestLevel) && (element.level <= depth))
                    {
                        bestLevelFit = element;
                        closestLevel = element.level;
                    }

                    // has the exact column or an column = 1 and a lower line
                    if (((element.column == -1) || (element.column == column)) && (element.level < lowerLevel) && (element.level > depth))
                    {
                        lowerLevelFit = element;
                        lowerLevel    = element.level;
                    }

                    // we are looking for any occurrence
                    if ((depth == -1) && (column == -1))
                    {
                        anyFit = element;
                    }
                } // if
            }     // foreach

            if (exact == eParameterFit.eExact)
            {
                // no exact fitting element was found
                return(null);
            }

            if (exact == eParameterFit.eAllColumnFit)
            {
                if (allColumnFit != null)
                {
                    ReturnValue = allColumnFit;
                }

                return(ReturnValue);
            }

            if (columnFit != null)
            {
                return(columnFit);
            }

            if (bestLevelFit != null)
            {
                return(bestLevelFit);
            }

            if (commonFit != null)
            {
                return(commonFit);
            }

            if ((lowerLevelFit != null) && (exact == eParameterFit.eBestFitEvenLowerLevel))
            {
                return(lowerLevelFit);
            }

            if ((ReturnValue == null) && (exact == eParameterFit.eBestFit) && (anyFit != null))
            {
                return(anyFit);
            }

            return(ReturnValue);
        }
Пример #9
0
        /// <summary>
        /// Common procedure to retrieve a parameter of any type; will return a TParameter object
        ///
        /// </summary>
        /// <returns>void</returns>
        public TParameter GetParameter(String parameterId, int column = -1, int depth = -1, eParameterFit exact = eParameterFit.eBestFit)
        {
            TParameter ReturnValue   = null;
            TParameter columnFit     = null;
            TParameter commonFit     = null;
            TParameter allColumnFit  = null;
            TParameter bestLevelFit  = null;
            TParameter lowerLevelFit = null;
            TParameter anyFit        = null;
            int        closestLevel  = -1;
            int        lowerLevel    = 20;

            foreach (TParameter element in Fparameters)
            {
                if (StringHelper.IsSame(element.name, parameterId))
                {
                    // is there an exact match?
                    if ((element.level == depth) && (element.column == column))
                    {
                        return(element);
                    }

                    // there is a global match
                    if (((element.level == -1) || (element.level == -2)) && (element.column == -1))
                    {
                        commonFit = element;
                    }

                    // there is a match for all data columns (ALLCOLUMNS)
                    if ((element.level == depth) && (element.column == TParameter.ALLCOLUMNS))
                    {
                        allColumnFit = element;
                    }

                    // has the exact column and is valid for all lines (1) or (2)
                    if (((element.level == -1) || (element.level == -2)) && (element.column == column))
                    {
                        columnFit = element;
                    }

                    // has the exact column or an column = 1 and the next line above
                    if (((element.column == -1) || (element.column == column)) && (element.level > closestLevel) && (element.level <= depth))
                    {
                        bestLevelFit = element;
                        closestLevel = element.level;
                    }

                    // has the exact column or an column = 1 and a lower line
                    if (((element.column == -1) || (element.column == column)) && (element.level < lowerLevel) && (element.level > depth))
                    {
                        lowerLevelFit = element;
                        lowerLevel    = element.level;
                    }

                    // we are looking for any occurrence
                    if ((depth == -1) && (column == -1))
                    {
                        anyFit = element;
                    }
                } // if
            }     // foreach

            if (exact == eParameterFit.eExact)
            {
                // no exact fitting element was found
                return(null);
            }

            if (exact == eParameterFit.eAllColumnFit)
            {
                if (allColumnFit != null)
                {
                    ReturnValue = allColumnFit;
                }

                return(ReturnValue);
            }

            if (columnFit != null)
            {
                return(columnFit);
            }

            if (bestLevelFit != null)
            {
                return(bestLevelFit);
            }

            if (commonFit != null)
            {
                return(commonFit);
            }

            if ((lowerLevelFit != null) && (exact == eParameterFit.eBestFitEvenLowerLevel))
            {
                return(lowerLevelFit);
            }

            if ((ReturnValue == null) && (exact == eParameterFit.eBestFit) && (anyFit != null))
            {
                return(anyFit);
            }

            return(ReturnValue);
        }
Пример #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);
        }
Пример #11
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;
 }