Esempio n. 1
0
        public virtual LocaleSetting UpdateLocaleSetting(LocaleSetting entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            LocaleSetting other = GetLocaleSetting(entity.LocaleSettingId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update LocaleSetting set  [LocaleSettingGUID]=@LocaleSettingGUID
							, [Name]=@Name
							, [Description]=@Description
							, [DisplayOrder]=@DisplayOrder
							, [CreatedOn]=@CreatedOn
							, [DefaultCurrencyID]=@DefaultCurrencyID 
							 where LocaleSettingID=@LocaleSettingID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@LocaleSettingID", entity.LocaleSettingId)
                , new SqlParameter("@LocaleSettingGUID", entity.LocaleSettingGuid)
                , new SqlParameter("@Name", entity.Name)
                , new SqlParameter("@Description", entity.Description)
                , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
                , new SqlParameter("@DefaultCurrencyID", entity.DefaultCurrencyId)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetLocaleSetting(entity.LocaleSettingId));
        }
Esempio n. 2
0
        public async Task ShouldUpdateSiteLocale()
        {
            using (var unifiClient = new Client(_url))
            {
                var loginResult = await unifiClient.LoginAsync(_user, _pass);

                loginResult.Result.ShouldBeTrue();

                var createResult = await unifiClient.CreateSiteAsync("LocaleSite");

                createResult.ShouldNotBeNull();
                createResult.Meta.Rc.ToLower().ShouldBe("ok");

                var locale = new LocaleSetting()
                {
                    Timezone = "Australia/Canberra",
                    SiteId   = createResult.Data.First().Id
                };

                var result = await unifiClient.SetSiteLocaleAsync(locale, createResult.Data.First().Name);

                result.Result.ShouldBe(true);

                await unifiClient.DeleteSiteAsync(createResult.Data.First().Id);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// set the site locale.
        /// </summary>
        /// <param name="locale">The locale to set for the site.</param>
        /// <param name="siteName">Name of the site. If left null the process will rename the site specified is client.Site.</param>
        /// <returns>returns true on success</returns>
        public async Task <BoolResponse> SetSiteLocaleAsync(LocaleSetting locale, string siteName = null)
        {
            var path        = $"api/s/{(siteName ?? Site)}/rest/setting/locale/{locale.Timezone}";
            var oJsonObject = JObject.FromObject(locale);

            return(await ExecuteBoolCommandAsync(path, oJsonObject));
        }
Esempio n. 4
0
        public Embed GetDiscordEmbed(LocaleSetting locale, out GuildEmote subEmote, out GuildEmote specialEmote, SocketGuild guild)
        {
            try
            {
                Image img = new Image(WebRequest.Create(GetSubWeapon().GetImageUrl()).GetResponse().GetResponseStream());
                subEmote = guild.CreateEmoteAsync(Name, img).GetAwaiter().GetResult();
            }
            catch
            {
                subEmote = null;
            }

            try
            {
                Image img = new Image(WebRequest.Create(GetSpecialWeapon().GetImageUrl()).GetResponse().GetResponseStream());
                specialEmote = guild.CreateEmoteAsync(Name, img).GetAwaiter().GetResult();
            }
            catch
            {
                specialEmote = null;
            }

            Embed eb = new EmbedBuilder()
                       .WithTitle(GetName(locale))
                       .WithThumbnailUrl(GetImageUrl())
                       .WithColor(new Color(0x00, 0xFF, 0x00))
                       .AddField("Sub Weapon", (subEmote == null ? "" : $"{subEmote} ") + $"*{GetSubWeapon().GetName(locale)}*")
                       .AddField("Special", (specialEmote == null ? "" : $"{specialEmote} ") + $"*{GetSpecialWeapon().GetName(locale)}*")
                       .AddField(Data.Locales[(int)locale].First(x => x.Key == Param0).Value, $"{ASCIIUI.CreateTextBar(ParamValue0, 100)} **[{ParamValue0}/100]**")
                       .AddField(Data.Locales[(int)locale].First(x => x.Key == Param1).Value, $"{ASCIIUI.CreateTextBar(ParamValue1, 100)} **[{ParamValue1}/100]**")
                       .AddField(Data.Locales[(int)locale].First(x => x.Key == Param2).Value, $"{ASCIIUI.CreateTextBar(ParamValue2, 100)} **[{ParamValue2}/100]**")
                       .Build();

            return(eb);
        }
Esempio n. 5
0
 public Embed GetDiscordEmbed(LocaleSetting locale)
 {
     return(new EmbedBuilder()
            .WithTitle(GetName(locale))
            .WithThumbnailUrl(GetImageUrl())
            .WithColor(new Color(0xFF, 0x90, 0x00))
            .Build());
 }
Esempio n. 6
0
File: Shell.cs Progetto: A-Kaga/ing
        public Shell(LayoutSetting layoutSetting, ITextStreamProvider gameProvider, LocaleSetting localeSetting, ILocalizationService localizationService)
        {
            this.layoutSetting       = layoutSetting;
            this.gameProvider        = gameProvider;
            this.localizationService = localizationService;

            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = localeSetting.Language.Value;
        }
Esempio n. 7
0
        public UWPShell(LayoutSetting layoutSetting, LocaleSetting localeSetting, ILocalizationService localization)
            : base(localization)
        {
            this.layoutSetting = layoutSetting;
            this.localization  = localization;

            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = localeSetting.Language.Value;
        }
Esempio n. 8
0
        public LocalizationService(LocaleSetting localeSetting)
        {
            string value = localeSetting.Language.Value;

            if (!string.IsNullOrEmpty(value))
            {
                CultureInfo.DefaultThreadCurrentUICulture             = CultureInfo.DefaultThreadCurrentCulture
                                                                      = new CultureInfo(value);
            }
        }
Esempio n. 9
0
 public string GetName(LocaleSetting locale)
 {
     try
     {
         return(Data.Locales[(int)locale].First(x => x.Key == Name).Value);
     }
     catch
     {
         return("ERROR!");
     }
 }
Esempio n. 10
0
        public virtual LocaleSetting LocaleSettingFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            LocaleSetting entity = new LocaleSetting();

            entity.LocaleSettingId   = (System.Int32)dr["LocaleSettingID"];
            entity.LocaleSettingGuid = (System.Guid)dr["LocaleSettingGUID"];
            entity.Name              = dr["Name"].ToString();
            entity.Description       = dr["Description"].ToString();
            entity.DisplayOrder      = (System.Int32)dr["DisplayOrder"];
            entity.CreatedOn         = (System.DateTime)dr["CreatedOn"];
            entity.DefaultCurrencyId = (System.Int32)dr["DefaultCurrencyID"];
            return(entity);
        }
Esempio n. 11
0
        public Shell(LayoutSetting layoutSetting, ILocalizationService localization, LocaleSetting locale, ITextStreamProvider provider)
        {
            _mainWindowVM = new MainWindowVM()
            {
                Title = "Intelligent Naval Gun",
            };
            this.layoutSetting = layoutSetting;
            this.localization  = localization;
            this.provider      = provider;
            localeName         = locale.Language.Value;
            var userFontName = locale.UserLanguageFont.Value;

            if (!string.IsNullOrEmpty(userFontName))
            {
                userFont = new FontFamily(userFontName);
            }
        }
Esempio n. 12
0
        public LocalizationService(LocaleSetting setting)
        {
            var asm = Assembly.GetExecutingAssembly();

            SupportedCultures = asm.GetManifestResourceNames()
                                .Select(x => new CultureInfo(Path.GetFileNameWithoutExtension(x).Split('.').Last()))
                                .ToArray();

            CultureInfo culture;

            if (string.IsNullOrEmpty(setting.Language.Value))
            {
                culture = CultureInfo.CurrentCulture;
            }
            else
            {
                CultureInfo.DefaultThreadCurrentUICulture             = CultureInfo.DefaultThreadCurrentCulture
                                                                      = culture = new CultureInfo(setting.Language.Value);
            }

            while (!string.IsNullOrEmpty(culture.Name))
            {
                using var stream = asm.GetManifestResourceStream(typeof(LocalizationService), $"Strings.{culture.Name}.json");
                if (stream is object)
                {
                    _currentCulture = LoadStringsAsync(stream).Result;
                    break;
                }
                culture = culture.Parent;
            }

            using var fallbackStream = asm.GetManifestResourceStream(typeof(LocalizationService), $"Strings.en-US.json");
            _fallback = LoadStringsAsync(fallbackStream).Result;
            using var gameContentStream = asm.GetManifestResourceStream(typeof(LocalizationService), $"Strings.ja.json");
            _gameContent = LoadStringsAsync(gameContentStream).Result;

            if (_currentCulture is null)
            {
                _currentCulture = _fallback;
            }
        }
Esempio n. 13
0
        public virtual LocaleSetting InsertLocaleSetting(LocaleSetting entity)
        {
            LocaleSetting other = new LocaleSetting();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into LocaleSetting ( [LocaleSettingGUID]
				,[Name]
				,[Description]
				,[DisplayOrder]
				,[CreatedOn]
				,[DefaultCurrencyID] )
				Values
				( @LocaleSettingGUID
				, @Name
				, @Description
				, @DisplayOrder
				, @CreatedOn
				, @DefaultCurrencyID );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@LocaleSettingID", entity.LocaleSettingId)
                    , new SqlParameter("@LocaleSettingGUID", entity.LocaleSettingGuid)
                    , new SqlParameter("@Name", entity.Name)
                    , new SqlParameter("@Description", entity.Description)
                    , new SqlParameter("@DisplayOrder", entity.DisplayOrder)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                    , new SqlParameter("@DefaultCurrencyID", entity.DefaultCurrencyId)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetLocaleSetting(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Esempio n. 14
0
        public DesktopShell(LayoutSetting layoutSetting, ILocalizationService localization, LocaleSetting locale, ITextStreamProvider provider)
            : base(localization)
        {
            this.layoutSetting = layoutSetting;
            this.localization  = localization;
            this.provider      = provider;
            localeName         = locale.Language.Value;
            var userFontName = locale.UserLanguageFont.Value;

            if (!string.IsNullOrEmpty(userFontName))
            {
                userFont = new FontFamily(userFontName);
            }
        }
Esempio n. 15
0
 public LocaleSetting InsertLocaleSetting(LocaleSetting entity)
 {
     return(_iLocaleSettingRepository.InsertLocaleSetting(entity));
 }
Esempio n. 16
0
        public NotificationManager(INotifier[] notifiers, ISettingsManager settings, ILocalizationService localization, IShell shell, LocaleSetting localeSetting)
        {
            translate              = localeSetting.TranslateContent.InitialValue;
            this.notifiers         = notifiers.Where(x => x.IsSupported).ToArray();
            AvailableNotifiers     = this.notifiers.Select(x => x.Id).ToArray();
            Notifier               = settings.Register <string>("notification.notifier");
            Notifier.ValueChanged += SetNotifier;
            SetNotifier(Notifier.Value);
            this.localization = localization;

            shell.Exited += () => SelectedNotifier.Deinitialize();
        }
Esempio n. 17
0
 public LocaleSettingView(LocaleSetting instance)
 {
     Instance = instance;
     InitializeComponent();
 }
Esempio n. 18
0
 public virtual LocaleSetting DeleteLocaleSetting(LocaleSetting entity)
 {
     this.DeleteLocaleSetting(entity.LocaleSettingId);
     return(entity);
 }
Esempio n. 19
0
 public LocaleSetting UpdateLocaleSetting(LocaleSetting entity)
 {
     return(_iLocaleSettingRepository.UpdateLocaleSetting(entity));
 }