Example #1
0
        /// <summary>
        /// 创建新的权限树
        /// </summary>
        private void CreateNewRightTree()
        {
            IList <MD_Menu>       _menuList;
            List <MD_RightDefine> _ret = new List <MD_RightDefine>();

            using (MetaDataServiceClient _mdc = new MetaDataServiceClient())
            {
                #region 通过菜单定义建立权限项
                try
                {
                    this.backgroundWorker2.ReportProgress(10, "正在取菜单定义数据...");
                    _menuList = _mdc.GetMenuDefineOfNode(this.NodesData.DWDM);
                    this.backgroundWorker2.ReportProgress(10, "取菜单定义成功!");
                }
                catch (Exception ex)
                {
                    this.backgroundWorker2.ReportProgress(10, string.Format("取菜单定义数据失败!!!{0}", ex.Message));
                    return;
                }

                try
                {
                    foreach (MD_Menu _menu in _menuList)
                    {
                        MD_RightDefine _item    = new MD_RightDefine();
                        decimal        _rightid = decimal.Parse(_menu.MenuID) * 1000;
                        _item.RightID       = _rightid.ToString();
                        _item.MenuID        = _menu.MenuID;
                        _item.FatherRightID = "";
                        _item.DisplayOrder  = _menu.DisplayOrder;
                        _item.RightDescript = _menu.MenuToolTip;
                        _item.RightName     = _menu.MenuName;
                        _item.RightType     = "动态菜单";
                        _item.RightMeta     = "";
                        _ret.Add(_item);


                        if (_menu.MenuType != null || _menu.MenuType != "")
                        {
                            //添加此类型菜单中的功能权限
                            AddPluginRight(_menu.MenuType, _item, _ret);
                        }

                        AddChildMenuRight(_menu, _item.RightID, _ret, _mdc);
                    }
                }
                catch (Exception ex)
                {
                    this.backgroundWorker2.ReportProgress(10, string.Format("处理权限定义数据失败!!!{0}", ex.Message));
                    return;
                }
                #endregion


                this.backgroundWorker2.ReportProgress(10, "处理权限数据完成!正在写入...");
                try
                {
                    if (_mdc.SaveRightDefine(_ret.ToArray()))
                    {
                        this.RightData = _ret;
                    }
                    this.backgroundWorker2.ReportProgress(10, "写入权限数据完成...");
                }
                catch (Exception ex)
                {
                    this.backgroundWorker2.ReportProgress(10, string.Format("写入权限定义数据失败!!!{0}", ex.Message));
                }
            }
        }