示例#1
0
文件: Entry.cs 项目: erynet/IMS
 public bool ConnectBus(BusHub busHub)
 {
     _busHub = busHub;
     _upsTotalStructsQueue = new BlockingCollection<UpsTotalStruct>();
     _busHub.Subscribe<UpsRxMsg>(Router);
     return true;
 }
示例#2
0
        public void Name()
        {
            var name = Guid.NewGuid().ToString();
            var fake = Configuration.ConnectionString;
            var bt   = new BusHub(name, fake);

            Assert.AreEqual(name, bt.Name);
        }
示例#3
0
文件: Core.cs 项目: erynet/IMS
 // 생성자
 public Core()
 {
     // 먼저 현재 실행중인 어셈블리의 폴더(exe)의 경로를 찾는다.
     _currentEntryAssemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
     _subComponentList = new List<ISubComponent>();
     _busHub = new BusHub();
     _loopContinue = true;
 }
示例#4
0
文件: Entry.cs 项目: erynet/IMS
 public bool ConnectBus(BusHub busHub)
 {
     _busHub = busHub;
     //_packageFlowQueue = new BlockingCollection<IPackage>();
     //busHub.Subscribe<IPackage>((m) => { Router(m); });
     busHub.Subscribe<IPackage>(Router);
     return true;
 }
示例#5
0
        public void PartitionCountHigh()
        {
            var random = new Random();
            var pc     = random.Next(32, 200);
            var fake   = Configuration.ConnectionString;
            var bt     = new BusHub(Guid.NewGuid().ToString(), fake, pc);

            Assert.AreEqual(32, bt.PartitionCount);
        }
示例#6
0
        public bool ConnectBus(BusHub busHub)
        {
            _busHub = busHub;
            _busHub.Subscribe<ITxMessage>((m) => { SendMessage(m.ConnectString); });

            //_packageFlowQueue = new BlockingCollection<ICPackage>();
            //busHub.Subscribe<ICPackage>((m) => { _packageFlowQueue.TryAdd(m); });

            return true;
        }
示例#7
0
        public Core()
        {
            // 먼저 현재 실행중인 어셈블리의 폴더(exe)의 경로를 찾는다.
            _currentEntryAssemblyPath =
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            _busHub = new BusHub();

            _subComponents = new List <ISubComponent>();
            _loopContinue  = true;
        }
示例#8
0
        public void Setup()
        {
            var random = new Random();

            this.name = string.Format("a{0}b", random.Next());

            var init = new BusHub(name, connection);

            init.CreateIfNotExists().Wait();
        }
示例#9
0
        public bool ConnectBus(BusHub busHub)
        {
            _busHub = busHub;
            _busHub.Subscribe <ITxMessage>((m) => { SendMessage(m.ConnectString); });

            //_packageFlowQueue = new BlockingCollection<ICPackage>();
            //busHub.Subscribe<ICPackage>((m) => { _packageFlowQueue.TryAdd(m); });


            return(true);
        }
示例#10
0
文件: ControlLine.cs 项目: radtek/MFE
 public void QueryState()
 {
     if (BusHub != null && BusModule != null)
     {
         byte[] request  = new byte[] { BusModuleAPI.CmdGetControlLineState, (byte)Type, Address };
         byte[] response = new byte[state.Length];
         if (BusHub.BusModuleWriteRead(BusModule, request, response))
         {
             state = response;
         }
     }
 }
示例#11
0
文件: ControlLine.cs 项目: radtek/MFE
        public void SetState(byte[] state)
        {
            if (BusHub != null && BusModule != null)
            {
                byte[] data = new byte[3 + state.Length];
                data[0] = BusModuleAPI.CmdSetControlLineState;
                data[1] = (byte)Type;
                data[2] = Address;
                Array.Copy(state, 0, data, 3, state.Length);

                byte[] response = new byte[state.Length];
                if (BusHub.BusModuleWriteRead(BusModule, data, response))
                {
                    State = response;
                }
            }
        }
        /// <summary>
        /// 启用第三方事件总线
        /// </summary>
        /// <param name="connectionName">连接字符串名称</param>
        public static void UseEventBus(this IEventBusConfiguration eventBusConfiguration, string connectionName = "Microsoft.ServiceBus.ConnectionString", int timeOut = 10, string queueName = "SinoQueue")
        {
            if (string.IsNullOrEmpty(connectionName))
            {
                throw new ArgumentNullException(nameof(connectionName));
            }

            BusHub = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
            {
                var host = cfg.Host(CloudConfigurationManager.GetSetting(connectionName), h =>
                {
                    h.OperationTimeout = TimeSpan.FromSeconds(timeOut);
                    h.TransportType    = Microsoft.ServiceBus.Messaging.TransportType.NetMessaging;
                });
                cfg.ReceiveEndpoint(host, "SinoQueue", e =>
                {
                    e.UseMessageScope();
                    e.LoadFrom(Ioc.IocContainer);
                });
            });

            //释放ABP自带的EventBus
            var releaseEventBus = Ioc.Resolve <IEventBus>();

            Ioc.Release(releaseEventBus);

            Ioc.IocContainer.Register(Component.For <IBus>().Instance(BusHub).Named("BusRegister"));
            Ioc.IocContainer.Register(Component.For <IBusControl>().Instance(BusHub).Named("BusControlRegister"));

            var eventBusExtensions = Ioc.Resolve <IEventBusExtensions>();

            Ioc.IocContainer.Register(
                Component.For <IEventBus>().
                Instance(eventBusExtensions).
                IsDefault().
                Named("Sino.EventBus")
                );

            BusHub.Start();
        }
示例#13
0
 public bool ConnectBus(BusHub busHub)
 {
     _busHub = busHub;
     return(true);
 }
示例#14
0
文件: Entry.cs 项目: erynet/IMS
 public Entry()
 {
     Log = null;
     _busHub = null;
     _loopContinue = true;
 }
 public static void Stop()
 {
     BusHub.Stop();
 }
示例#16
0
文件: Entry.cs 项目: erynet/IMS
 public Entry()
 {
     Log = null;
     _busHub = null;
 }
示例#17
0
 public bool ConnectBus(BusHub busHub)
 {
     _busHub = busHub;
     return true;
 }
示例#18
0
        public void TearDown()
        {
            var init = new BusHub(name, connection);

            init.Delete().Wait();
        }