public WebSocketServiceHost AddWebSocketService <T>(string path, int bufferSize = 4096) where T : WebSocketBehavior, new() { WebSocketServiceHost <T> host = new WebSocketServiceHost <T>(path, bufferSize); ServiceHosts.Add(path, host); return(host); }
/// <summary> /// 启动所有服务。 /// </summary> public void StartServices() { LocalSettings localSettings = new XmlSerializerWrapper <LocalSettings>().Entity; //使用 LocalSettings 里的数据库连接信息覆盖 App.config 里的 Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ConnectionStringSettings connectionStringSettings = configuration.ConnectionStrings.ConnectionStrings["GeelyPtlEntities"]; connectionStringSettings.ProviderName = localSettings.ConnectionStringProviderName; connectionStringSettings.ConnectionString = string.Format(CultureInfo.InvariantCulture, localSettings.ConnectionStringFormat, localSettings.ConnectionStringPassword); configuration.Save(); ConfigurationManager.RefreshSection("connectionStrings"); //确保基础数据已存在于数据库 BaseDatasInitializer.EnsureInitialized(); //启动通讯之前重值所有设备的在线状态 this.DeviceOnLineStatusReset(); //承载所有接口服务 ServiceHosts.Open(localSettings.ServiceIP, localSettings.ServicePort); //启动设备通讯 CartPtlHost.Instance.Start(); ChannelPtlHost.Instance.Start(); //启动PickZone通讯 PickZoneHost.Instance.Start(); //启动FeedZone通讯(分装工位) FeedZoneHost.Instance.Start(); CacheRegionHost.Instance.Start(); AssemblySectionHost.Instance.Start(); //启动MarketZone通讯 MarketZoneHost.Instance.Start(); //启动任务加载业务 AssortingExecutorLoader.Instance.Start(); CartFindingExecutor.Instance.Start(); IndicatingExecutorLoader.Instance.Start(); //启动结果回写业务 AssortResultWriteBack.Instance.Start(localSettings.PtlToLesServiceUrl); CartFindingDeliveryResultWriteBack.Instance.Start(localSettings.PtlToLesServiceUrl); AssembleResultWriteBack.Instance.Start(localSettings.PtlToMesServiceUrl); //启动历史记录清除器 Ptl.Device.Log.Logger.HoldingPeriodInDays = localSettings.HistoryHoldingDays; HistoryRecordsRemover.Instance.Start(localSettings.HistoryHoldingDays); //启动AGV配送任务发送业务 PickAreaService.Instance.Start(localSettings.PtlToAgvServiceUrl); ProductAreaService.Instance.Start(localSettings.PtlToAgvServiceUrl); InitService.Instance.Start(localSettings.PtlToAgvServiceUrl); //启动状态监控 this.StartRunningStatusRefreshThread(); }
private void InvokeHostStop() { if (ServiceHosts.Any()) { foreach (var host in ServiceHosts) { host.Stop(); } } }
public void Start() { if (webHost == null) { IWebHostBuilder webHostBuilder = WebHost.CreateDefaultBuilder().UseUrls(Url) .Configure(app => Configure(app)).ConfigureServices(services => ConfigureServices(services)); if (ServiceHosts.Any()) { webHost = webHostBuilder.Build(); } } webHost.Run(); }
/// <summary> /// 重新启动所有可临时中断的服务。 /// </summary> public void RestartSafelyServices() { LocalSettings localSettings = new XmlSerializerWrapper <LocalSettings>().Entity; //停止所有可临时中断的服务 this.StopRunningStatusRefreshThread(); PickAreaService.Instance.Stop(); ProductAreaService.Instance.Stop(); InitService.Instance.Stop(); HistoryRecordsRemover.Instance.Stop(); AssortResultWriteBack.Instance.Stop(); CartFindingDeliveryResultWriteBack.Instance.Stop(); AssembleResultWriteBack.Instance.Stop(); AssortingExecutorLoader.Instance.Stop(); CartFindingExecutor.Instance.Stop(); IndicatingExecutorLoader.Instance.Stop(); ServiceHosts.Close(); //启动所有可临时中断的服务 ServiceHosts.Open(localSettings.ServiceIP, localSettings.ServicePort); AssortingExecutorLoader.Instance.Start(); CartFindingExecutor.Instance.Start(); IndicatingExecutorLoader.Instance.Start(); AssortResultWriteBack.Instance.Start(localSettings.PtlToLesServiceUrl); CartFindingDeliveryResultWriteBack.Instance.Start(localSettings.PtlToLesServiceUrl); AssembleResultWriteBack.Instance.Start(localSettings.PtlToMesServiceUrl); HistoryRecordsRemover.Instance.Start(localSettings.HistoryHoldingDays); //启动AGV配送任务发送业务 PickAreaService.Instance.Start(localSettings.PtlToAgvServiceUrl); ProductAreaService.Instance.Start(localSettings.PtlToAgvServiceUrl); InitService.Instance.Start(localSettings.PtlToAgvServiceUrl); this.StartRunningStatusRefreshThread(); }
/// <summary> /// 停止所有服务。 /// </summary> public void StopServices() { this.StopRunningStatusRefreshThread(); PickAreaService.Instance.Stop(); ProductAreaService.Instance.Stop(); InitService.Instance.Stop(); Ptl.Device.Log.Logger.HoldingPeriodInDays = int.MaxValue; HistoryRecordsRemover.Instance.Stop(); AssortResultWriteBack.Instance.Stop(); CartFindingDeliveryResultWriteBack.Instance.Stop(); AssembleResultWriteBack.Instance.Stop(); AssortingExecutorLoader.Instance.Stop(); CartFindingExecutor.Instance.Stop(); IndicatingExecutorLoader.Instance.Stop(); CartPtlHost.Instance.Stop(); ChannelPtlHost.Instance.Stop(); //关闭PickZone通讯 PickZoneHost.Instance.Stop(); //关闭FeedZone通讯(分装工位) FeedZoneHost.Instance.Stop(); CacheRegionHost.Instance.Stop(); AssemblySectionHost.Instance.Stop(); //关闭MarketZone通讯 MarketZoneHost.Instance.Stop(); ServiceHosts.Close(); this.DeviceOnLineStatusReset(); }
public RequestOrchestrator(ServiceHosts hosts) { _hosts = hosts; }