コード例 #1
0
// Get format string for a date QueryColumn
        public static string GetFormatString(
            QueryColumn qc)
        {
            string formatString = qc.DisplayFormatString;

            if (qc.IsAggregationGroupBy)
            {
                AggregationDef        at  = qc.Aggregation;
                AggregationTypeDetail atd = at.TypeDetail;
                if (atd != null)
                {
                    formatString = atd.FormatString;
                }
            }

            if (Lex.Contains(formatString, "none"))             // remove any none for date format
            {
                formatString = Lex.Replace(formatString, "none", "").Trim();
            }

            if (Lex.IsNullOrEmpty(formatString))
            {
                formatString = DefaultFormat;
            }

            return(formatString);
        }
コード例 #2
0
/// <summary>
/// Get AggregationDef object allocating if null
/// </summary>
/// <returns></returns>

        public AggregationDef GetAggregation()
        {
            if (Aggregation == null)
            {
                Aggregation = new AggregationDef();
            }
            return(Aggregation);
        }
コード例 #3
0
        /// <summary>
        /// Set Aggregation by AggregationTypeDetail name
        /// </summary>

        public AggregationTypeDetail SetAggregation(string typeName)
        {
            if (Lex.IsUndefined(typeName) || Lex.Eq(typeName, "none"))             // clear?
            {
                Aggregation = null;
                return(null);
            }

            AggregationTypeDetail atd = AggregationTypeDetail.GetByTypeName(typeName);

            if (Aggregation != null && Lex.Eq(atd.TypeName, Aggregation.TypeName))
            {
                return(atd);                                                                               // same as before
            }
            Aggregation = new AggregationDef(typeName);

            return(atd);
        }
コード例 #4
0
        public static void ValidateForQuery(
            Query q)
        {
            List <QueryTable> keyAggregatedTables, nonKeyAggregatedTables;

            AnalyzeAggregation(q, out keyAggregatedTables, out nonKeyAggregatedTables);

            if (q.Tables.Count > 1 && nonKeyAggregatedTables.Count > 0)
            {
                throw new UserQueryException(
                          "Any tables that define data aggregation must include grouping of the key column if the query\r\n" +
                          "contains more than one table. The following table does not follow this rule:\r\n" +
                          "   " + nonKeyAggregatedTables[0].ActiveLabel);
            }

            foreach (List <QueryTable> qtList in new List <QueryTable>[] { keyAggregatedTables, nonKeyAggregatedTables })
            {
                if (qtList == null)
                {
                    continue;
                }

                foreach (QueryTable qt in qtList)
                {
                    foreach (QueryColumn qc in qt.QueryColumns)
                    {
                        if (qc.Selected)
                        {
                            AggregationDef ad = qc.Aggregation;
                            if (ad == null || !ad.RoleIsDefined)
                            {
                                throw new UserQueryException(
                                          "An aggregation role must be defined for the selected column: " + qc.ActiveLabel + "\r\n" +
                                          "in aggregated table: " + qt.ActiveLabel);
                            }
                        }
                    }
                }
            }

            return;
        }
コード例 #5
0
        /// <summary>
        /// Deserialize
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>

        public static AggregationDef Deserialize(
            XmlTextReader tr)
        {
            AggregationDef at = new AggregationDef();

            string txt = tr.GetAttribute("Role");

            if (Lex.IsDefined(txt))
            {
                EnumUtil.TryParse(txt, out at.Role);
            }

            txt = tr.GetAttribute("SummaryType");
            if (Lex.IsDefined(txt))
            {
                EnumUtil.TryParse(txt, out at.SummaryType);
            }

            txt = tr.GetAttribute("GroupingType");
            if (Lex.IsDefined(txt))
            {
                EnumUtil.TryParse(txt, out at.GroupingType);
            }

            XmlUtil.GetDecimalAttribute(tr, "NumericIntervalSize", ref at.NumericIntervalSize);

            if (!tr.IsEmptyElement)             // get end element if this is not empty
            {
                tr.Read();
                tr.MoveToContent();

                if (!Lex.Eq(tr.Name, "Aggregation") || tr.NodeType != XmlNodeType.EndElement)
                {
                    throw new Exception("Expected Aggregation end element");
                }
            }

            return(at);
        }