Beispiel #1
0
 //设置用户配置的显示格式信息。
 private void setFormatData(XmlNodeList nodeList, XWinLib.PivotGrid.ColPivotInfo info)
 {
     foreach (XmlNode node in nodeList)
     {
         if (node.NodeType != XmlNodeType.Element)
         {
             continue;
         }
         if (string.Compare(node.Name, "DisplayFormat", true) != 0)
         {
             continue;
         }
         DevExpress.Utils.FormatInfo cell = new DevExpress.Utils.FormatInfo();
         foreach (XmlNode childNode in node.ChildNodes)
         {
             if (childNode.NodeType != XmlNodeType.Element)
             {
                 continue;
             }
             if (string.Compare(childNode.Name, "FormatType", true) == 0)
             {
                 cell.FormatType = (DevExpress.Utils.FormatType)Enum.Parse(typeof(DevExpress.Utils.FormatType), childNode.InnerText.Trim());
             }
             else if (string.Compare(childNode.Name, "FormatString", true) == 0)
             {
                 cell.FormatString = childNode.InnerText.Trim();
             }
             else
             {
                 continue;
             }
         }
         info.CellFormat  = cell;
         info.ValueFormat = cell;
     }
 }
Beispiel #2
0
        //加载PivotList 列的信息
        private void loadPivotList(XWinLib.PivotGrid.ColPivotList pivotList, XmlNodeList nodeList)
        {
            if (nodeList.Count == 0)
            {
                return;
            }
            foreach (XmlNode node in nodeList)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (node.Attributes["FieldName"] == null)
                {
                    continue;
                }

                string fieldName = node.Attributes["FieldName"].Value;
                XWinLib.PivotGrid.ColPivotInfo info = new XWinLib.PivotGrid.ColPivotInfo(fieldName);

                if (node.Attributes["Description"] != null)
                {
                    info.Description = node.Attributes["Description"].Value;
                }

                if (node.Attributes["AllowedAreas"] != null)
                {
                    info.AllowedAreas = getAllowAreasByString(node.Attributes["AllowedAreas"].Value);
                }
                else
                {
                    info.AllowedAreas = DevExpress.XtraPivotGrid.PivotGridAllowedAreas.All;
                }

                if (node.Attributes["IniArea"] != null)
                {
                    info.IniArea = (DevExpress.XtraPivotGrid.PivotArea)Enum.Parse(typeof(DevExpress.XtraPivotGrid.PivotArea), node.Attributes["IniArea"].Value);
                }
                else
                {
                    info.IniArea = DevExpress.XtraPivotGrid.PivotArea.FilterArea;
                }

                if (node.Attributes["AreaIndex"] != null)
                {
                    info.AreaIndex = MB.Util.MyConvert.Instance.ToInt(node.Attributes["AreaIndex"].Value);
                }
                if (node.Attributes["GroupInterval"] != null)
                {
                    info.GroupInterval = (DevExpress.XtraPivotGrid.PivotGroupInterval)Enum.Parse(typeof(DevExpress.XtraPivotGrid.PivotGroupInterval), node.Attributes["GroupInterval"].Value);
                }
                if (node.Attributes["TopValueCount"] != null)
                {
                    info.TopValueCount = MB.Util.MyConvert.Instance.ToInt(node.Attributes["TopValueCount"].Value);
                }

                if (node.Attributes["DragGroupName"] != null)
                {
                    info.DragGroupName = node.Attributes["DragGroupName"].Value;
                }

                if (node.Attributes["DragGroupIndex"] != null)
                {
                    info.DragGroupIndex = MB.Util.MyConvert.Instance.ToInt(node.Attributes["DragGroupIndex"].Value);
                }

                if (node.Attributes["SummaryItemType"] != null)
                {
                    info.SummaryItemType = node.Attributes["SummaryItemType"].Value;
                }

                if (node.Attributes["Expression"] != null)
                {
                    info.Expression = node.Attributes["Expression"].Value;
                }

                if (node.Attributes["ExpressionSourceColumns"] != null)
                {
                    info.ExpressionSourceColumns = node.Attributes["ExpressionSourceColumns"].Value;
                }

                if (!string.IsNullOrEmpty(info.Expression))
                {
                    //在表达式中定义的占位符个数
                    var placeInExpressionCount = System.Text.RegularExpressions.Regex.Matches(info.Expression, @"\{\d\}").Count;

                    //自定义的SourceColumn的个数,需要与Expression中占位符的个数想符合
                    var sourceColumnCount = string.IsNullOrEmpty(info.ExpressionSourceColumns) ? 0 : info.ExpressionSourceColumns.Split(',').Length;
                    if (placeInExpressionCount != sourceColumnCount)
                    {
                        throw new MB.Util.APPException(string.Format("列{0}中Expression中的占位符ExpressionSourceColumns的个数不匹配", fieldName, MB.Util.APPMessageType.SysErrInfo));
                    }
                }

                if (node.ChildNodes.Count > 0)
                {
                    setFormatData(node.ChildNodes, info);
                }

                pivotList.Add(info);
            }
        }