Esempio n. 1
0
        public void BuildMenu(string parentMenu, PluginDescriptor pluginDescriptor)
        {
            if (pluginDescriptor.Installed) return;

            var parentResource = repository.Query<Resource>().FirstOrDefault(r => r.Name == parentMenu);

            Resource resource = new Resource()
            {
                ID = "__" + pluginDescriptor.SystemName,
                Name = pluginDescriptor.SystemName,
                Text = pluginDescriptor.FriendlyName,
                URL = pluginDescriptor.ConfigurationUrl,
                ShowToolBar = 0,
                Type = (short)ResourceType.Menu,
                ExpandIcon = "",
                ParentID = parentResource.ID,
                OpenMode = 1,
                ShowNavigation = 0,
                SortOrder = 1,
                CreateTime = DateTime.Now,
                Creator = "AgileEAP",
                Operates = new List<Operate>
                {
                    new Operate { ID="_newForm_", OperateName="新增", CommandName="newForm", Runat=(short)Runat.Ajax,SortOrder=1 },
                    new Operate { ID="_deleteForm_", OperateName="删除", CommandName="deleteForm", Runat=(short)Runat.Ajax,SortOrder=2 },
                    new Operate { ID="_designForm_", OperateName="修改", CommandName="designForm", Runat=(short)Runat.Ajax,SortOrder=3 }
                }
            };
            IAuthorizeService authService = new AuthorizeService();
            authService.SaveResource(resource);
        }
Esempio n. 2
0
        public void DeleteMenu(PluginDescriptor pluginDescriptor)
        {
            if (!pluginDescriptor.Installed) return;

            Resource resource = repository.GetDomain<Resource>("__" + pluginDescriptor.SystemName);
            if (resource != null)
            {
                IAuthorizeService authService = new AuthorizeService();
                authService.DeleteResource(resource);
            }
        }
Esempio n. 3
0
        public string Save(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Resource resource = JsonConvert.DeserializeObject<Resource>(argument);
                resource.ID = string.IsNullOrEmpty(CurrentId) ? CurrentId = IdGenerator.NewComb().ToString() : CurrentId;

                foreach (var operate in resource.Operates)
                {
                    operate.ID = string.IsNullOrWhiteSpace(operate.ID) ? IdGenerator.NewComb().ToString() : operate.ID;
                }

                IAuthorizeService authService = new AuthorizeService();
                authService.SaveResource(resource);
                doResult = DoResult.Success;

                //获取提示信息
                actionMessage = string.Format("保存菜单资源{0}成功", resource.Name);

                //记录操作日志
                AddActionLog(resource, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = resource.ID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
Esempio n. 4
0
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="argument"></param>
        public string DeleteTreeNode(string argument)
        {
            AjaxResult ajaxResult = new AjaxResult();
            DoResult doResult = DoResult.Failed;
            string actionMessage = string.Empty;
            try
            {
                Resource resource = repository.GetDomain<Resource>(argument);

                if (resource != null)
                {

                    IAuthorizeService authService = new AuthorizeService();
                    authService.DeleteResource(resource);
                    doResult = DoResult.Success;
                }
                else
                {
                    doResult = DoResult.Failed;
                }

                //获取提示信息
                actionMessage = string.Format("删除菜单资源{0},URL={1}", resource.Name, resource.URL);

                //记录操作日志
                AddActionLog(resource, doResult, actionMessage);

                ajaxResult.Result = doResult;
                ajaxResult.RetValue = resource.ParentID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(doResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
Esempio n. 5
0
        /// <summary>
        /// 初始化树
        /// </summary>
        private void InitTree()
        {
            AjaxTree1.PostType = PostType.None;
            AjaxTree1.ShowNodeIco = true;
            AjaxTree1.ShowCheckBox = !string.Equals(Request.QueryString["Entry"], "Operator");
            AjaxTree1.IsAjaxLoad = false;
            AjaxTree1.SelectionMode = SelectionMode.Single;
            AjaxTree1.Nodes.Clear();

            List<string> dataPriveleges =new AuthorizeService().GetDataPriveleges(User.ID);

            string root = Configure.Get("OrgRootID");
            Organization org = repository.GetDomain<Organization>(root);
            if (org == null) return;
            AjaxTreeNode parentNode = new AjaxTreeNode()
            {
                ID = org.ID,
                Text = org.Name,
                Value = org.Code,
                Tag = org.ID,
                NodeState = AgileEAP.WebControls.NodeState.Open,
                IcoSrc = string.Format("{0}Plugins/Authorize/Content/Themes/{1}/Images/orgtree.gif", WebUtil.GetRootPath(), Skin),
                Target = "ifrMain",
                VirtualNodeCount = repository.All<Organization>().Count(o => o.ParentID == root)
            };

            AjaxTree1.Nodes.Add(parentNode);

            BuildOrgTree(parentNode, dataPriveleges);
        }