Esempio n. 1
0
        //add by aifang
        private GridLayoutInfo GetPivotGridActiveLayout(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
        {
            try
            {
                var gridLayoutMainList = new MB.Util.Serializer.DataContractFileSerializer <List <GridLayoutMainInfo> >(GRID_LAYOUT_FILE_SETTING_FULLNAME).Read();
                if (gridLayoutMainList == null)
                {
                    return(null);
                }

                string sectionName    = getLayoutXmlSessionName(baseRule, xtraGrid);
                var    gridLayoutList = gridLayoutMainList.Find(o => o.GridSectionName.Equals(sectionName));
                if (gridLayoutList == null || gridLayoutList.GridLayoutList.Count == 0)
                {
                    return(null);
                }

                return(gridLayoutList.GridLayoutList.OrderByDescending(o => o.CreateTime).FirstOrDefault());
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message, Util.APPMessageType.SysErrInfo);
                return(null);
            }
        }
        public FrmDynamicColumnSetting(MB.WinBase.IFace.IClientRuleQueryBase clientRuleObject)
        {
            InitializeComponent();

            _ClientRuleObject = clientRuleObject;

            bindingEvent();
        }
Esempio n. 3
0
 public string getLayoutXmlSessionName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
 {
     if (xtraGrid.ParentForm == null)
     {
         return(null);
     }
     return(baseRule.GetType().FullName + "~" + xtraGrid.ParentForm.GetType().FullName + "~" + xtraGrid.Name);
 }
        public ucCombineFilterControl(MB.WinBase.IFace.IClientRuleQueryBase clientRule, DevExpress.XtraGrid.GridControl mainGridCtl, string filterCfgName)
        {
            InitializeComponent();

            _ClientRule    = clientRule;
            _FilterCfgName = filterCfgName;
            _MainGridCtl   = mainGridCtl;
        }
Esempio n. 5
0
        /// <summary>
        ///加载需要导入的数据。/
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="buiObj"></param>
        /// <param name="xmlFileName"></param>
        /// <param name="importFile"></param>
        /// <returns></returns>
        public DataSet  LoadImportData(IWin32Window parent, MB.WinBase.IFace.IClientRule buiObj, string xmlFileName, string importFile)
        {
            try {
                MB.WinBase.IFace.IForm iForm = parent as MB.WinBase.IFace.IForm;
                if (iForm != null)
                {
                    _ClientRuleObject = iForm.ClientRuleObject;
                }

                var     colPropertys = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnPropertys(xmlFileName);
                var     editCols     = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnEdits(colPropertys, xmlFileName);
                DataSet dsData       = createNULLDataByFieldPropertys(colPropertys);

                if (importFile.EndsWith(".txt"))
                {
                    MB.WinEIDrive.Import.TxtImport txtImport = new MB.WinEIDrive.Import.TxtImport(dsData, importFile);
                    ImportEngine helper = new ImportEngine(editCols, grdCtlMain, txtImport);
                    helper.Commit();
                }
                else
                {
                    if (ExistsRegedit() > 0)
                    {
                        MB.WinEIDrive.Import.OfficeXlsImport xlsImport = new WinEIDrive.Import.OfficeXlsImport(dsData, importFile);
                        ImportEngine helper = new ImportEngine(editCols, grdCtlMain, xlsImport);
                        helper.Commit();
                    }
                    else
                    {
                        MB.WinEIDrive.Import.XlsImport xlsImport = new MB.WinEIDrive.Import.XlsImport(dsData, importFile);
                        ImportEngine helper = new ImportEngine(editCols, grdCtlMain, xlsImport);
                        helper.Commit();
                    }
                }
                //移除空行数据
                MB.Util.DataValidated.Instance.RemoveNULLRowData(dsData);

                _ColPropertys      = colPropertys;
                _EditCols          = editCols;
                _CurrentImportData = dsData;
                _XmlFileName       = xmlFileName;
                return(_CurrentImportData);
            }
            catch (MB.Util.APPException aEx) {
                throw aEx;
            }
            catch (Exception ex) {
                throw new MB.Util.APPException("数据导入处理有误。", MB.Util.APPMessageType.SysFileInfo, ex);
            }
        }
Esempio n. 6
0
        public void RestoreLayout(DevExpress.XtraPivotGrid.PivotGridControl gridCtl, MB.WinBase.IFace.IClientRuleQueryBase baseRule)
        {
            PivotGridEx pivotGrid = gridCtl as PivotGridEx;

            if (pivotGrid == null)
            {
                return;
            }
            string name = getLayoutXmlSaveName(baseRule, pivotGrid);

            if (System.IO.File.Exists(LAYOUT_XML_PATH + name))
            {
                gridCtl.OptionsLayout.Columns.RemoveOldColumns = true;
                gridCtl.RestoreLayoutFromXml(LAYOUT_XML_PATH + name);
            }
        }
Esempio n. 7
0
        private string getLayoutXmlSaveName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
        {
            try
            {
                if (xtraGrid.ParentForm == null)
                {
                    return(null);
                }
                string         layoutXmlName = getLayoutXmlSessionName(baseRule, xtraGrid);
                GridLayoutInfo layoutInfo    = GetPivotGridActiveLayout(baseRule, xtraGrid);
                //add by aifang 2012-08-29 begin
                //判断状态保存日期是否大于动态列设置日期,如是,则生效,否则不生效。
                DateTime dt             = layoutInfo.CreateTime;
                var      dynamicSetting = XtraGridDynamicHelper.Instance.GetXtraGridDynamicSettingInfo(baseRule);
                if (dynamicSetting != null)
                {
                    if (dynamicSetting.LastModifyDate.Subtract(dt).TotalMilliseconds > 0)
                    {
                        layoutInfo = null;
                    }
                }
                //end

                if (layoutInfo == null)
                {
                    return(layoutXmlName + ".xml");
                }
                else
                {
                    return(layoutXmlName + "~" + layoutInfo.Name + ".xml");
                }
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message, Util.APPMessageType.SysErrInfo);
                return(null);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 把数据加载到PivotGrid 控件中。
 /// </summary>
 /// <param name="gridCtl">PivotGrid 控件。</param>
 /// <param name="dataSource">准备加载的数据源。</param>
 /// <param name="baseRule">当前正在处理的业务类。</param>
 public void LoadPivotGridData(DevExpress.XtraPivotGrid.PivotGridControl gridCtl,
                               object dataSource, MB.WinBase.IFace.IClientRuleQueryBase baseRule, ColPivotList xmlCfgLst)
 {
     addDataToCtl(gridCtl, dataSource, baseRule, xmlCfgLst);
     RestoreLayout(gridCtl, baseRule);
 }
Esempio n. 9
0
        //增加网格显示的格式化样式信息。
        private void addConditionsForStyles(DevExpress.XtraPivotGrid.PivotGridControl gridCtl, MB.WinBase.IFace.IClientRuleQueryBase busObj)
        {
            if (busObj == null)
            {
                return;
            }


            Dictionary <string, MB.WinBase.Common.StyleConditionInfo> styleConditions = busObj.UIRuleXmlConfigInfo.GetDefaultStyleConditions();

            if (styleConditions == null)
            {
                return;
            }

            XWinLib.Share.StyleCfgList styleList = XWinLib.Share.StyleCfgList.CreateInstance();
            if (styleList == null)
            {
                return;
            }

            foreach (MB.WinBase.Common.StyleConditionInfo info in  styleConditions.Values)
            {
                //判断定义的样式是否存在。
                if (!styleList.ContainsKey(info.StyleName))
                {
                    MB.Util.TraceEx.Write(string.Format("样式 {0} 需要在AppStylesConfig.xml 文件中配置,如果已经配置请检查大小写。", info.StyleName), MB.Util.APPMessageType.SysErrInfo);
                    continue;
                }
                DevExpress.XtraPivotGrid.PivotGridField pivField = gridCtl.Fields[info.ColumnName];
                if (pivField == null)
                {
                    MB.Util.TraceEx.Write(string.Format("字段 {0} 的 Style Format condition 列名称的配置,在数据源中找不到对应的列,请检查。", info.ColumnName), MB.Util.APPMessageType.SysErrInfo);
                    continue;
                }

                XWinLib.Share.StyleCfgInfo styleInfo = styleList[info.StyleName];

                //如果存在DispColName 的话,需要也是处理,在本应该程序中是在GridView的RowCellStyle事件中进行处理。
                if (info.IsByEvent || (info.DispColName != null && info.DispColName.Length > 0 && info.DispColName != info.ColumnName))
                {
                    continue;
                }
                //创建FormatCondition。
                if (gridCtl.FormatConditions[info.Name] == null)
                {
                    DevExpress.XtraGrid.FormatConditionEnum cc = (DevExpress.XtraGrid.FormatConditionEnum)Enum.Parse(typeof(DevExpress.XtraGrid.FormatConditionEnum), Enum.GetName(typeof(DataFilterConditions), info.Condition));
                    DevExpress.XtraPivotGrid.PivotGridStyleFormatCondition styleCondition = new DevExpress.XtraPivotGrid.PivotGridStyleFormatCondition();

                    styleCondition.Appearance.BackColor = styleInfo.BackColor;
                    styleCondition.Appearance.ForeColor = styleInfo.ForeColor;
                    styleCondition.Appearance.Font      = styleInfo.Font;

                    styleCondition.Appearance.Options.UseBackColor = true;
                    styleCondition.Appearance.Options.UseForeColor = true;
                    styleCondition.ApplyToCustomTotalCell          = false;
                    styleCondition.ApplyToGrandTotalCell           = false;
                    styleCondition.ApplyToTotalCell = false;

                    styleCondition.Condition = (DevExpress.XtraGrid.FormatConditionEnum)Enum.Parse(typeof(DevExpress.XtraGrid.FormatConditionEnum), Enum.GetName(typeof(DataFilterConditions), info.Condition));
                    styleCondition.Field     = pivField;
                    styleCondition.Value1    = info.Value;
                    styleCondition.Value2    = info.Value2;

                    gridCtl.FormatConditions.Add(styleCondition);
                }
            }
        }
Esempio n. 10
0
        //内部函数处理,把数据加载到pivot grid 控件中。
        private void addDataToCtl(DevExpress.XtraPivotGrid.PivotGridControl gridCtl, object dataSource
                                  , MB.WinBase.IFace.IClientRuleQueryBase baseRule, ColPivotList xmlCfgLst)
        {
            Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPros = XtraGridDynamicHelper.Instance.GetDynamicColumns(baseRule);

            //modify by aifang 2012-08-29 动态列加载  Dictionary<string, MB.WinBase.Common.ColumnPropertyInfo> colPros = baseRule.UIRuleXmlConfigInfo.GetDefaultColumns();

            if (colPros == null)
            {
                return;
            }

            //清除历史的设置
            gridCtl.Fields.Clear();
            gridCtl.Groups.Clear();

            List <Dictionary <DevExpress.XtraPivotGrid.PivotGridField, ColPivotInfo> > expressionFieldsList = new List <Dictionary <DevExpress.XtraPivotGrid.PivotGridField, ColPivotInfo> >();

            foreach (MB.WinBase.Common.ColumnPropertyInfo info in colPros.Values)
            {
                if (!info.IsPivotExpressionSourceColumn && (!info.Visibled || info.VisibleWidth < 1))
                {
                    continue;
                }
                var result = setPivotFieldByCfg(xmlCfgLst, gridCtl, info);
                if (result != null)
                {
                    expressionFieldsList.Add(result);
                }
            }

            //在绑定一般列以后再处理非绑定列的表达式,如果在一起处理会发生列的加载先后顺序
            foreach (Dictionary <DevExpress.XtraPivotGrid.PivotGridField, ColPivotInfo> expressionFields in expressionFieldsList)
            {
                foreach (KeyValuePair <DevExpress.XtraPivotGrid.PivotGridField, ColPivotInfo> expressionField in expressionFields)
                {
                    expressionField.Key.UnboundType = DevExpress.Data.UnboundColumnType.Object;

                    string[] sourceColumns          = expressionField.Value.ExpressionSourceColumns.Split(',');
                    string[] formattedSourceColumns = new string[sourceColumns.Length];
                    for (int i = 0; i < sourceColumns.Length; i++)
                    {
                        DevExpress.XtraPivotGrid.PivotGridField sourceField = gridCtl.Fields[sourceColumns[i]];
                        if (sourceField == null)
                        {
                            throw new MB.Util.APPException(string.Format("ExpressionSourceColumns中的列{0}中Expression中的列不存在,请注意配置中依赖列必需在被依赖列的前面", sourceColumns[i], MB.Util.APPMessageType.SysErrInfo));
                        }

                        formattedSourceColumns[i] = sourceField.ExpressionFieldName;
                    }

                    expressionField.Key.UnboundExpression = string.Format(expressionField.Value.Expression, formattedSourceColumns);
                }
            }

            //处理字段帮定的情况。
            processUnitField(xmlCfgLst, gridCtl);

            //通过条件增加样式
            addConditionsForStyles(gridCtl, baseRule);

            gridCtl.DataSource = dataSource;
        }