private void mStop_ItemClick(object sender, ItemClickEventArgs e) { try { // MainForm frm = new MainForm(); FormServerUtils form = Application.OpenForms["FormServerUtils"] as FormServerUtils; if (form != null) { form.Focus(); } form.host.Close(); form.close = true; if (form.host.State != CommunicationState.Opened) { mStart.Enabled = true; mStop.Enabled = false; form.txtStatus.Caption = "The Server is Not running"; } } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (CommunicationException ex) #pragma warning restore CS0168 // The variable 'ex' is declared but never used { } }
private void mStart_ItemClick(object sender, ItemClickEventArgs e) { // MainForm frm = new MainForm(); FormServerUtils form = Application.OpenForms["FormServerUtils"] as FormServerUtils; if (form != null) { form.Focus(); } if (form.close == true) { //IGetServiceBase iServiceDriver = Functions.GetAssemblyService(@"\Service\BaseService.dll", "BaseService.ServiceBase"); //form.host = iServiceDriver.GetServiceHostHttp("Modbus"); //form.host.Opened += form.host_Opened; //form.host.Open(); //form.close = false; } if (form.host.State == CommunicationState.Opened) { mStart.Enabled = false; mStop.Enabled = true; form.txtStatus.Caption = "The Server is running"; } foreach (var se in form.host.Description.Endpoints) { //var SUGrid = new ServerUtilsGrid(); //SUGrid.ColTIME = Convert.ToString(DateTime.Now); //SUGrid.ColMESSAGE = se.Address.ToString(); //form._ServerUtilsGrid.Add(SUGrid); } form.GridControl1.DataSource = form._ServerUtilsGrid; }