示例#1
0
        /// <summary>
        /// Update StopOrder object
        /// </summary>
        /// <param name="stopOrder">StopOrder with StopOrderID > 0</param>
        public void UpdateStopOrder(CommonData.StopOrder stopOrder)
        {
            StopOrder db_stopOrder = new StopOrder()
            {
                StopOrderID  = stopOrder.StopOrderID,
                Time         = StorageLib.ToDbTime(stopOrder.Time),
                InsID        = stopOrder.InsID,
                BuySell      = (byte)stopOrder.BuySell,
                StopType     = (byte)stopOrder.StopType,
                EndTime      = StorageLib.ToDbTime(stopOrder.EndTime),
                AlertPrice   = stopOrder.AlertPrice,
                Price        = stopOrder.Price,
                LotCount     = stopOrder.LotCount,
                Status       = (byte)stopOrder.Status,
                AccountID    = stopOrder.AccountID,
                CompleteTime = StorageLib.ToDbTime(stopOrder.CompleteTime),
                StopOrderNo  = stopOrder.StopOrderNo
            };

            _da.DbContext.Update(db_stopOrder);
        }
示例#2
0
        /// <summary>
        /// Get StopOrders list
        /// </summary>
        /// <param name="accountID">account Id</param>
        /// <param name="isActiveOnly">true - active stop orders only, false - all stop orders</param>
        /// <param name="idFrom">From StopOrderID</param>
        /// <returns>StopOrders list</returns>
        public IEnumerable <CommonData.StopOrder> GetStopOrders(int accountID, bool isActiveOnly, int idFrom)
        {
            List <CommonData.StopOrder> stopOrders = new List <CommonData.StopOrder>();

            var db_allStopOrders = _da.DbContext.Table <StopOrder>().Where(r => r.AccountID == accountID && r.StopOrderID >= idFrom);
            List <StopOrder> db_stopOrders;

            if (isActiveOnly)
            {
                db_stopOrders = db_allStopOrders.Where(r => (StopOrderStatus)r.Status == StopOrderStatus.Active).ToList();
            }
            else
            {
                db_stopOrders = db_allStopOrders.ToList();
            }

            foreach (var db_stopOrder in db_stopOrders)
            {
                var stopOrder = new CommonData.StopOrder()
                {
                    StopOrderID  = db_stopOrder.StopOrderID,
                    Time         = StorageLib.ToDateTime(db_stopOrder.Time),
                    InsID        = db_stopOrder.InsID,
                    BuySell      = (BuySell)db_stopOrder.BuySell,
                    StopType     = (StopOrderType)db_stopOrder.StopType,
                    EndTime      = StorageLib.ToDateTime(db_stopOrder.EndTime),
                    AlertPrice   = db_stopOrder.AlertPrice,
                    Price        = db_stopOrder.Price,
                    LotCount     = db_stopOrder.LotCount,
                    Status       = (StopOrderStatus)db_stopOrder.Status,
                    AccountID    = db_stopOrder.AccountID,
                    CompleteTime = StorageLib.ToDateTime(db_stopOrder.CompleteTime),
                    StopOrderNo  = db_stopOrder.StopOrderNo
                };
                stopOrders.Add(stopOrder);
            }

            return(stopOrders);
        }