Пример #1
0
    public static void FindUserFirstCulture(CultureType type)
    {
        bool found = true;

        if (SessionState.Culture == null || SessionState.Culture.Type != type)
        {
            found = false;
            using (CultureList culs = SessionState.User.ItemCulturesRelevant)
            {
                culs.Sort("Name");
                // Look for master culture first
                foreach (HyperCatalog.Business.Culture cul in culs)
                {
                    if (cul.Type == type)
                    {
                        found = true;
                        SessionState.Culture = cul;
                        break;
                    }
                }
            }
            if (!found)
            {
                // User has no cultures of this type in its scope
                UITools.DenyAccess(DenyMode.Standard);
            }
        }
    }
Пример #2
0
 /// <summary>
 ///     Creates a new <see cref="JsonStringLocalizer" />.
 /// </summary>
 /// <param name="type">The base name of the embedded resource in the <see cref="Assembly" /> that contains the strings.</param>
 /// <param name="cache"></param>
 /// <param name="logger"></param>
 /// <param name="options"></param>
 /// <param name="translater"></param>
 /// <summary>
 ///     Intended for testing purposes only.
 /// </summary>
 public JsonStringLocalizer(string type, IJsonLocalizationCache cache, ILogger<JsonStringLocalizer> logger, IOptions<DependencyInjection.LocalizationOptions> options, ITranslater translater)
 {
     _type = type;
     _cache = cache;
     _logger = logger;
     _option = options;
     _translater = translater;
     _defaultCulture = options.Value.MissingTranslation;
 }
Пример #3
0
        // Send Mail with Templates:
        private string createEmailBody(string message, CultureType lang)
        {
            if (lang == CultureType.DE)
            {
                //Read templates DE:
            }
            else if (lang == CultureType.EN)
            {
                //Read templates EN:
            }
            else
            {
                //Read templates ES:
            }

            return("");
        }
Пример #4
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        // Retrieve the current culture type
        cultureType = SessionState.Culture.Type;
        if (Request["g"] != null)
        {
            cultureType = (CultureType)Convert.ToInt32(Request["g"]);
        }
        else
        {
            cultureType = SessionState.Culture.Type;
        }

        if (!Page.IsPostBack)
        {
            UpdateDataView();
            UITools.UpdateTitle(this.Page);
        }
    }
Пример #5
0
        public List <LocationViewModel> GetLocationsByType(LocationType type)
        {
            Expression <System.Func <LocationCulture, bool> > locationExpression = null;

            switch (type)
            {
            case LocationType.All:
                locationExpression = loc => true;
                break;

            case LocationType.Continent:
                locationExpression = loc => loc.Location.ParentId == null;
                break;

            case LocationType.Country:
                locationExpression = loc => loc.Location.ParentId != null;
                break;
            }

            CultureType cultureType = CultureHelper.GetCurrentCultureType();
            Expression <System.Func <LocationCulture, bool> > cultureExpression = c => c.CultureId == (int)cultureType;

            var locations = UnitOfWork.LocationCultures
                            .Where(locationExpression.And(cultureExpression))
                            .OrderBy(x => x.Name)
                            .Select(s => new LocationViewModel()
            {
                Id           = s.LocationId,
                Name         = s.Name,
                Competitions =
                    s.Location.Competitions.SelectMany(x => x.Cultures)
                    .Where(x => x.CultureId == (int)cultureType)
                    .Select(s1 => new CompetitionCultureViewModel()
                {
                    CompetitionId   = s1.CompetitionId,
                    CompetitionName = s1.Name
                })
                    .ToList()
            })
                            .ToList();

            return(locations);
        }
Пример #6
0
 public List <TripDTO> GetPastRidesByUserId(int id, CultureType culture)
 {
     try
     {
         List <Trip> trips = _dbContext.UserTrips
                             .Where(x => x.User_Id == id && x.Trip.Status == TripStatus.Completed && x.Trip.EndTime <= DateTime.UtcNow).Select(c => c.Trip)
                             .Include(d => d.RideType).Include(d => d.RideType.RideTypeMLsList).Include(x => x.Driver).Include(x => x.PrimaryUser).OrderByDescending(x => x.EndTime).ToList();
         List <TripDTO> tripsResponse = Mapper.Map <List <Trip>, List <TripDTO> >(trips);
         for (int i = 0; i < trips.Count; i++)
         {
             tripsResponse[i].RideTypeName = trips[i].RideType.RideTypeMLsList.FirstOrDefault().Name;
         }
         return(tripsResponse);
     }
     catch (Exception ex)
     {
         Error.LogError(ex);
         return(null);
     }
 }
Пример #7
0
 public List <CancellationReasonDTO> GetAllCancellationReason(CultureType culture)
 {
     try
     {
         List <CancellationReason>    cancellationReasonsList         = _dbContext.CancellationReasons.Include(x => x.CancellationReasonMLsList).Where(x => x.Culture == CultureType.Both || x.Culture == culture).ToList();
         List <CancellationReasonDTO> cancellationReasonsResponseList = Mapper.Map <List <CancellationReason>, List <CancellationReasonDTO> >(cancellationReasonsList);
         CancellationReasonDTO        cancellationReasonsDTO          = new CancellationReasonDTO();
         for (int i = 0; i < cancellationReasonsList.Count; i++)
         {
             CancellationReasonML cancellationReasonML = cancellationReasonsList[i].CancellationReasonMLsList.FirstOrDefault(x => x.Culture == culture);
             Mapper.Map(cancellationReasonML, cancellationReasonsResponseList[i]);
         }
         return(cancellationReasonsResponseList);
     }
     catch (Exception ex)
     {
         Error.LogError(ex);
         return(null);
     }
 }
Пример #8
0
 public List <TripDTO> GetUpcomingRidesByUserId(int id, CultureType culture)
 {
     try
     {
         List <Trip> trips = _dbContext.UserTrips
                             .Where(x => x.User_Id == id && x.isScheduled == true && x.Trip.Status == TripStatus.Requested && x.RequestTime >= DateTime.UtcNow).Select(c => c.Trip)
                             .Include(d => d.RideType).Include(d => d.RideType.RideTypeMLsList).Include(x => x.PrimaryUser).ToList();
         List <TripDTO> tripsResponse = Mapper.Map <List <Trip>, List <TripDTO> >(trips);
         for (int i = 0; i < trips.Count; i++)
         {
             tripsResponse[i].RideTypeName = trips[i].RideType.RideTypeMLsList.FirstOrDefault(x => x.Culture == culture).Name;
         }
         return(tripsResponse);
     }
     catch (Exception ex)
     {
         Error.LogError(ex);
         return(null);
     }
 }
Пример #9
0
 //
 public void SendMailLang(EmailType type, EmailTarget targetUser, CultureType lang)
 {
 }
Пример #10
0
        public static List <Entity> PlaceEntities(WorldInstance worldRef, List <string> entityTypes)
        {
            List <Entity> entities = new List <Entity>();

            List <EntityTemplate> templates = EntityTemplateHandler.Templates;

            templates = templates.Where(x => entityTypes.Contains(x.CreatureType)).ToList();

            int numberToPlace = (worldRef.Tiles.GetLength(0) * worldRef.Tiles.GetLength(1)) / 50;

            List <Vector2Int> availablePoints = new List <Vector2Int>();

            for (int i = 0; i < worldRef.Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < worldRef.Tiles.GetLength(1); j++)
                {
                    Vector2Int point = new Vector2Int(i, j);
                    if (PhysicsManager.IsCollision(point, point, worldRef) == PhysicsResult.None && point != worldRef.SpawnPoint)
                    {
                        availablePoints.Add(point);
                    }
                }
            }

            for (int i = 0; i < numberToPlace; i++)
            {
                int pointIndex = RNG.Roll(0, availablePoints.Count - 1);

                int entityIndex = RNG.Roll(0, templates.Count - 1);

                Entity newEntity = null;
                if (templates[entityIndex].Sentient)
                {
                    CultureType culture = CultureHandler.Get(templates[entityIndex].CreatureType);

                    JobType jobType = JobHandler.GetRandom();

                    Dictionary <string, int> jobLevels = new Dictionary <string, int>();
                    jobLevels.Add(jobType.name, 1);

                    newEntity = WorldState.EntityHandler.Create(templates[entityIndex], EntityNeed.GetFullRandomisedNeeds(), 1, jobType, culture.ChooseSex(), culture.ChooseSexuality(),
                                                                new Vector2Int(-1, -1), ObjectIcons.GetSprites(templates[entityIndex].Tileset, templates[entityIndex].CreatureType).ToList(), null);
                }
                else
                {
                    CultureType culture = CultureHandler.Get(templates[entityIndex].CreatureType);

                    JobType jobType = JobHandler.GetRandom();

                    Dictionary <string, int> jobLevels = new Dictionary <string, int>();
                    jobLevels.Add(jobType.name, 1);

                    newEntity = WorldState.EntityHandler.Create(templates[entityIndex], EntityNeed.GetBasicRandomisedNeeds(), 1, jobType, culture.ChooseSex(), culture.ChooseSexuality(),
                                                                new Vector2Int(-1, -1), ObjectIcons.GetSprites(templates[entityIndex].Tileset, templates[entityIndex].CreatureType).ToList(), null);
                }
                newEntity.Move(availablePoints[pointIndex]);
                newEntity.MyWorld = worldRef;
                entities.Add(newEntity);

                availablePoints.RemoveAt(pointIndex);
            }

            return(entities);
        }
Пример #11
0
 public void setCultureBackground(CultureType ct)
 {
     cultureBackgroundImage = GameObject.Find("Canvas").transform.Find("Culture_Background").GetComponent <Image>();
     //cultureBackgroundImage.sprite = s;
 }
Пример #12
0
 public ResourceConfig GetConfig(CultureType culture)
 {
     if (configs.ContainsKey(culture))
         return configs[culture];
     else
         return null;
 }
Пример #13
0
 public string GetResourceValue(CultureType culture, string name)
 {
     ResourceConfig rConfig = GetConfig(culture);
     if (rConfig != null)
     {
         if (rConfig.ResourceDatas.ContainsKey(name))
             return rConfig.ResourceDatas[name];
         else
             return string.Empty;
     }
     else
         return string.Empty;
 }
Пример #14
0
 public BT_Claim(string name, CultureType cultureType) : base(name)
 {
     _cultureType = cultureType;
 }
Пример #15
0
 public static string CultureTypeToString(CultureType type)
 {
     switch (type)
     {
         case CultureType.Default:
             return "default";
         case CultureType.DADK:
             return "da-DK";
         case CultureType.DEAT:
             return "de-AT";
         case CultureType.DECH:
             return "de-CH";
         case CultureType.DEDE:
             return "de-DE";
         case CultureType.ESES:
             return "es-ES";
         case CultureType.ESLA:
             return "es-LA";
         case CultureType.ESMX:
             return "es-MX";
         case CultureType.ESUS:
             return "es-US";
         case CultureType.FIFI:
             return "fi-FI";
         case CultureType.FRCA:
             return "fr-CA";
         case CultureType.FRCH:
             return "fr-CH";
         case CultureType.FRFR:
             return "fr-FR";
         case CultureType.ITCH:
             return "it-CH";
         case CultureType.ITIT:
             return "it-IT";
         case CultureType.JAJP:
             return "ja-JP";
         case CultureType.NBNO:
             return "nb-NO";
         case CultureType.NLNL:
             return "nl-NL";
         case CultureType.SVSE:
             return "sv-SE";
         case CultureType.ZHCN:
             return "zh-CN";
         case CultureType.ENAU:
             return "en-AU";
         case CultureType.ENCA:
             return "en-CA";
         case CultureType.ENGB:
             return "en-GB";
         case CultureType.ENIE:
             return "en-IE";
         case CultureType.ENIN:
             return "en-IN";
         case CultureType.ENNZ:
             return "en-NZ";
         case CultureType.KOKR:
             return "ko-KR";
         case CultureType.PTBR:
             return "pt-BR";
         case CultureType.SESV:
             return "se-SV";
         case CultureType.ENKR:
             return "en-KR";
         case CultureType.FRBE:
             return "fr-BE";
         case CultureType.NLBE:
             return "nl-BE";
         case CultureType.PLPL:
             return "pl-PL";
         case CultureType.PTPT:
             return "pt-PT";
         case CultureType.RURU:
             return "ru-RU";
         case CultureType.TUTR:
             return "tu-TR";
         case CultureType.DKDK:
             return "dk-DK";
         case CultureType.NONO:
             return "no-NO";
         case CultureType.ENUS:
             return "en-US";
         case CultureType.DKDA:
             return "dk-DA";
         case CultureType.TRTR:
             return "tr-TR";
         default:
             return string.Empty;
     }
 }
Пример #16
0
    private void UpdateDataView()
    {
        if (SessionState.tmFilterExpression != null)
        {
            DDL_Countries.SelectedValue = SessionState.tmFilterExpression;
        }
        MaxRows = Convert.ToInt32(SessionState.CacheParams["MaxSearchQueryDisplayedRows"].Value);
        string search = txtFilter.Text;

        using (Database dbObj = Utils.GetMainDB())
        {
            using (HyperCatalog.Business.Culture c = HyperCatalog.Business.Culture.GetByKey(DDL_Countries.SelectedValue))
            {
                using (DataSet ds = dbObj.RunSPReturnDataSet("_Item_GetNPI",
                                                             new SqlParameter("@UserId", SessionState.User.Id.ToString()),
                                                             new SqlParameter("@CountryCode", c.CountryCode),
                                                             new SqlParameter("@DayCountNPI", SessionState.CacheParams["DayCountNPI"].Value),
                                                             new SqlParameter("@MaxRows", MaxRows),
                                                             new SqlParameter("@Filter", txtFilter.Text),
                                                             new SqlParameter("@Company", SessionState.CompanyName)))
                {
                    dbObj.CloseConnection();
                    if (dbObj.LastError != string.Empty)
                    {
                        lbMessage.Text     = "[ERROR] _Item_GetNPI -> " + dbObj.LastError;
                        lbMessage.CssClass = "hc_error";
                        lbMessage.Visible  = true;
                    }
                    else
                    {
                        using (HyperCatalog.Business.Culture selCul = HyperCatalog.Business.Culture.GetByKey(DDL_Countries.SelectedValue))
                        {
                            curCultureType = selCul.Type;
                        }
                        #region Results
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            dg.DataSource     = ds;
                            lbMessage.Visible = false;
                            Utils.InitGridSort(ref dg);
                            dg.DataBind();
                            dg.Visible = true;
                            dg.Columns.FromKey("ModifyDate").Format    = SessionState.User.FormatDate;
                            dg.Columns.FromKey("Class").Header.Caption = SessionState.ItemLevels[1].Name;

                            if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count == 1)
                            {
                                int count = Convert.ToInt32(ds.Tables[1].Rows[0]["ProductCount"]);
                                lbMessage.CssClass = "hc_success";
                                if (count <= MaxRows)
                                {
                                    lbMessage.Text = "Product count: " + count.ToString() + "<br />";
                                }
                                else
                                {
                                    lbMessage.Text = "Product count: " + count.ToString() + " (" + MaxRows.ToString() + " products are displayed)<br />Your report is returning too many rows (max = " + MaxRows.ToString() + ")<br />";
                                }
                                lbMessage.Visible = true;
                            }
                        }
                        #endregion
                        #region No result
                        else
                        {
                            lbMessage.CssClass = "hc_success";
                            lbMessage.Text     = "No new product found";
                            lbMessage.Visible  = true;
                            dg.Visible         = false;
                        }
                        #endregion
                    }
                }
            }
        }
    }
Пример #17
0
        public Dictionary <string, List <FootballLeagueRankingViewModel> > GetRanking(int competitionId, RankingType rankingType, int seasonId)
        {
            CultureType cultureType = CultureHelper.GetCurrentCultureType();
            var         result      = (from team in UnitOfWork.FootballTeams
                                       where
                                       team.HomeTeamMatches.Any(
                                           home => home.CompetitionId == competitionId && home.SeasonId == seasonId) ||
                                       team.AwayTeamMatches.Any(
                                           away => away.CompetitionId == competitionId && away.SeasonId == seasonId)
                                       group team by new { team.Id, team.Cultures.FirstOrDefault(x => x.CultureId == (int)cultureType).Name, team.EmblemImageUrl } into gr
                                       select new FootballLeagueRankingViewModel
            {
                Round = Resources.Resources.LeagueRankingTeamCaption,
                TeamId = gr.Key.Id,
                TeamName = gr.Key.Name,
                TeamImageUrl = gr.Key.EmblemImageUrl,
                HomeWins = gr.Sum(c =>
                                  c.HomeTeamMatches.Count(
                                      home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) >
                                      home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),
                AwayWins = gr.Sum(c =>
                                  c.AwayTeamMatches.Count(
                                      away => away.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) >
                                      away.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),
                HomeDraws = gr.Sum(c =>
                                   c.HomeTeamMatches.Count(
                                       home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) ==
                                       home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),
                AwayDraws = gr.Sum(c =>
                                   c.AwayTeamMatches.Count(
                                       away => away.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) ==
                                       away.Events.Count(ev => ev.EventTypeId == 1 && ev.TeamId != gr.Key.Id))),
                HomeLosses = gr.Sum(c =>
                                    c.HomeTeamMatches.Count(
                                        home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) <
                                        home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),
                AwayLosses = gr.Sum(c =>
                                    c.AwayTeamMatches.Count(
                                        away => away.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id) <
                                        away.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),

                PlayedMatchesAtHome = gr.Sum(c => c.HomeTeamMatches.Count()),

                PlayedMatchesAway = gr.Sum(c => c.AwayTeamMatches.Count()),

                HomeGoalScored = gr.Sum(s => s.HomeTeamMatches.Sum(
                                            home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id))),

                AwayGoalScored = gr.Sum(s => s.AwayTeamMatches.Sum(
                                            home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId == gr.Key.Id))),

                HomeGoalReceived = gr.Sum(s => s.HomeTeamMatches.Sum(
                                              home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),

                AwayGoalReceived = gr.Sum(s => s.AwayTeamMatches.Sum(
                                              home => home.Events.Count(ev => ev.EventTypeId == (int)Data.Enums.EventType.Goal && ev.TeamId != gr.Key.Id))),
            }).ToList();

            IOrderedEnumerable <FootballLeagueRankingViewModel> orderedTeams = null;

            switch (rankingType)
            {
            case RankingType.All:
                orderedTeams = result.OrderByDescending(order => order.Points);
                break;

            case RankingType.Home:
                orderedTeams = result.OrderByDescending(order => order.HomePoints);
                break;

            case RankingType.Away:
                orderedTeams = result.OrderByDescending(order => order.AwayPoints);
                break;
            }

            int count = 1;

            foreach (var item in orderedTeams)
            {
                item.Position = count;
                count++;
            }

            return(orderedTeams.GroupBy(gr => gr.Round, gr => gr).ToDictionary(x => x.Key, x => x.ToList()));
        }
Пример #18
0
 public BT_Reputation(string name, CultureType cultureType) : base(name)
 {
     _cultureType = cultureType;
 }
Пример #19
0
 public static TrainingInfo GetTrainingType(string userID, int generalID, CultureType cultureType)
 {
     string jiaQiang = ConfigEnvSet.GetString("User.JiaQiangTraining");
     string BaiJin = ConfigEnvSet.GetString("User.BaiJinTraining");
     string ZuanShi = ConfigEnvSet.GetString("User.ZuanShiTraining");
     string ZhiZun = ConfigEnvSet.GetString("User.ZhiZunTraining");
     string var = string.Empty;
     if (cultureType == CultureType.PuTong)
     {
         var = GetCultureMoney(userID, generalID).ToString() + LanguageManager.GetLang().GameMoney_Coin;
     }
     else if (cultureType == CultureType.JiaQiang)
     {
         var = jiaQiang + LanguageManager.GetLang().GameMoney_Gold;
     }
     else if (cultureType == CultureType.BaiJin)
     {
         var = BaiJin + LanguageManager.GetLang().GameMoney_Gold;
     }
     else if (cultureType == CultureType.ZuanShi)
     {
         var = ZuanShi + LanguageManager.GetLang().GameMoney_Gold;
     }
     else if (cultureType == CultureType.ZhiZun)
     {
         var = ZhiZun + LanguageManager.GetLang().GameMoney_Gold;
     }
     return new TrainingInfo() { CultureID = cultureType, CultureNum = var };
 }
Пример #20
0
 public MoonCulture(CultureType culture)
 {
     m_AssociatedCulture = culture;
 }