Example #1
0
        public bool Update(Domain.Report entity)
        {
            var original = this.FindById(entity.ReportId);
            var result   = true;

            using (UnitOfWork.Build(_reportRepository.DbContext))
            {
                result = _reportRepository.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.ReportId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.ReportId, this._appContext.BaseLanguage);
                //assigning roles
                if (original.IsAuthorization || !entity.IsAuthorization)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.ReportId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = ReportDefaults.ModuleName
                    });
                }
            }
            return(result);
        }
Example #2
0
        public bool Update(WorkFlow entity)
        {
            var original = _workFlowRepository.FindById(entity.WorkFlowId);
            var result   = true;

            using (UnitOfWork.Build(_workFlowRepository.DbContext))
            {
                result = _workFlowRepository.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.WorkFlowId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.WorkFlowId, _appContext.BaseLanguage);

                //assigning roles
                if (original.AuthorizationEnabled != entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.WorkFlowId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = WorkFlowDefaults.ModuleName
                    });
                }
            }
            return(result);
        }
Example #3
0
        public bool Update(Domain.QueryView entity)
        {
            var original = _queryViewRepository.FindById(entity.QueryViewId);

            entity.ModifiedBy = _currentUser.SystemUserId;
            entity.ModifiedOn = DateTime.Now;
            var result = true;

            using (UnitOfWork.Build(_queryViewRepository.DbContext))
            {
                result = _queryViewRepository.Update(entity);
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.QueryViewId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.QueryViewId, _appContext.BaseLanguage);
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.QueryViewId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = QueryViewDefaults.ModuleName
                    });
                }
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Example #4
0
        public bool Update(Domain.Attribute entity)
        {
            var result = true;

            using (UnitOfWork.Build(_attributeRepository.DbContext))
            {
                result = _attributeRepository.Update(entity);
                if (entity.OptionSetId.HasValue && entity.OptionSet != null && !entity.OptionSet.IsPublic)
                {
                    var details = _optionSetDetailFinder.Query(n => n.Select(f => f.OptionSetDetailId).Where(f => f.OptionSetId == entity.OptionSetId.Value));
                    foreach (var item in entity.OptionSet.Items)
                    {
                        if (item.OptionSetDetailId.Equals(Guid.Empty))
                        {
                            item.OptionSetDetailId = Guid.NewGuid();
                            result = _optionSetDetailCreater.Create(item);
                        }
                        else
                        {
                            result = _optionSetDetailUpdater.Update(item);
                        }
                    }
                    //delete lost
                    var ids    = entity.OptionSet.Items.Select(n => n.OptionSetDetailId);
                    var lostid = details.Select(n => n.OptionSetDetailId).Except(ids).ToList();
                    if (lostid.NotEmpty())
                    {
                        result = _optionSetDetailDeleter.DeleteById(lostid.ToArray());
                    }
                }
                if (entity.PickLists.NotEmpty())//bit
                {
                    foreach (var item in entity.PickLists)
                    {
                        if (item.StringMapId.Equals(Guid.Empty))
                        {
                            result = _stringMapCreater.Create(item);
                        }
                        else
                        {
                            result = _stringMapUpdater.Update(item);
                        }
                    }
                }
                //localization
                _localizedLabelService.Update(entity.LocalizedName.IfEmpty(""), "LocalizedName", entity.AttributeId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.AttributeId, this._appContext.BaseLanguage);
                //set to cache
                var optionSetEntity = _optionSetFinder.FindById(entity.OptionSet.OptionSetId);
                _cacheService.SetEntity(entity);
                _cacheServiceOption.RemoveEntity(optionSetEntity);
            }
            return(result);
        }
Example #5
0
        public bool Update(Domain.WebResource entity)
        {
            var flag = _webResourceRepository.Update(entity);

            if (flag)
            {
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.WebResourceId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.WebResourceId, _appContext.BaseLanguage);
                _cacheService.SetEntity(entity);
            }
            return(flag);
        }
Example #6
0
        public IActionResult UpdateLocalizationLabel(UpdateLocalizationLabelModel model)
        {
            if (ModelState.IsValid)
            {
                var labels = _localizedLabelService.Query(n => n.Where(f => f.ObjectColumnName == model.ObjectColumnName && f.ObjectId == model.ObjectId));
                int i      = 0;

                foreach (var item in model.Label)
                {
                    var original = labels.Find(n => (int)n.LanguageId == model.LanguageId[i]);
                    if (original != null)
                    {
                        if (item.IsEmpty())
                        {
                            //delete
                            _localizedLabelService.DeleteById(original.LocalizedLabelId);
                        }
                        else
                        {
                            //update
                            _localizedLabelService.Update(n => n.Set(f => f.Label, item).Where(f => f.LocalizedLabelId == original.LocalizedLabelId));
                        }
                    }
                    else
                    {
                        //create
                        //_localizedLabelService.Create(SolutionDefaults.DefaultSolutionId, item, labels.First().LabelTypeCode, model.ObjectColumnName, model.ObjectId, (LanguageEnum)Enum.ToObject(typeof(LanguageEnum), model.LanguageId[i]));
                    }
                    i++;
                }

                return(UpdateSuccess());
            }
            return(UpdateFailure(GetModelErrors()));
        }
Example #7
0
        public bool Update(Domain.OptionSet entity)
        {
            bool result = false;

            using (UnitOfWork.Build(_optionSetRepository.DbContext))
            {
                result = _optionSetRepository.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.OptionSetId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.OptionSetId, _appContext.BaseLanguage);

                //存在明细项,丢弃缓存,
                _cacheService.RemoveEntity(entity);
            }
            return(result);
        }
Example #8
0
        public bool Update(Chart entity)
        {
            entity.ModifiedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId;
            entity.ModifiedOn = DateTime.Now;
            var result = _chartRepository.Update(entity);

            if (result)
            {
                //依赖
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.ChartId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.ChartId, _appContext.BaseLanguage);
            }
            return(result);
        }
Example #9
0
        public bool Update(Privilege entity)
        {
            //判断重复
            if (IsExists(entity))
            {
                return(false);
            }
            var original = _privilegeRepository.FindById(entity.PrivilegeId);
            var flag     = _privilegeRepository.Update(entity);

            if (flag)
            {
                //localization
                _localizedLabelService.Update(entity.DisplayName.IfEmpty(""), "DisplayName", entity.PrivilegeId, this._appContext.BaseLanguage);
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.PrivilegeId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = SiteMapDefaults.ModuleName
                    });
                }

                //add to cache
                _cacheService.SetEntity(entity);
            }
            return(flag);
        }
Example #10
0
        public bool Update(DuplicateRule entity)
        {
            var result = false;

            using (UnitOfWork.Build(_duplicateRuleRepository.DbContext))
            {
                result = _duplicateRuleRepository.Update(entity);
                //依赖于字段
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.DuplicateRuleId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.DuplicateRuleId, _appContext.BaseLanguage);
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Example #11
0
        public bool Update(Domain.Entity entity)
        {
            var oldEntity = _entityRepository.FindById(entity.EntityId);

            if (oldEntity == null)
            {
                return(false);
            }
            var result = true;

            if (!oldEntity.IsCustomizable)
            {
                entity.AuthorizationEnabled = oldEntity.AuthorizationEnabled;
                entity.WorkFlowEnabled      = oldEntity.WorkFlowEnabled;
                entity.BusinessFlowEnabled  = oldEntity.BusinessFlowEnabled;
                entity.EntityMask           = oldEntity.EntityMask;
            }
            using (UnitOfWork.Build(_entityRepository.DbContext))
            {
                result = _entityRepository.Update(entity);
                //从组织范围改成用户范围
                if (oldEntity.EntityMask != entity.EntityMask && entity.EntityMask == EntityMaskEnum.User)
                {
                    //创建所有者字段
                    _attributeCreater.CreateOwnerAttributes(entity);
                }
                //启用审批流,创建相关字段
                if (!oldEntity.WorkFlowEnabled && entity.WorkFlowEnabled)
                {
                    _attributeCreater.CreateWorkFlowAttributes(entity);
                }
                //启用业务流,创建相关字段
                if (!oldEntity.BusinessFlowEnabled && entity.BusinessFlowEnabled)
                {
                    _attributeCreater.CreateBusinessFlowAttributes(entity);
                }
                //localization
                _localizedLabelService.Update(entity.LocalizedName.IfEmpty(""), "LocalizedName", entity.EntityId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.EntityId, _appContext.BaseLanguage);

                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Example #12
0
        public bool Update(Domain.StringMap entity)
        {
            var result = false;

            using (UnitOfWork.Build(_stringMapRepository.DbContext))
            {
                result = _stringMapRepository.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.StringMapId, this._appContext.BaseLanguage);
            }
            return(result);
        }
Example #13
0
        public bool Update(Domain.SerialNumberRule entity)
        {
            //检查是否已存在相同字段的编码规则
            if (_serialNumberRuleRepository.Exists(x => x.SerialNumberRuleId != entity.SerialNumberRuleId && x.EntityId == entity.EntityId && x.AttributeId == entity.AttributeId))
            {
                throw new XmsException(_loc["serial_number_duplicated"]);
            }
            bool result = _serialNumberRuleRepository.Update(entity);

            if (result)
            {
                //依赖于字段
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                //set to cache
                _cacheService.SetEntity(_serialNumberRuleRepository.FindById(entity.SerialNumberRuleId));
            }
            return(result);
        }
Example #14
0
        public bool Update(Domain.OptionSetDetail entity)
        {
            bool result = false;

            using (UnitOfWork.Build(_optionSetDetailRepository.DbContext))
            {
                result = _optionSetDetailRepository.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.OptionSetDetailId, _appContext.BaseLanguage);
            }
            return(result);
        }
Example #15
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);
        }
Example #16
0
        public bool Import(string file, Guid solutionId, LanguageCode baseLanguageId)
        {
            var data      = new DataTable();// _dataImporter.ExcelToDataTable(file);
            var languages = _languageService.Query(n => n.Sort(s => s.SortAscending(f => f.Name)));

            foreach (DataRow row in data.Rows)
            {
                var objectId = Guid.Parse(row[0].ToString());
                var name     = row[1].ToString();
                var typeCode = int.Parse(row[2].ToString());
                foreach (var lg in languages)
                {
                    if (data.Columns.Contains(lg.UniqueId.ToString()))
                    {
                        var label         = row[lg.UniqueId.ToString()] != null ? row[lg.UniqueId.ToString()].ToString() : string.Empty;
                        var originalLabel = _localizedLabelService.Find(n => n.ObjectId == objectId && n.ObjectColumnName == name && (int)n.LanguageId == lg.UniqueId);
                        if (originalLabel != null)
                        {
                            if (label.IsEmpty())
                            {
                                _localizedLabelService.DeleteById(originalLabel.LocalizedLabelId);
                            }
                            else if (!label.IsCaseInsensitiveEqual(originalLabel.Label))
                            {
                                originalLabel.Label = label;
                                _localizedLabelService.Update(originalLabel);
                            }
                        }
                        else if (label.IsNotEmpty())
                        {
                            _localizedLabelService.Create(solutionId, label, typeCode.ToString(), name, objectId, (LanguageCode)Enum.Parse(typeof(LanguageCode), lg.UniqueId.ToString()));
                        }
                    }
                }
            }
            return(true);
        }