/// <summary> /// Populates the serialization object order with the info from the API. /// </summary> /// <param name="src">The source.</param> private void PopulateOrderInfo(SerializableOrderListItem src) { OwnerID = src.OwnerID; ID = src.OrderID; Item = StaticItems.GetItemByID(src.ItemID); UnitaryPrice = src.UnitaryPrice; InitialVolume = src.InitialVolume; RemainingVolume = src.RemainingVolume; MinVolume = src.MinVolume; Duration = src.Duration; Issued = src.Issued; IssuedFor = src.IssuedFor; m_stationID = src.StationID; UpdateStation(); if (src.IsBuyOrder == 0) { return; } BuyOrder buyOrder = (BuyOrder)this; buyOrder.Escrow = src.Escrow; buyOrder.Range = src.Range; }
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src">The source.</param> /// <exception cref="System.ArgumentNullException">src</exception> protected MarketOrder(SerializableOrderListItem src) { src.ThrowIfNull(nameof(src)); PopulateOrderInfo(src); LastStateChange = DateTime.UtcNow; m_state = GetState(src); }
/// <summary> /// Try to update this order with a serialization object from the API. /// </summary> /// <param name="src"></param> /// <returns></returns> internal bool TryImport(SerializableOrderListItem src, List <MarketOrder> endedOrders) { // Note that, before a match is found, all orders have been marked for deletion : m_markedForDeletion == true // Checks whether ID is the same (IDs can be recycled ?) if (!MatchesWith(src)) { return(false); } // Prevent deletion m_markedForDeletion = false; // Update infos (if ID is the same it may have been modified either by the market // or by the user [modify order] so we update the orders info that are changeable) if (IsModified(src)) { // If it's a buying order, escrow may have changed if (src.IsBuyOrder != 0) { ((BuyOrder)this).Escrow = src.Escrow; } m_unitaryPrice = src.UnitaryPrice; m_remainingVolume = src.RemainingVolume; m_issued = src.Issued; m_state = OrderState.Modified; } else if (m_state == OrderState.Modified) { m_state = OrderState.Active; } // Update state OrderState state = GetState(src); if (m_state != OrderState.Modified && state != m_state) // it has either expired or fulfilled { m_state = state; m_lastStateChange = DateTime.UtcNow; // Should we notify it to the user ? if ((state == OrderState.Expired || state == OrderState.Fulfilled) && !Ignored) { endedOrders.Add(this); } } return(true); }
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src"></param> protected MarketOrder(SerializableOrderListItem src) { m_state = GetState(src); m_orderID = src.OrderID; m_itemID = src.ItemID; m_item = StaticItems.GetItemByID(src.ItemID); m_station = GetStationByID(src.StationID); m_unitaryPrice = src.UnitaryPrice; m_initialVolume = src.InitialVolume; m_remainingVolume = src.RemainingVolume; m_lastStateChange = DateTime.UtcNow; m_minVolume = src.MinVolume; m_duration = src.Duration; m_issued = src.Issued; m_issuedFor = src.IssuedFor; }
/// <summary> /// Gets the state of an order. /// </summary> /// <param name="src"></param> /// <returns></returns> private static OrderState GetState(SerializableOrderListItem src) { switch ((APIEnumerations.CCPOrderState)src.State) { case APIEnumerations.CCPOrderState.Closed: case APIEnumerations.CCPOrderState.Canceled: case APIEnumerations.CCPOrderState.CharacterDeleted: return(OrderState.Canceled); case APIEnumerations.CCPOrderState.Pending: case APIEnumerations.CCPOrderState.Opened: return(OrderState.Active); case APIEnumerations.CCPOrderState.ExpiredOrFulfilled: return(src.RemainingVolume == 0 ? OrderState.Fulfilled : OrderState.Expired); default: throw new NotImplementedException(); } }
/// <summary> /// Checks whether the given API object matches with this order. /// </summary> /// <param name="src"></param> /// <returns></returns> internal bool IsModified(SerializableOrderListItem src) { return(src.RemainingVolume != 0 && ((src.UnitaryPrice != m_unitaryPrice && src.Issued != m_issued) || src.RemainingVolume != m_remainingVolume)); }
/// <summary> /// Checks whether the given API object matches with this order. /// </summary> /// <param name="src"></param> /// <returns></returns> internal bool MatchesWith(SerializableOrderListItem src) { return(src.OrderID == m_orderID); }
/// <summary> /// Checks whether the given API object has been modified. /// </summary> /// <param name="src"></param> /// <returns></returns> private bool IsModified(SerializableOrderListItem src) => src.RemainingVolume != 0 && ((src.UnitaryPrice != UnitaryPrice && src.Issued != Issued) || src.RemainingVolume != RemainingVolume);
/// <summary> /// Checks whether the given API object matches with this order. /// </summary> /// <param name="src"></param> /// <returns></returns> private bool MatchesWith(SerializableOrderListItem src) => src.OrderID == ID;
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src"></param> internal BuyOrder(SerializableOrderListItem src) : base(src) { Escrow = src.Escrow; m_range = src.Range; }
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src"></param> internal SellOrder(SerializableOrderListItem src) : base(src) { }
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src"></param> internal SellOrder(SerializableOrderListItem src, CCPCharacter character) : base(src, character) { }
/// <summary> /// Constructor from the API. /// </summary> /// <param name="src"></param> internal BuyOrder(SerializableOrderListItem src, CCPCharacter character) : base(src, character) { Escrow = src.Escrow; Range = src.Range; }