protected void Prepared() { MysqlDBConnection.Current.Database = "taxmanagement"; MysqlDBConnection.Current.Server = "localhost"; MysqlDBConnection.Current.LoginUser = "******"; MysqlDBConnection.Current.Password = "******"; //数据库部署 MysqlDBConnection.Current.Deployment(); //集线器加载 HubContainer.Load(Assembly.Load("TaxManagementSystem.Business")); //服务加载 ServiceObjectContainer.Load(Assembly.Load("TaxManagementSystem.Business")); }
private void TryConnnect(HubContainer container) { var prismEventAggregator = new EventAggregator(); prismEventAggregator.GetEvent <PubSubEvent <ApiEvent> >().Subscribe(ApiEventAction); try { var clientShim = new ClientPrismEventAggregatorShim(prismEventAggregator); Initialise(container.HubConnection, clientShim); container.HubConnection.Start().Wait(); } catch (Exception ex) { } }
private void RunAnotherApiConnect() { foreach (var item in _urlList) { var container = new HubContainer { ContainerId = Guid.NewGuid(), HubConnection = new HubConnection(item), }; AddEvents(container); _containerList.Add(container); } _containerList.ForEach(x => Task.Run(() => TryConnnect(x))); _timer = new Timer(CheckAllConnection, null, 5000, 10000); }
public void Start() { foreach (var item in _urlList) { var container = new HubContainer { ContainerId = Guid.NewGuid(), HubConnection = new HubConnection(item), }; AddEvents(container); _containerList.Add(container); } TryConnnect(_containerList[_selectedItem]); _timer = new Timer(CheckAnyoneConnection, null, 5000, 1000); }
private void AddEvents(HubContainer container) { container.HubConnection.Error += ex => { container.Status = ConnectionStatus.Unknown; }; container.HubConnection.Closed += () => { container.Status = ConnectionStatus.Closed; }; container.HubConnection.Reconnected += () => { container.Status = ConnectionStatus.Open; }; container.HubConnection.Reconnecting += () => { container.Status = ConnectionStatus.Connecting; }; }
private void CheckSpecificStatus(HubContainer container) { container.Status = container.HubConnection.State == ConnectionState.Connected ? ConnectionStatus.Open : container.Status; }