Beispiel #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);
        }
        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);
        }