Ejemplo n.º 1
0
        public void Run()
        {
            Console.Clear();

            var inspectionResult = _selfInspectionService.Inspect();

            if (!inspectionResult.IsSuccessful)
            {
                Console.WriteLine(inspectionResult.Message);
                Console.WriteLine("Press any key to quit");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("Prease any key to start it");
            Console.ReadKey();
            Console.Clear();

            var observations  = _observationService.GetObservations();
            var currencyPairs = observations.Select(it => it.CurrencyPair).ToList();

            _exchangeDataService.Register(currencyPairs);
            _exchangeDataService.Start();
            _worker.Add(observations);


            Console.ReadLine();
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] Observation model)
 {
     model.Id          = Guid.NewGuid();
     model.DateCreated = DateTime.UtcNow;
     _observationService.Add(model);
     _worker.Add(model);
     return(NoContent());
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 新增工作
 /// </summary>
 /// <param name="worker">工作者</param>
 /// <param name="job">工作</param>
 public static void Add(this IWorker worker, IDisposable job)
 {
     if (!(job is IJob))
     {
         throw new ArgumentException(nameof(job));
     }
     worker.Add(job.AsJob());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Start data service, add default observations
        /// </summary>
        public void Run()
        {
            //Todo: create a service scope for each run times. else if many records are added in to coinContext. the Performance will deteriorate
            var observations = _observationService.GetObservations();
            ///Todo: Improve  if a new observatoin is added. we can register a new currencypair
            var currencyPairs = new List <CurrencyPair>()
            {
                CurrencyPair.BtcEur, CurrencyPair.LtcEur
            };

            _exchangeDataService.Register(currencyPairs);
            _exchangeDataService.Start();
            _worker.Add(observations);

            var wssv = new WebSocketServer(4888);

            wssv.AddWebSocketService <MessageBehavior>("/message");
            wssv.Start();
            var enviromnent = _appSettings.Production ? "production" : "test";

            Console.WriteLine($"{enviromnent} enviroment");
        }