Exemplo n.º 1
0
        public ActionResult DeleteLanguageConfirmation(Guid id)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    using (UnitOfWorkManager.NewUnitOfWork())
                    {
                        var language          = LocalizationService.Get(id);
                        var languageViewModel = new LanguageDisplayViewModel
                        {
                            Id        = language.Id,
                            IsDefault =
                                language.Id == LocalizationService.CurrentLanguage.Id,
                            Name            = language.Name,
                            LanguageCulture = language.LanguageCulture,
                        };

                        return(View(languageViewModel));
                    }
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                    LoggingService.Error("Delete confirmation not working");
                    return(View("Index"));
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult ManageLanguageResourceValues(Guid languageId, int?p, string search = "", string SearchKeys = "")
        {
            var language = LocalizationService.Get(languageId);

            if (language == null)
            {
                return(RedirectToAction("Index"));
            }

            int limit = 30;
            var count = LocalizationService.GetListKeyResourceCount(language.Id, SearchKeys, search);

            var Paging = CalcPaging(limit, p, count);

            var resourceListModel = new LanguageListResourcesViewModel
            {
                LanguageId      = language.Id,
                LanguageName    = language.Name,
                Search          = search,
                SearchKeys      = SearchKeys,
                Paging          = Paging,
                LocaleResources = LocalizationService.GetListKeyResource(language.Id, SearchKeys, search, Paging.Page, limit)
            };

            return(View("ListValues", resourceListModel));
        }
Exemplo n.º 3
0
    public static bool SetPlayModel()
    {
        if (Profile.Hearts < 1)
        {
            Game.Instance.OpenPopup <Popup_BuyHearts>();
            return(false);
        }
        else
        {
            Profile.Hearts--;
        }

        PlayModel.Reset(PlayModel.Type.Classic);
        PlayModel.ballId               = Profile.Avatar.BallId;
        PlayModel.level.name           = string.Format(LocalizationService.Get(111127), Profile.MaxClassicScore);
        PlayModel.level.theme          = Random.Range(0, 1000);
        PlayModel.level.pattern        = GlobalFactory.Patterns.Classic.Get();
        PlayModel.level.startBallCount = 5;
        PlayModel.level.minBlockHealth = 1;
        PlayModel.level.maxBlockHealth = 10;

        PlayModel.onPreLose = OnPreLose;
        PlayModel.onLose    = OnLose;

        return(true);
    }
        protected virtual async Task ReplyInteractiveAsync(ServiceResponse response, string titleSuccess)
        {
            var messageBuilder = new StringBuilder();

            messageBuilder.AppendLine(response.Message);
            var callbackCounter = 1;

            foreach (var resultInterActiveCallback in response.InterActiveCallbacks)
            {
                var emoji = EmojiService.Get(callbackCounter);
                messageBuilder.AppendLine(emoji.Name + " " + resultInterActiveCallback.Key);
                callbackCounter++;
            }
            var embed = BuildEmbed(LocalizationService.Get(typeof(i18n), "Base_Messages_Reply_Interactive"), messageBuilder.ToString(), Color.Orange);
            var reply = new ReactionCallbackData(string.Empty, embed, TimeSpan.FromSeconds(30));

            callbackCounter = 1;
            foreach (var resultInterActiveCallback in response.InterActiveCallbacks)
            {
                var emoji = EmojiService.Get(callbackCounter);
                reply.WithCallback(emoji, c => ReplyWithInteractive(resultInterActiveCallback.Value, titleSuccess));
                callbackCounter++;
            }
            await InlineReactionReplyAsync(reply);
        }
        public ActionResult ChangeLanguage(Guid lang)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var language = LocalizationService.Get(lang);
                LocalizationService.CurrentLanguage = language;

                // The current language is stored in a cookie
                var cookie = new HttpCookie(AppConstants.LanguageIdCookieName)
                {
                    HttpOnly = false,
                    Value    = language.Id.ToString(),
                    Expires  = DateTime.Now.AddYears(1)
                };

                Response.Cookies.Add(cookie);

                //TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                //{
                //    Message = LocalizationService.GetResourceString("Language.Changed"),
                //    MessageType = GenericMessages.success
                //};

                return(Content("success"));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Change the current language (typically called from each language link generated in this controller's index method)
        /// </summary>
        /// <param name="lang"></param>
        /// <returns></returns>
        public ActionResult ChangeLanguage(Guid lang)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var language = LocalizationService.Get(lang);
                LocalizationService.CurrentLanguage = language;

                // The current language is stored in a cookie
                var cookie = new HttpCookie(AppConstants.LanguageCultureCookieName)
                {
                    HttpOnly = false,
                    Value    = language.LanguageCulture,
                    Expires  = DateTime.UtcNow.AddYears(1)
                };

                Response.Cookies.Add(cookie);

                TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                {
                    Message     = LocalizationService.GetResourceString("Language.Changed"),
                    MessageType = GenericMessages.success
                };

                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Search through all resources for a language by page and search terms.
        ///     Search either by key or value.
        /// </summary>
        /// <param name="searchByKey">True means serach the keys else search the values</param>
        /// <param name="languageId"></param>
        /// <param name="p"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        private async Task <ActionResult> GetLanguageResources(bool searchByKey, Guid languageId, int?p, string search)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errors = (from key in ModelState.Keys
                                  select ModelState[key]
                                  into state
                                  where state.Errors.Any()
                                  select state.Errors.First().ErrorMessage).ToList();
                    ShowErrors(errors);
                }
                else
                {
                    var language  = LocalizationService.Get(languageId);
                    var pageIndex = p ?? 1;

                    // Get all the resources or just the ones that match the search
                    var allResources = string.IsNullOrWhiteSpace(search)
                        ? await LocalizationService.GetAllValues(language.Id, pageIndex,
                                                                 ForumConfiguration.Instance.AdminListPageSize)
                        : searchByKey
                            ? await LocalizationService.SearchResourceKeys(language.Id, search,
                                                                           pageIndex,
                                                                           ForumConfiguration.Instance.AdminListPageSize)
                            : await LocalizationService.SearchResourceValues(language.Id, search,
                                                                             pageIndex,
                                                                             ForumConfiguration.Instance.AdminListPageSize);

                    var models = allResources.Select(resource => new LocaleResourceViewModel
                    {
                        Id                = resource.Id,
                        ResourceKeyId     = resource.LocaleResourceKey.Id,
                        LocaleResourceKey = resource.LocaleResourceKey.Name,
                        ResourceValue     = resource.ResourceValue
                    }).ToList();

                    var resourceListModel = new LanguageListResourcesViewModel
                    {
                        LanguageId      = language.Id,
                        LanguageName    = language.Name,
                        LocaleResources = models,
                        PageIndex       = pageIndex,
                        TotalCount      = allResources.TotalCount,
                        Search          = search,
                        TotalPages      = allResources.TotalPages
                    };

                    return(View("ListValues", resourceListModel));
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            // Default ie error
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
        public ActionResult DeleteLanguage(Guid Id)
        {
            var language = LocalizationService.Get(Id);

            if (language == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(language));
        }
Exemplo n.º 9
0
        public ActionResult Index(EditSettingsViewModel settingsViewModel)
        {
            if (ModelState.IsValid)
            {
                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    try
                    {
                        var existingSettings = SettingsService.GetSettings();
                        var updatedSettings  = ViewModelMapping.SettingsViewModelToSettings(settingsViewModel, existingSettings);

                        // Map over viewModel from
                        if (settingsViewModel.NewMemberStartingRole != null)
                        {
                            updatedSettings.NewMemberStartingRole =
                                _roleService.GetRole(settingsViewModel.NewMemberStartingRole.Value);
                        }

                        if (settingsViewModel.DefaultLanguage != null)
                        {
                            updatedSettings.DefaultLanguage =
                                LocalizationService.Get(settingsViewModel.DefaultLanguage.Value);
                        }

                        var culture = new CultureInfo(updatedSettings.DefaultLanguage.LanguageCulture);

                        unitOfWork.Commit();

                        // Set the culture session too
                        Session["Culture"] = culture;
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        LoggingService.Error(ex);
                    }
                }

                // All good clear cache and get reliant lists
                using (UnitOfWorkManager.NewUnitOfWork())
                {
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = "Settings Updated",
                        MessageType = GenericMessages.success
                    };
                    settingsViewModel.Themes    = AppHelpers.GetThemeFolders();
                    settingsViewModel.Roles     = _roleService.AllRoles().ToList();
                    settingsViewModel.Languages = LocalizationService.AllLanguages.ToList();
                }
            }
            return(View(settingsViewModel));
        }
Exemplo n.º 10
0
    public bool Display(float delay, bool displayOnce, int stringId, System.Action onClose)
    {
        if (displayOnce)
        {
            bool displayed = PlayerPrefs.GetInt(name + ".Totorial." + stringId, 0) > 0;
            if (displayed)
            {
                return(false);
            }
            PlayerPrefs.SetInt(name + ".Totorial." + stringId, 1);
        }

        return(Display(delay, LocalizationService.Get(stringId), onClose));
    }
Exemplo n.º 11
0
    private IEnumerator Start()
    {
        scoreLabel.SetText("0");

        int totalBalls = PlayModel.result.totalBalls + PlayModel.level.startBallCount;

        descLabel.SetFormatedText(PlayModel.result.totalTurn.ToString(), PlayModel.result.totalBlocks.ToString(), totalBalls);

        inviteButton.onClick.AddListener(() =>
        {
            var str = string.Format(GlobalConfig.Socials.invitationText, Profile.Username, GlobalConfig.Market.storeUrl);
            SocialAndSharing.ShareText(str);
        });

        replayButton.onClick.AddListener(() =>
        {
            onReplayFunc(() =>
            {
                base.Back();
                UIBackground.Hide();
                Game.Instance.ClosePopup(true);
                Game.Instance.OpenState <State_Playing>();
            });
        });

        baloon.gameObject.SetActive(false);
        UiShowHide.ShowAll(transform);
        yield return(new WaitForSeconds(0.5f));

        // Incentive  text
        {
            var index        = BaloonIndex++ % 25;
            var incentiveStr = LocalizationService.Get(111090 + index);
            baloon.SetText(incentiveStr);
            baloon.gameObject.SetActive(true);
        }

        float t = 0;
        float curscore = 0, maxscore = PlayModel.GetScore();
        var   wait = new WaitForEndOfFrame();

        while (t < 1)
        {
            t       += Time.deltaTime * 0.75f;
            curscore = Mathf.Lerp(0, maxscore, t);
            scoreLabel.SetText(Mathf.RoundToInt(curscore).ToString());
            yield return(wait);
        }
    }
        public async Task OcrAsync()
        {
            try
            {
                var utcNow = SystemClock.Instance.GetCurrentInstant().InUtc();
                // Subtract around 30 seconds to account for the delay to take and send a screenshot
                utcNow = utcNow.Minus(Duration.FromSeconds(30));
                using (var httpClient = new HttpClient())
                {
                    foreach (var attachment in Context.Message.Attachments)
                    {
                        if (!await IsImageUrlAsync(httpClient, attachment.Url))
                        {
                            continue;
                        }
                        var tempImageFile = string.Empty;
                        try
                        {
                            tempImageFile = Path.GetTempFileName() + "." + attachment.Url.Split('.').Last();
                            await DownloadAsync(httpClient, new Uri(attachment.Url), tempImageFile);

                            var response = OcrService.AddRaidAsync(typeof(i18n), utcNow, ChannelTimeZone, tempImageFile, InteractiveReactionLimit, Fences, false);
                            await ReplyWithInteractive(() => response, LocalizationService.Get(typeof(i18n), "Raids_Messages_Ocr_Successful_Title"));
                        }
                        finally
                        {
                            try
                            {
                                if (File.Exists(tempImageFile))
                                {
                                    File.Delete(tempImageFile);
                                }
                            }
                            catch (Exception)
                            {
                                // Ignore
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var innerstEx = ex.GetInnermostException();
                Console.WriteLine(innerstEx.Message);
                Console.WriteLine(innerstEx.StackTrace);
                await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
            }
        }
Exemplo n.º 13
0
 public async Task RegisterAsync(string name, string newName = null)
 {
     try
     {
         var response = await PokestopService.ConvertToGymAsync(name, newName, Fences);
         await ReplyWithInteractive(() => Task.FromResult(response as ServiceResponse), "Converted");
     }
     catch (Exception ex)
     {
         var innerstEx = ex.GetInnermostException();
         Console.WriteLine(innerstEx.Message);
         Console.WriteLine(innerstEx.StackTrace);
         await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
     }
 }
Exemplo n.º 14
0
 public async Task RegisterAsync(string trainerName, double latitude, double longitude, string friendshipCode)
 {
     try
     {
         var response = await UserService.RegisterAsync(trainerName, latitude, longitude, friendshipCode, Context.Message.Author.Id, Context.Message.Author.Mention);
         await ReplyWithInteractive(() => Task.FromResult(response as ServiceResponse), "Registered");
     }
     catch (Exception ex)
     {
         var innerstEx = ex.GetInnermostException();
         Console.WriteLine(innerstEx.Message);
         Console.WriteLine(innerstEx.StackTrace);
         await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
     }
 }
Exemplo n.º 15
0
 public async Task AddQuestAsync(string pokestopName, string questNameOrAlias)
 {
     try
     {
         var response = await QuestService.AddAsync(pokestopName, questNameOrAlias, InteractiveReactionLimit, Fences);
         await ReplyWithInteractive(() => Task.FromResult(response), "Quest added");
     }
     catch (Exception ex)
     {
         var innerstEx = ex.GetInnermostException();
         Console.WriteLine(innerstEx.Message);
         Console.WriteLine(innerstEx.StackTrace);
         await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
     }
 }
Exemplo n.º 16
0
 private string TimeToString(long secconds)
 {
     if (secconds / 86400 > 0)
     {
         return(string.Format(LocalizationService.Get(111006), secconds / 86400));
     }
     if (secconds / 3600 > 0)
     {
         return(string.Format(LocalizationService.Get(111007), secconds / 3600));
     }
     if (secconds / 60 > 0)
     {
         return(string.Format(LocalizationService.Get(111008), secconds / 60));
     }
     return(string.Format(LocalizationService.Get(111009), secconds));
 }
Exemplo n.º 17
0
    void Update()
    {
        if (_label != null && _curLangId != (int)LocalizationService.CurrentLang)
        {
            _curLangId = (int)LocalizationService.CurrentLang;

            var val = LocalizationService.Get(_key);

            if (!string.IsNullOrEmpty(val))
            {
                val = val.Replace("\\n", "\n");
            }

            _label.text = val;
        }
    }
Exemplo n.º 18
0
        public ActionResult Index(EditSettingsViewModel settingsViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var existingSettings = SettingsService.GetSettings(false);
                    var updatedSettings  =
                        ViewModelMapping.SettingsViewModelToSettings(settingsViewModel, existingSettings);

                    // Map over viewModel from
                    if (settingsViewModel.NewMemberStartingRole != null)
                    {
                        updatedSettings.NewMemberStartingRole =
                            _roleService.GetRole(settingsViewModel.NewMemberStartingRole.Value);
                    }

                    if (settingsViewModel.DefaultLanguage != null)
                    {
                        updatedSettings.DefaultLanguage =
                            LocalizationService.Get(settingsViewModel.DefaultLanguage.Value);
                    }

                    Context.SaveChanges();
                    _cacheService.ClearStartsWith(CacheKeys.Settings.Main);
                }
                catch (Exception ex)
                {
                    Context.RollBack();
                    LoggingService.Error(ex);
                }


                // All good clear cache and get reliant lists

                TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                {
                    Message     = "Settings Updated",
                    MessageType = GenericMessages.success
                };
                settingsViewModel.Themes    = AppHelpers.GetThemeFolders();
                settingsViewModel.Roles     = _roleService.AllRoles().ToList();
                settingsViewModel.Languages = LocalizationService.AllLanguages.ToList();
            }
            return(View(settingsViewModel));
        }
Exemplo n.º 19
0
        public ActionResult DeleteLanguage(string buttonYes, string buttonNo, Guid id)
        {
            if (buttonYes != null)
            {
                try
                {
                    LocalizationService.Delete(LocalizationService.Get(id));
                    Context.SaveChanges();
                    ShowSuccess("Language Deleted");
                }
                catch (Exception ex)
                {
                    Context.RollBack();
                    ShowError(ex.Message);
                    LoggingService.Error(ex);
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
    // Use this for initialization
    private IEnumerator Start()
    {
        UiShowHide.ShowAll(transform);

        yield return(new WaitForSeconds(1));

        hint.gameObject.SetActive(true);
        hint.SetText(LocalizationService.Get(111045 + HintId++ % 5));

        var wait = new WaitForSeconds(0.5f);

        while (true)
        {
            if (PurchaseOffer.RemainedTime < 0)
            {
                Exit(false);
            }
            yield return(wait);
        }
    }
        protected async Task ReplyWithInteractive(Func <Task <ServiceResponse> > interactiveCallback, string titleSuccess)
        {
            var result = await interactiveCallback();

            if (result.IsSuccess)
            {
                var messageBuilder = new StringBuilder(LocalizationService.Get(typeof(i18n), "Base_Messages_Reply_Success", Context.Message.Author.Mention) + Environment.NewLine);
                messageBuilder.Append(result.Message);
                await ReplySuccessAsync(titleSuccess, messageBuilder.ToString());
            }
            else
            {
                if (result.InterActiveCallbacks != null)
                {
                    await ReplyInteractiveAsync(result, titleSuccess);

                    return;
                }
                await ReplyFailureAsync(result.Message);
            }
        }
Exemplo n.º 22
0
        private static string GetMessage(NotificationType notificationType)
        {
            switch (notificationType)
            {
            case NotificationType.FullFuel:
                return(LocalizationService.Get(111090));

            case NotificationType.FreePackage:
                return(LocalizationService.Get(111091));

            case NotificationType.LeagueStart:
                return(LocalizationService.Get(111092));

            case NotificationType.LegendStore:
                return(LocalizationService.Get(111093));

            default:
                Debug.LogError("Please add notificaitonType: " + notificationType);
                return(null);
            }
        }
        public async Task HatchRaidAsync(string gymName, string pokemonName)
        {
            try
            {
                // Only listen to commands in the configured channels or to exceptions
                if (!CanProcessRequest)
                {
                    return;
                }

                var response = RaidService.HatchAsync(typeof(i18n), gymName, pokemonName, InteractiveReactionLimit, Fences);
                await ReplyWithInteractive(() => response, LocalizationService.Get(typeof(i18n), "Raids_Messages_Successful_Title"));
            }
            catch (Exception ex)
            {
                var innerstEx = ex.GetInnermostException();
                Console.WriteLine(innerstEx.Message);
                Console.WriteLine(innerstEx.StackTrace);
                await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
            }
        }
Exemplo n.º 24
0
		public async Task ListRaidAsync(string pokemonNameOrRaidLevel)
		{
			try
			{
				// Only listen to commands in the configured channels or to exceptions
				if (!CanProcessRequest)
				{
					return;
				}

				var utcNow = SystemClock.Instance.GetCurrentInstant().InUtc();
				var response = RaidService.GetRaidList(typeof(i18n), utcNow, ChannelTimeZone, pokemonNameOrRaidLevel, Fences, "time", InteractiveReactionLimit, FormatRaidList);
				await ReplyWithInteractive(() => response, LocalizationService.Get(typeof(i18n), "Raids_Messages_Successful_Title"));
			}
			catch (Exception ex)
			{
				var innerstEx = ex.GetInnermostException();
				Console.WriteLine(innerstEx.Message);
				Console.WriteLine(innerstEx.StackTrace);
				await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
			}
		}
Exemplo n.º 25
0
        public ActionResult DeleteLanguage1(Guid Id)
        {
            var language = LocalizationService.Get(Id);

            if (language == null)
            {
                return(RedirectToAction("Index"));
            }

            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    LocalizationService.Delete(language);

                    unitOfWork.Commit();
                    LocalizationService.Clear();
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Xóa gói ngôn ngữ thành công"),
                        MessageType = GenericMessages.success
                    };
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    LoggingService.Error(ex.Message);
                    TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = LocalizationService.GetResourceString("Có lỗi xảy ra!"),
                        MessageType = GenericMessages.warning
                    };
                }
            }

            return(View(language));
        }
        public async Task AddRaidAsync([Summary("Der Name der Arena.")] string gymName, [Summary("Der Name des Pokemon oder das Level des Raids")] string pokemonNameOrRaidLevel, [Summary("Die Zeit bis der Raid startet bzw. endet.")] string timeLeft)
        {
            try
            {
                // Only listen to commands in the configured channels or to exceptions
                if (!CanProcessRequest)
                {
                    return;
                }

                //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("de-DE");
                var utcNow   = SystemClock.Instance.GetCurrentInstant().InUtc();
                var response = RaidService.AddAsync(typeof(i18n), utcNow, ChannelTimeZone, gymName, pokemonNameOrRaidLevel, timeLeft, InteractiveReactionLimit, Fences);
                await ReplyWithInteractive(() => response, LocalizationService.Get(typeof(i18n), "Raids_Messages_Successful_Title"));
            }
            catch (Exception ex)
            {
                var innerstEx = ex.GetInnermostException();
                Console.WriteLine(innerstEx.Message);
                Console.WriteLine(innerstEx.StackTrace);
                await ReplyFailureAsync(LocalizationService.Get(typeof(i18n), "Raids_Errors_Unexpected", innerstEx.Message));
            }
        }
Exemplo n.º 27
0
        public ActionResult DeleteLanguage(string buttonYes, string buttonNo, Guid id)
        {
            if (buttonYes != null)
            {
                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    try
                    {
                        LocalizationService.Delete(LocalizationService.Get(id));
                        unitOfWork.Commit();
                        ShowSuccess("Language Deleted");
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        ShowError(ex.Message);
                        LoggingService.Error(ex);
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 28
0
    private static void OnPreLose(System.Action <bool> callback)
    {
        var score = PlayModel.GetScore();

        if (score < 1)
        {
            callback(true);
            return;
        }

        var maxdelta    = PlayModel.type == PlayModel.Type.LeagueBalls ? 10 : 50;
        var nextProfile = GetNextNearProfile(score, maxdelta); // 111058
        var nextMedal   = GetNextNearMedal(score, maxdelta);   // 111059

        if (nextProfile == null && nextMedal == null)
        {
            callback(true);
            return;
        }

        string confirmStr = string.Empty;

        if (nextMedal != null)
        {
            var scoreDelta = nextMedal.startScore - score;
            var strformat  = LocalizationService.Get(111059);
            confirmStr = string.Format(strformat, Profile.Nickname, nextMedal.name, scoreDelta);
        }
        else
        {
            var scoreDelta = nextProfile.score - score;
            var strformat  = LocalizationService.Get(111058);
            confirmStr = string.Format(strformat, Profile.Nickname, nextProfile.nickname, scoreDelta);
        }

        Game.Instance.OpenPopup <Popup_Confirm>().Setup(confirmStr, true, true, ok => callback(ok)).GetComponent <UiCharacter>(true, true).SetBody(1).SetFace(2);
    }
Exemplo n.º 29
0
        private ActionResult GetLanguageResources(bool searchByKey, Guid languageId, int?p, string search)
        {
            try
            {
                using (UnitOfWorkManager.NewUnitOfWork())
                {
                    var language = LocalizationService.Get(languageId);

                    int count   = LocalizationService.GetCountResourceKey();
                    int limit   = 30;
                    int MaxPage = count / limit;
                    if (count % limit > 0)
                    {
                        MaxPage++;
                    }
                    if (MaxPage == 0)
                    {
                        MaxPage = 1;
                    }

                    if (p == null)
                    {
                        p = 1;
                    }
                    if (p > MaxPage)
                    {
                        p = MaxPage;
                    }

                    var resources = LocalizationService.GetListResourceKey((int)p, limit);

                    var resourceListModel = new LanguageListResourcesViewModel
                    {
                        LanguageId      = language.Id,
                        LanguageName    = language.Name,
                        LocaleResources = new List <LocaleResourceViewModel>(),
                        PageIndex       = p,
                        TotalCount      = count,
                        Search          = search,
                        TotalPages      = MaxPage
                    };

                    foreach (var it in resources)
                    {
                        var ResourceString = LocalizationService.GetValueResource(it.Id, languageId);

                        if (ResourceString == null)
                        {
                            ResourceString = new LocaleStringResource {
                                ResourceValue = ""
                            }
                        }
                        ;

                        resourceListModel.LocaleResources.Add(new LocaleResourceViewModel {
                            Id                = ResourceString.Id,
                            ResourceKeyId     = it.Id,
                            LocaleResourceKey = it.Name,
                            ResourceValue     = ResourceString.ResourceValue
                        });
                    }



                    return(View("ListValues", resourceListModel));
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            // Default ie error
            return(RedirectToAction("Index"));
        }
        protected virtual async Task ReplyFailureAsync(string message)
        {
            var embed = BuildEmbed(LocalizationService.Get(typeof(i18n), "Base_Messages_Reply_Failure"), message, Color.Red);

            await ReplyEmbed(embed);
        }