private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e)
        {
            string cultureName      = this.GetBinding <string>("CultureName");
            string urlMappingName   = this.GetBinding <string>("UrlMappingName");
            bool   accessToAllUsers = this.GetBinding <bool>("AccessToAllUsers");

            LocalizationFacade.AddLocale(cultureName, urlMappingName, accessToAllUsers);

            this.CloseCurrentView();

            ConsoleMessageQueueFacade.Enqueue(new BroadcastMessageQueueItem {
                Name = "LocalesUpdated", Value = ""
            }, null);


            var specificTreeRefresher = this.CreateSpecificTreeRefresher();

            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);

            var newLocaleDataItem = DataFacade.GetData <ISystemActiveLocale>().FirstOrDefault(l => l.CultureName == cultureName);

            if (newLocaleDataItem != null)
            {
                SelectElement(newLocaleDataItem.GetDataEntityToken());
            }
        }
Exemple #2
0
        private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e)
        {
            string cultureName      = this.GetBinding <string>("CultureName");
            string urlMappingName   = this.GetBinding <string>("UrlMappingName");
            bool   accessToAllUsers = this.GetBinding <bool>("AccessToAllUsers");

            LocalizationFacade.AddLocale(cultureName, urlMappingName, accessToAllUsers);

            this.CloseCurrentView();

            ConsoleMessageQueueFacade.Enqueue(new CollapseAndRefreshConsoleMessageQueueItem(), null);
            ConsoleMessageQueueFacade.Enqueue(new BroadcastMessageQueueItem {
                Name = "LocalesUpdated", Value = ""
            }, null);


            SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher();

            specificTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
Exemple #3
0
        /// <exclude />
        public override IEnumerable <XElement> Install()
        {
            Verify.IsNotNull(_localesToInstall, typeof(LocalePackageFragmentInstaller).Name + " has not been validated");

            XAttribute oldDefaultAttribute = null;

            if (DataLocalizationFacade.DefaultLocalizationCulture != null)
            {
                oldDefaultAttribute = new XAttribute("oldDefault", DataLocalizationFacade.DefaultLocalizationCulture.Name);
            }

            var localeElements = new List <XElement>();

            foreach (Tuple <CultureInfo, string, bool> tuple in _localesToInstall)
            {
                Log.LogVerbose(LogTitle, "Adding the locale '{0}'", tuple.Item1);

                LocalizationFacade.AddLocale(tuple.Item1, tuple.Item2, true, false);

                if (tuple.Item3)
                {
                    Log.LogVerbose(LogTitle, "Setting new default locale to '{0}'", tuple.Item1);

                    LocalizationFacade.SetDefaultLocale(tuple.Item1);
                }

                localeElements.Add(new XElement("Locale", new XAttribute("name", tuple.Item1.Name)));
            }

            var element = new XElement("Locales", localeElements);

            if (oldDefaultAttribute != null)
            {
                element.Add(oldDefaultAttribute);
            }

            yield return(element);
        }
Exemple #4
0
        /// <exclude />
        public static bool SetUp(string setupDescriptionXml, string username, string password, string email, string language, string consoleLanguage, bool newsletter)
        {
            ApplicationOnlineHandlerFacade.TurnApplicationOffline(false);

            username = username.Trim().ToLowerInvariant();

            XElement setupDescription = XElement.Parse(setupDescriptionXml);

            XElement setupRegistrationDescription = new XElement("registration",
                                                                 new XElement("user_email", email),
                                                                 new XElement("user_newsletter", newsletter),
                                                                 new XElement("user_consolelanguage", consoleLanguage),
                                                                 new XElement("user_websitelanguage", language),
                                                                 setupDescription);

            bool success = false;

            try
            {
                Log.LogInformation(VerboseLogTitle, "Downloading packages");

                string[]       packageUrls = GetPackageUrls(setupDescription).ToArray();
                MemoryStream[] packages    = new MemoryStream[packageUrls.Length];

                Parallel.For(0, packageUrls.Length, i =>
                {
                    packages[i] = DownloadPackage(packageUrls[i]);
                });

                Log.LogInformation(VerboseLogTitle, "Setting up the system for the first time");

                CultureInfo locale      = new CultureInfo(language);
                CultureInfo userCulture = new CultureInfo(consoleLanguage);

                ApplicationLevelEventHandlers.ApplicationStartInitialize();

                Log.LogInformation(VerboseLogTitle, "Creating first locale: " + language);
                LocalizationFacade.AddLocale(locale, "", true, false, true);


                Log.LogInformation(VerboseLogTitle, "Creating first user: "******"Installing package from url " + packageUrls[i]);
                        InstallPackage(packageUrls[i], packages[i]);

                        // Releasing a reference to reduce memory usage
                        packages[i].Dispose();
                        packages[i] = null;
                    }
                }

                RegisterSetup(setupRegistrationDescription.ToString(), "");

                Log.LogInformation(VerboseLogTitle, "Done setting up the system for the first time! Enjoy!");

                success = true;
            }
            catch (Exception ex)
            {
                Log.LogCritical(LogTitle, ex);
                Log.LogWarning(LogTitle, "First time setup failed - could not download, install package or otherwise complete the setup.");
                RegisterSetup(setupRegistrationDescription.ToString(), ex.ToString());

                if (RuntimeInformation.IsDebugBuild)
                {
                    ApplicationOnlineHandlerFacade.TurnApplicationOnline();
                    throw;
                }
            }

            ApplicationOnlineHandlerFacade.TurnApplicationOnline();
            return(success);
        }