/// <summary> /// Removes the given locale, all data is lost /// </summary> /// <param name="cultureInfo"></param> /// <param name="makeFlush"></param> public static void RemoveLocale(CultureInfo cultureInfo, bool makeFlush = true) { Verify.That(!IsDefaultLocale(cultureInfo), "The locale '{0}' is the default locale and can not be removed", cultureInfo); Verify.That(!IsOnlyActiveLocaleForSomeUsers(cultureInfo), "The locale '{0}' is the only locale for some user(s) and can not be removed", cultureInfo); using (var transactionScope = TransactionsFacade.CreateNewScope()) { string cultureName = cultureInfo.Name; var systemActiveLocale = DataFacade.GetData <ISystemActiveLocale>().SingleOrDefault(f => f.CultureName == cultureName); Verify.IsNotNull(systemActiveLocale, "The locale '{0}' has not beed added and can not be removed", cultureInfo); List <string> usernames = (from u in DataFacade.GetData <IUser>() select u.Username).ToList(); foreach (string username in usernames) { if (cultureInfo.Equals(UserSettings.GetCurrentActiveLocaleCultureInfo(username))) { CultureInfo fallbackCultureInfo = UserSettings.GetActiveLocaleCultureInfos(username).First(f => !f.Equals(cultureInfo)); UserSettings.SetCurrentActiveLocaleCultureInfo(username, fallbackCultureInfo); } if (cultureInfo.Equals(UserSettings.GetForeignLocaleCultureInfo(username))) { UserSettings.SetForeignLocaleCultureInfo(username, null); } UserSettings.RemoveActiveLocaleCultureInfo(username, cultureInfo); } DataFacade.Delete <ISystemActiveLocale>(systemActiveLocale); transactionScope.Complete(); } DynamicTypeManager.RemoveLocale(cultureInfo); if (makeFlush) { C1Console.Events.GlobalEventSystemFacade.FlushTheSystem(false); } }