예제 #1
0
        private bool DeleteCore(params Domain.SerialNumberRule[] deleteds)
        {
            Guard.NotEmpty(deleteds, nameof(deleteds));
            var result = true;
            var ids    = deleteds.Select(x => x.SerialNumberRuleId).ToArray();

            using (UnitOfWork.Build(_serialNumberRuleRepository.DbContext))
            {
                result = _serialNumberRuleRepository.DeleteMany(ids);
                //删除依赖项
                _dependencyService.Delete(ids);
                //localization
                _localizedLabelService.DeleteByObject(ids);
                //solution component
                _solutionComponentService.DeleteObject(deleteds.First().SolutionId, SerialNumberRuleDefaults.ModuleName, ids);
                var entityIds = deleteds.Select(x => x.EntityId).Distinct().ToArray();
                //plugin
                foreach (var eid in entityIds)
                {
                    _entityPluginDeleter.DeleteByEntityId(eid);
                }
                foreach (var deleted in deleteds)
                {
                    //remove from cache
                    _cacheService.RemoveEntity(deleted);
                }
            }
            return(result);
        }
예제 #2
0
        private bool DeleteCore(params FilterRule[] deleteds)
        {
            Guard.NotEmpty(deleteds, nameof(deleteds));
            var result = false;
            var ids    = deleteds.Select(x => x.FilterRuleId);

            using (UnitOfWork.Build(_filterRuleRepository.DbContext))
            {
                result = _filterRuleRepository.DeleteMany(ids);
                //删除依赖项
                _dependencyService.Delete(ids.ToArray());
                var entityIds = deleteds.Select(x => x.EntityId).Distinct().ToArray();
                //plugin
                foreach (var eid in entityIds)
                {
                    _entityPluginDeleter.DeleteByEntityId(eid);
                }
                foreach (var deleted in deleteds)
                {
                    //remove from cache
                    _cacheService.RemoveEntity(deleted);
                }
            }
            return(result);
        }
예제 #3
0
        private bool DeleteCore(params DuplicateRule[] deleteds)
        {
            Guard.NotEmpty(deleteds, nameof(deleteds));
            var result = false;
            var ids    = deleteds.Select(x => x.DuplicateRuleId).ToArray();

            using (UnitOfWork.Build(_duplicateRuleRepository.DbContext))
            {
                //cascade delete
                _cascadeDeletes?.ToList().ForEach((x) => { x.CascadeDelete(deleteds.ToArray()); });
                result = _duplicateRuleRepository.DeleteMany(ids);
                //删除依赖项
                _dependencyService.Delete(ids);
                //localization
                _localizedLabelService.DeleteByObject(ids);
                var entityIds = deleteds.Select(x => x.EntityId).Distinct().ToArray();
                //plugin
                foreach (var eid in entityIds)
                {
                    _entityPluginDeleter.DeleteByEntityId(eid);
                }
                foreach (var item in deleteds)
                {
                    //remove from cache
                    _cacheService.SetEntity(item);
                }
            }
            return(result);
        }