Ejemplo n.º 1
0
 /// <summary>
 /// NOTE : TARGET 설정 ORDER STATE TRACE 로 변경
 /// </summary>
 /// <param name="target"></param>
 protected virtual void AggroON(Transform target)
 {
     if (OrderState.Equals(ORDER_STATE.Chase))
     {
         return;
     }
     if (targetOb == null)
     {
         targetOb = target;
     }
     OrderState = ORDER_STATE.Chase;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Direction == other.Direction ||

                     Direction.Equals(other.Direction)
                     ) &&
                 (
                     ReduceOnly == other.ReduceOnly ||
                     ReduceOnly != null &&
                     ReduceOnly.Equals(other.ReduceOnly)
                 ) &&
                 (
                     Triggered == other.Triggered ||
                     Triggered != null &&
                     Triggered.Equals(other.Triggered)
                 ) &&
                 (
                     OrderId == other.OrderId ||
                     OrderId != null &&
                     OrderId.Equals(other.OrderId)
                 ) &&
                 (
                     Price == other.Price ||
                     Price != null &&
                     Price.Equals(other.Price)
                 ) &&
                 (
                     TimeInForce == other.TimeInForce ||

                     TimeInForce.Equals(other.TimeInForce)
                 ) &&
                 (
                     Api == other.Api ||
                     Api != null &&
                     Api.Equals(other.Api)
                 ) &&
                 (
                     OrderState == other.OrderState ||

                     OrderState.Equals(other.OrderState)
                 ) &&
                 (
                     Implv == other.Implv ||
                     Implv != null &&
                     Implv.Equals(other.Implv)
                 ) &&
                 (
                     Advanced == other.Advanced ||

                     Advanced.Equals(other.Advanced)
                 ) &&
                 (
                     PostOnly == other.PostOnly ||
                     PostOnly != null &&
                     PostOnly.Equals(other.PostOnly)
                 ) &&
                 (
                     Usd == other.Usd ||
                     Usd != null &&
                     Usd.Equals(other.Usd)
                 ) &&
                 (
                     StopPrice == other.StopPrice ||
                     StopPrice != null &&
                     StopPrice.Equals(other.StopPrice)
                 ) &&
                 (
                     OrderType == other.OrderType ||

                     OrderType.Equals(other.OrderType)
                 ) &&
                 (
                     LastUpdateTimestamp == other.LastUpdateTimestamp ||
                     LastUpdateTimestamp != null &&
                     LastUpdateTimestamp.Equals(other.LastUpdateTimestamp)
                 ) &&
                 (
                     OriginalOrderType == other.OriginalOrderType ||

                     OriginalOrderType.Equals(other.OriginalOrderType)
                 ) &&
                 (
                     MaxShow == other.MaxShow ||
                     MaxShow != null &&
                     MaxShow.Equals(other.MaxShow)
                 ) &&
                 (
                     ProfitLoss == other.ProfitLoss ||
                     ProfitLoss != null &&
                     ProfitLoss.Equals(other.ProfitLoss)
                 ) &&
                 (
                     IsLiquidation == other.IsLiquidation ||
                     IsLiquidation != null &&
                     IsLiquidation.Equals(other.IsLiquidation)
                 ) &&
                 (
                     FilledAmount == other.FilledAmount ||
                     FilledAmount != null &&
                     FilledAmount.Equals(other.FilledAmount)
                 ) &&
                 (
                     Label == other.Label ||
                     Label != null &&
                     Label.Equals(other.Label)
                 ) &&
                 (
                     Commission == other.Commission ||
                     Commission != null &&
                     Commission.Equals(other.Commission)
                 ) &&
                 (
                     Amount == other.Amount ||
                     Amount != null &&
                     Amount.Equals(other.Amount)
                 ) &&
                 (
                     Trigger == other.Trigger ||

                     Trigger.Equals(other.Trigger)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     AveragePrice == other.AveragePrice ||
                     AveragePrice != null &&
                     AveragePrice.Equals(other.AveragePrice)
                 ));
        }
Ejemplo n.º 3
0
        public bool SetOrderState(int waiterId, int orderId, OrderState state)
        {
            if (!CheckHasUserRole(waiterId, UserRole.Waiter))
                throw new SecurityException(String.Format("User id={0} is not logged in or is not a waiter.", waiterId));

            if (state.Equals(OrderState.Placed))
                throw new ArgumentException("Cannot change Order state to Placed");

            using(var db = new DataAccessProvider())
            {
                var order = db.Orders.Include("Client").FirstOrDefault( o => o.Id == orderId);
                if (order == null)
                    throw new ArgumentException(String.Format("No such Order (id={0}) exists", orderId));

                //Nie można zmienić stan zamówienia innego kelnera
                if (order.Waiter.Id != waiterId)
                    return false;

                if (state.Equals(OrderState.Accepted))
                {
                    //Nie można zaakceptować zamówienia, który jest w stanie innym niż Placed
                    if(!order.State.Equals(OrderState.Placed))
                        return false;
                }
                else if (state.Equals(OrderState.AwaitingDelivery))
                {
                    //Nie można zakończyć przygotowanie zamówienia, które nie zostało zaakceptowane
                    if (!order.State.Equals(OrderState.Accepted))
                        return false;
                }
                else if(state.Equals(OrderState.Realized) || state.Equals(OrderState.NotRealized) )
                {
                    //Nie można zakończyć zamówienie, które nie jest w stanie AwaitingDelivery
                    if (!order.State.Equals(OrderState.AwaitingDelivery))
                        return false;

                    order.ClosingDate = DateTime.Now;
                }

                order.State = state;
                db.SaveChanges();

                if (state.Equals(OrderState.AwaitingDelivery))
                {
                    CheckAreClientsAvailable();

                    lock (clientRegistrationRecords)
                    {
                        var clientRegRec = clientRegistrationRecords.FirstOrDefault(r => r.ClientId == order.Client.Id);
                        if (clientRegRec != null)
                            Task.Run(() => clientRegRec.Callback.NotifyOrderAwaitingDelivery(order.Id));
                        //klient zamówił przez stronę internetową, co oznacza, że nie posiada interfejsu wywołań zwrotnych. Wysyłamy kelnerowi bezpośrednio potwierdzenie zapłaty.
                        else
                        {
                            Task.Run(() => PayForOrderInternal(order.Client.Id, order.Id));
                        }
                    }
                }

                return true;
            }
        }