Esempio n. 1
0
 public static void start(AxKHOpenAPI gateway)
 {
     m_log        = log4net.LogManager.GetLogger("ProgramControl");
     m_gateway    = gateway;
     m_server     = new HttpServer(SystemInfo.PORT, DirectExecutionCommands.router);
     m_serverThrd = new Thread(new ThreadStart(m_server.Listen));
     if (PlanManager.loadPlans())
     {
         PlanManager.runPlans();
         m_serverThrd.Start();
     }
     else
     {
         //Info log
         //exit
         m_log.Error("계획을 로드하는데 실패함.");
         systemShutdown();
     }
 }
Esempio n. 2
0
        private static HttpResponse FDDLBuy(HttpRequest request)
        {
            if (request.Headers["Pass"].Equals(SystemInfo.PASS))
            {
                DownloadedTodayPlan downloadedInfo = JsonConvert.DeserializeObject <DownloadedTodayPlan>(request.Content);

                FDDLBuyExecution exe = new FDDLBuyExecution(downloadedInfo.ID, downloadedInfo.StockCode, downloadedInfo.Quantity, downloadedInfo.Price);
                PlanManager.getFDDLManager().addPlan(exe);
                exe.run();

                return(new HttpResponse()
                {
                    ReasonPhrase = "OK",
                    StatusCode = "200"
                });
            }

            return(new HttpResponse()
            {
                ReasonPhrase = "Unauth",
                StatusCode = "401"
            });
        }
Esempio n. 3
0
        private static HttpResponse schedulePlan(HttpRequest request)
        {
            if (request.Headers["Pass"].Equals(SystemInfo.PASS))
            {
                PlanManager.saveTomorrowPlans(request.Content);

                Timer timer = new Timer();
                timer.AutoReset = false;
                timer.Interval  = (DateTime.Now.AddSeconds(30) - DateTime.Now).TotalMilliseconds;
                timer.Elapsed  += shutdownComputer;

                return(new HttpResponse()
                {
                    ReasonPhrase = "OK",
                    StatusCode = "200"
                });
            }

            return(new HttpResponse()
            {
                ReasonPhrase = "Unauth",
                StatusCode = "401"
            });
        }