Пример #1
0
        public Result Close(string token)
        {
            if (token != ConfigurationManager.AppSettings["CloseToken"])
            {
                return(Result(ApiResultEnum.InvalidRequest));
            }

            int status_trade = MonitorRA.GetStatusTrade();

            UserRA.FlushDatabase(new List <int>()
            {
                7, 8, (int)DateTime.Now.AddDays(1).DayOfWeek
            });
            if (status_trade != 0)
            {
                if (LogTradeDA.Close("系统"))
                {
                    MonitorRA.SetStatusTrade((int)StatusTradeEnum.Closed);
                    OpenCloseBiz.Close();
                    NLog.Info("系统自动收盘");
                    return(Result(ApiResultEnum.Success));
                }
            }
            return(Result(ApiResultEnum.Order_Closed));
        }
Пример #2
0
        public Result UpdateStatusTrade(StatusTradeEnum status)
        {
            int status_trade = MonitorRA.GetStatusTrade();

            if (status_trade == 0)
            {
                if (status != StatusTradeEnum.Opening)
                {
                    return(Result(ApiResultEnum.Failed));
                }

                //开盘
                if (!LogTradeDA.Open(UserRA.Get(user_id.ToString(), "name")))
                {
                    return(Result(ApiResultEnum.Failed));
                }

                MonitorRA.SetStatusTrade((int)status);
                OpenCloseBiz.Open();
            }
            else
            {
                if (status == StatusTradeEnum.Opening)
                {
                    OpenCloseBiz.Open();
                    return(Result(ApiResultEnum.Success));
                }
                else if (status == StatusTradeEnum.Recovery)
                {
                    MonitorRA.SetStatusTrade((int)StatusTradeEnum.Opening);
                }
                else if (status == StatusTradeEnum.Pause)
                {
                    MonitorRA.SetStatusTrade((int)status);
                }
                else
                {
                    //收盘
                    if (!LogTradeDA.Close(UserRA.Get(user_id.ToString(), "name")))
                    {
                        return(Result(ApiResultEnum.Failed));
                    }
                    MonitorRA.SetStatusTrade((int)status);
                    OpenCloseBiz.Close();
                }
            }
            return(Result(ApiResultEnum.Success));
        }