Exemple #1
0
        public void Execute(IJobExecutionContext context)
        {
            LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>();

            var cateService  = new StockCategoryService();
            var stockService = new StockService();



            var cycleType = this.CycleType;

            IList <stockcategory> cateList = cateService.FindAll();

            foreach (var category in cateList)
            {
                IList <stock> stockList = stockService.GetStockByCategory(category.code);

                foreach (var stock in stockList)
                {
                    IList <PriceInfo> priceList = stockService.GetPriceInfo(stock.code, cycleType);

                    this.Log().Error("开始计算股票技术指数:" + stock.name + ",Code:" + stock.code);
                    var tech = new TechCalculate(ObjectType.Stock, cycleType, stock.code, priceList);
                    tech.Run();
                    this.Log().Error("计算结束:" + stock.name);

                    Thread.Sleep(100);
                }
            }
        }
        public void Start()
        {
            this.Log().Info("启动计算服务");
            _context = NetMQContext.Create();
            _socket  = _context.CreateSocket(ZmqSocketType.Rep);
            _socket.Connect(ConfigurationManager.AppSettings["broker"]);
            _running = true;
            while (_running)
            {
                this.Log().Info("开始接收消息");
                var message = _socket.ReceiveString();
                this.Log().Info("接收消息:{" + message + "}");
                var taskMesg = JsonConvert.DeserializeObject <IndexTask>(message);

                var objType   = taskMesg.type;
                var objCode   = taskMesg.code;
                var cycleType = taskMesg.cycle;// (TechCycle)Enum.Parse(typeof(TechCycle), taskMesg.cycle, true);
                //var date = taskMesg.date;
                IIndexService indexService = new IndexService();
                //获取数据
                var priceList = indexService.GetObjectData(objType.ToString(), cycleType, objCode);

                //计算指数结果
                //存储指数到MangoDB
                //更新状态数据到MangoDB
                if (priceList.Count > 0)
                {
                    var tech = new TechCalculate(objType, cycleType, objCode, priceList);
                    tech.Run();
                }
                this.Log().Info("处理完成");
                _socket.Send("处理完成:{" + message + "}");
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            var cateService = new StockCategoryService();



            var cycleType = this.CycleType;

            IList <stockcategory> cateList = cateService.GetCategoryList("tencent");

            foreach (var category in cateList)
            {
                var priceList = cateService.GetPriceInfo(category.code, cycleType);
                this.Log().Error("开始计算行业技术指数:" + category.name + ",Code:" + category.code);
                var tech = new TechCalculate(ObjectType.Category, cycleType, category.code, priceList);

                tech.Run();
                this.Log().Error("开始计算:" + category.name + ",Code:" + category.code);
            }
        }
        public void Excute(string message)
        {
            this.Log().Info("处理消息");
            var taskMesg = JsonConvert.DeserializeObject <IndexTask>(message);

            var objType   = taskMesg.type;
            var objCode   = taskMesg.code;
            var cycleType = taskMesg.cycle;// (TechCycle)Enum.Parse(typeof(TechCycle), taskMesg.cycle, true);
            //var date = taskMesg.date;
            IIndexService indexService = new IndexService();
            //获取数据
            var priceList = indexService.GetObjectData(objType.ToString(), cycleType, objCode);

            //计算指数结果
            //存储指数到MangoDB
            //更新状态数据到MangoDB
            if (priceList.Count > 0)
            {
                var tech = new TechCalculate(objType, cycleType, objCode, priceList);
                tech.Run();
            }
            this.Log().Info("处理完成");
        }
        public void Execute(IJobExecutionContext context)
        {
            var cateService = new CustomObjectService();

            //var type = "Day"; //context.Trigger.JobDataMap["cycle"] + "";

            //if (string.IsNullOrEmpty(type))
            //    return;

            var cycleType = this.CycleType;// (TechCycle)Enum.Parse(typeof(TechCycle), type, true);

            IList <customobject> objectList = cateService.FindAll();

            foreach (var item in objectList)
            {
                var priceList = cateService.GetPriceInfo(item.code, cycleType);

                this.Log().Error("开始计算大盘技术指数:" + item.name + ",Code:" + item.code);
                var tech = new TechCalculate(ObjectType.Object, cycleType, item.code, priceList);

                tech.Run();
                this.Log().Error("开始计算:" + item.name + ",Code:" + item.code);
            }
        }