Example #1
0
        private void ModifyItemList(int parentId, string field, IItemListAction actionToPerform)
        {
            var parentEntity = SxcContext.App.Data["Default"].List[parentId];

            var parentField = parentEntity.GetBestValue(field);
            var fieldList   = parentField as Eav.Data.EntityRelationship;

            if (fieldList == null)
            {
                throw new Exception("field " + field + " doesn't seem to be a list of content-items, must abort");
            }

            var ids = fieldList.EntityIds.ToList();

            if (!actionToPerform.Change(ids))
            {
                return;
            }

            // save
            var values = new Dictionary <string, object> {
                { field, ids.ToArray() }
            };
            var cgApp = SxcContext.App;
            var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId);

            eavDc.UserName = Environment.Dnn7.UserIdentity.CurrentUserIdentityToken;

            eavDc.Entities.UpdateEntity(parentEntity.EntityGuid, values);
        }
Example #2
0
        internal static void RemoveApp(int zoneId, int appId, PortalSettings ps, int userId)
        {
            if (zoneId != ZoneHelpers.GetZoneID(ps.PortalId))
            {
                throw new Exception("This app does not belong to portal " + ps.PortalId);
            }

            //var sexy = new SxcInstance(zoneId, appId);// 2016-03-26 2dm this used to have a third parameter false = don't enable caching, which hasn't been respected for a while; removed it
            var eavContext = EavDataController.Instance(zoneId, appId);

            if (appId != eavContext.AppId)  // this only happens if there is some kind of id-fallback
            {
                throw new Exception("An app can only be removed inside of it's own context.");
            }

            if (appId == AppHelpers.GetDefaultAppId(zoneId))
            {
                throw new Exception("The default app of a zone cannot be removed.");
            }

            var sexyApp = new App(zoneId, appId, ps);

            // Delete folder
            if (!String.IsNullOrEmpty(sexyApp.Folder) && Directory.Exists(sexyApp.PhysicalPath))
            {
                Directory.Delete(sexyApp.PhysicalPath, true);
            }

            // Delete the app
            eavContext.App.DeleteApp(appId);
        }
Example #3
0
        /// <summary>
        /// Add new Content Types for Pipeline Designer
        /// </summary>
        /// <remarks>Some Content Types are defined in EAV but some only in 2sxc. EAV.VersionUpgrade ensures Content Types are shared across all Apps.</remarks>
        internal void EnsurePipelineDesignerAttributeSets()
        {
            logger.LogStep("06.00.00", "EnsurePipelineDesignerAttributeSets start", false);

            // Ensure DnnSqlDataSource Configuration
            var dsrcSqlDataSource = ImportAttributeSet.SystemAttributeSet("|Config ToSic.SexyContent.DataSources.DnnSqlDataSource", "used to configure a DNN SqlDataSource",
                                                                          new List <ImportAttribute>
            {
                ImportAttribute.StringAttribute("ContentType", "ContentType", null, true),
                ImportAttribute.StringAttribute("SelectCommand", "SelectCommand", null, true, rowCount: 10)
            });

            // Collect AttributeSets for use in Import
            var attributeSets = new List <ImportAttributeSet>
            {
                dsrcSqlDataSource
            };
            var import = new Import(Constants.DefaultZoneId, Constants.MetaDataAppId, Settings.InternalUserName);

            import.RunImport(attributeSets, null);

            var metaDataCtx = EavDataController.Instance(Constants.DefaultZoneId, Constants.MetaDataAppId);

            metaDataCtx.AttribSet.GetAttributeSet(dsrcSqlDataSource.StaticName).AlwaysShareConfiguration = true;
            metaDataCtx.SqlDb.SaveChanges();

            // Run EAV Version Upgrade (also ensures Content Type sharing)
            var eavVersionUpgrade = new VersionUpgrade(Settings.InternalUserName);

            eavVersionUpgrade.EnsurePipelineDesignerAttributeSets();

            logger.LogStep("06.00.00", "EnsurePipelineDesignerAttributeSets done", false);
        }
Example #4
0
 public static Zone AddZone(string zoneName)
 {
     return(EavDataController.Instance(Constants.DefaultZoneId, AppHelpers.GetDefaultAppId(Constants.DefaultZoneId)).Zone
            .AddZone(zoneName).Item1);
     //return
     //    new SxcInstance(Constants.DefaultZoneId, AppHelpers.GetDefaultAppId(Constants.DefaultZoneId)).EavAppContext.Zone
     //        .AddZone(zoneName).Item1;
 }
Example #5
0
 public XmlExporter(int zoneId, int appId, bool appExport, string[] attrSetIds, string[] entityIds)
 {
     _isAppExport = appExport;
     //Sexy = new SxcInstance(_zoneId, _appId);
     _app            = new App(zoneId, appId, PortalSettings.Current);
     _eavAppContext  = _app.EavContext;
     AttributeSetIDs = attrSetIds;
     EntityIDs       = entityIds;
 }
Example #6
0
        private void Update(Dictionary <string, object> newValues)
        {
            var cgApp = ((ContentBlockBase)SxcContext.ContentBlock).Parent.App;
            var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId);

            eavDc.Entities.UpdateEntity(Math.Abs(SxcContext.ContentBlock.ContentBlockId), newValues);

            //((ContentBlockBase)SxcContext.ContentBlock).Parent.App
            //    .Data.Update(Math.Abs(SxcContext.ContentBlock.ContentBlockId), newValues);
        }
Example #7
0
        public void UpdateTemplate(int?templateId)
        {
            var values = new Dictionary <string, object>
            {
                { "Template", templateId.HasValue ? new[] { templateId.Value } : new int[] {} }
            };

            var context = EavDataController.Instance(_zoneId, _appId).Entities; // EavContext.Instance(_zoneId, _appId);

            context.UpdateEntity(_contentGroupEntity.EntityGuid, values);
        }
Example #8
0
        /// <summary>
        /// Creates an app and then imports the xml
        /// </summary>
        /// <returns>AppId of the new imported app</returns>
        public bool ImportApp(int zoneId, XDocument doc, out int?appId)
        {
            // Increase script timeout to prevent timeouts
            HttpContext.Current.Server.ScriptTimeout = 300;

            appId = new int?();

            if (!IsCompatible(doc))
            {
                ImportLog.Add(new ExportImportMessage("The import file is not compatible with the installed version of 2sxc.", ExportImportMessage.MessageTypes.Error));
                return(false);
            }

            // Get root node "SexyContent"
            var xmlSource = doc.Element(XmlConstants.RootNode);
            var xApp      = xmlSource?.Element(XmlConstants.Header)?.Element(XmlConstants.App);

            var appGuid = xApp?.Attribute(XmlConstants.Guid).Value;

            if (appGuid == null)
            {
                ImportLog.Add(new ExportImportMessage("Something is wrong in the xml structure, can't get an app-guid", ExportImportMessage.MessageTypes.Error));
                return(false);
            }

            if (appGuid != XmlConstants.AppContentGuid)
            {
                // Build Guid (take existing, or create a new)
                if (IsNullOrEmpty(appGuid) || appGuid == new Guid().ToString())
                {
                    appGuid = Guid.NewGuid().ToString();
                }

                // Adding app to EAV
                var eavDc = EavDataController.Instance(zoneId, null);
                var app   = eavDc.App.AddApp(appGuid);
                eavDc.SqlDb.SaveChanges();

                appId = app.AppID;
            }
            else
            {
                appId = _appId;
            }

            if (appId <= 0)
            {
                ImportLog.Add(new ExportImportMessage("App was not created. Please try again or make sure the package you are importing is correct.", ExportImportMessage.MessageTypes.Error));
                return(false);
            }

            return(ImportXml(zoneId, appId.Value, doc));
        }
Example #9
0
        public XmlExporter(int zoneId, int appId, bool appExport, string[] attrSetIds, string[] entityIds)
        {
            _isAppExport = appExport;
            //Sexy = new SxcInstance(_zoneId, _appId);
            _app            = new App(zoneId, appId, PortalSettings.Current);
            _eavAppContext  = _app.EavContext;
            AttributeSetIDs = attrSetIds;
            EntityIDs       = entityIds;

            // this must happen very early, to ensure that the file-lists etc. are correct for exporting when used externally
            InitExportXDocument();
        }
Example #10
0
        // 2016-09-24 2dm seems unused now
        //public Template GetTemplate(Guid templateGuid)
        //{
        //    return
        //        TemplateDataSource()
        //            .List.Where(t => t.Value.EntityGuid == templateGuid)
        //            .Select(t => new Template(t.Value))
        //            .FirstOrDefault();
        //}

        public bool DeleteTemplate(int templateId)
        {
            var template   = GetTemplate(templateId);
            var eavContext = EavDataController.Instance(_zoneId, _appId).Entities; //EavContext.Instance(_zoneId, _appId);
            var canDelete  = eavContext.CanDeleteEntity(template.TemplateId);

            if (!canDelete.Item1)
            {
                throw new Exception(canDelete.Item2);
            }
            return(eavContext.DeleteEntity(template.TemplateId));
        }
Example #11
0
        /// <summary>
        /// Will create a new app in the system and initialize the basic settings incl. the
        /// app-definition
        /// </summary>
        /// <param name="zoneId"></param>
        /// <param name="appName"></param>
        /// <param name="ownerPS"></param>
        /// <returns></returns>
        internal static App AddBrandNewApp(int zoneId, string appName, PortalSettings ownerPS)
        {
            if (appName == Constants.ContentAppName || appName == "Default" || String.IsNullOrEmpty(appName) || !Regex.IsMatch(appName, "^[0-9A-Za-z -_]+$"))
            {
                throw new ArgumentOutOfRangeException("appName '" + appName + "' not allowed");
            }

            // Adding app to EAV
            var eavContext = EavDataController.Instance(zoneId, AppHelpers.GetDefaultAppId(zoneId));
            var app        = eavContext.App.AddApp(Guid.NewGuid().ToString());

            eavContext.SqlDb.SaveChanges();

            EnsureAppIsConfigured(zoneId, app.AppID, appName);

            return(new App(zoneId, app.AppID, ownerPS));
        }
Example #12
0
        public Guid CreateNewContentGroup(int?templateId)
        {
            var context     = EavDataController.Instance(_zoneId, _appId).Entities;
            var contentType = DataSource.GetCache(_zoneId, _appId).GetContentType(ContentGroupTypeName);

            var values = new Dictionary <string, object>
            {
                { "Template", templateId.HasValue ? new [] { templateId.Value } : new int[] {} },
                { "Content", new int[] {} },
                { "Presentation", new int[] {} },
                { "ListContent", new int[] {} },
                { "ListPresentation", new int[] {} }
            };

            var entity = context.AddEntity(contentType.AttributeSetId, values, null, null);

            return(entity.EntityGUID);
        }
Example #13
0
        /// <summary>
        /// Returns all DNN Cultures with active / inactive state
        /// </summary>
        public static List <CulturesWithActiveState> GetCulturesWithActiveState(int portalId, int zoneId)
        {
            //var DefaultLanguageID = ContentContext.GetLanguageId();
            var AvailableEAVLanguages = EavDataController.Instance(zoneId, AppHelpers.GetDefaultAppId(zoneId)).Dimensions.GetLanguages();
            // var AvailableEAVLanguages = new SxcInstance(zoneId, AppHelpers.GetDefaultAppId(zoneId)).EavAppContext.Dimensions.GetLanguages();
            var DefaultLanguageCode     = new PortalSettings(portalId).DefaultLanguage;
            var DefaultLanguage         = AvailableEAVLanguages.Where(p => p.ExternalKey == DefaultLanguageCode).FirstOrDefault();
            var DefaultLanguageIsActive = DefaultLanguage != null && DefaultLanguage.Active;

            return((from c in LocaleController.Instance.GetLocales(portalId)
                    select new CulturesWithActiveState
            {
                Code = c.Value.Code,
                Text = c.Value.Text,
                Active = AvailableEAVLanguages.Any(a => a.Active && a.ExternalKey == c.Value.Code && a.ZoneID == zoneId),
                // Allow State Change only if
                // 1. This is the default language and default language is not active or
                // 2. This is NOT the default language and default language is active
                AllowStateChange = (c.Value.Code == DefaultLanguageCode && !DefaultLanguageIsActive) || (DefaultLanguageIsActive && c.Value.Code != DefaultLanguageCode)
            }).OrderByDescending(c => c.Code == DefaultLanguageCode).ThenBy(c => c.Code).ToList());
        }
Example #14
0
        private Entity CreateItemAndAddToList(int parentId, string field, int sortOrder, string contentTypeName,
                                              Dictionary <string, object> values)
        {
            var cgApp = SxcContext.App;
            var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId);

            eavDc.UserName = Environment.Dnn7.UserIdentity.CurrentUserIdentityToken;

            #region create the new entity --> note that it's the sql-type entity, not a standard ientity

            var contentType =
                DataSource.GetCache(cgApp.ZoneId, cgApp.AppId)
                .GetContentType(contentTypeName);

            var entity = eavDc.Entities.AddEntity(contentType.AttributeSetId, values, null, null);

            #endregion

            #region attach to the current list of items

            var cbEnt = SxcContext.App.Data["Default"].List[parentId];
            // ((EntityContentBlock) SxcContext.ContentBlock).ContentBlockEntity;
            var blockList = ((Eav.Data.EntityRelationship)cbEnt.GetBestValue(field)).ToList() ?? new List <IEntity>();

            var intList = blockList.Select(b => b.EntityId).ToList();
            if (sortOrder > intList.Count)
            {
                sortOrder = intList.Count;
            }
            intList.Insert(sortOrder, entity.EntityID);

            var updateDic = new Dictionary <string, int[]> {
                { field, intList.ToArray() }
            };
            eavDc.Entities.UpdateEntity(cbEnt.EntityGuid, updateDic);

            #endregion

            return(entity);
        }
Example #15
0
        /// <summary>
        /// Adds or updates a template - will create a new template if templateId is not specified
        /// </summary>
        public void UpdateTemplate(int?templateId, string name, string path, string contentTypeStaticName,
                                   int?contentDemoEntity, string presentationTypeStaticName, int?presentationDemoEntity,
                                   string listContentTypeStaticName, int?listContentDemoEntity, string listPresentationTypeStaticName,
                                   int?listPresentationDemoEntity, string templateType, bool isHidden, string location, bool useForList,
                                   bool publishData, string streamsToPublish, int?pipelineEntity, string viewNameInUrl)
        {
            var values = new Dictionary <string, object>
            {
                { "Name", name },
                { "Path", path },
                { "ContentTypeStaticName", contentTypeStaticName },
                { "ContentDemoEntity", contentDemoEntity.HasValue ? new[] { contentDemoEntity.Value } : new int[] {} },
                { "PresentationTypeStaticName", presentationTypeStaticName },
                { "PresentationDemoEntity", presentationDemoEntity.HasValue ? new[] { presentationDemoEntity.Value } : new int[] {} },
                { "ListContentTypeStaticName", listContentTypeStaticName },
                { "ListContentDemoEntity", listContentDemoEntity.HasValue ? new[] { listContentDemoEntity.Value } : new int[] {} },
                { "ListPresentationTypeStaticName", listPresentationTypeStaticName },
                { "ListPresentationDemoEntity", listPresentationDemoEntity.HasValue ? new[] { listPresentationDemoEntity.Value } : new int[] {} },
                { "Type", templateType },
                { "IsHidden", isHidden },
                { "Location", location },
                { "UseForList", useForList },
                { "PublishData", publishData },
                { "StreamsToPublish", streamsToPublish },
                { "Pipeline", pipelineEntity.HasValue ? new[] { pipelineEntity } : new int?[] {} },
                { "ViewNameInUrl", viewNameInUrl }
            };

            var context = EavDataController.Instance(_zoneId, _appId).Entities;// EavContext.Instance(_zoneId, _appId);

            if (templateId.HasValue)
            {
                context.UpdateEntity(templateId.Value, values);
            }
            else
            {
                var contentType = DataSource.GetCache(_zoneId, _appId).GetContentType(TemplateTypeName);
                context.AddEntity(contentType.AttributeSetId, values, null, null);
            }
        }
Example #16
0
        private void SaveChangedLists(Dictionary <string, int?[]> values)
        {
            // ensure that there are never more presentations than values
            if (values.ContainsKey(cPresentation))
            {
                var contentCount = Content.Count;
                if (values.ContainsKey(cContent))
                {
                    contentCount = values[cContent].Length;
                }
                if (values[cPresentation].Length > contentCount)
                {
                    throw new Exception("Presentation may not contain more items than Content.");
                }
            }

            var context = EavDataController.Instance(_zoneId, _appId).Entities; // EavContext.Instance(_zoneId, _appId);

            context.UpdateEntity(_contentGroupEntity.EntityGuid, values);

            // Refresh content group entity (ensures contentgroup is up to date)
            _contentGroupEntity =
                new ContentGroupManager(_zoneId, _appId).GetContentGroup(_contentGroupEntity.EntityGuid)._contentGroupEntity;
        }
Example #17
0
        /// <summary>
        /// Do the import
        /// </summary>
        public bool ImportXml(int zoneId, int appId, XDocument doc, bool leaveExistingValuesUntouched = true)
        {
            //_sexy = new SxcInstance(zoneId, appId); // 2016-03-26 2dm this used to have a third parameter false = don't enable caching, which hasn't been respected for a while; removed it
            // App = new App(zoneId, appId, PortalSettings.Current); // 2016-04-07 2dm refactored this out of this, as using App had side-effects
            _eavContext = EavDataController.Instance(zoneId, appId);

            _appId  = appId;
            _zoneId = zoneId;

            if (!IsCompatible(doc))
            {
                ImportLog.Add(new ExportImportMessage("The import file is not compatible with the installed version of 2sxc.", ExportImportMessage.MessageTypes.Error));
                return(false);
            }

            // Get root node "SexyContent"
            var xmlSource = doc.Element(XmlConstants.RootNode);

            if (xmlSource == null)
            {
                ImportLog.Add(new ExportImportMessage("Xml doesn't have expected root node: " + XmlConstants.RootNode, ExportImportMessage.MessageTypes.Error));
                return(false);
            }
            PrepareFolderIdCorrectionListAndCreateMissingFolders(xmlSource);
            PrepareFileIdCorrectionList(xmlSource);

            #region Prepare dimensions
            _sourceDimensions = xmlSource.Element(XmlConstants.Header)?.Element(XmlConstants.Dimensions)?.Elements(XmlConstants.Dim).Select(p => new Dimension
            {
                DimensionID = int.Parse(p.Attribute(XmlConstants.DimId).Value),
                Name        = p.Attribute("Name").Value,
                SystemKey   = p.Attribute("SystemKey").Value,
                ExternalKey = p.Attribute("ExternalKey").Value,
                Active      = Parse(p.Attribute("Active").Value)
            }).ToList();

            _sourceDefaultLanguage = xmlSource.Element(XmlConstants.Header)?.Element(XmlConstants.Language)?.Attribute(XmlConstants.LangDefault).Value;
            if (_sourceDimensions == null || _sourceDefaultLanguage == null)
            {
                ImportLog.Add(new ExportImportMessage("Cant find source dimensions or source-default language.", ExportImportMessage.MessageTypes.Error));
                return(false);
            }

            _sourceDefaultDimensionId = _sourceDimensions.Any() ?
                                        _sourceDimensions.FirstOrDefault(p => p.ExternalKey == _sourceDefaultLanguage)?.DimensionID
                                : new int?();

            _targetDimensions = _eavContext.Dimensions.GetDimensionChildren("Culture");
            if (_targetDimensions.Count == 0)
            {
                _targetDimensions.Add(new Dimension
                {
                    Active      = true,
                    ExternalKey = DefaultLanguage,
                    Name        = "(added by import System, default language " + DefaultLanguage + ")",
                    SystemKey   = "Culture"
                });
            }
            #endregion

            var atsNodes = xmlSource.Element(XmlConstants.AttributeSets)?.Elements(XmlConstants.AttributeSet);
            var entNodes = xmlSource.Elements(XmlConstants.Entities).Elements(XmlConstants.Entity);

            var importAttributeSets = GetImportAttributeSets(atsNodes);
            var importEntities      = GetImportEntities(entNodes, ContentTypeHelpers.AssignmentObjectTypeIDDefault);

            var import = new Import(_zoneId, _appId, UserName, leaveExistingValuesUntouched);
            import.RunImport(importAttributeSets, importEntities);
            ImportLog.AddRange(GetExportImportMessagesFromImportLog(import.ImportLog));

            if (xmlSource.Elements(XmlConstants.Templates).Any())
            {
                ImportXmlTemplates(xmlSource);
            }

            return(true);
        }
Example #18
0
 public BllCommandBase(EavDataController dataController)
 {
     Context = dataController;
 }
Example #19
0
 public DbValue(EavDataController cntx)
     : base(cntx)
 {
 }
Example #20
0
        private int CreateItemAndAddToList(int parentId, string field, int sortOrder, string contentTypeName,
                                           Dictionary <string, object> values, Guid?newGuid)
        {
            var cgApp = SxcContext.App;
            var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId);

            eavDc.UserName = Environment.Dnn7.UserIdentity.CurrentUserIdentityToken;

            #region create the new entity --> note that it's the sql-type entity, not a standard ientity

            var contentType =
                DataSource.GetCache(cgApp.ZoneId, cgApp.AppId)
                .GetContentType(contentTypeName);

            int entityId;
            // check that it doesn't exist yet...
            if (newGuid.HasValue && eavDc.Entities.EntityExists(newGuid.Value))
            {
                // check if it's deleted - if yes, resurrect
                var existingEnt = eavDc.Entities.GetEntitiesByGuid(newGuid.Value).First();
                if (existingEnt.ChangeLogDeleted != null)
                {
                    existingEnt.ChangeLogDeleted = null;
                }

                entityId = existingEnt.EntityID;
                // todo: check if it exists on this list, or elsewhere. if it's elsewhere, then map it
                // throw new Exception("can't create this - already exists");
            }
            else
            {
                var entity = eavDc.Entities.AddEntity(contentType.AttributeSetId, values, null, null, entityGuid: newGuid);
                entityId = entity.EntityID;
            }

            #endregion

            #region attach to the current list of items

            var cbEnt = SxcContext.App.Data["Default"].List[parentId];
            // ((EntityContentBlock) SxcContext.ContentBlock).ContentBlockEntity;
            var blockList = ((Eav.Data.EntityRelationship)cbEnt.GetBestValue(field)).ToList() ?? new List <IEntity>();

            var intList = blockList.Select(b => b.EntityId).ToList();
            // add only if it's not already in the list (could happen if http requests are run again)
            if (!intList.Contains(entityId))
            {
                if (sortOrder > intList.Count)
                {
                    sortOrder = intList.Count;
                }
                intList.Insert(sortOrder, entityId);
            }
            var updateDic = new Dictionary <string, int[]> {
                { field, intList.ToArray() }
            };
            eavDc.Entities.UpdateEntity(cbEnt.EntityGuid, updateDic);

            #endregion

            return(entityId);
        }
Example #21
0
 public DbPipeline(EavDataController c)
     : base(c)
 {
 }
Example #22
0
 public DbAttribute(EavDataController cntx)
     : base(cntx)
 {
 }
Example #23
0
 // public DbDimensions(EavDataController dc) : base(dc) { }
 public DbDimensions(EavDataController ctx)
     : base(ctx)
 {
 }
Example #24
0
 public DbRelationship(EavDataController cntx)
     : base(cntx)
 {
 }
Example #25
0
        public static List <Zone> GetZones()
        {
            return(EavDataController.Instance(Constants.DefaultZoneId, AppHelpers.GetDefaultAppId(Constants.DefaultZoneId)).Zone.GetZones());

            //return new SxcInstance(Constants.DefaultZoneId, AppHelpers.GetDefaultAppId(Constants.DefaultZoneId)).EavAppContext.Zone.GetZones();
        }
Example #26
0
 public DbContentType(EavDataController cntx)
     : base(cntx)
 {
 }
Example #27
0
 public DbPublishing(EavDataController c)
     : base(c)
 {
 }
Example #28
0
        /// <summary>
        /// Create app-describing entity for configuration and add Settings and Resources Content Type
        /// </summary>
        /// <param name="zoneId"></param>
        /// <param name="appId"></param>
        internal static void EnsureAppIsConfigured(int zoneId, int appId, string appName = null)
        {
            var appMetaData  = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp, appId, Settings.AttributeSetStaticNameApps).FirstOrDefault();
            var appResources = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp, appId, Settings.AttributeSetStaticNameAppResources).FirstOrDefault();
            var appSettings  = DataSource.GetMetaDataSource(zoneId, appId).GetAssignedEntities(ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp, appId, Settings.AttributeSetStaticNameAppSettings).FirstOrDefault();

            // Get appName from cache
            var eavAppName = ((BaseCache)DataSource.GetCache(zoneId, null)).ZoneApps[zoneId].Apps[appId];

            if (eavAppName == Constants.DefaultAppName)
            {
                return;
            }

            var EavContext = EavDataController.Instance(zoneId, appId);

            if (appMetaData == null)
            {
                // Add app-describing entity
                var appAttributeSet = EavContext.AttribSet.GetAttributeSet(Settings.AttributeSetStaticNameApps).AttributeSetID;
                var values          = new OrderedDictionary
                {
                    { "DisplayName", String.IsNullOrEmpty(appName) ? eavAppName : appName },
                    { "Folder", String.IsNullOrEmpty(appName) ? eavAppName : RemoveIllegalCharsFromPath(appName) },
                    { "AllowTokenTemplates", "False" },
                    { "AllowRazorTemplates", "False" },
                    { "Version", "00.00.01" },
                    { "OriginalId", "" }
                };
                EavContext.Entities.AddEntity(appAttributeSet, values, null, appId, ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp);
            }

            if (appSettings == null)
            {
                AttributeSet settingsAttributeSet;
                // Add new (empty) ContentType for Settings
                if (!EavContext.AttribSet.AttributeSetExists(Settings.AttributeSetStaticNameAppSettings, appId))
                {
                    settingsAttributeSet = EavContext.AttribSet.AddAttributeSet(Settings.AttributeSetStaticNameAppSettings,
                                                                                "Stores settings for an app", Settings.AttributeSetStaticNameAppSettings, Settings.AttributeSetScopeApps);
                }
                else
                {
                    settingsAttributeSet = EavContext.AttribSet.GetAttributeSet(Settings.AttributeSetStaticNameAppSettings);
                }

                DataSource.GetCache(zoneId, appId).PurgeCache(zoneId, appId);
                EavContext.Entities.AddEntity(settingsAttributeSet, new OrderedDictionary(), null, appId, ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp);
            }

            if (appResources == null)
            {
                AttributeSet resourcesAttributeSet;

                // Add new (empty) ContentType for Resources
                if (!EavContext.AttribSet.AttributeSetExists(Settings.AttributeSetStaticNameAppResources, appId))
                {
                    resourcesAttributeSet = EavContext.AttribSet.AddAttributeSet(
                        Settings.AttributeSetStaticNameAppResources, "Stores resources like translations for an app",
                        Settings.AttributeSetStaticNameAppResources, Settings.AttributeSetScopeApps);
                }
                else
                {
                    resourcesAttributeSet = EavContext.AttribSet.GetAttributeSet(Settings.AttributeSetStaticNameAppResources);
                }

                DataSource.GetCache(zoneId, appId).PurgeCache(zoneId, appId);
                EavContext.Entities.AddEntity(resourcesAttributeSet, new OrderedDictionary(), null, appId, ContentTypeHelpers.AssignmentObjectTypeIDSexyContentApp);
            }

            if (appMetaData == null || appSettings == null || appResources == null)
            {
                DataSource.GetCache(zoneId, appId).PurgeCache(zoneId, appId);
            }
        }
Example #29
0
 public DbZone(EavDataController cntx)
     : base(cntx)
 {
 }
Example #30
0
 public DbEntity(EavDataController cntx) : base(cntx)
 {
 }
Example #31
0
 public DbApp(EavDataController cntx)
     : base(cntx)
 {
 }