Beispiel #1
0
 public ConsoleView()
 {
     InitializeComponent();
     SimpleEventBus.GetDefaultEventBus().Register(this);
     DataContext = dc;
     Loaded     += MainWindow_Loaded;
 }
Beispiel #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);
        }
Beispiel #3
0
 public void RunCommand()
 {
     ConsoleOutput.Add(ConsoleInput);
     // do your stuff here.
     SimpleEventBus.GetDefaultEventBus().Post(new ConsoleInputEvent(ConsoleInput), TimeSpan.Zero);
     ConsoleInput = String.Empty;
 }
Beispiel #4
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));
        }
Beispiel #5
0
        public WebStationClient()
        {
            eventBus = SimpleEventBus.GetDefaultEventBus();
            eventBus.Register(this);
            foreach (var item in StaticData.AppHostConfig.StationNodes)
            {
                IStationDevice dObj      = null;
                string         className = item.GetType().GetProperty($"{StaticData.AppHostConfig.Environment}Service").GetValue(item).ToString();
                if (Type.GetType(className) == null)
                {
                    string path = $@"{StaticData.AppHostConfig.AppBinPath}\AgvStationClient.dll";

                    var assembly = Assembly.LoadFrom(path);
                    var tpe      = assembly.GetType(className);
                    dObj = Activator.CreateInstance(tpe) as IStationDevice;
                }
                else
                {
                    dObj = Assembly.GetAssembly(Type.GetType(className)).CreateInstance(className) as IStationDevice;
                }

                var proxy = new StationProxyService((AgvStationEnum)Enum.Parse(typeof(AgvStationEnum), item.StationId), dObj);
                dObj.RawIn_Prod          = item.GetType().GetProperty("ProdeuctType").GetValue(item).ToString();
                dObj.RawIn_Mate          = item.GetType().GetProperty("MaterielType").GetValue(item).ToString();
                proxy.SendSingnalrEvent += Proxy_SendSingnalrEvent;
                proxy.SendLogEvent      += Proxy_SendLogEvent;
                stationProxyServices.Add(proxy);
            }
        }
        public void SimpleCQRSScenarioTest1()
        {
            var serviceCollection = new ServiceCollection();
            var messageHandlerExecutionContext = new ServiceProviderMessageHandlerExecutionContext(serviceCollection);

            var changedName      = string.Empty;
            var eventStore       = new DictionaryEventStore();
            var eventBus         = new SimpleEventBus(new MessageJsonSerializer(), messageHandlerExecutionContext);
            var snapshotProvider = new SuppressedSnapshotProvider();

            eventBus.MessageReceived += (s, e) =>
            {
                if (e.Message is NameChangedEvent)
                {
                    changedName = (e.Message as NameChangedEvent).Name;
                }
            };

            var domainRepository = new EventSourcingDomainRepository(eventStore, eventBus, snapshotProvider);

            var id    = Guid.NewGuid();
            var model = new Employee(id);

            model.ChangeName("daxnet");
            domainRepository.Save <Guid, Employee>(model);

            Assert.Equal("daxnet", changedName);
        }
Beispiel #7
0
        public void PostTest()
        {
            var test1 = new TestClass1();
            var test2 = new TestClass2();

            SimpleEventBus.Register(test1);
            SimpleEventBus.Register(test2);
            SimpleEventBus.Post(new TestEvent {
                Str = "A", Num = 1000
            });

            Assert.AreEqual("A1", test1.Str);
            Assert.AreEqual(1001, test1.Num);
            Assert.AreEqual("A2", test2.Str);
            Assert.AreEqual(1002, test2.Num);

            SimpleEventBus.Unregister(test1);
            SimpleEventBus.Post(new TestEvent {
                Str = "B", Num = 2000
            });

            Assert.AreEqual("A1", test1.Str);
            Assert.AreEqual(1001, test1.Num);
            Assert.AreEqual("B2", test2.Str);
            Assert.AreEqual(2002, test2.Num);
        }
Beispiel #8
0
        public MainWindow()
        {
            InitializeComponent();
            SimpleEventBus.GetDefaultEventBus().Register(this);
            SimpleEventBus.GetDefaultEventBus().Register(ActionEngine.Instance);
//            LoadPlugins();
            InitPluginEngine();
        }
 private void ShowPopover()
 {
     if (!_isMasterPopoverShown)
     {
         AnimateMasterView(true);
         SimpleEventBus.Publish(new PopoverMenuToggled(true));
     }
 }
Beispiel #10
0
 /// <summary>
 /// 初始化新实例。
 /// </summary>
 /// <param name="session"></param>
 /// <param name="appSeqService"></param>
 /// <param name="opHelper"></param>
 /// <param name="simpleEventBus"></param>
 /// <param name="logger"></param>
 public InboundOrdersController(ISession session, IAppSeqService appSeqService, OpHelper opHelper, SimpleEventBus simpleEventBus, ILogger logger)
 {
     _session        = session;
     _appSeqService  = appSeqService;
     _opHelper       = opHelper;
     _simpleEventBus = simpleEventBus;
     _logger         = logger;
 }
Beispiel #11
0
        private void InitPluginEngine()
        {
            PluginEngine pluginEngine = new PluginEngine();

            //Restore from context
            pluginEngine.RestorePlugins();
            SimpleEventBus.GetDefaultEventBus().Register(pluginEngine);
        }
 private void HidePopover()
 {
     if (_isMasterPopoverShown)
     {
         AnimateMasterView(false);
         SimpleEventBus.Publish(new PopoverMenuToggled(false));
     }
 }
Beispiel #13
0
        public Services(IAcceptsOneControl viewFrame)
        {
            EventBus = new SimpleEventBus();
            IPresenterMapper presenterMapper = new PresenterMapper(this);
            PlaceController = new PlaceController(EventBus, presenterMapper, viewFrame);

            TestView = new TestView();
        }
Beispiel #14
0
        public Services(IAcceptsOneControl viewFrame)
        {
            EventBus = new SimpleEventBus();
            IPresenterMapper presenterMapper = new PresenterMapper(this);

            PlaceController = new PlaceController(EventBus, presenterMapper, viewFrame);

            TestView = new TestView();
        }
Beispiel #15
0
 public LocController(ISession session, LocationHelper locHelper, ILocationFactory locFactory, OpHelper opHelper, SimpleEventBus eventBus, ILogger logger)
 {
     _session    = session;
     _locHelper  = locHelper;
     _locFactory = locFactory;
     _opHelper   = opHelper;
     _eventBus   = eventBus;
     _logger     = logger;
 }
Beispiel #16
0
 /// <summary>
 /// 初始化新实例。
 /// </summary>
 /// <param name="session"></param>
 /// <param name="outboundOrderAllocator">出库单库存分配程序</param>
 /// <param name="appSeqService"></param>
 /// <param name="opHelper"></param>
 /// <param name="simpleEventBus"></param>
 /// <param name="logger"></param>
 public WioController(ISession session, IOutboundOrderAllocator outboundOrderAllocator, IAppSeqService appSeqService, OpHelper opHelper, SimpleEventBus simpleEventBus, ILogger logger)
 {
     _session = session;
     _outboundOrderAllocator = outboundOrderAllocator;
     _appSeqService          = appSeqService;
     _opHelper       = opHelper;
     _simpleEventBus = simpleEventBus;
     _logger         = logger;
 }
        private static void LogMessage(LogMessageArgs args)
        {
            var simpleEventBus = SimpleEventBus <AsyncMessageEvent> .Resolve();

            if (args?.Message != null)
            {
                simpleEventBus.Raise(new AsyncMessageEvent(args.Message.ToString()));
            }
        }
 public CqsModule()
 {
     CommandBus      = new SimpleCommandBus();
     QueryBus        = new SimpleQueryBus();
     EventBus        = new SimpleEventBus();
     RequestReplyBus = new SimpleRequestReplyBus();
     _requestMethod  = GetType().GetMethod("ExecuteRequest", BindingFlags.NonPublic | BindingFlags.Instance);
     _commandMethod  = GetType().GetMethod("ExecuteCommand", BindingFlags.NonPublic | BindingFlags.Instance);
     _queryMethod    = GetType().GetMethod("ExecuteQuery", BindingFlags.NonPublic | BindingFlags.Instance);
 }
Beispiel #19
0
        public string Initialize(SimpleEventBus eventBus)
        {
            MusicPlayerWindow musicPlayerWindow = new MusicPlayerWindow();

            eventBus.Post(new ShowWindowEvent(musicPlayerWindow), TimeSpan.Zero);

            WpfConsole.WriteLine("Hello from Music Plugin!");

            return("OK");
        }
Beispiel #20
0
        /// <summary>
        /// 发布事件
        /// </summary>
        /// <typeparam name="TEvent">事件类型</typeparam>
        /// <param name="event">事件</param>
        public async Task PublishAsync <TEvent>(TEvent @event) where TEvent : IEvent
        {
            await SimpleEventBus.PublishAsync(@event);

            if (!(@event is IMessageEvent messageEvent))
            {
                return;
            }
            await MessageEventBus.PublishAsync(messageEvent);
        }
Beispiel #21
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));
        }
Beispiel #22
0
        private async Task SynchronizeAsyncImpl()
        {
            SynchronizationResult result;

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

            ShowSynchronizationResultMessage(result);
        }
 //窗口关闭监听
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (MessageBox.Show("是否要关闭?", "确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         e.Cancel = false;
     }
     else
     {
         e.Cancel = true;
         SimpleEventBus.GetDefaultEventBus().Deregister(this);
     }
 }
Beispiel #24
0
        public I18NEngine(Visual root, ResourceManager resourceManager, bool registerInDefaultEventListener = true)
        {
            this.root        = root;
            _resourceManager = resourceManager;
            _elements        = new Dictionary <Visual, string>(100);
            _menuItems       = new Dictionary <MenuItem, string>(100);

            GetControlsToTranslateKeyDictionary(root);
            if (registerInDefaultEventListener)
            {
                SimpleEventBus.GetDefaultEventBus().Register(this);
            }
        }
        private void AddMenuPlayButton()
        {
            menuItem           = new MenuItem();
            menuItem.Header    = "Text_Play";
            menuItem.IsEnabled = false;
            menuItem.Click    += ButtonPlay_OnClick;

            AddMenuItemEvent addMenuItemEvent = new AddMenuItemEvent("file", menuItem, Properties.Resources.ResourceManager);

            SimpleEventBus.GetDefaultEventBus().Post(addMenuItemEvent, TimeSpan.Zero);

            _i18NEngine.AddTranslateElement(menuItem);
        }
        private void ButtonPlay_OnClick(object sender, RoutedEventArgs e)
        {
            string filePath = ContextEngine.Instance.GetStringContextObject("selectedFile");

            if (!File.Exists(filePath))
            {
                return;
            }

            PlayMusicAction playMusicAction = new PlayMusicAction(filePath);

            SimpleEventBus.GetDefaultEventBus().Post(new DoActionEvent(playMusicAction), TimeSpan.Zero);
        }
Beispiel #27
0
        public void InitializePlugin(string fileExePath)
        {
            Assembly assembly = Assembly.LoadFrom(fileExePath);

            Type objectType = (from type in assembly.GetTypes()
                               where type.IsClass && type.Name == "PluginApp"
                               select type).Single();
            IBasePlugin basePlugin = (IBasePlugin)Activator.CreateInstance(objectType);

            WpfConsole.WriteLine("Initialize: " + basePlugin.GetPluginName());
            var result = basePlugin.Initialize(SimpleEventBus.GetDefaultEventBus());

            WpfConsole.WriteLine("Initialize result: " + result);
        }
        public MainWindow()
        {
            InitializeComponent();
            //加入窗口关闭监听
            this.Closing += Window_Closing;

            //注册EventBus监听
            SimpleEventBus eventBus = SimpleEventBus.GetDefaultEventBus();

            eventBus.Register(this);
            //连接服务端
            mClient = new NettyClient(Host, Port);
            mClient.StartClient();
        }
Beispiel #29
0
        private void ChangeLanguage(string language)
        {
            var culture    = CultureInfo.GetCultureInfo(language);
            var oldCulture = Dispatcher.Thread.CurrentCulture;

            Dispatcher.Thread.CurrentCulture   = culture;
            Dispatcher.Thread.CurrentUICulture = culture;

            ChangeLanguageEvent changeLanguageEvent = new ChangeLanguageEvent(culture.Name, oldCulture.Name);

            SimpleEventBus.GetDefaultEventBus().Post(changeLanguageEvent, TimeSpan.Zero);

            WpfConsole.WriteLine("Change localization on: " + culture.Name + " from: " + oldCulture.Name);
        }
Beispiel #30
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            SimpleEventBus.Subscribe <PopoverMenuToggleRequested>(OnPopoverMenuToggled);

            if (null == _dataMap)
            {
                var emptyState = new UIImageView(Theme.DetailEmptyStateImage)
                {
                    ContentMode = UIViewContentMode.TopLeft
                };

                View = emptyState;
            }
        }
Beispiel #31
0
        public void SetContextObject(string key, object value)
        {
            object oldValue = GetContextObject(key);
            ContextPropertiesChangedEvent contextPropertiesChangedEvent =
                new ContextPropertiesChangedEvent(key, oldValue, value);

            if (_contextData.ContainsKey(key))
            {
                _contextData[key] = value;
            }
            else
            {
                _contextData.Add(key, value);
            }

            SimpleEventBus.GetDefaultEventBus().Post(contextPropertiesChangedEvent, TimeSpan.Zero);
        }
Beispiel #32
0
        private static CqsServer CreateServer()
        {
            var cmdBus = new SimpleCommandBus();
            cmdBus.Register(typeof (Program).Assembly);

            var queryBus = new SimpleQueryBus();
            queryBus.Register(typeof (Program).Assembly);

            var requestReplyBus = new SimpleRequestReplyBus();
            requestReplyBus.Register(typeof (Program).Assembly);

            var eventBus = new SimpleEventBus();
            eventBus.Register(typeof (Program).Assembly);

            var server = new CqsServer(cmdBus, queryBus, eventBus, requestReplyBus);
            server.SerializerFactory = () => new JsonMessageSerializer();
            
            return server;
        }