Example #1
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public TRptLevel GetLevel(string name)
        {
            if (rptGrpLevel == null)
            {
                return(null);
            }

            for (int counter = 0; counter < rptGrpLevel.Count; counter++)
            {
                TRptLevel element = (TRptLevel)rptGrpLevel[counter];

                if (element.strName == name)
                {
                    return(element);
                }
            }

            TLogging.Log("could not find level \"" + name + "\"");
            throw new Exception("could not find level \"" + name + "\"");
        }
Example #2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="cur2"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        protected TRptLevel ParseLevel(XmlNode cur2, int order)
        {
            XmlNode   cur;
            Object    r;
            TRptLevel element;

            cur                       = cur2;
            element                   = new TRptLevel(order);
            element.strName           = GetAttribute(cur, "name");
            element.strIdentification = GetAttribute(cur, "identification");
            element.strCondition      = GetAttribute(cur, "condition");
            cur                       = NextNotBlank(cur.FirstChild);

            if ((cur != null) && (cur.Name == "header"))
            {
                ParseFooterHeader(NextNotBlank(cur.FirstChild), out element.rptGrpHeaderField, out element.rptGrpHeaderSwitch);
                cur = GetNextEntity(cur);
            }

            r = Parse(cur, ref report.detailsId, "detail");

            if (r != null)
            {
                element.rptDetail = ((TRptDetail)r);
                cur = GetNextEntity(cur);
            }

            if ((cur != null) && (cur.Name == "footer"))
            {
                element.strFooterLine  = GetAttribute(cur, "line").ToLower();
                element.strFooterSpace = GetAttribute(cur, "space").ToLower();
                ParseFooterHeader(NextNotBlank(cur.FirstChild), out element.rptGrpFooterField, out element.rptGrpFooterSwitch);
            }

            return(element);
        }
Example #3
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="cur2"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        protected TRptLevel ParseLevel(XmlNode cur2, int order)
        {
            XmlNode cur;
            Object r;
            TRptLevel element;

            cur = cur2;
            element = new TRptLevel(order);
            element.strName = GetAttribute(cur, "name");
            element.strIdentification = GetAttribute(cur, "identification");
            element.strCondition = GetAttribute(cur, "condition");
            cur = NextNotBlank(cur.FirstChild);

            if ((cur != null) && (cur.Name == "header"))
            {
                ParseFooterHeader(NextNotBlank(cur.FirstChild), out element.rptGrpHeaderField, out element.rptGrpHeaderSwitch);
                cur = GetNextEntity(cur);
            }

            r = Parse(cur, ref report.detailsId, "detail");

            if (r != null)
            {
                element.rptDetail = ((TRptDetail)r);
                cur = GetNextEntity(cur);
            }

            if ((cur != null) && (cur.Name == "footer"))
            {
                element.strFooterLine = GetAttribute(cur, "line").ToLower();
                element.strFooterSpace = GetAttribute(cur, "space").ToLower();
                ParseFooterHeader(NextNotBlank(cur.FirstChild), out element.rptGrpFooterField, out element.rptGrpFooterSwitch);
            }

            return element;
        }
Example #4
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;
        }