Exemple #1
0
        public async Task ExecuteRefresh()
        {
            try
            {
                CommandViewModel cmd = SelectedContent;


                var res  = new ObservableCollection <CommandViewModel>();
                var cmds = await _warehouse.DBService.GetCommands(Command.EnumCommandStatus.Active, DateTime.Now.AddMinutes(-30), DateTime.Now);

                CommandList.Clear();
                foreach (var c in cmds)
                {
                    if (c is CommandMaterial)
                    {
                        CommandList.Add((CommandViewModel) new CommandMaterialViewModel {
                            Command = c
                        });
                    }
                    else if (c is CommandSegment)
                    {
                        CommandList.Add((CommandViewModel) new CommandSegmentViewModel {
                            Command = c
                        });
                    }
                    else
                    {
                        CommandList.Add((CommandViewModel) new CommandCommandViewModel {
                            Command = c
                        });
                    }
                }
                foreach (var c in CommandList)
                {
                    c.Initialize(_warehouse);
                }
                if (cmd != null)
                {
                    SelectedContent = CommandList.FirstOrDefault(p => p.ID == cmd.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));
            }
        }
Exemple #2
0
 public void ExecuteAddMat()
 {
     try
     {
         IsEnabledCC      = true;
         IsEnabledField   = true;
         _selectedCommand = CommandType.AddMaterial;
         _manageContent   = new CommandMaterialViewModel {
             Command = new CommandMaterial()
         };
         _manageContent.Initialize(_warehouse);
         DetailedContent = _manageContent;
         DetailedContent.ValidationEnabled = true;
     }
     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));
     }
 }