Exemple #1
0
        private bool CreateCore(Domain.SystemForm entity, Action <Domain.SystemForm> createDependents)
        {
            if (entity.FormConfig.IsEmpty())
            {
                return(false);
            }
            entity.OrganizationId = _appContext.OrganizationId;
            _formService.Init(entity);
            var result = true;

            using (UnitOfWork.Build(_systemFormRepository.DbContext))
            {
                result = _systemFormRepository.Create(entity);
                //依赖项
                createDependents?.Invoke(entity);
                //本地化标签
                _localizedLabelService.Append(entity.SolutionId, entity.Name.IfEmpty(""), entity.FormType == (int)FormType.Dashboard ? DashBoardDefaults.ModuleName : FormDefaults.ModuleName, "LocalizedName", entity.SystemFormId)
                .Append(entity.SolutionId, entity.Description.IfEmpty(""), entity.FormType == (int)FormType.Dashboard ? DashBoardDefaults.ModuleName : FormDefaults.ModuleName, "Description", entity.SystemFormId)
                .Save();
                _formService.UpdateLocalizedLabel(null);
                if (entity.FormType == (int)FormType.Dashboard)
                {
                    //solution component
                    result = _solutionComponentService.Create(entity.SolutionId, entity.SystemFormId, DashBoardDefaults.ModuleName);
                }
                //add to cache
                _cacheService.SetEntity(_systemFormRepository.FindById(entity.SystemFormId));
            }
            return(result);
        }
Exemple #2
0
        public Domain.SystemForm FindById(Guid id)
        {
            var dic = new Dictionary <string, string>();

            dic.Add("SystemFormId", id.ToString());

            Domain.SystemForm entity = _cacheService.Get(dic, () =>
            {
                return(_systemFormRepository.FindById(id));
            });
            if (entity != null)
            {
                WrapLocalizedLabel(entity);
            }
            return(entity);
        }
Exemple #3
0
        public bool Update(Domain.SystemForm entity, bool updatedConfig)
        {
            var original = _systemFormRepository.FindById(entity.SystemFormId);
            var result   = true;

            _formService.Init(entity);
            using (UnitOfWork.Build(_systemFormRepository.DbContext))
            {
                result = _systemFormRepository.Update(entity);
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.SystemFormId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.SystemFormId, _appContext.BaseLanguage);
                if (updatedConfig)
                {
                    _formService.UpdateLocalizedLabel(original);
                }
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.SystemFormId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = FormDefaults.ModuleName
                    });
                }
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }