Пример #1
0
        protected override void PersistUpdatedItem(IDictionaryItem entity)
        {
            entity.UpdatingEntity();

            foreach (var translation in entity.Translations)
            {
                translation.Value = translation.Value.ToValidXmlString();
            }

            var dto = DictionaryItemFactory.BuildDto(entity);

            Database.Update(dto);

            foreach (var translation in entity.Translations)
            {
                var textDto = DictionaryTranslationFactory.BuildDto(translation, entity.Key);
                if (translation.HasIdentity)
                {
                    Database.Update(textDto);
                }
                else
                {
                    translation.Id  = Convert.ToInt32(Database.Insert(textDto));
                    translation.Key = entity.Key;
                }
            }

            entity.ResetDirtyProperties();

            //Clear the cache entries that exist by uniqueid/item key
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(entity.ItemKey));
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(entity.Key));
        }
Пример #2
0
        /// <inheritdoc />
        protected override void PersistUpdatedItem(IConsent entity)
        {
            ((EntityBase)entity).UpdatingEntity();

            var dto = ConsentFactory.BuildDto(entity);

            Database.Update(dto);
            entity.ResetDirtyProperties();

            IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey <IConsent>(entity.Id));
        }
Пример #3
0
        private IEnumerable <IMember> MapDtosToContent(List <MemberDto> dtos, bool withCache = false)
        {
            var temps        = new List <TempContent <Member> >();
            var contentTypes = new Dictionary <int, IMemberType>();
            var content      = new Member[dtos.Count];

            for (var i = 0; i < dtos.Count; i++)
            {
                var dto = dtos[i];

                if (withCache)
                {
                    // if the cache contains the (proper version of the) item, use it
                    var cached = IsolatedCache.GetCacheItem <IMember>(RepositoryCacheKeys.GetKey <IMember>(dto.NodeId));
                    if (cached != null && cached.VersionId == dto.ContentVersionDto.Id)
                    {
                        content[i] = (Member)cached;
                        continue;
                    }
                }

                // else, need to build it

                // get the content type - the repository is full cache *but* still deep-clones
                // whatever comes out of it, so use our own local index here to avoid this
                var contentTypeId = dto.ContentDto.ContentTypeId;
                if (contentTypes.TryGetValue(contentTypeId, out var contentType) == false)
                {
                    contentTypes[contentTypeId] = contentType = _memberTypeRepository.Get(contentTypeId);
                }

                var c = content[i] = ContentBaseFactory.BuildEntity(dto, contentType);

                // need properties
                var versionId = dto.ContentVersionDto.Id;
                temps.Add(new TempContent <Member>(dto.NodeId, versionId, 0, contentType, c));
            }

            // load all properties for all documents from database in 1 query - indexed by version id
            var properties = GetPropertyCollections(temps);

            // assign properties
            foreach (var temp in temps)
            {
                temp.Content.Properties = properties[temp.VersionId];

                // reset dirty initial properties (U4-1946)
                temp.Content.ResetDirtyProperties(false);
            }

            return(content);
        }
Пример #4
0
        protected override void PersistDeletedItem(IDictionaryItem entity)
        {
            RecursiveDelete(entity.Key);

            Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = entity.Key });
            Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = entity.Key });

            //Clear the cache entries that exist by uniqueid/item key
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(entity.ItemKey));
            IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(entity.Key));

            entity.DeleteDate = DateTime.Now;
        }
Пример #5
0
        private void RecursiveDelete(Guid parentId)
        {
            var list = Database.Fetch <DictionaryDto>("WHERE parent = @ParentId", new { ParentId = parentId });

            foreach (var dto in list)
            {
                RecursiveDelete(dto.UniqueId);

                Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = dto.UniqueId });
                Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = dto.UniqueId });

                //Clear the cache entries that exist by uniqueid/item key
                IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(dto.Key));
                IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem>(dto.UniqueId));
            }
        }