예제 #1
0
        public ContentItem Get(int id, VersionOptions options)
        {
            var record = _contentStorageManager
                         .Query <ContentItemVersionRecord>(x => _query(x, id, options))
                         .OrderBy(x => x.Number)
                         .LastOrDefault();

            return(new ContentItem {
                VersionRecord = record
            });
        }
예제 #2
0
        private ContentTypeRecord AcquireContentTypeRecord(string contentType)
        {
            var contentTypeRecord = _contentStorageManager
                                    .Query <ContentTypeRecord>(x => x.Name == contentType)
                                    .SingleOrDefault();

            if (contentTypeRecord == null)
            {
                //TEMP: this is not safe... ContentItem types could be created concurrently?
                contentTypeRecord = new ContentTypeRecord {
                    Name = contentType
                };
                _contentStorageManager.Store(contentTypeRecord);
            }

            var contentTypeId = contentTypeRecord.Id;

            // There is a case when a content type record is created locally but the transaction is actually
            // cancelled. In this case we are caching an Id which is none existent, or might represent another
            // content type. Thus we need to ensure that the cache is valid, or invalidate it and retrieve it
            // another time.

            var result = _contentStorageManager
                         .Get <ContentTypeRecord>(contentTypeId);

            if (result != null && result.Name.Equals(contentType, StringComparison.OrdinalIgnoreCase))
            {
                return(result);
            }

            // invalidate the cache entry and load it again
            return(AcquireContentTypeRecord(contentType));
        }
예제 #3
0
        public void DeleteTypeDefinition(string name)
        {
            var record = _contentStorageManager
                         .Query <ContentTypeDefinitionRecord>(x => x.Name == name)
                         .SingleOrDefault();

            // deletes the content type record associated
            if (record != null)
            {
                _contentStorageManager.Remove <ContentTypeDefinitionRecord>(record.Id);
            }
        }
        public IEnumerable <string> GetFeaturesThatNeedUpdate()
        {
            var currentVersions = _contentStorageManager
                                  .Query <DataMigrationDocument>(x => x != null)
                                  .SelectMany(x => x.DataMigrationRecords)
                                  .ToDictionary(r => r.DataMigrationClass);

            var outOfDateMigrations = _dataMigrations.Where(dataMigration => {
                DataMigrationRecord record;
                if (currentVersions.TryGetValue(dataMigration.GetType().FullName, out record))
                {
                    return(CreateUpgradeLookupTable(dataMigration).ContainsKey(record.Version.Value));
                }

                return(GetCreateMethod(dataMigration) != null);
            });

            return(outOfDateMigrations.Select(m => m.Feature.Descriptor.Id).ToList());
        }
 private ShellDescriptorRecord GetDescriptorRecord()
 {
     return(_contentStorageManager.Query <ShellDescriptorRecord>(x => x != null).FirstOrDefault());
 }