public bool Start() { try { NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(AvailabilityChangedCallback); if (!LoadConfiguration()) { throw new Exception("无法读取基本配置"); } ReadInitPara(); //LoadAssets(); var b = (Buoy)Buoy[0]; b.IP = _MonConfInfo.IP[0]; b = (Buoy)Buoy[1]; b.IP = _MonConfInfo.IP[1]; b = (Buoy)Buoy[2]; b.IP = _MonConfInfo.IP[2]; b = (Buoy)Buoy[3]; b.IP = _MonConfInfo.IP[3]; if (NetCore.IsInitialize) { NetCore.Stop(); } NetCore.Initialize(); if (!NetCore.StartUDPService())//只启动udp服务,tcp服务单独启动 { throw new Exception("UDP服务启动失败"); } if (!MonTraceService.CreateService()) { throw new Exception("数据服务启动失败"); } _serviceStarted = true; Error = NetCore.Error; return(ServiceStarted); } catch (Exception ex) { Error = ex.Message; EventAggregator.PublishMessage(new ErrorEvent(ex, LogType.Both)); return(false); } }
public void Stop() { SaveInitPara(); if (NetCore == null) { return; } if (NetCore.IsTCPWorking) { NetCore.StopTCpService(); } if (NetCore.IsUDPWorking) { NetCore.StopUDPService(); } /*if (CommCore.IsWorking) * CommCore.Stop();*/ if (MonTraceService != null) { MonTraceService.TearDownService(); } _serviceStarted = false; }