public async Task <IActionResult> Post([FromBody] ActionsViewModel actions) { if (ModelState.IsValid) { try { Actions _actions = Mapper.Map <Actions>(actions); //_actions.Name = _actions.Name.ToUpper(); _actions.ProcessId = actions.ProcessId; _actions.Process = _unitOfWork.Process.GetSingleOrDefault(e => e.Id == actions.ProcessId); _unitOfWork.Actions.Add(_actions); await _unitOfWork.SaveChangesAsync(); return(Ok("OK")); } catch (Exception ex) { return(BadRequest(ex.Data)); } } else { return(BadRequest(ModelState)); } }
public PartialViewResult GetActionsView(long uri, bool vertical) { var hvm = new ActionsViewModel(); if (AppUserState == null || AppUserState.Connected == false) { return(null); } var conn = new InforConnection(tu: _tu, tup: _tup); var rec = (InforRecord)conn.GetRecordWeb(uri, AppUserState.UserName, AppUserState.Wgs, AppUserState.Ds); hvm.Actions = ActionService.GetActions(AppUserState.Wgs, AppUserState.Ds, AppUserState.UserName, uri); hvm.RecordNumber = rec.RecordNumber; var firstOrDefault = hvm.Actions.FirstOrDefault(ac => ac.Status == InforActionStatus.Current); if (firstOrDefault != null) { hvm.CurrentActionUri = firstOrDefault.Uri; } hvm.RecordUri = rec.Uri; hvm.Title = rec.Title; hvm.VerticalView = vertical; hvm.CanAddActions = rec.CanAddActions; return(PartialView("_Actions", hvm)); }
private void InitializeViews() { BasesViewModel = new BasesViewModel(db); BasesView = new BasesView { DataContext = BasesViewModel }; PlatformViewModel = new PlatformViewModel(db); PlatformView = new PlatformView { DataContext = PlatformViewModel }; ActionsViewModel = new ActionsViewModel(db); ActionsView = new ActionsView { DataContext = ActionsViewModel }; DistributionViewModel = new DistributionViewModel(db); DistributionView = new DistributionView { DataContext = DistributionViewModel }; HomeViewModel = new HomeViewModel(db); HomeView = new HomeView { DataContext = HomeViewModel }; TelegramViewModel = new TelegramViewModel(db); TelegramView = new TelegramView { DataContext = TelegramViewModel }; }
/// <summary> /// Initializes a new instance of the <see cref="SendToWindowActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allActionDescriptions">All action descriptions.</param> public SendToWindowActionViewModel([NotNull] SendToWindowAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allActionDescriptions) : base(action, actionDescriptor, allActionDescriptions) { _action = action; _allDescriptors = allActionDescriptions; _actionsToExecute = new ActionsViewModel(action.ActionsToExecute, allActionDescriptions); _actionsToExecute.PropertyChanged += HandleActionDescriptionChange; }
public RoomViewModel Clone() { var additionalRoomParameters = AdditionalRoomParameters.Clone(); return(new RoomViewModel(Room, additionalRoomParameters, Exits, Zone, _allActionDescriptions) { _actionsViewModel = ActionsViewModel.Clone(additionalRoomParameters.ActionsToExecuteOnRoomEntry) }); }
/// <summary> /// /// </summary> /// <param name="hotkey"></param> /// <param name="actionDescriptions"></param> public GlobalHotkeyViewModel([NotNull] Hotkey hotkey, [NotNull] IEnumerable <ActionDescription> actionDescriptions) { Assert.ArgumentNotNull(hotkey, "hotkey"); Assert.ArgumentNotNull(actionDescriptions, "actionDescriptions"); _actionDescriptions = actionDescriptions; Hotkey = hotkey; ActionsViewModel = new ActionsViewModel(hotkey.Actions, _actionDescriptions); }
public WindowOverTrayHelper(Window window, ActionsViewModel vm) { this.window = window; this.viewModel = vm; // Общие события this.window.Closing += window_Closing; this.window.IsVisibleChanged += window_IsVisibleChanged; }
public AliasViewModel Clone() { var clonedAlias = new CommandAlias(); return(new AliasViewModel(AllGroups, AliasGroup, clonedAlias, _actionDescriptions) { ActionsViewModel = ActionsViewModel.Clone(clonedAlias.Actions), Command = Command }); }
protected virtual void InitViewModels() { ActionsViewModel = new ActionsViewModel(BaseLayer, ActionErrorCatcher); ActionViewModel = new ActionViewModel(CreateActionTemplate(), ActionsViewModel, ActionErrorCatcher); EventsViewModel = new EventsViewModel(BaseLayer, EventErrorCatcher); EventViewModel = new EventViewModel(CreateEventTemplate(), EventsViewModel, EventErrorCatcher); TaskParamsViewModel = new TaskParamsViewModel(BaseLayer, TaskParamErrorCatcher); EventsDepActionsViewModel = new EventsDepActionsViewModel(BaseLayer, EventErrorCatcher); EventDepActionViewModel = new EventDepActionViewModel(BaseLayer, CreateEventTemplate(), EventsDepActionsViewModel, EventErrorCatcher); }
public HotkeyViewModel Clone() { var clonedHotkey = new Hotkey(); return(new HotkeyViewModel(AllGroups, HotkeyGroup, clonedHotkey, _actionDescriptions) { Key = Key, ModifierKeys = ModifierKeys, ActionsViewModel = ActionsViewModel.Clone(clonedHotkey.Actions) }); }
/// <summary> /// Updates the specified room view model. /// </summary> /// <param name="roomViewModel">The room view model.</param> public void Update([NotNull] RoomViewModel roomViewModel) { Assert.ArgumentNotNull(roomViewModel, "roomViewModel"); _actionsViewModel = null; AdditionalRoomParameters = roomViewModel.AdditionalRoomParameters; AdditionalRoomParameters.HasChanges = true; OnPropertyChanged("Icon"); OnPropertyChanged("Color"); OnPropertyChanged("Alias"); OnPropertyChanged("Comments"); }
/// <summary> /// Initializes a new instance of the <see cref="AliasViewModel"/> class. /// </summary> /// <param name="allGroups">All groups.</param> /// <param name="aliasGroup">The alias group.</param> /// <param name="commandAlias">The alias.</param> /// <param name="actionDescriptions">The action descriptions.</param> public AliasViewModel([NotNull] IEnumerable <GroupViewModel> allGroups, [NotNull] GroupViewModel aliasGroup, [NotNull] CommandAlias commandAlias, [NotNull] IEnumerable <ActionDescription> actionDescriptions) { Assert.ArgumentNotNull(allGroups, "allGroups"); Assert.ArgumentNotNull(aliasGroup, "aliasGroup"); Assert.ArgumentNotNull(commandAlias, "commandAlias"); Assert.ArgumentNotNull(actionDescriptions, "actionDescriptions"); _aliasGroup = aliasGroup; _actionDescriptions = actionDescriptions; CommandAlias = commandAlias; AllGroups = allGroups; ActionsViewModel = new ActionsViewModel(commandAlias.Actions, actionDescriptions); }
/// <summary> /// Initializes a new instance of the <see cref="TriggerViewModel"/> class. /// </summary> /// <param name="allGroups">All groups.</param> /// <param name="triggersGroup">The triggers group.</param> /// <param name="trigger">The trigger.</param> /// <param name="actionDescriptions">The action descriptions.</param> public TriggerViewModel([NotNull] IEnumerable <GroupViewModel> allGroups, [NotNull] GroupViewModel triggersGroup, [NotNull] TextTrigger trigger, [NotNull] IEnumerable <ActionDescription> actionDescriptions) { Assert.ArgumentNotNull(allGroups, "allGroups"); Assert.ArgumentNotNull(triggersGroup, "triggersGroup"); Assert.ArgumentNotNull(trigger, "trigger"); Assert.ArgumentNotNull(actionDescriptions, "actionDescriptions"); AllGroups = allGroups; _triggersGroup = triggersGroup; _actionDescriptions = actionDescriptions; Trigger = trigger; ActionsViewModel = new ActionsViewModel(trigger.Actions, _actionDescriptions); }
/// <summary> /// Initializes a new instance of the <see cref="HotkeyViewModel"/> class. /// </summary> /// <param name="allGroups">All groups.</param> /// <param name="hotkeyGroup">The hot key group.</param> /// <param name="hotkey">The hotkey.</param> /// <param name="actionDescriptions">The action descriptions.</param> public HotkeyViewModel([NotNull] IEnumerable <GroupViewModel> allGroups, [NotNull] GroupViewModel hotkeyGroup, [NotNull] Hotkey hotkey, [NotNull] IEnumerable <ActionDescription> actionDescriptions) { Assert.ArgumentNotNull(allGroups, "allGroups"); Assert.ArgumentNotNull(hotkeyGroup, "hotkeyGroup"); Assert.ArgumentNotNull(hotkey, "hotkey"); Assert.ArgumentNotNull(actionDescriptions, "actionDescriptions"); AllGroups = allGroups; _hotkeyGroup = hotkeyGroup; _actionDescriptions = actionDescriptions; Hotkey = hotkey; ActionsViewModel = new ActionsViewModel(hotkey.Actions, _actionDescriptions); }
public GlobalHotkeyViewModel Clone() { var clonedHotkey = new Hotkey() { Key = Key, ModifierKeys = ModifierKeys }; return(new GlobalHotkeyViewModel(clonedHotkey, _actionDescriptions) { Key = Key, ModifierKeys = ModifierKeys, ActionsViewModel = ActionsViewModel.Clone(clonedHotkey.Actions) }); }
public PopupWindow(ActionsViewModel vm) { InitializeComponent(); this.viewModel = vm; this.uiHelper = new WindowOverTrayHelper(this, viewModel); this.DataContext = viewModel; this.viewModel.NewActionRetreived += viewModel_NewActionRetreived; this.hideTimer = new DispatcherTimer(DispatcherPriority.ContextIdle); hideTimer.Interval = TimeSpan.FromSeconds(ShowTimeoutSeconds); hideTimer.Tick += hideTimer_Tick; this.chimePlayer = new SoundPlayer(AppResources.chime); }
/// <summary> /// Initializes a new instance of the <see cref="ConditionalActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allDescriptors">All descriptors.</param> /// <param name="parameterDescriptions">The parameter descriptions.</param> public ConditionalActionViewModel([NotNull] ConditionalAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allDescriptors, [NotNull] IEnumerable <ParameterDescription> parameterDescriptions) : base(action, actionDescriptor, allDescriptors) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(actionDescriptor, "actionDescriptor"); Assert.ArgumentNotNull(allDescriptors, "allDescriptors"); Assert.ArgumentNotNull(parameterDescriptions, "parameterDescriptions"); _action = action; _allDescriptors = allDescriptors; ParameterDescriptions = parameterDescriptions; _leftConditionParameter = ActionParametersViewModel.CreateParameterViewModel(_action.LeftConditionParameter, parameterDescriptions); _leftConditionParameter.PropertyChanged += HandleParameterOrActionDescriptionChange; _rightConditionParameter = ActionParametersViewModel.CreateParameterViewModel(_action.RightConditionParameter, parameterDescriptions); _rightConditionParameter.PropertyChanged += HandleParameterOrActionDescriptionChange; _actionsToExecute = new ActionsViewModel(action.ActionsToExecute, allDescriptors); _actionsToExecute.PropertyChanged += HandleParameterOrActionDescriptionChange; }
public async Task WorksCorrectly() { const string actionDisplayName = "Test action display name"; var actionsVM = new ActionsViewModel(); var actionMock = new Mock <IReversibleAction>(); actionMock.Setup(a => a.Act()).Verifiable(); actionMock.Setup(a => a.Revert()).Verifiable(); actionMock.SetupGet(a => a.DisplayName).Returns(actionDisplayName); await actionsVM.Execute.Execute(actionMock.Object); Assert.Equal(actionDisplayName, actionsVM.LastDone); await actionsVM.Undo.Execute(); await Task.Delay(1); // without this the variables do not get updated for some reason. Assert.Equal(actionDisplayName, actionsVM.LastUndone); Assert.NotEqual(actionDisplayName, actionsVM.LastDone); await actionsVM.Redo.Execute(); await Task.Delay(1); // without this the variables do not get updated for some reason. Assert.Equal(actionDisplayName, actionsVM.LastDone); Assert.NotEqual(actionDisplayName, actionsVM.LastUndone); actionMock.Verify(a => a.Act(), Times.Exactly(2)); actionMock.Verify(a => a.Revert(), Times.Once); // make sure clearing works await actionsVM.Clear.Execute(); Assert.Null(actionsVM.LastDone); Assert.Null(actionsVM.LastUndone); }
/// <summary> /// Запустить функциональность проверки недавних действий /// </summary> public void StartActivity() { this.viewModel = new ActionsViewModel(); this.uiHelper = new WindowOverTrayHelper(this, viewModel); this.DataContext = viewModel; this.popupNotifyWindow = new PopupWindow(viewModel); SetupNotifyIcon(); if (SettingsStore.Instance.IsCleanRun) { ShowNotifyBaloon(); } // Таймер проверки новых действий checkTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle); checkTimer.Interval = TimeSpan.FromSeconds(CheckIntervalSeconds); checkTimer.Tick += checkTimer_Tick; checkTimer.Start(); // Проверить сразу же checkTimer_Tick(this, EventArgs.Empty); }
public ActionsView(ActionsViewModel model) { InitializeComponent(); DataContext = model; }
private void OnActionsCommandExecute() { CurrentManagerPage = new ActionsViewModel(); }
public ActionsListBoxSample() { InitializeComponent(); DataContext = new ActionsViewModel(); }
public void Initialize() { _model = ContainerHelper.Container.Resolve <ActionsViewModel>(); }
public ActionsView() { InitializeComponent(); DataContext = new ActionsViewModel(); }