private async void saveButton_Click(object sender, EventArgs e) { using (Channel<IServerTcpService> channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; OperatorInterruption = await taskPool.AddTask(channel.Service.EditOperatorInterruption(operatorInterruption)); 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; } } }
private async void EditOperatorInterruptionForm_Load(object sender, EventArgs e) { typeControl.Initialize<OperatorInterruptionType>(); dayOfWeekControl.Initialize<DayOfWeek>(); try { Enabled = false; using (var channel = ServerUserChannelManager.CreateChannel()) { operatorControl.Initialize(await taskPool.AddTask(channel.Service.GetUserLinks(UserRole.Operator))); } if (operatorInterruptionId != Guid.Empty) { using (var channel = ChannelManager.CreateChannel()) { OperatorInterruption = await taskPool.AddTask(channel.Service.GetOperatorInterruption(operatorInterruptionId)); } } else { OperatorInterruption = new OperatorInterruption() { StartTime = new TimeSpan(12, 0, 0), FinishTime = new TimeSpan(13, 0, 0) }; } } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } finally { Enabled = true; } }