Пример #1
0
        /// <summary>
        /// calculate the value of a switch
        /// </summary>
        /// <param name="rptSwitch"></param>
        /// <returns></returns>
        public TVariant Calculate(TRptSwitch rptSwitch)
        {
            TVariant ReturnValue;
            TRptDataCalcField rptDataCalcField;
            TRptDataCalcValue rptDataCalcValue;
            TRptDataCalcSwitch rptDataCalcSwitch;
            TRptCase rptCase;

            ReturnValue = new TVariant();
            rptCase = GetFittingCase(rptSwitch);

            if (rptCase == null)
            {
                return ReturnValue;
            }

            if (rptCase.rptSwitch != null)
            {
                rptDataCalcSwitch = new TRptDataCalcSwitch(this);
                ReturnValue.Add(rptDataCalcSwitch.Calculate(rptCase.rptSwitch));
            }
            else
            {
                if (rptCase.rptGrpField != null)
                {
                    rptDataCalcField = new TRptDataCalcField(this);
                    rptDataCalcField.Calculate(rptCase.rptGrpField);
                }

                if (rptCase.rptGrpValue != null)
                {
                    rptDataCalcValue = new TRptDataCalcValue(this);
                    ReturnValue.Add(rptDataCalcValue.Calculate(rptCase.rptGrpValue));
                }
            }

            return ReturnValue;
        }
Пример #2
0
        /// <summary>
        /// calculate a level
        ///
        /// </summary>
        /// <returns>The number of the line calculated. -1 if unsuccessful
        /// </returns>
        public int Calculate(TRptLevel rptLevel, int masterRow)
        {
            if (rptLevel == null)
            {
                return -1;
            }

            TRptDetail rptDetail = rptLevel.rptDetail;

            if (rptDetail == null)
            {
                return -1;
            }

            if (Parameters.Get("CancelReportCalculation").ToBool() == true)
            {
                // TLogging.Log('Report calculation was cancelled', [ToStatusBar]);
                return -1;
            }

            int thisRunningCode = GetNextRunningCode();
            List <TRptField>rptGrpField = rptDetail.rptGrpField;
            List <TRptLowerLevel>rptGrpLowerLevel = rptDetail.rptGrpLowerLevel;
//          TLogging.Log("[MReporting\\Calculation.cs] Calculate(" + rptLevel.strName + ", " + masterRow + ")");

            if (rptDetail.rptSwitch != null)
            {
                TRptDataCalcSwitch calcSwitch = new TRptDataCalcSwitch(this);
                calcSwitch.Calculate(rptDetail.rptSwitch, out rptGrpLowerLevel, out rptGrpField);
            }

            if (rptGrpLowerLevel != null)
            {
                TRptDataCalcLowerLevel calcLowerLevel;

                if (Depth == 0)
                {
                    Int16 subreport = 0;

                    foreach (TRptLowerLevel rptLowerLevel in rptGrpLowerLevel)
                    {
                        Parameters.Add("CurrentSubReport", subreport);
                        calcLowerLevel = new TRptDataCalcLowerLevel(this);
                        calcLowerLevel.Calculate(rptLowerLevel, thisRunningCode);
                        subreport++;

                        if (Parameters.Get("CancelReportCalculation").ToBool() == true)
                        {
                            // TLogging.Log('Report calculation was cancelled', [ToStatusBar]);
                            return -1;
                        }
                    }

                    Parameters.Add("CurrentSubReport", -1);
                }
                else
                {
                    foreach (TRptLowerLevel rptLowerLevel in rptGrpLowerLevel)
                    {
                        calcLowerLevel = new TRptDataCalcLowerLevel(this);
                        calcLowerLevel.Calculate(rptLowerLevel, thisRunningCode);

                        if (Parameters.Get("CancelReportCalculation").ToBool() == true)
                        {
                            // TLogging.Log('Report calculation was cancelled', [ToStatusBar]);
                            return -1;
                        }
                    }
                }
            }
            else if (rptGrpField != null)
            {
                TRptDataCalcField calcGrpField = new TRptDataCalcField(this);
                calcGrpField.Calculate(rptGrpField);
            }

            TRptDataCalcHeaderFooter calcHeaderFooter = new TRptDataCalcHeaderFooter(this);
            calcHeaderFooter.Calculate(rptLevel.rptGrpHeaderField, rptLevel.rptGrpHeaderSwitch);
            calcHeaderFooter.Calculate(rptLevel.rptGrpFooterField, rptLevel.rptGrpFooterSwitch, rptLevel.strFooterLine, rptLevel.strFooterSpace);

            string strIdentification = rptLevel.strIdentification;
            string strId = "";

            while (strIdentification.Length != 0)
            {
                if (strId.Length != 0)
                {
                    strId += '/';
                }

                string strTemp = StringHelper.GetNextCSV(ref strIdentification).Trim();

                if (Parameters.Exists(strTemp, -1, Depth))
                {
                    strId += Parameters.Get(strTemp, -1, Depth).ToString(false);
                }
                else
                {
                    strId += strTemp;
                }
            }

            this.LineId = thisRunningCode;
            this.ParentRowId = masterRow;
            TRptDataCalcResult calcResult = new TRptDataCalcResult(this, Depth, -1, this.LineId, this.ParentRowId);

            if (calcResult.SavePrecalculation(masterRow, rptLevel.strCondition, strId))
            {
                // only write log if something was actually saved.
                TLogging.Log("preparing " + strId, TLoggingType.ToStatusBar);
            }

            if (Parameters.Get("CancelReportCalculation").ToBool() == true)
            {
                // TLogging.Log('Report calculation was cancelled', [ToStatusBar]);
                return -1;
            }

            if (thisRunningCode == 0)
            {
                // at this point all the values are precalculated
                // go again through the numbers, and calculate the function results, e.g. variance on ReportingConsts.COLUMNs
                calcResult.RecalculateFunctionColumns();
                calcResult.CheckDisplayStatus();

                if (Parameters.Exists("param_sortby_columns"))
                {
                    TLogging.Log("sorting...", TLoggingType.ToStatusBar);

                    Boolean SortMultipleLevels = false;

                    if (Parameters.Exists("param_sort_multiple_levels"))
                    {
                        // if we allow sorting of multiple levels, the result will be changed to flat table
                        // and we will end up with all the results in level 0. We might want this in some reports (e.g. Personnel-Birthday report)
                        SortMultipleLevels = true;
                    }

                    calcResult.GetResults().Sort(Parameters.Get("param_sortby_columns").ToString(), SortMultipleLevels);
                }

                TLogging.Log("finished", TLoggingType.ToStatusBar);
            }

            return thisRunningCode;
        }
Пример #3
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="rptGrpField"></param>
        /// <param name="rptGrpSwitch"></param>
        /// <param name="strLine"></param>
        /// <param name="strSpace"></param>
        public void Calculate(List <TRptField>rptGrpField, List <TRptSwitch>rptGrpSwitch, string strLine, string strSpace)
        {
            TRptDataCalcSwitch calcSwitch;
            TRptDataCalcField calcField;

            if ((strLine != null) && (strLine.IndexOf("above") != -1))
            {
                GetParameters().Add("FullLineAbove", new TVariant(true), -1, Depth);
            }

            if ((strLine != null) && (strLine.IndexOf("below") != -1))
            {
                GetParameters().Add("FullLineBelow", new TVariant(true), -1, Depth);
            }

            if ((strSpace != null) && (strSpace.IndexOf("above") != -1))
            {
                GetParameters().Add("SpaceLineAbove", new TVariant(true), -1, Depth);
            }

            if ((strSpace != null) && (strSpace.IndexOf("below") != -1))
            {
                GetParameters().Add("SpaceLineBelow", new TVariant(true), -1, Depth);
            }

            if (rptGrpSwitch != null)
            {
                column = -1;
                calcSwitch = new TRptDataCalcSwitch(this);
                calcSwitch.Calculate(rptGrpSwitch);
            }

            if (rptGrpField != null)
            {
                calcField = new TRptDataCalcField(this);
                calcField.Calculate(rptGrpField);
            }
        }