Exemplo n.º 1
0
        public static List <TradeTimeRange> GetTimeRanges(long contractId)
        {
            var openTimes         = Get(contractId);
            var allTradeTimeRange = new List <TradeTimeRange>();

            foreach (var item in openTimes)
            {
                var range = new TradeTimeRange();
                range.BeginTime = Convert.ToInt32(item.BeginTime.Replace(":", ""));
                range.EndTime   = Convert.ToInt32(item.EndTime.Replace(":", ""));
                allTradeTimeRange.Add(range);
            }
            var result = new List <TradeTimeRange>();
            var list   = allTradeTimeRange.Where(w => w.BeginTime >= 210000).OrderBy(o => o.BeginTime);

            result.AddRange(list);
            list = allTradeTimeRange.Where(w => w.BeginTime < 210000).OrderBy(o => o.BeginTime);
            result.AddRange(list);
            return(allTradeTimeRange);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从数据库获取品种详情
        /// </summary>
        /// <returns></returns>
        public static List <VarietyDetail> GetDbVeriDetail()
        {
            var varieties = GetDbVarieties();

            if (varieties == null || varieties.Count <= 0)
            {
                return(null);
            }

            var openTimes = GetDbVarietyOpenTimes();

            if (openTimes == null)
            {
                return(null);
            }

            var indCatgList = GetDbIndCatgList();

            if (indCatgList == null)
            {
                return(null);
            }

            var veriIndList = GetDbVeriIndList();

            if (veriIndList == null)
            {
                return(null);
            }

            var f10List = GetVarietyInfoList();


            var result = new List <VarietyDetail>();

            foreach (var variety in varieties)
            {
                var detail = new VarietyDetail();
                detail.EID       = (Exchange)variety.EID;
                detail.Lots      = variety.Lots;
                detail.PriceStep = variety.PriceStep;
                detail.State     = variety.State;

                detail.TradeTimeList = new List <TradeTimeRange>();
                foreach (var item in openTimes.Where(w => w.VID == variety.ID))
                {
                    var range = new TradeTimeRange();
                    range.BeginTime = Convert.ToInt32(item.BeginTime.Replace(":", ""));
                    range.EndTime   = Convert.ToInt32(item.EndTime.Replace(":", ""));

                    detail.TradeTimeList.Add(range);
                }

                detail.Type        = variety.Type;
                detail.VarietyCode = variety.VarietyCode;
                detail.VarietyName = variety.VarietyName;
                detail.VarietyID   = variety.ID;

                detail.VariIndCatgList = new List <VeriIndCatg>();
                foreach (var item in veriIndList.Where(w => w.VerietyID == variety.ID))
                {
                    var indCatg = indCatgList.FirstOrDefault(f => f.Id == item.IndCatgID);
                    if (indCatg == null)
                    {
                        continue;
                    }
                    var catg = new VeriIndCatg();
                    catg.IndCatgID = item.IndCatgID;
                    catg.Name      = indCatg.Name;

                    detail.VariIndCatgList.Add(catg);
                }

                detail.F10 = new Dictionary <string, string>();

                foreach (var source in f10List.Where(p => p.VarietyID == variety.ID))
                {
                    if (detail.F10.ContainsKey(source.KeyName))
                    {
                        detail.F10[source.KeyName] = source.KeyValue;
                    }
                    else
                    {
                        detail.F10.Add(source.KeyName, source.KeyValue);
                    }
                }
                result.Add(detail);
            }
            return(result);
        }