コード例 #1
0
ファイル: XmlExport.cs プロジェクト: 2sic/eav-server
        /// <summary>
        /// Returns an Entity XElement
        /// Works, but does not export the entity relationships
        /// </summary>
        public XElement GetEntityXElementUncached(int entityId)
        {
            //var cache = DataSource.GetCache(Context.ZoneId, Context.AppId);
            //var iEntity = cache.List[entityId];
            var iEntity = new DbLoadIntoEavDataStructure(Context).GetEavEntity(entityId);

            return GetEntityXElement(iEntity);
        }
コード例 #2
0
ファイル: DbVersioning.cs プロジェクト: 2sic/eav-server
        /// <summary>
        /// Restore an Entity to the specified Version by creating a new Version using the Import
        /// </summary>
        public void RestoreEntityVersion(int entityId, int changeId, int? defaultCultureDimension)
        {
            // Get Entity in specified Version/ChangeId
            var newVersion = GetEntityVersion(entityId, changeId, defaultCultureDimension);

            // Restore Entity
            var import = new Import.Import(Context.ZoneId /* _zoneId*/,Context.AppId /* _appId*/, Context.UserName, false, false);
            import.RunImport(null, new List<Import.ImportEntity> { newVersion });

            // Delete Draft (if any)
            var entityDraft = new DbLoadIntoEavDataStructure(Context).GetEavEntity(entityId).GetDraft();
            if (entityDraft != null)
                Context.Entities.DeleteEntity(entityDraft.RepositoryId);
        }
コード例 #3
0
        protected void UpdateModuleTitleIfNecessary(Entity entity)
        {
            // Creating new Context, because EntityTitle gets not refreshed otherwise
            var sexyContext = new SexyContent(ZoneId, AppId, true);

            // Get ContentGroup
            var listContentGroupItem = ContentGroup.ListContent;
            var entityModel = new DbLoadIntoEavDataStructure(sexyContext.ContentContext).GetEavEntity(entity.EntityID); // sexyContext.ContentContext.GetEntityModel(entity.EntityID);

            // If this is the list title, or no list-title exists, set module title
            if (ItemType == "ListContent" || (listContentGroupItem == null && ItemType == "Content" && SortOrder == 0) && entityModel.IsPublished)
            {
                var languages = Sexy.ContentContext.Dimensions.GetLanguages();
                // Find Module for default language
                var moduleController = new ModuleController();
                var originalModule = moduleController.GetModule(ModuleID);

                // Update Original Module if no languages active
                if (languages.Count == 0)
                {
                    // Get Title value of Entitiy in current language
                    var titleValue = entityModel.Title[0].ToString();

                    originalModule.ModuleTitle = titleValue;
                    moduleController.UpdateModule(originalModule);
                }

                foreach (var dimension in languages)
                {
                    // Get Title value of Entitiy in current language
                    var titleValue = entityModel.Title[dimension.DimensionID].ToString();

                    if(!originalModule.IsDefaultLanguage)
                        originalModule = originalModule.DefaultLanguageModule;

                    // Break if default language module is null
                    if (originalModule == null)
                        return;

                    // Find module for given Culture
                    var moduleByCulture = moduleController.GetModuleByCulture(originalModule.ModuleID, originalModule.TabID, PortalId, LocaleController.Instance.GetLocale(dimension.ExternalKey));

                    // Break if no module found
                    if (moduleByCulture == null)
                        return;

                    moduleByCulture.ModuleTitle = titleValue;
                    moduleController.UpdateModule(moduleByCulture);
                }
            }
        }
コード例 #4
0
ファイル: EAVContextTest.cs プロジェクト: 2sic/eav-server
        public void DraftEntitiesTest()
        {
            var db1 = EavContext.Instance(appId: 2);
            var publishedWitDraft = new DbLoadIntoEavDataStructure(db1).GetEavEntity(5454);
            Assert.NotNull(publishedWitDraft.GetDraft());

            var db2 = EavContext.Instance(appId: 2);
            var draftEntity = new DbLoadIntoEavDataStructure(db2).GetEavEntity(5458);
            Assert.NotNull(draftEntity.GetPublished());
        }