private async void SendMessage() { if (!IsSendButtonEnabled) { return; } if (Message.Attachments != null && Message.Attachments.Any(a => a.IsNotCompleted)) { var errorDialog = MessageBox.Show("Подождите окончания загрузки"); return; } //добавляем полные имена файлов для расшифровки (#имя:ключ,имя:ключ) if (Message.Attachments != null && Message.Attachments.Any()) { Message.Body += '#' + string.Join(",", Message.Attachments.Select(a => a.Document.FullName + ":" + a.EncryptedSymmetricKey).ToList()); } try { IsMessageSending = true; if (string.IsNullOrEmpty(Message.Body) && (Message.Attachments == null || !Message.Attachments.Any())) { return; } if (!string.IsNullOrEmpty(Message.Body)) { var simpleMessage = new Message { Body = Message.Body, UserId = SelectedUser.Id, Out = true, Attachments = Message.Attachments, UnixTime = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, IsNotRead = true }; var cryptedMessage = _cryptTool.MakingEnvelope(Message.Body); Message.Body = cryptedMessage; await _messageService.SendMessage(SelectedUser.Id, Message); Message = new Message(); AddMessages(simpleMessage); } } catch (WebException) { ShowWebErrorMessage(); } finally { IsMessageSending = false; } }