private async void EditServiceParameterNumberForm_Load(object sender, EventArgs e) { Enabled = false; using (var channel = ChannelManager.CreateChannel()) { try { if (serviceId != Guid.Empty) { service = await taskPool.AddTask(channel.Service.GetService(serviceId)); } ServiceParameterNumber = serviceParameterNumberId != Guid.Empty ? await taskPool.AddTask(channel.Service.GetServiceParameter(serviceParameterNumberId)) as ServiceParameterNumber : new ServiceParameterNumber() { Service = service, Name = "Новый параметр" }; Enabled = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } }
private async void saveButton_Click(object sender, EventArgs e) { using (var channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; ServiceParameterNumber = await taskPool.AddTask(channel.Service.EditServiceParameterNumber(serviceParameterNumber)); if (Saved != null) { Saved(this, EventArgs.Empty); } } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } finally { saveButton.Enabled = true; } } }