예제 #1
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     var orderTagName = actionData.GetAsString("OrderTagName");
     if (ticket != null && !string.IsNullOrEmpty(orderTagName))
     {
         var orderTagValue = actionData.GetAsString("OrderTagValue");
         if (ticket.Orders.Any(y => y.OrderTagExists(z => z.TagName == orderTagName && z.TagValue == orderTagValue)))
         {
             var tid = ticket.Id;
             EventServiceFactory.EventService.PublishEvent(EventTopicNames.CloseTicketRequested, true);
             ticket = _ticketService.OpenTicket(tid);
             var orders = ticket.Orders.Where(y => y.OrderTagExists(z => z.TagName == orderTagName && z.TagValue == orderTagValue)).ToArray();
             var commitResult = _ticketService.MoveOrders(ticket, orders, 0);
             if (string.IsNullOrEmpty(commitResult.ErrorMessage) && commitResult.TicketId > 0)
             {
                 ExtensionMethods.PublishIdEvent(commitResult.TicketId, EventTopicNames.DisplayTicket);
             }
             else
             {
                 ExtensionMethods.PublishIdEvent(tid, EventTopicNames.DisplayTicket);
             }
         }
     }
 }
예제 #2
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");

            if (ticket != null)
            {
                var menuItemName = actionData.GetAsString("MenuItemName");
                var menuItem = _cacheService.GetMenuItem(y => y.Name == menuItemName);
                var portionName = actionData.GetAsString("PortionName");
                var quantity = actionData.GetAsDecimal("Quantity");
                var tag = actionData.GetAsString("Tag");
                var orderStateName = actionData.GetAsString("OrderStateName");
                var orderState = actionData.GetAsString("OrderState");

                var osv = orderState.Contains("=") ? orderState : orderStateName + "=" + orderState;
                var order = _ticketService.AddOrder(ticket, menuItem.Id, quantity, portionName, osv);

                if (!string.IsNullOrEmpty(actionData.GetAsString("Price")))
                    order.UpdatePrice(actionData.GetAsDecimal("Price"), "");
                if (!string.IsNullOrEmpty(actionData.GetAsString("IncreaseInventory")))
                    order.IncreaseInventory = actionData.GetAsBoolean("IncreaseInventory");
                if (!string.IsNullOrEmpty(actionData.GetAsString("DecreaseInventory")))
                    order.DecreaseInventory = actionData.GetAsBoolean("DecreaseInventory");
                if (!string.IsNullOrEmpty(actionData.GetAsString("Locked")))
                    order.Locked = actionData.GetAsBoolean("Locked");
                if (!string.IsNullOrEmpty(actionData.GetAsString("CalculatePrice")))
                    order.CalculatePrice = actionData.GetAsBoolean("CalculatePrice");

                if (order != null) order.Tag = tag;
                actionData.DataObject.Order = order;
                order.PublishEvent(EventTopicNames.OrderAdded);
            }
        }
예제 #3
0
 public override void Process(ActionData actionData)
 {
     var entityId = actionData.GetDataValueAsInt("EntityId");
     var entityTypeId = actionData.GetDataValueAsInt("EntityTypeId");
     var stateName = actionData.GetAsString("EntityStateName");
     var state = actionData.GetAsString("EntityState");
     var quantityExp = actionData.GetAsString("QuantityExp");
     if (state != null)
     {
         if (entityId > 0 && entityTypeId > 0)
         {
             _entityServiceClient.UpdateEntityState(entityId, entityTypeId, stateName, state, quantityExp);
         }
         else
         {
             var ticket = actionData.GetDataValue<Ticket>("Ticket");
             if (ticket != null)
             {
                 var entityTypeName = actionData.GetAsString("EntityTypeName");
                 foreach (var ticketEntity in ticket.TicketEntities)
                 {
                     var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
                     if (string.IsNullOrEmpty(entityTypeName.Trim()) || entityType.Name == entityTypeName)
                         _entityServiceClient.UpdateEntityState(ticketEntity.EntityId, ticketEntity.EntityTypeId, stateName, state, quantityExp);
                 }
             }
         }
     }
 }
예제 #4
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");
            var orders = Helper.GetOrders(actionData, ticket);
            if (orders.Any())
            {
                foreach (var order in orders)
                {
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Quantity")))
                        order.Quantity = actionData.GetAsDecimal("Quantity");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Price")))
                        order.UpdatePrice(actionData.GetAsDecimal("Price"), "");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("IncreaseInventory")))
                        order.IncreaseInventory = actionData.GetAsBoolean("IncreaseInventory");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("DecreaseInventory")))
                        order.DecreaseInventory = actionData.GetAsBoolean("DecreaseInventory");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Locked")))
                        order.Locked = actionData.GetAsBoolean("Locked");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("CalculatePrice")))
                        order.CalculatePrice = actionData.GetAsBoolean("CalculatePrice");
                    if (!string.IsNullOrEmpty(actionData.GetAsString("AccountTransactionType")))
                        _ticketService.ChangeOrdersAccountTransactionTypeId(ticket, new List<Order> { order },
                                                                           _cacheService.GetAccountTransactionTypeIdByName
                                                                               (actionData.GetAsString("AccountTransactionType")));

                    if (!string.IsNullOrEmpty(actionData.GetAsString("PortionName")) || !string.IsNullOrEmpty(actionData.GetAsString("PriceTag")))
                    {
                        var portionName = actionData.GetAsString("PortionName");
                        var priceTag = actionData.GetAsString("PriceTag");
                        _ticketService.UpdateOrderPrice(order, portionName, priceTag);
                    }
                }
            }
        }
예제 #5
0
파일: Helper.cs 프로젝트: GHLabs/SambaPOS-3
        public static IList<Order> GetOrders(ActionData x, Ticket ticket)
        {
            IList<Order> orders = new List<Order>();
            var selectedOrder = x.GetDataValue<Order>("Order");

            if (selectedOrder != null && ticket != null && selectedOrder.SelectedQuantity > 0 &&
                selectedOrder.SelectedQuantity != selectedOrder.Quantity)
            {
                selectedOrder = ticket.ExtractSelectedOrder(selectedOrder);
                x.DataObject.Order = selectedOrder;
            }

            if (selectedOrder == null)
            {
                if (ticket != null)
                {
                    orders = ticket.Orders.Any(y => y.IsSelected)
                                 ? ticket.ExtractSelectedOrders().ToList()
                                 : ticket.Orders;
                    x.DataObject.Order = null;
                }
            }
            else orders.Add(selectedOrder);
            return orders;
        }
예제 #6
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");
            var orders = Helper.GetOrders(actionData, ticket);
            if (orders.Any())
            {
                var tagName = actionData.GetAsString("OrderTagName");
                var orderTag = _cacheService.GetOrderTagGroupByName(tagName);

                if (orderTag != null)
                {
                    var tagValue = actionData.GetAsString("OrderTagValue");
                    var oldTagValue = actionData.GetAsString("OldOrderTagValue");
                    var tagNote = actionData.GetAsString("OrderTagNote");
                    var orderTagValue = orderTag.OrderTags.SingleOrDefault(y => y.Name == tagValue);

                    if (orderTagValue != null)
                    {
                        if (!string.IsNullOrEmpty(actionData.GetAsString("OrderTagPrice")))
                        {
                            var price = actionData.GetAsDecimal("OrderTagPrice");
                            orderTagValue.Price = price;
                        }

                        if (!string.IsNullOrEmpty(oldTagValue))
                            orders = orders.Where(o => o.OrderTagExists(y => y.OrderTagGroupId == orderTag.Id && y.TagValue == oldTagValue)).ToList();
                        if (actionData.Action.ActionType == ActionNames.TagOrder)
                            _ticketService.TagOrders(ticket, orders, orderTag, orderTagValue, tagNote);
                        if (actionData.Action.ActionType == ActionNames.UntagOrder)
                            _ticketService.UntagOrders(ticket, orders, orderTag, orderTagValue);
                    }
                }
            }
        }
예제 #7
0
        public static IList <Order> GetOrders(ActionData x, Ticket ticket)
        {
            IList <Order> orders        = new List <Order>();
            var           selectedOrder = x.GetDataValue <Order>("Order");

            if (selectedOrder != null && ticket != null && selectedOrder.SelectedQuantity > 0 &&
                selectedOrder.SelectedQuantity != selectedOrder.Quantity)
            {
                selectedOrder      = ticket.ExtractSelectedOrder(selectedOrder);
                x.DataObject.Order = selectedOrder;
            }

            if (selectedOrder == null)
            {
                if (ticket != null)
                {
                    orders = ticket.Orders.Any(y => y.IsSelected)
                                 ? ticket.ExtractSelectedOrders().ToList()
                                 : ticket.Orders;
                    x.DataObject.Order = null;
                }
            }
            else
            {
                orders.Add(selectedOrder);
            }
            return(orders);
        }
예제 #8
0
 public override void Process(ActionData actionData)
 {
     var entityId = actionData.GetDataValueAsInt("EntityId");
     var entityName = actionData.GetAsString("EntityName");
     var fieldName = actionData.GetAsString("FieldName");
     var value = actionData.GetAsString("FieldValue");
     if (entityId > 0)
     {
         _entityServiceClient.UpdateEntityData(entityId, fieldName, value);
     }
     else if (!string.IsNullOrEmpty(entityName))
     {
         var entityTypeName = actionData.GetAsString("EntityTypeName");
         var entityType = _cacheService.GetEntityTypeByName(entityTypeName);
         if (entityType != null)
         {
             _entityServiceClient.UpdateEntityData(entityType, entityName, fieldName, value);
         }
     }
     else
     {
         var ticket = actionData.GetDataValue<Ticket>("Ticket");
         if (ticket != null)
         {
             var entityTypeName = actionData.GetAsString("EntityTypeName");
             foreach (var ticketEntity in ticket.TicketEntities)
             {
                 var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
                 if (string.IsNullOrEmpty(entityTypeName.Trim()) || entityType.Name == entityTypeName)
                     _entityServiceClient.UpdateEntityData(ticketEntity.EntityId, fieldName, value);
             }
         }
     }
 }
        public override void Process(ActionData actionData)
        {
            var ticket       = actionData.GetDataValue <Ticket>("Ticket");
            var orderTagName = actionData.GetAsString("OrderTagName");

            if (ticket != null && !string.IsNullOrEmpty(orderTagName))
            {
                var orderTagValue = actionData.GetAsString("OrderTagValue");
                if (ticket.Orders.Any(y => y.OrderTagExists(z => z.TagName == orderTagName && z.TagValue == orderTagValue)))
                {
                    var tid = ticket.Id;
                    EventServiceFactory.EventService.PublishEvent(EventTopicNames.CloseTicketRequested, true);
                    ticket = _ticketService.OpenTicket(tid);
                    var orders       = ticket.Orders.Where(y => y.OrderTagExists(z => z.TagName == orderTagName && z.TagValue == orderTagValue)).ToArray();
                    var commitResult = _ticketService.MoveOrders(ticket, orders, 0);
                    if (string.IsNullOrEmpty(commitResult.ErrorMessage) && commitResult.TicketId > 0)
                    {
                        ExtensionMethods.PublishIdEvent(commitResult.TicketId, EventTopicNames.DisplayTicket);
                    }
                    else
                    {
                        ExtensionMethods.PublishIdEvent(tid, EventTopicNames.DisplayTicket);
                    }
                }
            }
        }
예제 #10
0
        public override void Process(ActionData actionData)
        {
            var entityId     = actionData.GetDataValueAsInt("EntityId");
            var entityTypeId = actionData.GetDataValueAsInt("EntityTypeId");
            var stateName    = actionData.GetAsString("EntityStateName");
            var state        = actionData.GetAsString("EntityState");
            var quantityExp  = actionData.GetAsString("QuantityExp");

            if (state != null)
            {
                if (entityId > 0 && entityTypeId > 0)
                {
                    _entityServiceClient.UpdateEntityState(entityId, entityTypeId, stateName, state, quantityExp);
                }
                else
                {
                    var ticket = actionData.GetDataValue <Ticket>("Ticket");
                    if (ticket != null)
                    {
                        var entityTypeName = actionData.GetAsString("EntityTypeName");
                        foreach (var ticketEntity in ticket.TicketEntities)
                        {
                            var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
                            if (string.IsNullOrEmpty(entityTypeName.Trim()) || entityType.Name == entityTypeName)
                            {
                                _entityServiceClient.UpdateEntityState(ticketEntity.EntityId, ticketEntity.EntityTypeId, stateName, state, quantityExp);
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         ticket.PublishEvent(EventTopicNames.DisplayTicketLog);
     }
 }
예제 #12
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null && ticket != Ticket.Empty && CanCloseTicket(ticket))
     {
         EventServiceFactory.EventService.PublishEvent(EventTopicNames.CloseTicketRequested, true);
     }
 }
예제 #13
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null && ticket != Ticket.Empty && _ticketService.CanSettleTicket(ticket))
     {
         ticket.PublishEvent(EventTopicNames.MakePayment);
     }
 }
예제 #14
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         ticket.StopActiveTimers();
     }
 }
예제 #15
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         ticket.RequestLock();
     }
 }
예제 #16
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null && ticket.Orders.Count > 0)
     {
         actionData.DataObject.Order = ticket.Orders.Last();
     }
 }
예제 #17
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         CommonEventPublisher.EnqueueTicketEvent(EventTopicNames.SelectAutomationCommand);
     }
 }
예제 #18
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                ticket.Close();
            }
        }
예제 #19
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null && ticket != Ticket.Empty && CanCloseTicket(ticket))
            {
                EventServiceFactory.EventService.PublishEvent(EventTopicNames.CloseTicketRequested, true);
            }
        }
예제 #20
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                ticket.PublishEvent(EventTopicNames.DisplayTicketLog);
            }
        }
예제 #21
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null && ticket.Orders.Count > 0)
            {
                actionData.DataObject.Order = ticket.Orders.Last();
            }
        }
예제 #22
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if ((ticket == null || ticket == Ticket.Empty) && actionData.GetAsBoolean("CanCreateTicket") && !_applicationState.IsLocked)
            {
                ticket = _ticketService.OpenTicket(0);
                actionData.DataObject.Ticket = ticket;
                ticket.PublishEvent(EventTopicNames.SetSelectedTicket);
            }

            if (ticket != null)
            {
                var entityTypeName        = actionData.GetAsString("EntityTypeName");
                var entityName            = actionData.GetAsString("EntityName");
                var customDataSearchValue = actionData.GetAsString("EntitySearchValue");
                var entityType            = _cacheService.GetEntityTypeByName(entityTypeName);
                if (entityType != null)
                {
                    if (string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(customDataSearchValue))
                    {
                        CommonEventPublisher.PublishEntityOperation(Entity.GetNullEntity(entityType.Id), EventTopicNames.SelectEntity, EventTopicNames.EntitySelected);
                        return;
                    }

                    Entity entity = null;
                    if (!string.IsNullOrEmpty(customDataSearchValue))
                    {
                        var entities = _entityService.SearchEntities(entityType,
                                                                     customDataSearchValue,
                                                                     null);
                        if (entities.Count == 1)
                        {
                            entity = entities.First();
                        }
                    }

                    if (entity == null)
                    {
                        entity = _cacheService.GetEntityByName(entityTypeName, entityName);
                    }

                    if (entity == null && string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(customDataSearchValue))
                    {
                        entity = Entity.GetNullEntity(entityType.Id);
                    }

                    if (entity != null)
                    {
                        _ticketService.UpdateEntity(ticket, entity);
                        actionData.DataObject.EntityName = entity.Name;
                        actionData.DataObject.EntityId   = entity.Id;
                        actionData.DataObject.CustomData = entity.CustomData;
                    }
                }
            }
        }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                CommonEventPublisher.EnqueueTicketEvent(EventTopicNames.SelectAutomationCommand);
            }
        }
예제 #24
0
        public override void Process(ActionData actionData)
        {
            Ticket dataValue = actionData.GetDataValue <Ticket>("Ticket");

            if (dataValue != null)
            {
                dataValue.IsClosed = false;
            }
        }
예제 #25
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");
            if ((ticket == null || ticket == Ticket.Empty) && actionData.GetAsBoolean("CanCreateTicket") && !_applicationState.IsLocked)
            {
                ticket = _ticketService.OpenTicket(0);
                actionData.DataObject.Ticket = ticket;
                ticket.PublishEvent(EventTopicNames.SetSelectedTicket);
            }

            if (ticket != null)
            {
                var entityTypeName = actionData.GetAsString("EntityTypeName");
                var entityName = actionData.GetAsString("EntityName");
                var customDataSearchValue = actionData.GetAsString("EntitySearchValue");
                var entityType = _cacheService.GetEntityTypeByName(entityTypeName);
                if (entityType != null)
                {
                    if (string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(customDataSearchValue))
                    {
                        CommonEventPublisher.PublishEntityOperation(Entity.GetNullEntity(entityType.Id), EventTopicNames.SelectEntity, EventTopicNames.EntitySelected);
                        return;
                    }

                    Entity entity = null;
                    if (!string.IsNullOrEmpty(customDataSearchValue))
                    {

                        var entities = _entityService.SearchEntities(entityType,
                                                                    customDataSearchValue,
                                                                    null);
                        if (entities.Count == 1)
                        {
                            entity = entities.First();
                        }
                    }

                    if (entity == null)
                    {
                        entity = _cacheService.GetEntityByName(entityTypeName, entityName);
                    }

                    if (entity == null && string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(customDataSearchValue))
                    {
                        entity = Entity.GetNullEntity(entityType.Id);
                    }

                    if (entity != null)
                    {
                        _ticketService.UpdateEntity(ticket, entity);
                        actionData.DataObject.EntityName = entity.Name;
                        actionData.DataObject.EntityId = entity.Id;
                        actionData.DataObject.CustomData = entity.CustomData;
                    }
                }
            }
        }
예제 #26
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null && ticket != Ticket.Empty && _ticketService.CanSettleTicket(ticket))
            {
                ticket.PublishEvent(EventTopicNames.MakePayment);
            }
        }
예제 #27
0
        public override void Process(ActionData actionData)
        {
            var entityId   = actionData.GetDataValueAsInt("EntityId");
            var entityName = actionData.GetAsString("EntityName");
            var fieldName  = actionData.GetAsString("FieldName");
            var value      = actionData.GetAsString("FieldValue");

            if (entityId > 0)
            {
                _entityServiceClient.UpdateEntityData(entityId, fieldName, value);
            }
            else if (!string.IsNullOrEmpty(entityName))
            {
                var entityTypeName = actionData.GetAsString("EntityTypeName");
                var entityType     = _cacheService.GetEntityTypeByName(entityTypeName);
                if (entityType != null)
                {
                    _entityServiceClient.UpdateEntityData(entityType, entityName, fieldName, value);
                }
            }
            else
            {
                var ticket = actionData.GetDataValue <Ticket>("Ticket");
                if (ticket != null)
                {
                    var entityTypeName = actionData.GetAsString("EntityTypeName");
                    foreach (var ticketEntity in ticket.TicketEntities)
                    {
                        var entityType = _cacheService.GetEntityTypeById(ticketEntity.EntityTypeId);
                        if (string.IsNullOrEmpty(entityTypeName.Trim()) || entityType.Name == entityTypeName)
                        {
                            _entityServiceClient.UpdateEntityData(ticketEntity.EntityId, fieldName, value);
                        }
                    }
                }
            }

            var entity = actionData.GetDataValue <Entity>("Entity");

            if (entity != null && entity.Id == entityId)
            {
                entity.SetCustomData(fieldName, value);
            }
        }
예제 #28
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         var tagName = actionData.GetAsString("TagName");
         var tagValue = actionData.GetAsString("TagValue");
         _ticketService.UpdateTag(ticket, tagName, tagValue);
     }
 }
예제 #29
0
        public override void Process(ActionData actionData)
        {
            Ticket dataValue = actionData.GetDataValue <Ticket>("Ticket");
            string asString  = actionData.GetAsString("Date");

            if (dataValue != null && !string.IsNullOrWhiteSpace(asString))
            {
                dataValue.Date = DateFuncParser.Parse(asString, dataValue.Date);
            }
        }
예제 #30
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                ticket.UnLock();
            }
            EventServiceFactory.EventService.PublishEvent(EventTopicNames.UnlockTicketRequested);
        }
예제 #31
0
        public override void Process(ActionData actionData)
        {
            Ticket dataValue = actionData.GetDataValue <Ticket>("Ticket");

            if (dataValue != null)
            {
                bool asBoolean = actionData.GetAsBoolean("SelectAll", false);
                dataValue.Orders.ToList <Order>().ForEach((Order x) => x.IsSelected = asBoolean);
                IDictionary <string, object> dataObject = (IDictionary <string, object>)((dynamic)actionData.DataObject);
                if (dataObject.ContainsKey("Order"))
                {
                    dataObject.Remove("Order");
                }
                string asString = actionData.GetAsString("OrderIds");
                if (!string.IsNullOrEmpty(asString))
                {
                    char[]     chrArray = new char[] { ',' };
                    List <int> list     = (
                        from x in asString.Split(chrArray)
                        where !string.IsNullOrEmpty(x)
                        select Convert.ToInt32(x)).ToList <int>();
                    foreach (Order order in dataValue.Orders)
                    {
                        order.IsSelected = list.Contains(order.Id);
                    }
                }
                string str = actionData.GetAsString("OrderState");
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strArrays = str.Split(new char[] { ',' });
                    for (int i = 0; i < (int)strArrays.Length; i++)
                    {
                        string str1 = strArrays[i];
                        foreach (Order order1 in dataValue.Orders)
                        {
                            if (!str1.Contains <char>('='))
                            {
                                order1.IsSelected = order1.IsInState(str1);
                            }
                            else
                            {
                                string[] strArrays1 = str1.Split(new char[] { '=' });
                                order1.IsSelected = order1.IsInState(strArrays1[0], strArrays1[1]);
                            }
                        }
                    }
                }
                if (dataValue.Orders.Count <Order>((Order x) => x.IsSelected) == 1)
                {
                    dynamic       obj    = actionData.DataObject;
                    IList <Order> orders = dataValue.Orders;
                    obj.Order = orders.FirstOrDefault <Order>((Order x) => x.IsSelected);
                }
            }
        }
예제 #32
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var tagName  = actionData.GetAsString("TagName");
                var tagValue = actionData.GetAsString("TagValue");
                _ticketService.UpdateTag(ticket, tagName, tagValue);
            }
        }
예제 #33
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");
            var orders = Helper.GetOrders(actionData, ticket);

            if (orders.Any())
            {
                foreach (var order in orders)
                {
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Quantity")))
                    {
                        order.Quantity = actionData.GetAsDecimal("Quantity");
                        order.ResetSelectedQuantity();
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Price")))
                    {
                        order.UpdatePrice(actionData.GetAsDecimal("Price"), "");
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("IncreaseInventory")))
                    {
                        order.IncreaseInventory = actionData.GetAsBoolean("IncreaseInventory");
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("DecreaseInventory")))
                    {
                        order.DecreaseInventory = actionData.GetAsBoolean("DecreaseInventory");
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("Locked")))
                    {
                        order.Locked = actionData.GetAsBoolean("Locked");
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("CalculatePrice")))
                    {
                        order.CalculatePrice = actionData.GetAsBoolean("CalculatePrice");
                    }
                    if (!string.IsNullOrEmpty(actionData.GetAsString("AccountTransactionType")))
                    {
                        _ticketService.ChangeOrdersAccountTransactionTypeId(ticket, new List <Order> {
                            order
                        },
                                                                            _cacheService.GetAccountTransactionTypeIdByName
                                                                                (actionData.GetAsString("AccountTransactionType")));
                    }

                    if (!string.IsNullOrEmpty(actionData.GetAsString("PortionName")) || !string.IsNullOrEmpty(actionData.GetAsString("PriceTag")))
                    {
                        var portionName = actionData.GetAsString("PortionName");
                        var priceTag    = actionData.GetAsString("PriceTag");
                        _ticketService.UpdateOrderPrice(order, portionName, priceTag);
                    }
                }
            }
        }
예제 #34
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         var stateName = actionData.GetAsString("StateName");
         var currentState = actionData.GetAsString("CurrentState");
         var state = actionData.GetAsString("State");
         var stateValue = actionData.GetAsString("StateValue");
         var quantity = actionData.GetAsInteger("Quantity");
         _ticketService.UpdateTicketState(ticket, stateName, currentState, state, stateValue, quantity);
     }
 }
예제 #35
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         var category = actionData.GetAsString("Category");
         var log = actionData.GetAsString("Log");
         if (!string.IsNullOrEmpty(log))
         {
             ticket.AddLog(_applicationState.CurrentLoggedInUser.Name, category, log);
         }
     }
 }
예제 #36
0
 public override void Process(ActionData actionData)
 {
     var entityId = actionData.GetAsInteger("EntityId");
     var entity = entityId > 0 ? _cacheService.GetEntityById(entityId) : actionData.GetDataValue<Entity>("Entity");
     if (entity == null) return;
     var printerName = actionData.GetAsString("PrinterName");
     var printerTemplateName = actionData.GetAsString("PrinterTemplateName");
     var printer = _cacheService.GetPrinters().FirstOrDefault(x => x.Name == printerName);
     var printerTemplate = _cacheService.GetPrinterTemplates().FirstOrDefault(y => y.Name == printerTemplateName);
     if (printer == null) return;
     if (printerTemplate == null) return;
     _printerService.PrintObject(entity, printer, printerTemplate);
 }
예제 #37
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var category = actionData.GetAsString("Category");
                var log      = actionData.GetAsString("Log");
                if (!string.IsNullOrEmpty(log))
                {
                    ticket.AddLog(_applicationState.CurrentLoggedInUser.Name, category, log);
                }
            }
        }
예제 #38
0
        public override void Process(ActionData actionData)
        {
            Ticket dataValue = actionData.GetDataValue <Ticket>("Ticket");

            if (dataValue != null)
            {
                dataValue.Payments.ToList <Payment>().ForEach(new Action <Payment>(dataValue.RemovePayment));
                dataValue.ChangePayments.ToList <ChangePayment>().ForEach(new Action <ChangePayment>(dataValue.RemoveChangePayment));
                dataValue.PaidItems.ToList <PaidItem>().ForEach((PaidItem x) => dataValue.PaidItems.Remove(x));
                this._ticketService.RefreshAccountTransactions(dataValue);
                this._ticketService.RecalculateTicket(dataValue, false);
                dataValue.PublishEvent <Ticket>("RegenerateSelectedTicket");
            }
        }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var stateName    = actionData.GetAsString("StateName");
                var currentState = actionData.GetAsString("CurrentState");
                var state        = actionData.GetAsString("State");
                var stateValue   = actionData.GetAsString("StateValue");
                var quantity     = actionData.GetAsString("QuantityExp");
                _ticketService.UpdateTicketState(ticket, stateName, currentState, state, stateValue, quantity);
            }
        }
예제 #40
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var menuItemName = actionData.GetAsString("MenuItemName");
                var menuItem     = GetMenuItem(menuItemName);
                if (menuItem == null)
                {
                    return;
                }
                var portionName    = actionData.GetAsString("PortionName");
                var quantity       = actionData.GetAsDecimal("Quantity");
                var tag            = actionData.GetAsString("Tag");
                var orderStateName = actionData.GetAsString("OrderStateName");
                var orderState     = actionData.GetAsString("OrderState");

                var osv   = orderState.Contains("=") ? orderState : orderStateName + "=" + orderState;
                var order = _ticketService.AddOrder(ticket, menuItem.Id, quantity, portionName, osv);

                if (!string.IsNullOrEmpty(actionData.GetAsString("Price")))
                {
                    order.UpdatePrice(actionData.GetAsDecimal("Price"), "");
                }
                if (!string.IsNullOrEmpty(actionData.GetAsString("IncreaseInventory")))
                {
                    order.IncreaseInventory = actionData.GetAsBoolean("IncreaseInventory");
                }
                if (!string.IsNullOrEmpty(actionData.GetAsString("DecreaseInventory")))
                {
                    order.DecreaseInventory = actionData.GetAsBoolean("DecreaseInventory");
                }
                if (!string.IsNullOrEmpty(actionData.GetAsString("Locked")))
                {
                    order.Locked = actionData.GetAsBoolean("Locked");
                }
                if (!string.IsNullOrEmpty(actionData.GetAsString("CalculatePrice")))
                {
                    order.CalculatePrice = actionData.GetAsBoolean("CalculatePrice");
                }

                if (order != null)
                {
                    order.Tag = tag;
                }
                actionData.DataObject.Order = order;
                order.PublishEvent(EventTopicNames.OrderAdded);
            }
        }
예제 #41
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null && ticket != Ticket.Empty && _ticketService.CanSettleTicket(ticket))
            {
                var paymentTypeName = actionData.GetAsString("PaymentTypeName");
                var paymentType     = _cacheService.GetPaymentTypeByName(paymentTypeName);
                if (paymentType != null && ticket.RemainingAmount > 0)
                {
                    _ticketService.PayTicket(ticket, paymentType);
                }
                actionData.DataObject.RemainingAmount = 0m;
            }
        }
예제 #42
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");

            if (ticket != null && ticket != Ticket.Empty && _ticketService.CanSettleTicket(ticket))
            {
                var paymentTypeName = actionData.GetAsString("PaymentTypeName");
                var paymentType = _cacheService.GetPaymentTypeByName(paymentTypeName);
                if (paymentType != null && ticket.RemainingAmount > 0)
                {
                    _ticketService.PayTicket(ticket, paymentType);
                }
                actionData.DataObject.RemainingAmount = 0m;
            }
        }
예제 #43
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     var orders = Helper.GetOrders(actionData, ticket);
     if (orders.Any())
     {
         var stateName = actionData.GetAsString("StateName");
         var currentState = actionData.GetAsString("CurrentState");
         var groupOrder = actionData.GetAsInteger("GroupOrder");
         var state = actionData.GetAsString("State");
         var stateOrder = actionData.GetAsInteger("StateOrder");
         var stateValue = actionData.GetAsString("StateValue");
         _ticketService.UpdateOrderStates(ticket, orders.ToList(), stateName, currentState, groupOrder, state, stateOrder, stateValue);
     }
 }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");
            var orders = Helper.GetOrders(actionData, ticket);

            if (orders.Any())
            {
                var stateName    = actionData.GetAsString("StateName");
                var currentState = actionData.GetAsString("CurrentState");
                var groupOrder   = actionData.GetAsInteger("GroupOrder");
                var state        = actionData.GetAsString("State");
                var stateOrder   = actionData.GetAsInteger("StateOrder");
                var stateValue   = actionData.GetAsString("StateValue");
                _ticketService.UpdateOrderStates(ticket, orders.ToList(), stateName, currentState, groupOrder, state, stateOrder, stateValue);
            }
        }
예제 #45
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         var calculationTypeName = actionData.GetAsString("CalculationType");
         var calculationType = _cacheService.GetCalculationTypeByName(calculationTypeName);
         if (calculationType != null)
         {
             var amount = actionData.GetAsDecimal("Amount");
             ticket.AddCalculation(calculationType, amount);
             _ticketService.RecalculateTicket(ticket);
             EventServiceFactory.EventService.PublishEvent(EventTopicNames.RegenerateSelectedTicket);
         }
     }
 }
예제 #46
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");

            if (ticket != null)
            {
                var menuItemName = actionData.GetAsString("MenuItemName");
                var menuItem = _cacheService.GetMenuItem(y => y.Name == menuItemName);
                var portionName = actionData.GetAsString("PortionName");
                var quantity = actionData.GetAsDecimal("Quantity");
                var tag = actionData.GetAsString("Tag");
                var order = _ticketService.AddOrder(ticket, menuItem.Id, quantity, portionName);
                if (order != null) order.Tag = tag;
                order.PublishEvent(EventTopicNames.OrderAdded);
            }
        }
예제 #47
0
 private static IList<Order> GetOrders(ActionData x, Ticket ticket)
 {
     IList<Order> orders = new List<Order>();
     var selectedOrder = x.GetDataValue<Order>("Order");
     if (selectedOrder == null)
     {
         if (ticket != null)
         {
             orders = ticket.Orders.Any(y => y.IsSelected)
                          ? ticket.ExtractSelectedOrders().ToList()
                          : ticket.Orders;
         }
     }
     else orders.Add(selectedOrder);
     return orders;
 }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var calculationTypeName = actionData.GetAsString("CalculationType");
                var calculationType     = _cacheService.GetCalculationTypeByName(calculationTypeName);
                if (calculationType != null)
                {
                    var amount = actionData.GetAsDecimal("Amount");
                    ticket.AddCalculation(calculationType, amount);
                    _ticketService.RecalculateTicket(ticket);
                    EventServiceFactory.EventService.PublishEvent(EventTopicNames.RegenerateSelectedTicket);
                }
            }
        }
예제 #49
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");
            var pjName = actionData.GetAsString("PrintJobName");

            if (!string.IsNullOrEmpty(pjName))
            {
                var j = _cacheService.GetPrintJobByName(pjName);
                if (j != null)
                {
                    var copies      = actionData.GetAsInteger("Copies");
                    var printTicket = actionData.GetAsBoolean("PrintTicket", true);
                    var priority    = actionData.GetAsBoolean("HighPriority");
                    if (ticket != null && printTicket)
                    {
                        var orderTagName    = actionData.GetAsString("OrderTagName");
                        var orderTagValue   = actionData.GetAsString("OrderTagValue");
                        var orderStateName  = actionData.GetAsString("OrderStateName");
                        var orderState      = actionData.GetAsString("OrderState");
                        var orderStateValue = actionData.GetAsString("OrderStateValue");

                        Expression <Func <Order, bool> > expression = ex => true;
                        if (!string.IsNullOrWhiteSpace(orderTagName))
                        {
                            expression =
                                ex => ex.OrderTagExists(y => y.TagName == orderTagName && y.TagValue == orderTagValue);
                        }
                        if (!string.IsNullOrWhiteSpace(orderStateName))
                        {
                            expression = expression.And(ex => ex.IsInState(orderStateName, orderState));
                            if (!string.IsNullOrWhiteSpace(orderStateValue))
                            {
                                expression = expression.And(ex => ex.IsAnyStateValue(orderStateValue));
                            }
                        }
                        _ticketService.UpdateTicketNumber(ticket, _applicationState.CurrentTicketType.TicketNumerator);
                        ExecuteByCopies(copies, () => _printerService.PrintTicket(ticket, j, expression.Compile(), priority));
                    }
                    else
                    {
                        ExecuteByCopies(copies, () => _printerService.ExecutePrintJob(j, priority));
                    }
                }
            }
        }
예제 #50
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var menuItemName = actionData.GetAsString("MenuItemName");
                var menuItem     = _cacheService.GetMenuItem(y => y.Name == menuItemName);
                var portionName  = actionData.GetAsString("PortionName");
                var quantity     = actionData.GetAsDecimal("Quantity");
                var tag          = actionData.GetAsString("Tag");
                var order        = _ticketService.AddOrder(ticket, menuItem.Id, quantity, portionName);
                if (order != null)
                {
                    order.Tag = tag;
                }
                order.PublishEvent(EventTopicNames.OrderAdded);
            }
        }
예제 #51
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue<Ticket>("Ticket");
            var pjName = actionData.GetAsString("PrintJobName");
            if (!string.IsNullOrEmpty(pjName))
            {
                var j = _cacheService.GetPrintJobByName(pjName);
                if (j != null)
                {
                    var copies = actionData.GetAsInteger("Copies");
                    var printTicket = actionData.GetAsBoolean("PrintTicket", true);
                    var priority = actionData.GetAsBoolean("HighPriority");
                    if (ticket != null && printTicket)
                    {
                        var orderTagName = actionData.GetAsString("OrderTagName");
                        var orderTagValue = actionData.GetAsString("OrderTagValue");
                        var orderStateName = actionData.GetAsString("OrderStateName");
                        var orderState = actionData.GetAsString("OrderState");
                        var orderStateValue = actionData.GetAsString("OrderStateValue");

                        Expression<Func<Order, bool>> expression = ex => true;
                        if (!string.IsNullOrWhiteSpace(orderTagName))
                        {
                            expression =
                                ex => ex.OrderTagExists(y => y.TagName == orderTagName && y.TagValue == orderTagValue);
                        }
                        if (!string.IsNullOrWhiteSpace(orderStateName))
                        {
                            expression = expression.And(ex => ex.IsInState(orderStateName, orderState));
                            if (!string.IsNullOrWhiteSpace(orderStateValue))
                                expression = expression.And(ex => ex.IsAnyStateValue(orderStateValue));
                        }
                        _ticketService.UpdateTicketNumber(ticket, _applicationState.CurrentTicketType.TicketNumerator);
                        ExecuteByCopies(copies, () => _printerService.PrintTicket(ticket, j, expression.Compile(), priority));
                    }
                    else
                    {
                        ExecuteByCopies(copies, () => _printerService.ExecutePrintJob(j, priority));
                    }
                }
            }
        }
예제 #52
0
        private static IList <Order> GetOrders(ActionData x, Ticket ticket)
        {
            IList <Order> orders        = new List <Order>();
            var           selectedOrder = x.GetDataValue <Order>("Order");

            if (selectedOrder == null)
            {
                if (ticket != null)
                {
                    orders = ticket.Orders.Any(y => y.IsSelected)
                                 ? ticket.ExtractSelectedOrders().ToList()
                                 : ticket.Orders;
                }
            }
            else
            {
                orders.Add(selectedOrder);
            }
            return(orders);
        }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");
            var orders = Helper.GetOrders(actionData, ticket);

            if (orders.Any())
            {
                var tagName  = actionData.GetAsString("OrderTagName");
                var orderTag = _cacheService.GetOrderTagGroupByName(tagName);

                if (orderTag != null)
                {
                    var tagValue      = actionData.GetAsString("OrderTagValue");
                    var oldTagValue   = actionData.GetAsString("OldOrderTagValue");
                    var tagNote       = actionData.GetAsString("OrderTagNote");
                    var orderTagValue = orderTag.OrderTags.SingleOrDefault(y => y.Name == tagValue);

                    if (orderTagValue != null)
                    {
                        if (!string.IsNullOrEmpty(actionData.GetAsString("OrderTagPrice")))
                        {
                            var price = actionData.GetAsDecimal("OrderTagPrice");
                            orderTagValue.Price = price;
                        }

                        if (!string.IsNullOrEmpty(oldTagValue))
                        {
                            orders = orders.Where(o => o.OrderTagExists(y => y.OrderTagGroupId == orderTag.Id && y.TagValue == oldTagValue)).ToList();
                        }
                        if (actionData.Action.ActionType == ActionNames.TagOrder)
                        {
                            _ticketService.TagOrders(ticket, orders, orderTag, orderTagValue, tagNote);
                        }
                        if (actionData.Action.ActionType == ActionNames.UntagOrder)
                        {
                            _ticketService.UntagOrders(ticket, orders, orderTag, orderTagValue);
                        }
                    }
                }
            }
        }
예제 #54
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null)
     {
         var amount = actionData.GetAsDecimal("Amount");
         var transactionName = actionData.GetAsString("AccountTransactionTypeName");
         if (!string.IsNullOrEmpty(transactionName))
         {
             var accountTransactionType = _cacheService.GetAccountTransactionTypeByName(transactionName);
             if (accountTransactionType != null)
             {
                 var ts = ticket.TicketEntities.FirstOrDefault(x => _ticketService.CanMakeAccountTransaction(x, accountTransactionType, 0));
                 if (ts != null)
                 {
                     ticket.TransactionDocument.AddNewTransaction(accountTransactionType, ticket.GetTicketAccounts(), amount, 1);
                 }
             }
         }
     }
 }
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var amount          = actionData.GetAsDecimal("Amount");
                var transactionName = actionData.GetAsString("AccountTransactionTypeName");
                if (!string.IsNullOrEmpty(transactionName))
                {
                    var accountTransactionType = _cacheService.GetAccountTransactionTypeByName(transactionName);
                    if (accountTransactionType != null)
                    {
                        var ts = ticket.TicketEntities.FirstOrDefault(x => _ticketService.CanMakeAccountTransaction(x, accountTransactionType, 0));
                        if (ts != null)
                        {
                            ticket.TransactionDocument.AddNewTransaction(accountTransactionType, ticket.GetTicketAccounts(), amount, 1);
                        }
                    }
                }
            }
        }
예제 #56
0
        public override void Process(ActionData actionData)
        {
            var ticket = actionData.GetDataValue <Ticket>("Ticket");

            if (ticket != null)
            {
                var menuItemName   = actionData.GetAsString("MenuItemName");
                var menuItem       = _cacheService.GetMenuItem(y => y.Name == menuItemName);
                var portionName    = actionData.GetAsString("PortionName");
                var quantity       = actionData.GetAsDecimal("Quantity");
                var tag            = actionData.GetAsString("Tag");
                var orderStateName = actionData.GetAsString("OrderStateName");
                var orderState     = actionData.GetAsString("OrderState");
                var osv            = orderState.Contains("=") ? orderState : orderStateName + "=" + orderState;
                var order          = _ticketService.AddOrder(ticket, menuItem.Id, quantity, portionName, osv);
                if (order != null)
                {
                    order.Tag = tag;
                }
                actionData.DataObject.Order = order;
                order.PublishEvent(EventTopicNames.OrderAdded);
            }
        }
예제 #57
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null) ticket.UnLock();
     EventServiceFactory.EventService.PublishEvent(EventTopicNames.UnlockTicketRequested);
 }
예제 #58
0
 public override void Process(ActionData actionData)
 {
     var ticket = actionData.GetDataValue<Ticket>("Ticket");
     if (ticket != null) ticket.Close();
 }