示例#1
0
        private async Task ExecuteRefreshCommandWMS()
        {
            try
            {
                if (_commandid == null)
                {
                    _commandid = SelectedCommand?.WMSID;
                }

                var cmds = ActiveOrder != null ? await _dbservicewms.GetCommandsWMSForOrder(ActiveOrder.ERPID, ActiveOrder.OrderID) : null;

                DataListCommand.Clear();
                if (cmds != null)
                {
                    foreach (var cmd in cmds)
                    {
                        DataListCommand.Add(new CommandWMSViewModel
                        {
                            WMSID              = cmd.ID,
                            OrderERPID         = cmd.OrderERPID,
                            OrderID            = cmd.Order_ID,
                            OrderOrderID       = cmd.OrderOrderID,
                            OrderSubOrderID    = cmd.OrderSubOrderID,
                            OrderSubOrderERPID = cmd.OrderSubOrderERPID,
                            OrderSubOrderName  = cmd.OrderSubOrderName,
                            OrderSKUID         = cmd.OrderSKUID,
                            OrderSKUBatch      = cmd.OrderSKUBatch,
                            Source             = cmd.Source,
                            Target             = cmd.Target,
                            TUID      = cmd.TU_ID,
                            BoxID     = cmd.Box_ID,
                            Operation = (EnumOrderOperation)cmd.Operation,
                            Time      = cmd.Time,
                            Status    = (EnumCommandWMSStatus)cmd.Status,
                        });
                    }
                    foreach (var l in DataListCommand)
                    {
                        l.Initialize(_warehouse);
                    }

                    var cmdsDrop = cmds
                                   .Where(p => p.Status == (int)EnumCommandWMSStatus.Active && p.Operation == (int)EnumOrderOperation.DropBox)
                                   .Select(p => p)
                                   .ToList();
                    var cmdsPick = cmds
                                   .Where(p => p.Status == (int)EnumCommandWMSStatus.Active && p.Operation == (int)EnumOrderOperation.PickBox)
                                   .Select(p => p)
                                   .ToList();
                    if (cmdsDrop.Count > 0 && Operation == null)
                    {
                        Operation = new StationActionViewModel();
                        (Operation as StationActionViewModel).Initialize(_warehouse, cmdsDrop);
                        (Operation as StationActionViewModel).Command = StationActionViewModel.CommandType.DropBox;
                        VisibleOperation = true;
                        EnabledCC        = true;
                        EditEnabled      = true;
                    }
                    if (cmdsPick.Count > 0 && Operation == null)
                    {
                        Operation = new StationActionViewModel();
                        (Operation as StationActionViewModel).Initialize(_warehouse, cmdsPick);
                        (Operation as StationActionViewModel).Command = StationActionViewModel.CommandType.PickBox;
                        VisibleOperation = true;
                        EnabledCC        = true;
                        EditEnabled      = true;
                    }
                    else if (cmdsDrop.Count == 0 && cmdsPick.Count == 0 && Operation is StationActionViewModel)
                    {
                        Operation        = null;
                        VisibleOperation = false;
                        EnabledCC        = false;
                        EditEnabled      = false;
                    }
                }
            }
            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));
            }
        }