Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
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();
        }