Exemplo n.º 1
0
        public string GetResourceString(string key)
        {
            if (CurrentLang.ContainsKey(key))
            {
                return(CurrentLang[key] as string);
            }

            try
            {
                return(GetResourceString(Lang_Id, key));
            }
            catch
            {
                return(key);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 翻訳された文字列を取得します.
 /// </summary>
 /// <param name="key">Key.</param>
 public string this[string key] => CurrentLang != null ? (CurrentLang.ContainsKey(key) ? CurrentLang[key] : key) : key;
    public override void DataBind()
    {
        LangaugeSystem ls = new LangaugeSystem();

        CurrentUserCountry = ls.CurrentUserCountry;

        TxtClanName.Text = "GuestClan" + new Random().Next(1, 9999).ToString();


        SkillsSystem ss = new SkillsSystem();
        // !Skills!
        // check cache
        List <dynamic> getSkills = (List <dynamic>)Cache["WebSearch_getSkills" + CurrentLangId];

        if (getSkills == null)
        {
            getSkills = ss.GetSkills(CurrentLangId);
            if (getSkills != null)
            {
                // add Cache
                Cache.Add("WebSearch_getSkills" + CurrentLangId, getSkills, null, TimeZoneManager.DateTimeNow.AddDays(5),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        DdlClanSkill.Items.Clear();
        DdlClanSkill.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        DdlSearchSkill.Items.Clear();
        DdlSearchSkill.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        foreach (dynamic g in getSkills)
        {
            DdlClanSkill.Items.Add(new ListItem(g.SearchWarSkillName, g.SearchWarSkillId.ToString()));
            DdlSearchSkill.Items.Add(new ListItem(g.SearchWarSkillName, g.SearchWarSkillId.ToString()));

            // DdlSearchSkill.Items.Add(new ListItem(currentSkill.GetAnonymousObject("SearchWarSkillName").GetValue<string>(), currentSkill.GetAnonymousObject("SearchWarSkillId").GetValue<int>().ToString()));
        }

        // !Games!
        // check cache
        GamesSystem             gs       = new GamesSystem();
        List <SW_SearchWarGame> getGames = (List <SW_SearchWarGame>)Cache["WebSearch_getGames"];

        if (getGames == null)
        {
            getGames = gs.GetGames().OrderBy(g => g.SearchWarGameName).ToList <SW_SearchWarGame>();
            if (getGames != null)
            {
                // add Cache
                Cache.Add("WebSearch_getGames", getGames, null, TimeZoneManager.DateTimeNow.AddDays(1),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }

        DdlSearchGame.Items.Clear();
        DdlSearchGame.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        for (int i = 0; i < getGames.Count(); i++)
        {
            var g = getGames[i];
            DdlSearchGame.Items.Add(new ListItem(g.SearchWarGameName, g.SearchWarGameId.ToString()));
        }


        DdlSearchGameType.Items.Clear();
        DdlSearchGameType.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(), string.Empty));
        HfSearchGameType.Value = DdlSearchGameType.Items.FindByText(GetLocalResourceObject("ListItemChooseResource1").ToString()).Value;


        // !Continents!
        // check cache
        ContinentSystem cs = new ContinentSystem();

        List <dynamic> getContinents = (List <dynamic>)Cache["WebSearch_getContinents" + CurrentLangId];

        if (getContinents == null)
        {
            getContinents = cs.GetContinents(CurrentLangId);
            if (getContinents != null)
            {
                // add Cache
                Cache.Add("WebSearch_getContinents" + CurrentLangId, getContinents, null, TimeZoneManager.DateTimeNow.AddDays(1),
                          System.Web.Caching.Cache.NoSlidingExpiration,
                          System.Web.Caching.CacheItemPriority.Normal,
                          null);
            }
        }
        if (getContinents != null && getContinents.Count > 0)
        {
            DdlClanContinent.Items.Clear();
            DdlClanContinent.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                    string.Empty));

            for (int i = 0; i < getContinents.Count(); i++)
            {
                dynamic currentContinent = getContinents[i];

                DdlClanContinent.Items.Add(
                    new ListItem(currentContinent.SearchWarContinentName,
                                 currentContinent.SearchWarContinentId.ToString()));
            }
            DdlClanContinent.DataBind();


            DdlSearchContinent.Items.Clear();
            DdlSearchContinent.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                      string.Empty));

            for (int i = 0; i < getContinents.Count(); i++)
            {
                dynamic currentContinent = getContinents[i];

                DdlSearchContinent.Items.Add(
                    new ListItem(currentContinent.SearchWarContinentName,
                                 currentContinent.SearchWarContinentId.ToString()));
            }
            DdlSearchContinent.DataBind();
        }


        // !Countries!
        CountrySystem  CS           = new CountrySystem();
        List <dynamic> getCountries = CS.GetCountries(CurrentLangId);

        if (getCountries != null && getCountries.Count > 0)
        {
            // find contient for usercountry
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    DdlClanContinent.Items.FindByValue(
                        currentCountry.SearchWarContinentId.ToString()).
                    Selected = true;
                }
            }
            // Remove countries there is not in the continent
            getCountries =
                getCountries.Where(
                    C =>
                    C.SearchWarContinentId ==
                    Convert.ToInt32(DdlClanContinent.SelectedValue)).ToList <dynamic>();



            // Add "Select" for dropdownbox
            DdlClanCountry.Items.Clear();
            DdlClanCountry.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                  string.Empty));

            // Loop countries
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                // Add Country to dropdownbox
                DdlClanCountry.Items.Add(
                    new ListItem(currentCountry.SearchWarCountryName,
                                 currentCountry.SearchWarCountryId.ToString()));

                // Select current country
                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    // Set current country in dropdownbox
                    DdlClanCountry.Items.FindByValue(
                        currentCountry.SearchWarCountryId.ToString()).Selected
                        = true;

                    // set value in hiddenfield
                    HfClanCountry.Value =
                        DdlClanCountry.Items.FindByValue(currentCountry.SearchWarCountryId.ToString()).
                        Value;
                }
            }


            // Add "Select" for dropdownbox
            DdlSearchCountry.Items.Clear();
            DdlSearchCountry.Items.Add(new ListItem(GetLocalResourceObject("ListItemChooseResource1").ToString(),
                                                    string.Empty));
            // Loop all countries
            for (int i = 0; i < getCountries.Count(); i++)
            {
                dynamic currentCountry = getCountries[i];

                // Add country to dropdownbox
                DdlSearchCountry.Items.Add(
                    new ListItem(currentCountry.SearchWarCountryName,
                                 currentCountry.SearchWarCountryId.ToString()));

                // Select that current country
                if (CurrentUserCountry ==
                    currentCountry.SearchWarCountryTLD)
                {
                    // Set current continent for country
                    DdlSearchContinent.Items.FindByValue(
                        currentCountry.SearchWarContinentId.ToString()).Selected = true;

                    // set value for country ("empty" because the system need to search after more than one country)
                    HfSearchCountry.Value = "";
                }
            }
        }


        // !Players!
        const int maxPlayer = 16;

        DdlSearchXvsX.Items.Clear();
        for (int p = 1; p <= maxPlayer; p++)
        {
            DdlSearchXvsX.Items.Add(new ListItem(p.ToString() + GetLocalResourceObject("LblVersusResource1.Text") + p.ToString(), p.ToString() + "-" + p.ToString()));
        }
        DdlSearchXvsX.Items.FindByValue("5-5").Selected = true;

        // !DATETIME!
        TimeZoneManager timeMng = new TimeZoneManager(CurrentUserIP);

        DateTime datetimeNow         = timeMng.ConvertDateTimeFromUtc(TimeZoneManager.DateTimeNow).AddMinutes(20);
        DateTime getDateTimePlusHour = datetimeNow.AddHours(1);

        txtFromDate.Text = datetimeNow.Day.ToString("00") + "/" + datetimeNow.Month.ToString("00") + "/" + datetimeNow.Year.ToString("0000");
        amorpm.InnerText = datetimeNow.ToString("tt");
        if (CurrentLang.ToLower() == "da-dk")
        {
            txtFromTime.Text = datetimeNow.ToString("HH:mm");
            amorpm.Attributes.Add("style", "display: none");
        }
        else
        {
            txtFromTime.Text = datetimeNow.ToString("hh:mm");
        }
    }