Exemplo n.º 1
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 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();
            var ranks = from n in rank orderby n.Rank select n;

            return(ranks);
        }