Esempio n. 1
0
        private bool ExportNameSpace()
        {
            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                //取表定义
                this.panelWait.Visible = true;
                SetProgress("正在读取数据表的元数据定义...", 0);

                IList <MD_Table> _tbList = _mdc.GetTablesAtNamespace(Namespace.NameSpace);
                SetProgressStep(10, 40, _tbList.Count);

                foreach (MD_Table _tb in _tbList)
                {
                    ShowProgressContinu(string.Format("正在读取{0}表的字段定义...", _tb.TableName));
                    _tb.Columns = _mdc.GetColumnsOfTable(_tb.TID);
                }

                //取查询模型定义
                SetProgress("正在读取查询模型的元数据定义...", 42);

                IList <MD_QueryModel> _qvList = _mdc.GetQueryModelAtNamespace(Namespace.NameSpace);
                SetProgressStep(45, 90, _qvList.Count);
                foreach (MD_QueryModel _qv in _qvList)
                {
                    ShowProgressContinu(string.Format("正在读取{0}的模型定义...", _qv.DisplayTitle));
                    _qv.MainTable      = _mdc.GetMainTableOfQueryModel(_qv.QueryModelID);
                    _qv.ChildTables    = _mdc.GetChildTableOfQueryModel(_qv.QueryModelID);
                    _qv.View2ViewGroup = _mdc.GetView2ViewGroupOfQueryModel(_qv.QueryModelID);

                    if (_qv.View2ViewGroup != null)
                    {
                        foreach (MD_View2ViewGroup _gr in _qv.View2ViewGroup)
                        {
                            _gr.View2Views = _mdc.GetView2ViewList(_gr.ID, _qv.QueryModelID);
                        }
                    }

                    try
                    {
                        _qv.View2GuideLines = _mdc.GetView2GuideLineList(_qv.QueryModelID);
                    }
                    catch (FaultException ex)
                    {
                        MessageBox.Show(ex.Message, "系统错误");
                    }
                    _qv.View2Application = _mdc.GetView2ApplicationList(_qv.QueryModelID);
                }

                //取代码表
                SetProgress("正在读取代码表的元数据定义...", 92);
                IList <MD_RefTable> _refList = _mdc.GetRefTableAtNamespace(Namespace.NameSpace);

                Namespace.RefTableList   = _refList;
                Namespace.QueryModelList = _qvList;
                Namespace.TableList      = _tbList;
                SetProgress("正在写入导出文件...", 92);
                WriteExportFile(Namespace);
                SetProgress("导出完成!", 100);
                return(true);
            }
        }
Esempio n. 2
0
        private void LoadChildData(TreeListNode _fnode, object _value)
        {
            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                MD_Title     _mt;
                MD_Namespace _ns;
                if (_value is MD_Nodes)
                {
                    _fnode.Nodes.Clear();
                    MD_Nodes _node = _value as MD_Nodes;

                    IList <MD_Namespace> _namespaces = _mdc.GetNameSpaceAtNode(_node.DWDM);
                    if (_node.NameSpaces == null)
                    {
                        _node.NameSpaces = new List <MD_Namespace>();
                    }
                    foreach (MD_Namespace _space in _namespaces)
                    {
                        TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                        _newnode.SetValue(this.treeListColumn1, _space);
                        _newnode.ImageIndex       = 1;
                        _newnode.SelectImageIndex = 0;
                        _newnode.HasChildren      = true;
                        _node.NameSpaces.Add(_space);
                    }

                    _mt = new MD_Title("菜单定义", "MD_MENU", _node);
                    TreeListNode _newnode2 = treeList1.AppendNode(null, _fnode);
                    _newnode2.SetValue(this.treeListColumn1, _mt);
                    _newnode2.ImageIndex       = 1;
                    _newnode2.SelectImageIndex = 0;
                    _newnode2.HasChildren      = true;
                }

                if (_value is MD_Namespace)
                {
                    _fnode.Nodes.Clear();
                    _ns = _value as MD_Namespace;
                    _mt = new MD_Title("数据表", "MD_TABLE", _ns);
                    TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                    _newnode.SetValue(this.treeListColumn1, _mt);
                    _newnode.ImageIndex       = 1;
                    _newnode.SelectImageIndex = 0;
                    _newnode.HasChildren      = true;

                    _mt                       = new MD_Title("查询模型", "MD_QUERYMODEL", _ns);
                    _newnode                  = treeList1.AppendNode(null, _fnode);
                    _newnode.ImageIndex       = 1;
                    _newnode.SelectImageIndex = 0;
                    _newnode.SetValue(this.treeListColumn1, _mt);
                    _newnode.HasChildren = true;

                    _mt                       = new MD_Title("代码表", "MD_REFTABLE", _ns);
                    _newnode                  = treeList1.AppendNode(null, _fnode);
                    _newnode.ImageIndex       = 1;
                    _newnode.SelectImageIndex = 0;
                    _newnode.SetValue(this.treeListColumn1, _mt);
                    _newnode.HasChildren = true;
                }

                if (_value is MD_Title)
                {
                    _fnode.Nodes.Clear();
                    MD_Title _mdtitle = _value as MD_Title;

                    switch (_mdtitle.TitleType)
                    {
                    case "MD_TABLE":
                        _ns = (MD_Namespace)_mdtitle.FatherObj;
                        IList <MD_Table> _tables = _mdc.GetTablesAtNamespace(_ns.NameSpace);
                        if (_ns.TableList == null)
                        {
                            _ns.TableList = new List <MD_Table>();
                        }

                        foreach (MD_Table _tb in _tables)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _tb);
                            _newnode.HasChildren      = true;
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                            _ns.TableList.Add(_tb);
                            _tb.NamespaceName = _ns.NameSpace;
                        }
                        break;

                    case "MD_QUERYMODEL":
                        _ns = (MD_Namespace)_mdtitle.FatherObj;
                        IList <MD_QueryModel> _models = _mdc.GetQueryModelAtNamespace(_ns.NameSpace);
                        if (_ns.QueryModelList == null)
                        {
                            _ns.QueryModelList = new List <MD_QueryModel>();
                        }
                        foreach (MD_QueryModel _model in _models)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _model);
                            _newnode.ImageIndex       = 1;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = true;
                            _ns.QueryModelList.Add(_model);
                            _model.Namespace = _ns;
                        }
                        break;

                    case "MD_REFTABLE":
                        _ns = (MD_Namespace)_mdtitle.FatherObj;
                        IList <MD_RefTable> _refTables = _mdc.GetRefTableAtNamespace(_ns.NameSpace);
                        if (_ns.RefTableList == null)
                        {
                            _ns.RefTableList = new List <MD_RefTable>();
                        }
                        foreach (MD_RefTable _rt in _refTables)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _rt);
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = false;
                            _ns.RefTableList.Add(_rt);
                            _rt.Namespace = _ns;
                        }
                        break;

                    case "MD_MENU":
                        MD_Nodes        _node      = (MD_Nodes)_mdtitle.FatherObj;
                        IList <MD_Menu> _menuTable = _mdc.GetMenuDefineOfNode(_node.DWDM);
                        foreach (MD_Menu _menu in _menuTable)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _menu);

                            if (_menu.MenuType.Length > 3 && _menu.MenuType.Substring(0, 3) == "WEB")
                            {
                                _newnode.ImageIndex       = 4;
                                _newnode.SelectImageIndex = 0;
                            }
                            else if (_menu.MenuType.Length > 3 && _menu.MenuType.Substring(0, 3) == "SL_")
                            {
                                _newnode.ImageIndex       = 5;
                                _newnode.SelectImageIndex = 0;
                            }
                            else
                            {
                                _newnode.ImageIndex       = 2;
                                _newnode.SelectImageIndex = 0;
                            }
                            _newnode.HasChildren = true;
                            _menu.NodeID         = _node.ID;
                            _menu.MD_Nodes       = _node;
                        }
                        break;

                    case "MD_CONCEPTGROUP":
                        InitConceptGroup(_fnode);
                        break;

                    case "MD_VIEW_GUIDELINE":
                        InitView2GuideLine(_fnode, (MD_QueryModel)_mdtitle.FatherObj);
                        break;

                    case "MD_VIEW_APPLICATION":
                        InitView2Application(_fnode, (MD_QueryModel)_mdtitle.FatherObj);
                        break;

                    case "MD_VIEW_EXRIGHT":
                        InitViewExRight(_fnode, (MD_QueryModel)_mdtitle.FatherObj);
                        break;
                    }
                }

                if (_value is MD_QueryModel_ExRight)
                {
                    _fnode.Nodes.Clear();
                    MD_QueryModel_ExRight         _fright = _value as MD_QueryModel_ExRight;
                    IList <MD_QueryModel_ExRight> _erList = _mdc.GetQueryModelExRights(_fright.ModelID, _fright.ID);
                    foreach (MD_QueryModel_ExRight _right in _erList)
                    {
                        TreeListNode _node = treeList1.AppendNode(null, _fnode);
                        _node.ImageIndex       = 1;
                        _node.SelectImageIndex = 0;
                        _node.SetValue(this.treeListColumn1, _right);
                        _node.HasChildren = true;
                    }
                }

                if (_value is MD_QueryModel)
                {
                    _fnode.Nodes.Clear();
                    MD_QueryModel _qm        = _value as MD_QueryModel;
                    MD_ViewTable  _mainTable = _mdc.GetMainTableOfQueryModel(_qm.QueryModelID);
                    if (_mainTable != null)
                    {
                        TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                        _newnode.SetValue(this.treeListColumn1, _mainTable);
                        _newnode.ImageIndex       = 2;
                        _newnode.SelectImageIndex = 0;
                        _newnode.HasChildren      = true;
                        _mainTable.QueryModelID   = _qm.QueryModelID;
                        _qm.MainTable             = _mainTable;
                    }
                    List <MD_View2ViewGroup> _v2vGroup = _mdc.GetView2ViewGroupOfQueryModel(_qm.QueryModelID).ToList <MD_View2ViewGroup>();
                    if (_v2vGroup != null && _v2vGroup.Count > 0)
                    {
                        foreach (MD_View2ViewGroup _g in _v2vGroup)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _g);
                            _newnode.ImageIndex       = 3;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = true;
                            _g.QueryModelID           = _qm.QueryModelID;
                        }
                    }
                    _mt = new MD_Title("关联数据指标", "MD_VIEW_GUIDELINE", _qm);
                    TreeListNode _newqxnode2 = treeList1.AppendNode(null, _fnode);
                    _newqxnode2.ImageIndex       = 8;
                    _newqxnode2.SelectImageIndex = 0;
                    _newqxnode2.SetValue(this.treeListColumn1, _mt);
                    _newqxnode2.HasChildren = true;

                    _mt = new MD_Title("集成应用展示", "MD_VIEW_APPLICATION", _qm);
                    TreeListNode _newAppnode = treeList1.AppendNode(null, _fnode);
                    _newAppnode.ImageIndex       = 8;
                    _newAppnode.SelectImageIndex = 0;
                    _newAppnode.SetValue(this.treeListColumn1, _mt);
                    _newAppnode.HasChildren = true;

                    _mt = new MD_Title("扩展权限定义", "MD_VIEW_EXRIGHT", _qm);
                    TreeListNode _newqxnode = treeList1.AppendNode(null, _fnode);
                    _newqxnode.ImageIndex       = 6;
                    _newqxnode.SelectImageIndex = 0;
                    _newqxnode.SetValue(this.treeListColumn1, _mt);
                    _newqxnode.HasChildren = true;
                }



                if (_value is MD_View2ViewGroup)
                {
                    _fnode.Nodes.Clear();
                    MD_View2ViewGroup   _v2vg = _value as MD_View2ViewGroup;
                    List <MD_View2View> _v2vs = _mdc.GetView2ViewList(_v2vg.ID, _v2vg.QueryModelID).ToList <MD_View2View>();
                    if (_v2vs != null)
                    {
                        foreach (MD_View2View _v in _v2vs)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _v.QueryModelID = _v2vg.QueryModelID;
                            _v.ViewGroupID  = _v2vg.ID;
                            _newnode.SetValue(this.treeListColumn1, _v);
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = true;
                        }
                    }
                }



                if (_value is MD_Table)
                {
                    _fnode.Nodes.Clear();
                    MD_Table             _tb   = _value as MD_Table;
                    List <MD_Table2View> _t2vs = _mdc.GetTable2ViewList(_tb.TID).ToList <MD_Table2View>();
                    if (_t2vs != null)
                    {
                        foreach (MD_Table2View _t2v in _t2vs)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _t2v);
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = true;
                        }
                    }
                }

                if (_value is MD_ViewTable)
                {
                    _fnode.Nodes.Clear();
                    MD_ViewTable _vt = _value as MD_ViewTable;
                    if (_vt.ViewTableType == MDType_ViewTable.MainTable)
                    {
                        MetaDataServiceClient _msc         = new MetaDataServiceClient();
                        IList <MD_ViewTable>  _childTables = _msc.GetChildTableOfQueryModel(_vt.QueryModelID);


                        foreach (MD_ViewTable _cvt in _childTables)
                        {
                            TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                            _newnode.SetValue(this.treeListColumn1, _cvt);
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                            _newnode.HasChildren      = true;
                            _cvt.QueryModelID         = _vt.QueryModelID;
                        }
                    }
                }

                if (_value is MD_Menu)
                {
                    MD_Menu         _fmenu     = _value as MD_Menu;
                    IList <MD_Menu> _menuTable = _mdc.GetSubMenuDefine(_fmenu.MenuID);
                    foreach (MD_Menu _menu in _menuTable)
                    {
                        TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                        _newnode.SetValue(this.treeListColumn1, _menu);
                        if (_menu.MenuType.Length > 3 && _menu.MenuType.Substring(0, 3) == "WEB")
                        {
                            _newnode.ImageIndex       = 4;
                            _newnode.SelectImageIndex = 0;
                        }
                        else if (_menu.MenuType.Length > 3 && _menu.MenuType.Substring(0, 3) == "SL_")
                        {
                            _newnode.ImageIndex       = 5;
                            _newnode.SelectImageIndex = 0;
                        }
                        else
                        {
                            _newnode.ImageIndex       = 2;
                            _newnode.SelectImageIndex = 0;
                        }
                        _newnode.HasChildren = true;
                        _menu.NodeID         = _fmenu.MD_Nodes.ID;
                        _menu.MD_Nodes       = _fmenu.MD_Nodes;
                    }
                }

                if (_value is MD_ConceptGroup)
                {
                    MD_ConceptGroup       _cGroup      = _value as MD_ConceptGroup;
                    List <MD_ConceptItem> _itemDefines = _mdc.GetSubConceptTagDefine(_cGroup.Name).ToList <MD_ConceptItem>();
                    _cGroup.Items = _itemDefines;
                    _fnode.Nodes.Clear();
                    foreach (MD_ConceptItem _item in _itemDefines)
                    {
                        TreeListNode _newnode = treeList1.AppendNode(null, _fnode);
                        _newnode.SetValue(this.treeListColumn1, _item);
                        _newnode.HasChildren = false;
                    }
                }
            }
        }