Пример #1
0
        public async void Execute(IApplicationCommandArguments arguments)
        {
            var args = (ApplicationCommandArguments)arguments;

            // TODO: Execute the OnNew pipeline?
            var sequence = await args
                           .MetadataRepository
                           .LoadAndIncrementSequenceAsync(args.ApplicationSchemaDefinition, "wonum");

            var originator = args.DataMap;
            var followUp   = new DataMap(args.ApplicationSchemaDefinition);

            ConfigureFollowUp(originator, followUp, sequence, args.User, arguments.ApplicationSchemaDefinition);
            ConfigureOriginator(originator, args.User);

            // Save the originator work order with our recent
            // modifications. We can safely bypass the Save
            // method provided by the controller because by
            // design the data is saved before the command
            // execution, so we just need to save our changes.
            await args
            .DataRepository
            .SaveAsync(args.ApplicationSchemaDefinition, originator);

            // And now let's save a data operation
            // to register it and later process it.
            await args
            .DataRepository
            .SaveAsync(CreateDataOperation(args, followUp));

            Alert.Show("Follow-Up", "Here is your new work order. You can now provide the follow-up details.", explicitlyInvokeOnMainThread: true);

            SimpleEventBus.Publish(new DataMapSaved(originator));
            SimpleEventBus.Publish(new DataMapSelected(followUp, true));
        }
Пример #2
0
        public async Task <bool> SaveAsync()
        {
            if (null == _dataMap)
            {
                return(false);
            }

            using (ActivityIndicator.Start(View)) {
                if (false == _compositeController.Commit())
                {
                    ShowSegmentImpl(0);
                    return(false);
                }

                // TODO: should we reload the table view
                // to refresh data potentially changed by
                // the OnBeforeSave pipeline?
                await new DataRepository().SaveAsync(_dataMap);

                // Refresh our form to update validation
                // status, commands availability, ...
                _compositeController.OnSave();

                SimpleEventBus.Publish(new DataMapSaved(_dataMap.Composite));
            }

            return(true);
        }
Пример #3
0
 private void HidePopover()
 {
     if (_isMasterPopoverShown)
     {
         AnimateMasterView(false);
         SimpleEventBus.Publish(new PopoverMenuToggled(false));
     }
 }
Пример #4
0
 private void ShowPopover()
 {
     if (!_isMasterPopoverShown)
     {
         AnimateMasterView(true);
         SimpleEventBus.Publish(new PopoverMenuToggled(true));
     }
 }
Пример #5
0
        /// <summary>
        ///     Invoked when a data map is selected on the screen.
        /// </summary>
        /// <param name="dataMap">The data map just selected.</param>
        private void OnDataMapSelected(DataMap dataMap)
        {
            var searchBar = _searchBar;

            if (null != searchBar)
            {
                searchBar.ResignFirstResponder();
            }

            SimpleEventBus.Publish(new DataMapSelected(dataMap, false));
        }
Пример #6
0
        private async Task SynchronizeAsyncImpl()
        {
            SynchronizationResult result;

            using (ActivityIndicator.Start(View)) {
                result = await new SynchronizationFacade().Synchronize();
                SimpleEventBus.Publish(new DataSynchronized());
            }

            ShowSynchronizationResultMessage(result);
        }
Пример #7
0
        public void MessagePublishAndHandleWithEventHandlerTest()
        {
            var serviceCollection = new ServiceCollection();
            var list = new List <string>();
            var messageHandlerExecutionContext = new ServiceProviderMessageHandlerExecutionContext(serviceCollection);

            serviceCollection.AddSingleton(list);

            var eventBus = new SimpleEventBus(new MessageJsonSerializer(), messageHandlerExecutionContext);

            eventBus.Subscribe <NameChangedEvent, NameChangedEventHandler>();

            eventBus.Publish(new NameChangedEvent("myName"));

            Assert.Single(list);
            Assert.Equal("myName", list[0]);
        }
Пример #8
0
 private void OnNewButtonClick(object sender, EventArgs e)
 {
     new DataRepository()
     .NewAsync(_applicationMetadata)
     .ContinueWith(t => SimpleEventBus.Publish(new DataMapSelected(t.Result, true)));
 }
Пример #9
0
 private void OnTogglePopoverMenu()
 {
     SimpleEventBus.Publish(new PopoverMenuToggleRequested(false));
     NavigationItem.SetLeftBarButtonItems(new UIBarButtonItem[0], true);
 }
Пример #10
0
 private void OnNextClicked(object sender, EventArgs e)
 {
     SimpleEventBus.Publish(new DataMapSelected(_dataMap.Composite.Next, false));
 }