Ejemplo n.º 1
0
 public HomeController(IHostingEnvironment env, SubscriberManager subscriberManager, IpLogger ipLogger, IRateLimitCounterStore rateLimiter)
 {
     this._env = env;
     this._subscriberManager = subscriberManager;
     this._ipLogger          = ipLogger;
     this._rateLimiter       = rateLimiter;
 }
    public Subscriber(string topic, Action <T> callback)
    {
        this.topic = topic;
        SubscriberManager <T> subsss = new SubscriberManager <T>(topic, callback);

        WebSocketManager.Instance.sublist.Add(subsss);
    }
Ejemplo n.º 3
0
        public void Fail_Test_If_Validating_user_In_BusinessLayer()
        {
            Mock <ISubscriber> db = new Mock <ISubscriber>();

            db.Setup(x => x.validate_user("Divya", "divya"));
            SubscriberManager businessManager = new SubscriberManager(db.Object);
            var target = businessManager.validate_user("divya", "sbrvw");

            Assert.AreEqual(false, target);
        }
Ejemplo n.º 4
0
        public void Test_BusinessLayer_To_Get_Notification_count()
        {
            Mock <ISubscriber> db = new Mock <ISubscriber>();

            db.Setup(x => x.GetNotificationCount("Divya")).Returns(It.IsAny <int>());
            SubscriberManager businessManager = new SubscriberManager(db.Object);
            var target = businessManager.GetNotificationCount("Divya");

            Assert.IsNotNull(target);
        }
Ejemplo n.º 5
0
        public void Test_BusinessLayer_To_Reset_Unread_count()
        {
            Mock <ISubscriber> db = new Mock <ISubscriber>();

            db.Setup(x => x.ResetUnreadCount("Divya")).Returns(true);
            SubscriberManager businessManager = new SubscriberManager(db.Object);
            var target = businessManager.ResetUnreadCount("Divya");

            Assert.AreEqual(true, target);
        }
Ejemplo n.º 6
0
        public void Test_BusinessLayer_To_Get_Notifications_List()
        {
            Mock <ISubscriber> db = new Mock <ISubscriber>();

            db.Setup(x => x.GetNotifications()).Returns(new List <Publisher>());
            SubscriberManager businessManager = new SubscriberManager(db.Object);
            var target = businessManager.GetNotifications();

            Assert.IsNotNull(target);
            Assert.IsInstanceOfType(new List <Publisher>(), target.GetType());
        }
Ejemplo n.º 7
0
        private static IConfigurableEventBus CreateServiceBus(EventBusBuilder eventBusBuilder,
                                                              IServiceProvider serviceProvider,
                                                              SubscriberManager subscriberManager)
        {
            var connection = serviceProvider.GetServices <IServiceBusConnection>()
                             .Single(x => x.Name == eventBusBuilder.ConfigurationName);

            return(new ServiceBusEventBus(eventBusBuilder.ConfigurationName,
                                          connection,
                                          subscriberManager,
                                          serviceProvider,
                                          serviceProvider.GetRequiredService <ILoggerFactory>()));
        }
Ejemplo n.º 8
0
        public void Test_businesslayer_CreateSubscriber()
        {
            Mock <ISubscriber> db = new Mock <ISubscriber>();

            db.Setup(x => x.create_Subscriber(It.IsAny <string>(), It.IsAny <string>(), new Subscriber {
                UserName = "******"
            }));
            SubscriberManager businessManager = new SubscriberManager(db.Object);
            var target = businessManager.create_Subscriber(It.IsAny <string>(), It.IsAny <string>(), new Subscriber {
                UserName = "******"
            });

            Assert.IsNotNull(target);
        }
Ejemplo n.º 9
0
 static async Task MainAsync(ConfigurationFile configurationFile)
 {
     if (configurationFile.ApplicationMode == ApplicationMode.Publisher)
     {
         _publisherManager = new PublisherManager(configurationFile);
         _publisherManager.Setup();
     }
     else if (configurationFile.ApplicationMode == ApplicationMode.Subscriber)
     {
         _subscriberManager = new SubscriberManager(configurationFile);
         _subscriberManager.Setup();
     }
     Console.Read();
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.Title = "HuaWei OPC_UA Client";
            Task result = ConnectAsync();

            result.ContinueWith((task) =>
            {
                Console.WriteLine("Connect to  opc.tcp://localhost:62567 success!");
                SubscriberManager.OpcUaClient = client;
                SubscriberManager.RegistSubscriber();
            });
            Console.WriteLine("Please enter any key to quit!");
            Console.ReadLine();
            Disconnect();
        }
Ejemplo n.º 11
0
        public ServiceBusEventBus(string configurationName,
                                  IServiceBusConnection connection,
                                  SubscriberManager subscriber,
                                  IServiceProvider serviceProvider,
                                  ILoggerFactory loggerFactory,
                                  IConfiguration configuration)
            : base(subscriber, serviceProvider, loggerFactory)
        {
            if (string.IsNullOrWhiteSpace(configurationName))
            {
                throw new ArgumentException($"'{nameof(configurationName)}' cannot be null or whitespace", nameof(configurationName));
            }

            Name           = configurationName;
            _connection    = connection;
            _configuration = configuration;

            //TODO: Add logs
        }
Ejemplo n.º 12
0
        public RabbitMqEventBus(string name,
                                IConfiguration configuration,
                                SubscriberManager subscriber,
                                IRabbitMqConnection connection,
                                IServiceProvider serviceProvider,
                                ILoggerFactory loggerFactory) : base(subscriber, serviceProvider, loggerFactory)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace", nameof(name));
            }

            Name = name;

            _connection    = connection;
            _configuration = configuration;
            _logger        = loggerFactory.CreateLogger <RabbitMqEventBus>();
            _queues        = new List <Queue>();
        }
Ejemplo n.º 13
0
        static async Task Main(string[] args)
        {
            Console.Title = "HuaWei OPC_UA Client";
            var connectionStrs = GetConfig().GetSection("OpcConnectionStrings").Get <string[]>();

            Console.WriteLine($"当前主线程ID: {Thread.CurrentThread.ManagedThreadId}");
            foreach (var connectionStr in connectionStrs)
            {
                ThreadPool.QueueUserWorkItem(async obj =>
                {
                    Console.WriteLine($"当前 {connectionStr} 子线程ID: {Thread.CurrentThread.ManagedThreadId}");
                    var client = await ConnectAsync(connectionStr);
                    Console.WriteLine($"Connect to {connectionStr} success!");
                    SubscriberManager.Clients[connectionStr] = client;
                    SubscriberManager.RegistSubscriber(client);
                });
            }
            Console.WriteLine("Please enter any key to quit!");
            Console.ReadLine();
            Disconnect();
        }
Ejemplo n.º 14
0
 public void Notify(string publishServiceName)
 {
     SubscriberManager.ReceiveNotify(publishServiceName, clientLink);
 }
Ejemplo n.º 15
0
 public override void Init()
 {
     Internal = new SubscriberManager();
     Remote   = new SubscriberManager();
 }
Ejemplo n.º 16
0
 public TestEventBus(SubscriberManager subscriber, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) : base(subscriber, serviceProvider, loggerFactory)
 {
 }
Ejemplo n.º 17
0
        public static void Run(StartType type)
        {
            switch (type)
            {
            case StartType.BaseService:
                mAppHost = new ServiceHost(typeof(BaseService));
                //初始化连接池,默认10分钟清理连接
                ClientLinkPoolCache.Init(true, 200, 30, 600, "wcfserver", 30);

                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";
                AppGlobal.appType     = AppType.WCF;
                AppGlobal.IsSaas      = HostSettingConfig.GetValue("issaas") == "1" ? true : false;
                AppGlobal.AppStart();


                ClientManage.IsHeartbeat   = HostSettingConfig.GetValue("heartbeat") == "1" ? true : false;
                ClientManage.HeartbeatTime = Convert.ToInt32(HostSettingConfig.GetValue("heartbeattime"));

                ClientManage.StartHost();
                mAppHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "数据服务启动完成");
                break;

            case StartType.FileService:
                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";

                mFileHost = new ServiceHost(typeof(FileService));
                mFileHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "文件服务启动完成");
                break;

            case StartType.HttpService:
                //初始化连接池,默认10分钟清理连接
                ClientLinkPoolCache.Init(true, 200, 30, 600, "httpserver", 30);
                AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\";

                mHttpHost = new WebServiceHost(typeof(HttpService));
                mHttpHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "Http服务启动完成");
                break;

            case StartType.RouterBaseService:
                mRouterHost = new ServiceHost(typeof(RouterBaseService));
                RouterManage.Start();
                mRouterHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由数据服务启动完成");
                break;

            case StartType.RouterFileService:
                mFileRouterHost = new ServiceHost(typeof(RouterFileService));
                mFileRouterHost.Open();

                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由文件服务启动完成");
                break;

            case StartType.SuperClient:
                SuperClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "超级客户端启动完成");

                PublisherManage.Start();
                SubscriberManager.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "发布订阅启动完成");

                DistributedCacheManage.Start();
                DistributedCacheClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "分布式缓存启动完成");

                UpgradeManage.Start();
                UpgradeClient.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "升级包管理启动完成");

                MonitorTirggerManage.Start();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "监视触发器启动完成");
                break;

            case StartType.MiddlewareTask:
                MiddlewareTask.StartTask();    //开启定时任务
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "定时任务启动完成");
                break;
            }
        }
Ejemplo n.º 18
0
 private static void GetAllConfig()
 {
     #region 收集配置信息
     Action <HostRunConfigSubject> psAction = ((HostRunConfigSubject subject) =>
     {
         MNodePlugin nodeP = RemotePluginManage.GetLocalPlugin();
         if (nodeP != null)
         {
             HostRunConfigObject configObj;
             foreach (var p in nodeP.RemotePlugin)
             {
                 configObj = new HostRunConfigObject();
                 configObj.Label = "远程插件";
                 configObj.Key = p.PluginName;
                 configObj.Value = p.PluginName;
                 configObj.Memo = p.PluginName + "\t" + String.Join(",", p.MNodeIdentify.ToArray());
                 subject.ConfigObjList.Add(configObj);
             }
         }
     });
     Action <HostRunConfigSubject> pubsAction = ((HostRunConfigSubject subject) =>
     {
         if (PublisherManage.GetPublishServiceList() != null)
         {
             HostRunConfigObject configObj;
             foreach (var p in PublisherManage.GetPublishServiceList())
             {
                 configObj = new HostRunConfigObject();
                 configObj.Label = "发布服务";
                 configObj.Key = p.publishServiceName;
                 configObj.Value = p.publishServiceName;
                 configObj.Memo = p.publishServiceName + "\t" + p.explain;
                 subject.ConfigObjList.Add(configObj);
             }
         }
     });
     Action <HostRunConfigSubject> subsAction = ((HostRunConfigSubject subject) =>
     {
         if (SubscriberManager.GetSubscribeService() != null)
         {
             HostRunConfigObject configObj;
             foreach (var p in SubscriberManager.GetSubscribeService())
             {
                 configObj = new HostRunConfigObject();
                 configObj.Label = "订阅服务";
                 configObj.Key = p.publishServiceName;
                 configObj.Value = p.publishServiceName;
                 configObj.Memo = p.publishServiceName;
                 subject.ConfigObjList.Add(configObj);
             }
         }
     });
     Action <HostRunConfigSubject> taskAction = ((HostRunConfigSubject subject) =>
     {
         if (MiddlewareTask.TaskConfigList != null)
         {
             HostRunConfigObject configObj;
             foreach (var p in MiddlewareTask.TaskConfigList)
             {
                 configObj = new HostRunConfigObject();
                 configObj.Label = p.taskname;
                 configObj.Key = p.taskname;
                 configObj.Value = p.taskname;
                 configObj.Memo = (p.qswitch ? "已开启" : "未开启") + "\t" + p.execfrequencyName + "\t" + p.shorttimeName + "\t" + p.serialorparallelName;
                 subject.ConfigObjList.Add(configObj);
             }
         }
     });
     HostRunConfigInfo.LoadConfigInfo(Identify, psAction, pubsAction, subsAction, taskAction);
     #endregion
 }