コード例 #1
0
        /// <summary>
        /// 执行调试服务代码
        /// </summary>
        public void Execution()
        {
            // Get all services need to start
            var list = dataSyncServiceRepository.GetAllNeedStartServices().Result;

            Console.WriteLine("There are " + list.Count + " services need to process.");

            ServiceFactory factory = new ServiceFactory(accessTokenRepository, tradeManager);

            // enqueue them to execution queue.
            foreach (var service in list)
            {
                IService serviceJob     = factory.Create(service);
                var      dataSyncEntity = dataSyncServiceRepository.Get(service.Id);

                try
                {
                    serviceJob.Execute();
                    UpdateStatusWhenSuccess(dataSyncEntity, "Success");
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.ToString());
                    UpdateStatusWhenFailure(dataSyncEntity, "Failed", exc);
                }

                // BackgroundJob.Enqueue(() => Console.WriteLine("Service will start."));
            }
        }
コード例 #2
0
        public void Execute(long serviceId)
        {
            var      syncServiceEntity = _dataSyncServiceRepository.Get(serviceId);
            var      accessToken       = _accessTokenRepository.Get(syncServiceEntity.AccessTokenId);
            IService service           = new AlibabaTradeGetSellerOrderListService(accessToken, _tradeManager);

            service.Execute();
        }