private async Task ExecuteRefreshCommand()
        {
            try
            {
                SimpleCommandViewModel sc = SelectedContent;
                var scmds = await _warehouse.DBService.GetSimpleCommands(null, SimpleCommand.EnumStatus.Finished, DateFrom.TimeStamp, DateTo.TimeStamp);

                SimpleCommandList.Clear();
                foreach (var s in scmds)
                {
                    if (s is SimpleCraneCommand)
                    {
                        SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandCraneViewModel {
                            Command = s
                        });
                    }
                    else if (s is SimpleSegmentCommand)
                    {
                        SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandSegmentViewModel {
                            Command = s
                        });
                    }
                    else
                    {
                        SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandConveyorViewModel {
                            Command = s
                        });
                    }
                }

                foreach (SimpleCommandViewModel scvm in SimpleCommandList)
                {
                    scvm.Initialize(_warehouse);
                }
                Records = SimpleCommandList.Count();
                if (sc != null)
                {
                    SelectedContent = SimpleCommandList.FirstOrDefault(p => p.ID == sc.ID);
                }
            }
            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));
            }
        }
예제 #2
0
        public async Task ExecuteRefreshSimpleCommands(IList items)
        {
            try
            {
                NumberOfSelectedItems = items == null ? 0 : items.Count;

                SimpleCommandList.Clear();
                if (SelectedContent != null)
                {
                    List <SimpleCommand> l = await _warehouse.DBService.GetSimpleCommands(SelectedContent.Command.ID, SimpleCommand.EnumStatus.Finished, null, null);

                    foreach (var cmd in l)
                    {
                        if (cmd is SimpleCraneCommand)
                        {
                            SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandCraneViewModel {
                                Command = cmd
                            });
                        }
                        else if (cmd is SimpleSegmentCommand)
                        {
                            SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandSegmentViewModel {
                                Command = cmd
                            });
                        }
                        else
                        {
                            SimpleCommandList.Add((SimpleCommandViewModel) new SimpleCommandConveyorViewModel {
                                Command = cmd
                            });
                        }
                    }
                }
            }
            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));
            }
        }
예제 #3
0
        private void ExecuteConfirm()
        {
            SimpleCommand cmd;

            try
            {
                IsEnabledField = false;
                IsEnabledCC    = false;
                switch (_selectedCommand)
                {
                case CommandType.Add:
                    // execute cmd based on DetailedContent
                    DetailedContent.Time = DateTime.Now;
                    cmd = DetailedContent.Command;
                    if (cmd.Material == 0)
                    {
                        cmd.Material = null;
                    }
                    if (cmd.Material != null)
                    {
                        _warehouse.DBService.FindMaterialID((int)cmd.Material, true);
                    }
                    _warehouse.DBService.AddSimpleCommand(cmd);
                    SimpleCommandList.Add(DetailedContent);
                    break;

                case CommandType.Restart:
                    cmd = _warehouse.DBService.FindSimpleCommandByID(DetailedContent.Command.ID);
                    if (cmd != null)
                    {
                        cmd.Status = SimpleCommand.EnumStatus.NotActive;
                        cmd.Time   = DateTime.Now;
                        _warehouse.DBService.AddSimpleCommand(cmd);
                    }
                    break;

                case CommandType.Delete:
                    cmd = _warehouse.DBService.FindSimpleCommandByID(DetailedContent.Command.ID);
                    if (cmd != null && cmd.Status == SimpleCommand.EnumStatus.NotActive)
                    {
                        cmd.Status = SimpleCommand.EnumStatus.Canceled;
                        _warehouse.DBService.UpdateSimpleCommand(cmd);
                    }
                    else if (cmd.Status == SimpleCommand.EnumStatus.InPlc ||
                             cmd.Status == SimpleCommand.EnumStatus.Written)
                    {
                        if (cmd is SimpleCraneCommand)
                        {
                            if (cmd.Material == 0)
                            {
                                cmd.Material = null;
                            }
                            _warehouse.DBService.AddSimpleCommand(
                                new SimpleCraneCommand
                            {
                                Material = cmd.Material,
                                Source   = cmd.Source,
                                Task     = SimpleCommand.EnumTask.Cancel,
                                Unit     = (cmd as SimpleCraneCommand).Unit,
                                CancelID = cmd.ID,
                                Status   = SimpleCommand.EnumStatus.NotActive,
                                Time     = DateTime.Now
                            });
                        }
                        else if (cmd is SimpleConveyorCommand)     // in case of hanging comman (inplc, written, you delete of command is forced)
                        {
                            DetailedContent.Status = EnumSimpleCommandStatus.Canceled;
                            cmd        = _warehouse.DBService.FindSimpleCommandByID(DetailedContent.Command.ID);
                            cmd.Status = SimpleCommand.EnumStatus.Canceled;
                            _warehouse.DBService.UpdateSimpleCommand(cmd);
                        }
                    }
                    break;

                default:
                    break;
                }
                DetailedContent.ValidationEnabled = false;
                DetailedContent = SelectedContent;
            }
            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));
            }
        }