Exemplo n.º 1
0
        private async void Init()
        {
            Servers = (await _infoRepository.GetServerInfoAsync()).Select(x => new ServerInfoModel(x)).ToList();


            using (var dc = new ReasonRepository())
            {
                BanReasons = (await dc.GetBanReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                KickReasons = (await dc.GetKickReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                BanTimes =
                    (await dc.GetBanTimesAsync()).Select(x => new BanTimeEdit {
                    Text = x.Title, Minutes = x.TimeInMinutes
                }).ToList();

                BadNicknames = (await dc.GetBadNicknamesAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                ImportantWords = (await dc.GetImportantWordsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
            }

            var zones = TimeZoneInfo.GetSystemTimeZones().ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i].Id == Settings.TimeZoneInfo?.Id)
                {
                    zones[i] = Settings.TimeZoneInfo;
                }
            }

            TimeZones = zones;

            RaisePropertyChanged(nameof(Servers));
            RaisePropertyChanged(nameof(BanReasons));
            RaisePropertyChanged(nameof(KickReasons));
            RaisePropertyChanged(nameof(BanTimes));
            RaisePropertyChanged(nameof(BadNicknames));
            RaisePropertyChanged(nameof(ImportantWords));
            RaisePropertyChanged(nameof(TimeZones));
        }
Exemplo n.º 2
0
 async Task <IEnumerable <BanFullTime> > GetBanTimes()
 {
     try
     {
         using (var repo = new ReasonRepository())
         {
             var str = (await repo.GetBanTimesAsync()).Select(x => new BanFullTime
             {
                 Text          = x.Title,
                 Period        = System.TimeSpan.FromMinutes(x.TimeInMinutes),
                 PeriodMinutes = x.TimeInMinutes
             }).ToArray();
             return(str);
         }
     }
     catch (Exception)
     {
         return(Enumerable.Empty <BanFullTime>());
     }
 }
Exemplo n.º 3
0
        private async void Init()
        {
            var dbServers = (await _infoRepository.GetServerInfoAsync()).ToArray();

            Servers = dbServers.Select(x => new ServerInfoModel(x)).ToList();


            using (var dc = new ReasonRepository())
            {
                BanReasons = (await dc.GetBanReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                KickReasons = (await dc.GetKickReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                BanTimes =
                    (await dc.GetBanTimesAsync()).Select(x => new BanTimeEdit {
                    Text = x.Title, Minutes = x.TimeInMinutes
                }).ToList();

                BadNicknames = (await dc.GetBadNicknamesAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                ImportantWords = (await dc.GetImportantWordsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
            }

            var zones = TimeZoneInfo.GetSystemTimeZones().ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i].Id == Settings.TimeZoneInfo?.Id)
                {
                    zones[i] = Settings.TimeZoneInfo;
                }
            }

            TimeZones = zones;

            var customStore = _settingsStoreSource.GetCustomSettingsStore();

            ServerSettings = dbServers.Select(x => new
            {
                ServerSettings =
                    customStore.Load <ServerSettings>(x.Id.ToString()) ?? new ServerSettings()
                {
                    IdleTimeInMins  = 0,
                    KickIdlePlayers = false,
                    IdleKickReason  = "Lobby Idle",
                    ServerId        = x.Id
                },
                ServerName = x.Name
            })
                             .Select(x => new ServerSettingsVM()
            {
                ServerId        = x.ServerSettings.ServerId,
                IdleTimeInMins  = x.ServerSettings.IdleTimeInMins,
                ServerName      = x.ServerName,
                IdleKickReason  = x.ServerSettings.IdleKickReason,
                KickIdlePlayers = x.ServerSettings.KickIdlePlayers
            })
                             .ToList();


            RaisePropertyChanged(nameof(Servers));
            RaisePropertyChanged(nameof(BanReasons));
            RaisePropertyChanged(nameof(KickReasons));
            RaisePropertyChanged(nameof(BanTimes));
            RaisePropertyChanged(nameof(BadNicknames));
            RaisePropertyChanged(nameof(ImportantWords));
            RaisePropertyChanged(nameof(TimeZones));
            RaisePropertyChanged(nameof(ServerSettings));
        }