コード例 #1
0
ファイル: RibbonButtonUpdater.cs プロジェクト: zzdxpq007/xms
        public bool Update(Domain.RibbonButton entity)
        {
            var original = _ribbonButtonRepository.FindById(entity.RibbonButtonId);
            var result   = true;

            using (UnitOfWork.Build(_ribbonButtonRepository.DbContext))
            {
                result = _ribbonButtonRepository.Update(entity);
                //依赖
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Label.IfEmpty(""), "LocalizedName", entity.RibbonButtonId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.RibbonButtonId, this._appContext.BaseLanguage);
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.RibbonButtonId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = RibbonButtonDefaults.ModuleName
                    });
                }
            }
            return(result);
        }
コード例 #2
0
        public bool Update(Domain.RibbonButton entity)
        {
            if (entity.JsLibrary.IsNotEmpty() && entity.JsLibrary.StartsWith("$webresource:"))
            {
                //依赖于web资源
                _dependencyService.Update(RibbonButtonDefaults.ModuleName, entity.RibbonButtonId, WebResourceDefaults.ModuleName, new Guid(entity.JsLibrary.Replace("$webresource:", "")));
            }

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// 设置按钮可用/可见状态
        /// </summary>
        /// <param name="button"></param>
        /// <param name="appContext"></param>
        /// <param name="formState"></param>
        /// <param name="record"></param>
        /// <param name="entityPermissions"></param>
        public static void SetButtonStatus(this Domain.RibbonButton button, FormState?formState = null, Core.Data.Entity record = null)
        {
            bool enabled  = true;
            bool visibled = true;

            if (button.CommandRules.IsNotEmpty())
            {
                var rules = new CommandDefinition();
                rules = rules.DeserializeFromJson(button.CommandRules);
                if (formState.HasValue && rules.FormStateRules != null && rules.FormStateRules.States.NotEmpty())
                {
                    enabled  = !rules.FormStateRules.Enabled;
                    visibled = !rules.FormStateRules.Visibled;
                    foreach (var item in rules.FormStateRules.States)
                    {
                        if (item == formState.Value)
                        {
                            //if (enabled)
                            //{
                            enabled = rules.FormStateRules.Enabled;
                            //}
                            //if (visibled)
                            //{
                            visibled = rules.FormStateRules.Visibled;
                            //}
                            if (!visibled)
                            {
                                break;
                            }
                        }
                    }
                }
                if (visibled && record != null && rules.ValueRules != null && rules.ValueRules.Values.NotEmpty())
                {
                    enabled  = !rules.ValueRules.Enabled;
                    visibled = !rules.ValueRules.Visibled;
                    foreach (var item in rules.ValueRules.Values)
                    {
                        //if null value
                        if ((item.Value.IsCaseInsensitiveEqual("null") && record[item.Field] == null) ||
                            (item.Value.IsCaseInsensitiveEqual(record.GetStringValue(item.Field))))
                        {
                            //if (enabled)
                            //{
                            enabled = rules.ValueRules.Enabled;
                            //}
                            //if (visibled)
                            //{
                            visibled = rules.ValueRules.Visibled;
                            //}
                            if (!visibled)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            button.IsEnabled  = enabled;
            button.IsVisibled = visibled;
        }
コード例 #4
0
ファイル: RibbonButtonCreater.cs プロジェクト: zzdxpq007/xms
 public bool Create(Domain.RibbonButton entity)
 {
     return(CreateCore(entity));
 }