private async void EditAdministratorForm_Load(object sender, EventArgs e) { if (administratorId != Guid.Empty) { Enabled = false; try { using (var channel = UserChannelManager.CreateChannel()) { Administrator = await taskPool.AddTask(channel.Service.GetUser(administratorId)) as QueueAdministrator; } 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); } } else { Administrator = new QueueAdministrator() { Surname = "Новый пользователь", IsActive = true }; } }
private async void saveButton_Click(object sender, EventArgs e) { try { saveButton.Enabled = false; using (var channel = UserChannelManager.CreateChannel()) { Administrator = await taskPool.AddTask(channel.Service.EditAdministrator(administrator)); } 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; } }