Exemplo n.º 1
0
        private async Task ExecuteRefreshOrders()
        {
            try
            {
                int?erpid   = SelectedOrder?.ERPID;
                int?orderid = SelectedOrder?.OrderID;
                _suborderid = SelectedSubOrder?.ID;
                _commandid  = SelectedCommand?.WMSID;

                var orders = await _dbservicewms.GetOrdersWithCount(DateTime.Now.AddDays(-1), DateTime.Now, (int)EnumWMSOrderStatus.OnTargetPart, null, null);

                DataListOrder.Clear();
                foreach (var p in orders)
                {
                    DataListOrder.Add(new ReleaseOrderViewModel
                    {
                        ERPID       = p.ERPID,
                        ERPIDref    = p.ERPIDStokbar,
                        OrderID     = p.OrderID,
                        Destination = p.Destination,
                        ReleaseTime = p.ReleaseTime,
                        LastChange  = p.LastChange,
                        Portion     = $"{p.CountAll - p.CountActive - p.CountMoveDone - p.CountFinished}+{p.CountActive}+{p.CountMoveDone}+{p.CountFinished}={p.CountAll}",
                        Status      = (EnumWMSOrderStatus)p.Status
                    });
                }
                foreach (var l in DataListOrder)
                {
                    l.Initialize(_warehouse);
                }
                if (orderid != null)
                {
                    SelectedOrder = DataListOrder.FirstOrDefault(p => p.ERPID == erpid && p.OrderID == orderid);
                }
            }
            catch (Exception e)
            {
                _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception,
                                    string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }