コード例 #1
0
        public List<GameTypeModel> GetGameTypeItems(int userID = 0)
        {
            string sql = @"select r.*,GameID=g.id,g.name,g.filepath,g.filesize,g.ImageFilePath,g.Detail
            from RecreationType r left join Game g on g.typeid=r.id where maintype='单机游戏'";

            if (userID != 0)
                sql += string.Format(" and g.userID={0}", userID);
            List<GameTypeModel> list = new List<GameTypeModel>();
            DataTable dt = new DataTable();
            SqlAccess.QueryDt(dt, sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GameTypeModel typeModel = null;
                var typeName = Normal.ListStr(dt.Rows[i]["TypeName"]);
                var mainType = Normal.ListStr(dt.Rows[i]["MainType"]);
                var gameid = Normal.ParseInt(dt.Rows[i]["GameID"]);
                typeModel = list.SingleOrDefault(t => t.TypeName == typeName && t.MainType == mainType);
                if (typeModel == null)
                {
                    typeModel = new GameTypeModel()
                    {
                        ID = Normal.ParseInt(dt.Rows[i]["ID"]),
                        MainType = mainType,
                        TypeName = typeName
                    };

                    if (gameid != 0)
                        typeModel.Games.Add(new GameModel()
                        {
                            ID = gameid,
                            Name = Normal.ListStr(dt.Rows[i]["Name"]),
                            FilePath = Normal.ListStr(dt.Rows[i]["FilePath"]),
                            FileSize = Normal.ListStr(dt.Rows[i]["FileSize"]),
                            ImageFilePath = Normal.ListStr(dt.Rows[i]["ImageFilePath"]),
                            Detail = Normal.ListStr(dt.Rows[i]["Detail"])
                        });
                    list.Add(typeModel);
                }
                else
                {
                    if (gameid != 0)
                        typeModel.Games.Add(new GameModel()
                        {
                            ID = Normal.ParseInt(dt.Rows[i]["GameID"]),
                            Name = Normal.ListStr(dt.Rows[i]["Name"]),
                            FilePath = Normal.ListStr(dt.Rows[i]["FilePath"]),
                            FileSize = Normal.ListStr(dt.Rows[i]["FileSize"]),
                            ImageFilePath = Normal.ListStr(dt.Rows[i]["ImageFilePath"]),
                            Detail = Normal.ListStr(dt.Rows[i]["Detail"])
                        });

                }
            }
            return list;
        }
コード例 #2
0
        public SetGameChatCommand()
            : base("Set Game", "setgame", 5, MixerRoleEnum.Mod)
        {
            this.Actions.Add(new CustomAction(async(UserViewModel user, IEnumerable <string> arguments) =>
            {
                if (ChannelSession.Chat != null)
                {
                    if (arguments.Count() > 0)
                    {
                        GameTypeModel newGame = null;
                        if (arguments.Count() == 1 && uint.TryParse(arguments.ElementAt(0), out uint gameID))
                        {
                            newGame = await ChannelSession.Connection.GetGameType(gameID);
                        }
                        else
                        {
                            string newGameName = string.Join(" ", arguments);
                            IEnumerable <GameTypeModel> games = await ChannelSession.Connection.GetGameTypes(newGameName);

                            newGame = games.FirstOrDefault(g => g.name.Equals(newGameName, StringComparison.CurrentCultureIgnoreCase));
                        }

                        if (newGame != null)
                        {
                            await ChannelSession.Connection.UpdateChannel(ChannelSession.Channel.id, gameTypeID: newGame.id);
                            await ChannelSession.RefreshChannel();

                            await ChannelSession.Chat.Whisper(user.UserName, "Game Updated: " + newGame.name);
                        }
                        else
                        {
                            await ChannelSession.Chat.Whisper(user.UserName, "We could not find a game with that name/ID");
                        }
                    }
                    else
                    {
                        await ChannelSession.Chat.Whisper(user.UserName, "Usage: !setgame <GAME NAME>");
                    }
                }
            }));
        }
コード例 #3
0
        public async Task ReplaceCommonSpecialModifiers(UserViewModel user, IEnumerable <string> arguments = null)
        {
            foreach (string counter in ChannelSession.Counters.Keys)
            {
                this.ReplaceSpecialIdentifier(counter, ChannelSession.Counters[counter].ToString());
            }

            foreach (var kvp in SpecialIdentifierStringBuilder.CustomSpecialIdentifiers)
            {
                this.ReplaceSpecialIdentifier(kvp.Key, kvp.Value);
            }

            this.ReplaceSpecialIdentifier("date", DateTimeOffset.Now.ToString("d"));
            this.ReplaceSpecialIdentifier("time", DateTimeOffset.Now.ToString("t"));
            this.ReplaceSpecialIdentifier("datetime", DateTimeOffset.Now.ToString("g"));

            if (user != null)
            {
                if (string.IsNullOrEmpty(user.AvatarLink))
                {
                    user.AvatarLink = UserViewModel.DefaultAvatarLink;
                }

                if (user.AvatarLink.Equals(UserViewModel.DefaultAvatarLink))
                {
                    UserModel avatarUser = await ChannelSession.Connection.GetUser(user.UserName);

                    if (!string.IsNullOrEmpty(user.AvatarLink))
                    {
                        user.AvatarLink = avatarUser.avatarUrl;
                    }
                }

                for (int i = 0; i < ChannelSession.Settings.Currencies.Count; i++)
                {
                    UserCurrencyViewModel     currency     = ChannelSession.Settings.Currencies.Values.ElementAt(i);
                    UserCurrencyDataViewModel currencyData = user.Data.GetCurrency(currency);

                    UserRankViewModel rank = currencyData.GetRank();
                    this.ReplaceSpecialIdentifier(currency.UserRankNameSpecialIdentifier, rank.Name);
                    this.ReplaceSpecialIdentifier(currency.UserAmountSpecialIdentifier, currencyData.Amount.ToString());
                }
                this.ReplaceSpecialIdentifier("usertime", user.Data.ViewingTimeString);
                this.ReplaceSpecialIdentifier("userhours", user.Data.ViewingHoursString);
                this.ReplaceSpecialIdentifier("usermins", user.Data.ViewingMinutesString);

                this.ReplaceSpecialIdentifier("userfollowage", user.FollowAgeString);
                this.ReplaceSpecialIdentifier("usersubage", user.SubscribeAgeString);
                this.ReplaceSpecialIdentifier("usersubmonths", user.SubscribeMonths.ToString());

                if (this.ContainsSpecialIdentifier("usergame"))
                {
                    GameTypeModel game = await ChannelSession.Connection.GetGameType(user.GameTypeID);

                    this.ReplaceSpecialIdentifier("usergame", game.name.ToString());
                }

                this.ReplaceSpecialIdentifier("useravatar", user.AvatarLink);
                this.ReplaceSpecialIdentifier("userurl", "https://www.mixer.com/" + user.UserName);
                this.ReplaceSpecialIdentifier("username", user.UserName);
                this.ReplaceSpecialIdentifier("userid", user.ID.ToString());
            }

            if (arguments != null)
            {
                for (int i = 0; i < arguments.Count(); i++)
                {
                    string username = arguments.ElementAt(i);
                    username = username.Replace("@", "");

                    UserModel argUserModel = await ChannelSession.Connection.GetUser(username);

                    if (argUserModel != null)
                    {
                        UserViewModel argUser = new UserViewModel(argUserModel);
                        await argUser.SetDetails();

                        if (ChannelSession.Settings.UserData.ContainsKey(argUser.ID))
                        {
                            UserDataViewModel userData = ChannelSession.Settings.UserData[argUser.ID];

                            for (int c = 0; c < ChannelSession.Settings.Currencies.Count; c++)
                            {
                                UserCurrencyViewModel     currency     = ChannelSession.Settings.Currencies.Values.ElementAt(i);
                                UserCurrencyDataViewModel currencyData = userData.GetCurrency(currency);

                                UserRankViewModel rank = currencyData.GetRank();
                                this.ReplaceSpecialIdentifier("arg" + (i + 1) + currency.UserRankNameSpecialIdentifier, rank.Name);
                                this.ReplaceSpecialIdentifier("arg" + (i + 1) + currency.UserAmountSpecialIdentifier, currencyData.Amount.ToString());
                            }
                            this.ReplaceSpecialIdentifier("arg" + (i + 1) + "usertime", userData.ViewingTimeString);
                            this.ReplaceSpecialIdentifier("arg" + (i + 1) + "userhours", userData.ViewingHoursString);
                            this.ReplaceSpecialIdentifier("arg" + (i + 1) + "usermins", userData.ViewingMinutesString);
                        }

                        if (this.ContainsSpecialIdentifier("arg" + (i + 1) + "usergame"))
                        {
                            GameTypeModel game = await ChannelSession.Connection.GetGameType(argUser.GameTypeID);

                            this.ReplaceSpecialIdentifier("arg" + (i + 1) + "usergame", game.name.ToString());
                        }

                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "userfollowage", argUser.FollowAgeString);
                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "usersubage", argUser.SubscribeAgeString);
                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "usersubmonths", argUser.SubscribeMonths.ToString());

                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "useravatar", argUser.AvatarLink);
                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "userurl", "https://www.mixer.com/" + argUser.UserName);
                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "username", argUser.UserName);
                        this.ReplaceSpecialIdentifier("arg" + (i + 1) + "userid", argUser.ID.ToString());
                    }

                    this.ReplaceSpecialIdentifier("arg" + (i + 1) + "text", arguments.ElementAt(i));
                }

                this.ReplaceSpecialIdentifier("allargs", string.Join(" ", arguments));
            }
        }
コード例 #4
0
 public void UpdateGameType(GameTypeModel gameTypeToUpdate)
 {
     unitOfWork.GameTypeRepo.Update(gameTypeToUpdate);
 }
コード例 #5
0
 public void AddGameType(GameTypeModel gameTypeToAdd)
 {
     unitOfWork.GameTypeRepo.Add(gameTypeToAdd);
 }
コード例 #6
0
        public ActionResult AddGameType()
        {
            GameTypeModel model = new GameTypeModel();

            return(PartialView("GameTypeModal", model));
        }
コード例 #7
0
        private async void FindChannelToRaidButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            await this.Window.RunAsyncOperation(async() =>
            {
                if (this.ChannelToRaidSearchCriteriaComboBox.SelectedIndex < 0)
                {
                    await MessageBoxHelper.ShowMessageDialog("Must select a search criteria for finding a channel to raid");
                    return;
                }

                await ChannelSession.RefreshChannel();

                IEnumerable <ChannelModel> channels   = null;
                RaidSearchCriteriaEnum searchCriteria = EnumHelper.GetEnumValueFromString <RaidSearchCriteriaEnum>((string)this.ChannelToRaidSearchCriteriaComboBox.SelectedItem);
                if (searchCriteria == RaidSearchCriteriaEnum.SameGame)
                {
                    channels = await ChannelSession.Connection.GetChannelsByGameTypes(ChannelSession.Channel.type, 1);
                }
                else if (searchCriteria == RaidSearchCriteriaEnum.SameTeam)
                {
                    Dictionary <uint, UserWithChannelModel> teamChannels = new Dictionary <uint, UserWithChannelModel>();
                    foreach (TeamMembershipExpandedModel extendedTeam in await ChannelSession.Connection.GetUserTeams(ChannelSession.User))
                    {
                        TeamModel team = await ChannelSession.Connection.GetTeam(extendedTeam.id);
                        IEnumerable <UserWithChannelModel> teamUsers = await ChannelSession.Connection.GetTeamUsers(team);
                        foreach (UserWithChannelModel userChannel in teamUsers.Where(u => u.channel.online))
                        {
                            teamChannels[userChannel.id] = userChannel;
                        }
                    }
                    channels = teamChannels.Values.Select(c => c.channel);
                }
                else
                {
                    string query = "channels";
                    if (searchCriteria == RaidSearchCriteriaEnum.AgeRating)
                    {
                        query += "?where=audience:eq:" + ChannelSession.Channel.audience;
                    }
                    else if (searchCriteria == RaidSearchCriteriaEnum.LargeStreamer)
                    {
                        query += "?where=viewersCurrent:gte:25";
                    }
                    else if (searchCriteria == RaidSearchCriteriaEnum.MediumStreamer)
                    {
                        query += "?where=viewersCurrent:gte:10,viewersCurrent:lt:25";
                    }
                    else if (searchCriteria == RaidSearchCriteriaEnum.SmallStreamer)
                    {
                        query += "?where=viewersCurrent:gt:0,viewersCurrent:lt:10";
                    }
                    else if (searchCriteria == RaidSearchCriteriaEnum.PartneredStreamer)
                    {
                        query += "?where=partnered:eq:true";
                    }
                    channels = await ChannelSession.Connection.Connection.Channels.GetPagedNumberAsync <ChannelModel>(query, 50, linkPagesAvailable: false);
                }

                this.ChannelRaidNameTextBox.Clear();
                if (channels != null && channels.Count() > 0)
                {
                    this.channelToRaid = channels.ElementAt(RandomHelper.GenerateRandomNumber(channels.Count()));

                    UserModel user     = await ChannelSession.Connection.GetUser(this.channelToRaid.userId);
                    GameTypeModel game = await ChannelSession.Connection.GetGameType(this.channelToRaid.typeId.GetValueOrDefault());

                    this.ChannelRaidNameTextBox.Text     = user.username;
                    this.ChannelRaidViewersTextBox.Text  = this.channelToRaid.viewersCurrent.ToString();
                    this.ChannelRaidAudienceTextBox.Text = EnumHelper.GetEnumName(EnumHelper.GetEnumValueFromString <AgeRatingEnum>(this.channelToRaid.audience));
                    this.ChannelRaidGameTextBox.Text     = (game != null) ? game.name : "Unknown";
                }
                else
                {
                    await MessageBoxHelper.ShowMessageDialog("Unable to find a channel that met your search critera, please try selecting a different option");
                }
            });
        }
コード例 #8
0
        public List <GameTypeModel> GetGameTypeItems(int userID = 0)
        {
            string sql = @"select r.*,GameID=g.id,g.name,g.filepath,g.filesize,g.ImageFilePath,g.Detail 
from RecreationType r left join Game g on g.typeid=r.id where maintype='单机游戏'";

            if (userID != 0)
            {
                sql += string.Format(" and g.userID={0}", userID);
            }
            List <GameTypeModel> list = new List <GameTypeModel>();
            DataTable            dt   = new DataTable();

            SqlAccess.QueryDt(dt, sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GameTypeModel typeModel = null;
                var           typeName  = Normal.ListStr(dt.Rows[i]["TypeName"]);
                var           mainType  = Normal.ListStr(dt.Rows[i]["MainType"]);
                var           gameid    = Normal.ParseInt(dt.Rows[i]["GameID"]);
                typeModel = list.SingleOrDefault(t => t.TypeName == typeName && t.MainType == mainType);
                if (typeModel == null)
                {
                    typeModel = new GameTypeModel()
                    {
                        ID       = Normal.ParseInt(dt.Rows[i]["ID"]),
                        MainType = mainType,
                        TypeName = typeName
                    };

                    if (gameid != 0)
                    {
                        typeModel.Games.Add(new GameModel()
                        {
                            ID            = gameid,
                            Name          = Normal.ListStr(dt.Rows[i]["Name"]),
                            FilePath      = Normal.ListStr(dt.Rows[i]["FilePath"]),
                            FileSize      = Normal.ListStr(dt.Rows[i]["FileSize"]),
                            ImageFilePath = Normal.ListStr(dt.Rows[i]["ImageFilePath"]),
                            Detail        = Normal.ListStr(dt.Rows[i]["Detail"])
                        });
                    }
                    list.Add(typeModel);
                }
                else
                {
                    if (gameid != 0)
                    {
                        typeModel.Games.Add(new GameModel()
                        {
                            ID            = Normal.ParseInt(dt.Rows[i]["GameID"]),
                            Name          = Normal.ListStr(dt.Rows[i]["Name"]),
                            FilePath      = Normal.ListStr(dt.Rows[i]["FilePath"]),
                            FileSize      = Normal.ListStr(dt.Rows[i]["FileSize"]),
                            ImageFilePath = Normal.ListStr(dt.Rows[i]["ImageFilePath"]),
                            Detail        = Normal.ListStr(dt.Rows[i]["Detail"])
                        });
                    }
                }
            }
            return(list);
        }
コード例 #9
0
 public UserQuoteViewModel(string quote, DateTimeOffset dateTime, GameTypeModel game)
     : this(quote)
 {
     this.DateTime = dateTime;
     this.GameName = game.name;
 }