public void UpdateInput(Setting setting, bool restart) { this.restart = restart; SetSetting(setting); CloseInput(); StartInput(); ChannelFactory <Service.IContractIn> myChannelFactory = new ChannelFactory <Service.IContractIn>(new BasicHttpBinding(), new EndpointAddress("http://localhost:8000/sparkInput")); Service.IContractIn wcfInput = myChannelFactory.CreateChannel(); ((IClientChannel)wcfInput).OperationTimeout = new TimeSpan(0, 1, 10); string[] data = new string[setting.Inputs.Count]; for (int i = 0; i < setting.Inputs.Count; i++) { data[i] = JsonConvert.SerializeObject(setting.Inputs[i]); } int countConnect = 0; while (true) { try { countConnect++; wcfInput.UpdateInputs(data, setting.Title); break; } catch (Exception ex) { System.Threading.Thread.Sleep(500); if (countConnect > 5) { Service.Log.LogShow(EnvPath, "Не удается подключиться к модулю входов", ex.ToString(), "Ошибка", Service.MessageViewMode.Error); break; } } } }
public void SendSoOnToInput(string inputTitle) { ChannelFactory <Service.IContractIn> myChannelFactory = new ChannelFactory <Service.IContractIn>(new BasicHttpBinding(), new EndpointAddress("http://localhost:8000/sparkInput")); Service.IContractIn wcfInput = myChannelFactory.CreateChannel(); ((IClientChannel)wcfInput).OperationTimeout = new TimeSpan(0, 0, 3); try { wcfInput.SendSoOn(inputTitle); } catch { } }