示例#1
0
        public List <string> BahaGetDayList(string mode)
        {
            var result = new List <string>();
            var client = ThriftTool.GetClient("default", ref _transport);

            CqlResult cqlResult = client.execute_cql_query(ThriftTool.ToByte("select first 30 Date from BahamutDays where Mode='" + mode + "'"), Compression.NONE);

            foreach (CqlRow t in cqlResult.Rows)
            {
                foreach (var col in t.Columns)
                {
                    var name = ThriftTool.ToString(col.Name);
                    switch (name)
                    {
                    case "Date":
                        result.Add(ThriftTool.ToString(col.Value));
                        break;
                    }
                }
            }
            ThriftTool.TransportClose(ref _transport);
            result.Sort();

            return(result);
        }
示例#2
0
        public HighChart[] BahaGetOneGame(string game, string startDate, string endDate)
        {
            var gameList  = game.Split(',');
            var chartList = new HighChart[gameList.Length];
            var client    = ThriftTool.GetClient("default", ref _transport);

            for (var i = 0; i < gameList.Length; i++)
            {
                var       rank      = new List <ScoreList>();
                CqlResult cqlResult = client.execute_cql_query(ThriftTool.ToByte("select * from BahamutGames where Title='" + gameList[i] + "'"), Compression.NONE);

                foreach (CqlRow t in cqlResult.Rows)
                {
                    var rl = new ScoreList();
                    foreach (var col in t.Columns)
                    {
                        var name = ThriftTool.ToString(col.Name);
                        switch (name)
                        {
                        case "Title":
                            rl.Title = ThriftTool.ToString(col.Value);
                            break;

                        case "Link":
                            rl.Link = ThriftTool.ToString(col.Value);
                            break;

                        case "Article":
                            rl.Article = ThriftTool.ToString(col.Value);
                            break;

                        case "Popular":
                            rl.Popular = ThriftTool.ToString(col.Value);
                            break;

                        case "Date":
                            rl.Date = ThriftTool.ToInt(col.Value);
                            break;
                        }
                    }
                    rank.Add(rl);
                }

                var ranks = from n in rank orderby n.Date select n;

                chartList[i] = ParseToHighChart(ranks);
            }
            ThriftTool.TransportClose(ref _transport);

            return(chartList);
        }
示例#3
0
        public static MvcHtmlString GenDayList()
        {
            var client = ThriftTool.GetClient("default", ref _transport);
            var result = ThriftTool.GetAllFromCF("BahamutDays", 30, client);

            ThriftTool.TransportClose(ref _transport);
            var sb = new StringBuilder();

            foreach (var ks in result)
            {
                foreach (var keySlice in ks.Columns)
                {
                    var key = ThriftTool.ToString(keySlice.Column.Name);
                    sb.Append("<option value='" + key + "'>" + key + "</option>");
                }
            }
            return(new MvcHtmlString(sb.ToString()));
        }
示例#4
0
 public Datacenter()
 {
     Client = ThriftTool.GetClient();
 }
示例#5
0
        /// <summary>
        /// 取得Baha單日資料
        /// </summary>
        /// <param name="key">日期</param>
        /// <param name="columnFamily">CF name (BahamutOnline,BahamutAll)</param>
        /// <returns></returns>
        public IOrderedEnumerable <RankList> BahaGetOneDay(string key, string columnFamily)
        {
            var rank = new List <RankList>();

            var client = ThriftTool.GetClient("default", ref _transport);

            var lb = new List <byte[]> {
                ThriftTool.ToByte(key)
            };

            Dictionary <byte[], List <ColumnOrSuperColumn> > results = client.multiget_slice(lb, ThriftTool.GetParent(columnFamily), ThriftTool.GetPredicate(100), ConsistencyLevel.ONE);

            if (results.Count > 0) //if have result
            {
                foreach (var result in results)
                {
                    foreach (var scol in result.Value)
                    {
                        if (scol.GetType() == typeof(ColumnOrSuperColumn))
                        {
                            var rl = new RankList();
                            foreach (var col in scol.Super_column.Columns)
                            {
                                string name = ThriftTool.ToString(col.Name);
                                if (name == "Title")
                                {
                                    rl.Title = ThriftTool.ToString(col.Value);
                                }
                                if (name == "Rank")
                                {
                                    rl.Rank = int.Parse(ThriftTool.ToString(col.Value));
                                }
                                if (name == "Article")
                                {
                                    rl.Article = ThriftTool.ToString(col.Value);
                                }
                                if (name == "Link")
                                {
                                    rl.Link = ThriftTool.ToString(col.Value);
                                }
                                if (name == "Popular")
                                {
                                    rl.Popular = ThriftTool.ToString(col.Value);
                                }
                                if (name == "Date")
                                {
                                    rl.Date = DateTime.Parse(ThriftTool.ToString(col.Value));
                                }
                                if (name == "Change")
                                {
                                    rl.Change = ThriftTool.ToString(col.Value);
                                }
                            }
                            rank.Add(rl);
                        }
                    }
                }
            }

            ThriftTool.TransportClose(ref _transport);
            var ranks = from n in rank orderby n.Rank select n;

            return(ranks);
        }