protected virtual void OnPosCheckChanged(PosCheck posCheck)
        {
            var handler = PosOrderChanged;

            if (handler != null)
            {
                handler(posCheck);
            }
        }
        private void OnSendPosError(string msgError, PosCheck posCheck)
        {
            MessageBox.Show(@"Error pos: " + msgError);

            if (_iTries++ > MAX_TRIES)
            {
                return;
            }
            SendPosCheckInfo(posCheck);
        }
        private void SendPosCheckInfo(PosCheck posCheck)
        {
            if (posCheck == null)
            {
                return;
            }

            Client.ExecutionProxy.ExecuteRequest <PosCheck, PosCheck, ResponseMessageData <bool>, ResponseMessageData <bool> >
                (posCheck, TransferDto.SameType, SharedConstants.Server.POS_RECEIVER_HUB, SharedConstants.Server.ORDER_POS_RECEIVER_HUB_METHOD, TransferDto.SameType)
            .Subscribe(x => OnSendPosOk(x, posCheck), x => OnSendPosError(x, posCheck));
        }
Exemplo n.º 4
0
        public long?SavePosCheck(PosCheck model)
        {
            var entity = new PosOrder
            {
                CheckId       = model.CheckId,
                FranchiseCode = model.FranchiseCode,
                GuidId        = model.GuidId,
                OrderDatetime = DateTime.Now,
                Subtotal      = (Decimal)model.SubTotal,
                Taxes         = (Decimal)model.Tax,
                Total         = (Decimal)model.Total,
                UserId        = AccountRepository.GetIdByUsername(model.Username, DbEntities),
            };

            DbEntities.PosOrder.Add(entity);
            DbEntities.SaveChanges();

            foreach (var itemModel in model.LstItems)
            {
                var item = new PosOrderItem
                {
                    CheckItemId = itemModel.CheckItemId,
                    ItemId      = itemModel.ItemId,
                    Name        = itemModel.RealName,
                    Price       = (Decimal)itemModel.Price,
                    LevelItem   = (int)itemModel.Level,
                    ParentId    = itemModel.Parent != null ? itemModel.Parent.CheckItemId : (long?)null,
                    PosOrderId  = entity.PosOrderId
                };

                DbEntities.PosOrderItem.Add(item);
                DbEntities.SaveChanges();
                itemModel.CheckItemId = item.PosOrderItemId;
            }

            if (model.Promos != null && model.Promos.Any())
            {
                var lstPromos = model.Promos.Values.Select(promo => new PosOrderPromo
                {
                    PosOrderId         = entity.PosOrderId,
                    EntriesIdsSelected = JsonConvert.SerializeObject(promo.LstEntries),
                    PromoEntryId       = promo.PromoEntryId,
                    PromoTypeId        = promo.PromoTypeId
                }).ToList();

                DbEntities.PosOrderPromo.AddRange(lstPromos);
                DbEntities.SaveChanges();
            }


            model.Id = entity.PosOrderId;
            DbEntities.Entry(entity).State = EntityState.Detached;
            return(model.Id);
        }
Exemplo n.º 5
0
 public ResponseMessageData <PosCheck> SavePosCheck(PosCheck model)
 {
     try
     {
         return(AppInit.Container.Resolve <IOrderService>().SavePosCheck(model));
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <PosCheck> .CreateCriticalMessage("No fue posible almacenar la orden del POS"));
     }
 }
        private void OnSendPosOk(IStale <ResponseMessageData <bool> > obj, PosCheck posCheck)
        {
            if (obj.IsStale)
            {
                OnSendPosError("Error de red", posCheck);
                return;
            }

            if (obj.Data.IsSuccess == false)
            {
                OnSendPosError(obj.Data.Message, posCheck);
            }
        }
        public void OnPosOrderChanged(PosCheck posCheck)
        {
            var checkInfo  = String.Empty;
            var checkTotal = String.Empty;

            if (posCheck.Status == SharedConstants.Client.RECORD_SAVED)
            {
                checkInfo  = String.Format("ID Orden POS: {0}", posCheck.CheckId);
                checkTotal = String.Format("Total: {0}", posCheck.TotalTx);
            }

            OnItemChanged(PosCheckView, posCheck.Status, checkInfo, posCheck.Message, checkTotal);
        }
        public ResponseMessageData <bool> SendOrder(PosCheck posCheck)
        {
            try
            {
                MessageBus.Current.SendMessage(posCheck, SharedMessageConstants.ORDER_SEND_POSORDER);

                return(new ResponseMessageData <bool>
                {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(ResponseMessageData <bool> .CreateCriticalMessage("No fue posible enviar la orden al POS"));
            }
        }
        public ResponseMessageData <PosCheck> SavePosCheck(PosCheck model)
        {
            using (_repository)
            {
                using (var transaction = _repository.Db.Database.BeginTransaction(IsolationLevel.Snapshot))
                {
                    model.Id = _repository.SavePosCheck(model);
                    transaction.Commit();
                }

                return(new ResponseMessageData <PosCheck>
                {
                    Data = model,
                    IsSuccess = true,
                    Message = String.Empty
                });
            }
        }
        private void GetPromosIfAny(IIberObject chkObject, PosCheck posCheck)
        {
            try
            {
                var dicPromos = new Dictionary <long, PromoModel>();
                foreach (IIberObject objInternal in chkObject.GetEnum(INTERNAL_CHECKS_PROMOS))
                {
                    var promoModel = new PromoModel {
                        PromoEntryId = objInternal.GetLongVal("ID"), PromoTypeId = objInternal.GetLongVal("PROMOTION_ID")
                    };

                    var lstEntries = (from IIberObject objElement in objInternal.GetEnum(INTERNAL_PROMOS_ITEMS) select objElement.GetLongVal("ID")).ToList();

                    promoModel.LstEntries = lstEntries;
                    dicPromos.Add(promoModel.PromoEntryId, promoModel);
                }
                posCheck.Promos = dicPromos;
            }
            catch
            {
                //return null;
            }
        }
Exemplo n.º 11
0
        public void OnPosOrderChanged(PosCheck posCheck)
        {
            PosCheck = posCheck;

            if (_currentFranchiseCode == OrderService.OrderModel.Franchise.Code)
            {
                return;
            }

            _currentFranchiseCode = OrderService.OrderModel.Franchise.Code;

            List <ItemCatalog> lstCatalogs;

            CatalogsClientModel.DicFranchiseStore.TryGetValue(_currentFranchiseCode, out lstCatalogs);

            RxApp.MainThreadScheduler.Schedule(_ =>
            {
                LstStores.ClearAndAddRange(lstCatalogs);
                if (OrderService.OrderModel.StoreModel != null && OrderService.OrderModel.StoreModel.IdKey.HasValue)
                {
                    PickUpStore = LstStores.FirstOrDefault(e => e.Id == OrderService.OrderModel.StoreModel.IdKey.Value);
                }
            });
        }
        private void GetInternalItems(int iCheckId)
        {
            var pDepot = new IberDepot();

            try
            {
                _iTries = 0;
                var posCheck   = new PosCheck();
                var lstItems   = new List <ItemModel>();
                var dictLevels = new Dictionary <int, ItemModel>();



                foreach (IIberObject chkObject in pDepot.FindObjectFromId(INTERNAL_CHECKS, iCheckId))
                {
                    GetPromosIfAny(chkObject, posCheck);

                    foreach (IIberObject objItem in chkObject.GetEnum(INTERNAL_CHECKS_ENTRIES))
                    {
                        var modCode = objItem.GetLongVal("MOD_CODE");
                        if (modCode == 8)
                        {
                            continue;               //ITEM DELETED
                        }
                        var idItem = objItem.GetLongVal("DATA");
                        if (idItem <= 0)
                        {
                            continue;
                        }

                        //var type = objItem.GetStringVal("TYPE");
                        //var mode = objItem.GetStringVal("MODE");
                        //var routing = objItem.GetStringVal("ROUTING");
                        //var menu = objItem.GetStringVal("MENU");
                        var origin = objItem.GetLongVal("ORIGIN");

                        var idCheckItem = objItem.GetLongVal("ID");
                        var itemName    = objItem.GetStringVal("DISP_NAME");
                        var price       = objItem.GetDoubleVal("PRICE");
                        var level       = objItem.GetLongVal("LEVEL");
                        var item        = new ItemModel {
                            ItemId  = idItem, CheckItemId = idCheckItem, Name = itemName, IsIdSpecified = true, Price = price, Level = level,
                            ModCode = modCode, Origin = origin
                        };

                        //Console.WriteLine(type + mode + origin + routing + menu);

                        dictLevels[level] = item;

                        if (level > 0)
                        {
                            item.Parent = dictLevels[level - 1];
                        }

                        lstItems.Add(item);
                    }

                    posCheck.CheckId = iCheckId;
                    posCheck.GuidId  = Guid.NewGuid();
                    var dValue = chkObject.GetDoubleVal("SUBTOTAL");
                    posCheck.SubTotal = dValue;
                    dValue            = chkObject.GetDoubleVal("TAX");
                    posCheck.Tax      = dValue;
                    dValue            = chkObject.GetDoubleVal("COMPLETETOTAL");
                    posCheck.Total    = dValue;
                    posCheck.LstItems = lstItems;

                    //var strPosCheck = posCheck.Serialize();
                    //Console.WriteLine(strPosCheck);
                    _currentCheck = posCheck;
                    //SendPosCheckInfo(_currentCheck);
                }
            }
            catch //(Exception ex)
            {
                //MessageBox.Show(ex.Message + @" - " + ex.StackTrace);
            }
        }
 public void OpenCheck(int iemployeeId, int iqueueId, int itableId, int icheckId)
 {
     _currentCheck = null;
 }
 private void OnSendPosError(Exception ex, PosCheck posCheck)
 {
     OnSendPosError(ex.Message + " | " + ex.StackTrace + " | " + (ex.InnerException != null ? ex.InnerException.Message : " No inner"), posCheck);
 }
Exemplo n.º 15
0
    private List <GroupDistance> CalcAllDistances()
    {
        List <GroupDistance> distList = new List <GroupDistance>();
        int indexCounter = 0;

        List <Vector3> posList = new List <Vector3>();

        GameObject[] objectArray   = GameObject.FindGameObjectsWithTag(StringManager.Tags.Waypoints);
        int          waypointCount = objectArray.Length;

        for (int i = 0; i < waypointCount; i++)
        {
            posList.Add(objectArray[i].transform.position);
        }

        for (int i = 0; i < waypointCount; i++)
        {
            GameObject[] childs     = objectArray[i].GetComponent <WaypointTreeNode>().getAllWaypoints();
            int          childCount = childs.Length;

            for (int j = 0; j < childCount; j++)
            {
                PosCheck check = checkVector3(objectArray[i].transform.position, childs[j].transform.position);

                GroupDistance element;
                element.m_WaypointFrom = check.a;
                element.m_WaypointTo   = check.b;
                element.m_Index        = indexCounter;
                element.m_Distance     = Mathf.Abs(Vector3.Distance(element.m_WaypointFrom, element.m_WaypointTo));

                if (!distList.Contains(element))
                {
                    distList.Add(element);
                }

                ++indexCounter;     // no need to fullfill auto_increment, unique only
            }
        }

        for (int i = 0; i < waypointCount; i++)
        {
            Vector3 curPosition = objectArray[i].transform.position;
            for (int j = 0; j < waypointCount; j++)
            {
                if (i != j)
                {
                    Vector3 anyNext = objectArray[j].transform.position;

                    PosCheck check = checkVector3(curPosition, anyNext);

                    GroupDistance element;
                    element.m_WaypointFrom = check.a;
                    element.m_WaypointTo   = check.b;
                    element.m_Index        = indexCounter;
                    element.m_Distance     = Mathf.Abs(Vector3.Distance(element.m_WaypointFrom, element.m_WaypointTo));

                    if (!distList.Contains(element))
                    {
                        distList.Add(element);
                    }

                    ++indexCounter;     // no need to fullfill auto_increment, unique only
                }
            }
        }

        objectArray = null;
        return(distList);
    }
 public void ProcessPosOrder(PosCheck posCheck)
 {
     _model.PosCheck = posCheck;
     SavePosOrder();
 }