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 ConsoleView() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); DataContext = dc; Loaded += MainWindow_Loaded; }
public void RunCommand() { ConsoleOutput.Add(ConsoleInput); // do your stuff here. SimpleEventBus.GetDefaultEventBus().Post(new ConsoleInputEvent(ConsoleInput), TimeSpan.Zero); ConsoleInput = String.Empty; }
private void InitPluginEngine() { PluginEngine pluginEngine = new PluginEngine(); //Restore from context pluginEngine.RestorePlugins(); SimpleEventBus.GetDefaultEventBus().Register(pluginEngine); }
public MainWindow() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); SimpleEventBus.GetDefaultEventBus().Register(ActionEngine.Instance); // LoadPlugins(); InitPluginEngine(); }
//窗口关闭监听 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); } }
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); }
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 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); }
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); }
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(); }
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); }
public WebAgvMissionManager() { eventBus = SimpleEventBus.GetDefaultEventBus(); eventBus.Register(this); string className = StaticData.AppHostConfig.GetType().GetProperty($"{StaticData.AppHostConfig.Environment}CarryDevice").GetValue(StaticData.AppHostConfig).ToString(); string path = $@"{StaticData.AppHostConfig.AppBinPath}\RightCarryService.dll"; var assembly = Assembly.LoadFrom(path); var tpe = assembly.GetType(className); RightCarryService.IControlDevice dObj = Activator.CreateInstance(tpe) as IControlDevice; agvMissionManagerClient = new AgvMissionManagerClient(dObj); agvMissionManagerClient.SendAgvMissonEvent += AgvMissionManagerClient_SendAgvMissonEvent; agvMissionManagerClient.SendSignalrEvent += AgvMissionManagerClient_SendSignalrEvent; agvMissionManagerClient.ShowLogEvent += AgvMissionManagerClient_ShowLogEvent; }
public JsonResult LocationDevices(string id) { var query = Request.QueryString["action"]; if (Request.HttpMethod == "POST" && query == "arrived") { var keyArr = id.Split('_'); var key = $"{keyArr[0]}_{keyArr[1]}"; var hubContext = GlobalHost.ConnectionManager.GetHubContext <AgvMissonHub>(); hubContext.Clients.All.agvStateChange(id); var hubContext2 = GlobalHost.ConnectionManager.GetHubContext <NoticeHub>(); hubContext2.Clients.All.agvSignalChange(id); var eventBus = SimpleEventBus.GetDefaultEventBus(); eventBus.Post(new agvStateChange(id), TimeSpan.FromSeconds(1)); if (keyArr.Length >= 3) { hubContext2.Clients.All.agvOrderArrived(id); } return(Json(new { state = true, id = id }, JsonRequestBehavior.AllowGet)); } bool isArrived = true; if (StaticData.SignalDict.ContainsKey(id)) { isArrived = StaticData.SignalDict[id]; } var actionStatus = isArrived ? ActionStatus.DONE : ActionStatus.EXECUTING; var status = isArrived ? Status.IDLE : Status.EXECUTING; var node = new LocationDevice() { lastAction = query, name = id, lastActionStatus = Enum.Parse(typeof(ActionStatus), actionStatus.ToString(), false).ToString(), status = Enum.Parse(typeof(Status), status.ToString(), false).ToString() }; return(Json(node, JsonRequestBehavior.AllowGet)); }
protected override void ChannelRead0(IChannelHandlerContext ctx, object msg) { //String json = msg as String; //MessagePackSerializer.; //读取到消息,对消息进行解析 //这样判断感觉有些尴尬,由于对C#不熟,暂时还没有更好的办法,有好的实现方法还望给出宝贵建议 object[] values = (object[])msg; int index = Convert.ToInt32(values[0]);//获取消息类别,第一个字段为EventType,这是约定好的 String eventType = Enum.GetName(typeof(EventType), index); if (eventType.Equals(EventType.TEST_EVENT.ToString())) //测试类事件 { TestEvent testEvent = MessagePackSerializer.Deserialize <TestEvent>(MessagePackSerializer.Serialize(msg)); Console.WriteLine("Client接收到消息:" + testEvent); SimpleEventBus.GetDefaultEventBus().Post(testEvent.ToString(), TimeSpan.Zero); } else if (eventType.Equals(EventType.OTHER_EVENT.ToString())) {//其他类事件 Console.WriteLine("Client接收到消息:其他类事件,暂未处理"); } }
private void InitPluginEngine() { PluginEngine pluginEngine = new PluginEngine(); SimpleEventBus.GetDefaultEventBus().Register(pluginEngine); }
public MenuToolbar() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); }
private void LoadServices() { SimpleEventBus.GetDefaultEventBus().Register(new ContextService()); }
private void UndoAction_OnClick(object sender, RoutedEventArgs e) { UndoActionEvent undoActionEvent = new UndoActionEvent(); SimpleEventBus.GetDefaultEventBus().Post(undoActionEvent, TimeSpan.Zero); }
private void HandleFileOpen(string filePath) { SelectFileAction selectFileAction = new SelectFileAction(filePath); SimpleEventBus.GetDefaultEventBus().Post(new DoActionEvent(selectFileAction), TimeSpan.Zero); }
/// <summary>初始化</summary> public virtual void Initialize() { //初始化容器 if (Kernel == null) { if (!this.EnableWeb) { var settings = new NinjectSettings(); settings.ExtensionSearchPatterns = new string[] { "Ninject.Extensions.*.dll" }; Kernel = new StandardKernel(settings); } else { Kernel = new StandardKernel(); } } var kernel = Kernel; kernel.Bind <IServiceProvider>().ToConstant(kernel); var implementsAssembly = Assembly.Load(this.ImplementsAssembly); //加载日志组件 var loggingLoaderConfig = new LoggingLoaderConfig(); SetLogggingConfig(loggingLoaderConfig); if (loggingLoaderConfig.Enable) { LoadLoggging(kernel, implementsAssembly, loggingLoaderConfig); } //加载异常组件 var exceptionLoaderConfig = new ExceptionLoaderConfig(); SetExceptionConfig(exceptionLoaderConfig); if (exceptionLoaderConfig.Enable) { LoadException(kernel, implementsAssembly, exceptionLoaderConfig); } //加载缓存组件 var cacheLoaderConfig = new CacheLoaderConfig(); SetCacheConfig(cacheLoaderConfig); if (cacheLoaderConfig.Enable) { LoadCache(kernel, implementsAssembly, cacheLoaderConfig); } //加载仓储数据访问组件 var repositoryLoaderConfig = new RepositoryLoaderConfig(); SetRepositoryConfig(repositoryLoaderConfig); if (repositoryLoaderConfig.Enable) { kernel.Bind <IEventBus>().ToConstant(SimpleEventBus.GetDefaultEventBus()); LoadRepository(kernel, implementsAssembly, repositoryLoaderConfig); } //加载对象自动映射组件 var objectMapperLoaderConfig = new ObjectMapperLoaderConfig(); SetObjectMapperConfig(objectMapperLoaderConfig); if (objectMapperLoaderConfig.Enable) { LoadObjectMapper(kernel, implementsAssembly, objectMapperLoaderConfig); } //按约定注入绑定 var bindingInjectLoaderConfig = new BindingInjectLoaderConfig(); SetBindingInjectConfig(bindingInjectLoaderConfig); if (bindingInjectLoaderConfig.Enable) { LoadBindingInject(kernel, implementsAssembly, bindingInjectLoaderConfig); } //JSON序列化设置 //JsonUtil.DefaultUseCamelCaseNamingStrategy(); }
public static void WriteLine(string message) { SimpleEventBus.GetDefaultEventBus().Post(new ConsoleOutputEvent(message), TimeSpan.Zero); }
public override void ChannelInactive(IChannelHandlerContext context) { base.ChannelInactive(context); Console.WriteLine("Client ChannelInactive:" + context); SimpleEventBus.GetDefaultEventBus().Post("连接断开:" + context, TimeSpan.Zero); }
public override void ChannelActive(IChannelHandlerContext context) { Console.WriteLine("Client channelActive:" + context); SimpleEventBus.GetDefaultEventBus().Post("建立连接:" + context, TimeSpan.Zero); }
public StationHub() { eventBus = SimpleEventBus.GetDefaultEventBus(); }
public MusicPlayerWindow() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); }
public MainContent() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); }
public UploadView() { InitializeComponent(); SimpleEventBus.GetDefaultEventBus().Register(this); }
public RestHub() { eventBus = SimpleEventBus.GetDefaultEventBus(); }