Esempio n. 1
0
        private static string GetGameRecommendedUrl(long domainID,
                                                    bool isMobile,
                                                    VendorID vendor,
                                                    string gameCode)
        {
            //http://109.205.93.227:8000/sim/?GameVendor={0}&GameCode={1}&GameType={2}&TopN={3}
            string url = string.Format(CultureInfo.InvariantCulture
                                       , ConfigurationManager.AppSettings["Recommendation.GameRecommendedURL"]
                                       , RecommendedGame.ConvertToReportVendorID(vendor)
                                       , gameCode
                                       , isMobile ? "Mobile" : "Desktop");

            return(url);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the recommended games
        /// </summary>
        /// <param name="domainID">domain ID</param>
        /// <param name="isMobile">is mobile</param>
        /// <param name="userID">user ID</param>
        /// <param name="countryID">country ID</param>
        /// <param name="gender">Female / Male</param>
        /// <param name="age">age</param>
        /// <param name="maxNumber">The maximum records of the recommended games</param>
        /// <returns></returns>
        public static bool TryGet(long domainID,
                                  bool isMobile,
                                  VendorID vendor,
                                  string gameCode,
                                  out List <RecommendedGame> games)
        {
            string url = GetGameRecommendedUrl(domainID, isMobile, vendor, gameCode);

            bool success = RecommendedGame.TryGet(url, out games);

            if (success)
            {
                games = games.Skip(1).ToList();
            }
            return(success);
//            string request = BuildRequest(domainID, isMobile, vendor, gameCode, maxRecords);

//            #region fake JSON
//            string json = @"{
//   ""code"":201,
//   ""message"":""success"",
//   ""results"":{
//      ""GameType"":""Desktop"",
//      ""Recolist"":[
//         [
//            ""NetEnt"",
//            ""lrtxsholdem_sw"",
//            0.5
//         ],
//         [
//            ""EGT"",
//            ""804"",
//            0.3
//         ],
//         [
//            ""PlaynGO"",
//            ""34"",
//            0.1
//         ]
//      ]
//   }
//}";
//            #endregion

//            return RecommendedGame.Parse(json);
        }
Esempio n. 3
0
        /// <summary>
        /// Get the recommended games
        /// </summary>
        /// <param name="domainID">domain ID</param>
        /// <param name="isMobile">is mobile</param>
        /// <param name="userID">user ID</param>
        /// <param name="countryID">country ID</param>
        /// <param name="gender">Female / Male</param>
        /// <param name="age">age</param>
        /// <param name="maxNumber">The maximum records of the recommended games</param>
        /// <returns></returns>
        public static bool TryGet(long domainID,
                                  bool isMobile,
                                  long userID,
                                  int countryID,
                                  string gender,
                                  DateTime?birthday,
                                  out List <RecommendedGame> games)
        {
            //string request = BuildRequest(domainID, isMobile, userID, countryID, gender, birthday, maxRecords);
            string url = GetUserRecommendedUrl(domainID, isMobile, userID, countryID, gender, birthday);

            return(RecommendedGame.TryGet(url, out games));

//            #region fake JSON
//            string json = @"{
//   ""code"":201,
//   ""message"":""success"",
//   ""results"":{
//      ""GameType"":""Desktop"",
//      ""Recolist"":[
//         [
//            ""NetEnt"",
//            ""lrtxsholdem_sw"",
//            0.5
//         ],
//         [
//            ""EGT"",
//            ""804"",
//            0.3
//         ],
//         [
//            ""PlaynGO"",
//            ""34"",
//            0.1
//         ]
//      ]
//   }
//}";
//            #endregion

//            return RecommendedGame.Parse(json);
        }
Esempio n. 4
0
        static List <RecommendedGame> Parse(string json)
        {
            using (StringReader sr = new StringReader(json))
                using (JsonTextReader reader = new JsonTextReader(sr))
                {
                    int    code    = 0;
                    string message = null;
                    List <RecommendedGame> games = new List <RecommendedGame>();

                    while (reader.Read())
                    {
                        if (reader.TokenType == JsonToken.PropertyName)
                        {
                            string name = reader.Value as string;

                            if (string.Equals(name, "code", StringComparison.InvariantCultureIgnoreCase))
                            {
                                reader.Read();
                                code = Convert.ToInt32(reader.Value);
                            }
                            else if (string.Equals(name, "message", StringComparison.InvariantCultureIgnoreCase))
                            {
                                reader.Read();
                                message = reader.Value as string;
                            }
                            else if (string.Equals(name, "results", StringComparison.InvariantCultureIgnoreCase))
                            {
                                while (reader.Read())
                                {
                                    if (reader.TokenType == JsonToken.PropertyName)
                                    {
                                        string name2 = reader.Value as string;

                                        if (string.Equals(name2, "GameType", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            reader.Read();
                                            string gameType = reader.Value as string;
                                        }
                                        else if (string.Equals(name2, "Recolist", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            reader.Read();
                                            while (reader.Read())
                                            {
                                                if (reader.TokenType == JsonToken.StartArray)
                                                {
                                                    RecommendedGame game = new RecommendedGame();

                                                    reader.Read();
                                                    game.VendorID = ConvertToCoreVendorID(reader.Value as string);

                                                    reader.Read();
                                                    game.GameCode = reader.Value as string;

                                                    reader.Read();
                                                    game.Score = Convert.ToDouble(reader.Value);

                                                    games.Add(game);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //return games.Skip(1).ToList();
                    return(games);
                }
        }