public static EmailMessageModel ConstructAdoptedEmail(Adopter adopter) { var content = ""; var sender = new EmailAddressModel { Name = "Šaponja", Address = "*****@*****.**" }; var receiver = new EmailAddressModel() { Name = adopter.FirstName, Address = adopter.Email }; var email = new EmailMessageModel { Subject = "Odabrani ste kao udomitelj", SenderAddress = sender, ReceiverAddress = receiver, Content = content }; return(email); }
public static EmailMessageModel ConstructDocumentationEmail(Adopter adopter) { var content = ""; var sender = new EmailAddressModel { Name = "Šaponja", Address = "*****@*****.**" }; var receiver = new EmailAddressModel() { Name = adopter.FirstName, Address = adopter.Email }; var email = new EmailMessageModel { Subject = $"Dokumentacija za{adopter.Animal.Name}", SenderAddress = sender, ReceiverAddress = receiver, Content = content, AttachmentPath = adopter.Animal.Shelter.DocumentationFilePath }; return(email); }
public IActionResult SendMail([FromServices] IEmailConfiguration myEmailConfig, [FromForm] string messageContent, [FromForm] string messageSubject, [FromForm] string replyAddress) { var myEmailService = new EmailService(myEmailConfig); var recipient = new EmailAddressModel { Address = "*****@*****.**" }; var sender = new EmailAddressModel { Address = "*****@*****.**" }; var externalSender = new EmailAddressModel { Address = replyAddress }; var myMessage = new EmailMessageModel(); myMessage.ToAddresses.Add(recipient); myMessage.FromAddresses.Add(sender); myMessage.Subject = messageSubject; myMessage.Content = messageContent + " sent from: " + replyAddress; myMessage.FromAddresses.Add(externalSender); myEmailService.Send(myMessage); return(View()); }
public ActionResult ForgotPassword(EmailAddressModel model) { if (ModelState.IsValid) { // Attempt to send the user a password email try { _membershipProvider.GeneratePasswordResetToken(model.EmailAddress); } catch (MembershipException) { ModelState.AddModelError("EmailAddress", "User not found."); return(View()); } try { User user = _membershipProvider.GetUserByEmailAddress(model.EmailAddress); _mailer.SendPasswordResetAsync(user); } catch (Exception ex) { ModelState.AddModelError("", "Unable to send password reset email."); ex.ToExceptionless().SetUserEmail(model.EmailAddress).Submit(); return(View()); } ViewBag.EmailSent = true; return(View()); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> GetMailForAllAccounts() { if (User.Identity.IsAuthenticated) { ApplicationUser user = Manager.FindById(User.Identity.GetUserId()); var emails = applicationDbContext.EmailModels.Where(x => x.User.Id == user.Id); var messages = new System.Collections.Generic.List <EmailMessage>(); foreach (var mail in emails) { var addressModel = new EmailAddressModel { Email = mail.Email, Password = mail.Password, PopPort = 995 }; // TODO: change await var mList = await apiGateway.GetMessagesPop3(addressModel); messages.AddRange(mList); } return(View("AllMail", messages)); } return(View("Index")); }
public ConversationMessageDetails(ConversationMessageModel message) { this.Dispatcher.Invoke(() => { InitializeComponent(); DetailsTable.AddItem("Data: ", message.InitialDate.Value.ToString("dd.MM.yyyy HH:mm")); if (message.Attachments.Count == 0) { AttachmentListContainer.Visibility = Visibility.Collapsed; } else { foreach (FileModel attachment in message.Attachments) { FileListItem listItem = new FileListItem(attachment); listItem.AllowDelete = false; listItem.AllowDownload = false; listItem.AllowRename = false; listItem.AllowSelect = false; AttachmentList.Children.Add(listItem); } } if (message is ConversationEmailMessageModel) { ConversationEmailMessageModel emailMessage = (ConversationEmailMessageModel)message; EmailAddressModel email = message.Author.EmailAddresses.Find(obj => obj.Id == message.AuthorFrom); DetailsTable.AddItem("Od: ", message.Author.FullName + " <" + email.Address + ">"); SubjectLabel.Text = emailMessage.MessageSubject; MessageContainer.Text = emailMessage.MessageContent; } else if (message is ConversationPhoneMessageModel) { ConversationPhoneMessageModel phoneMessage = (ConversationPhoneMessageModel)message; DetailsTable.AddItem("Od: ", message.Author.FullName + " (" + phoneMessage.AuthorPhoneNumber.Number + ")"); DetailsTable.AddItem("Do: ", phoneMessage.Recipient.FullName + " (" + phoneMessage.RecipientPhoneNumber.Number + ")"); SubjectLabelContainer.Visibility = Visibility.Collapsed; if (!phoneMessage.CallAnswered) { CallUnansweredContainer.Visibility = Visibility.Visible; } MessageContainer.Margin = new Thickness(MessageContainer.Margin.Left, 10, MessageContainer.Margin.Right, MessageContainer.Margin.Bottom); MessageContainer.Text = phoneMessage.CallDescription; } CloseButton.PreviewMouseLeftButtonDown += CloseButton_PreviewMouseLeftButtonDown; CloseButton.MouseEnter += CloseButton_MouseEnter; CloseButton.MouseLeave += CloseButton_MouseLeave; }); }
public JsonResult EditEmailAddress(EmailAddressModel EmailAddress) { var input = EmailAddressMapper.EditEmailAddress(EmailAddress); var response = EmailAddressService.EditEmailAddress(input); return(new JsonResult(response) { StatusCode = response.StatusCode }); }
public void SendMessages(EmailAddressModel model, List <EmailMessage> messages) { var mailListContainer = new MailListContainer(model, messages); var serialized = _jsonConverter.SerializeMailListContainer(mailListContainer); var bytes = Encoding.UTF8.GetBytes(serialized); var pair = _connectionsDictionary.Where(x => x.Key.Equals("spammer")); var channel = pair.First().Value; channel.BasicPublish("", "spammer", null, bytes); }
public EmailAddress GetEmailAddress(EmailAddressModel emailAddress) { var emailAddressFromDb = _context.EmailAddresses .Where(e => e.Email == emailAddress.Email) .Select(e => e) .SingleOrDefault(); if (emailAddressFromDb.Name != emailAddress.Name) { emailAddressFromDb.Name = emailAddress.Name; } return(emailAddressFromDb); }
public void SendMessage(EmailAddressModel model, EmailMessage wrapMessage) { var container = new Container(model, wrapMessage); string data = _jsonConverter.ConvertContainer(container); byte[] bytes = Encoding.UTF8.GetBytes(data); var pair = _connectionsDictionary.Where(x => x.Key.Equals("smtp sender")); var channel = pair.First().Value; channel.BasicPublish(exchange: "", routingKey: "sender", basicProperties: null, body: bytes); }
// Returns the email address entity from the database correlating to the provided email public EmailAddress GetEmailAddress(EmailAddressModel emailAddress) { var emailAddressFromDb = _context.EmailAddresses .Where(e => e.Email == emailAddress.Email) .Select(e => e) .SingleOrDefault(); // If name from database isn't the same as the received name, change it to the newly received name if (emailAddressFromDb.Name != emailAddress.Name) { emailAddressFromDb.Name = emailAddress.Name; } return(emailAddressFromDb); }
public void SendMessagesAtTime(EmailAddressModel model, List <EmailMessage> messages, DateTime time) { var container = new TimerListContainer { info = model, list = messages, time = time }; var serialized = _jsonConverter.SerizlizeTimerListContainer(container); var bytes = Encoding.UTF8.GetBytes(serialized); var pair = _connectionsDictionary.Where(x => x.Key.Equals("mass_timer")); var channel = pair.First().Value; channel.BasicPublish("", "mass_timer", null, bytes); }
public static EmailAddress ToDomain(this EmailAddressModel model, EmailAddress domain) { if (model != null) { domain.Id = model.Id; domain.Address = model.Address; domain.IsPrimary = model.IsPrimary; if (model.Type != null) { domain.Type.Id = model.Type.Id; } } return(domain); }
private void _contactList_PersonShowDetails(object sender, EventArgs e) { ContactPersonListItem personItem = (ContactPersonListItem)sender; PersonDetails details = new PersonDetails(_parent, personItem.Person); details.ReadyButtonClicked += (s, ea) => { List <PersonDetailListItem> emailItems = details.EmailItems; List <PersonDetailListItem> phoneItems = details.PhoneItems; foreach (PersonDetailListItem detail in emailItems) { EmailAddressModel emailAdress = (EmailAddressModel)detail.ChildObject; emailAdress.Name = detail.Name; emailAdress.Address = detail.DetailValue; detail.ChildObject = emailAdress; } foreach (PersonDetailListItem detail in phoneItems) { PhoneNumberModel phoneNumber = (PhoneNumberModel)detail.ChildObject; phoneNumber.Name = detail.Name; phoneNumber.Number = detail.DetailValue; detail.ChildObject = phoneNumber; } _parent.Client.UpdatePersonDetails(details.Person.Id, details.FirstNameTextBox.Text, details.LastNameTextBox.Text, details.GenderComboBox.SelectedItem == details.GenderComboBox.Items.First() ? Gender.Female : Gender.Male, details.Company, details.EmailItems.Select(obj => (EmailAddressModel)obj.ChildObject).ToList(), details.PhoneItems.Select(obj => (PhoneNumberModel)obj.ChildObject).ToList()); _parent.Darkened = false; _parent.mainCanvas.Children.Remove(details); }; details.CancelButtonClicked += (s, ea) => { _parent.Darkened = false; _parent.mainCanvas.Children.Remove(details); }; _parent.Darkened = true; _parent.mainCanvas.Children.Add(details); }
public static EmailAddressModel ToModel(this EmailAddress domain) { var model = new EmailAddressModel(); if (domain != null) { model.Id = domain.Id; model.Address = domain.Address; model.IsPrimary = domain.IsPrimary; if (domain.Type != null) { model.Type = domain.Type.ToModel(); } } return(model); }
public static EmailAddress ToDomain(this EmailAddressModel model) { var domain = new EmailAddress(); if (model != null) { domain.Id = model.Id; domain.Address = model.Address; domain.IsPrimary = model.IsPrimary; if (model.Type != null) { domain.Type = model.Type.ToDomain(); } } return(domain); }
private EmailAddresses getEmails(SqlDataReader reader, int count, List <string> mappings) { EmailAddresses addresses = new EmailAddresses(); for (int i = 0; i < count; i++) { try { EmailAddressModel email = new EmailAddressModel(); email.EmailAddress = reader[mappings[i]].ToString(); email.EmailType = i + 1; addresses.EmailAddress.Add(email); } catch (Exception ex) { throw new WebFaultException <string>(string.Format("Column <{0}> not found in query results: {1}", mappings[i], ex.Message), HttpStatusCode.InternalServerError); } } return(addresses); }
public List <EmailMessage> GetMessagesPop3Indexed(EmailAddressModel info, int index) { string data = _jsonConverter.ConvertIndexContainer(new IndexContainer(info, index)); byte[] bytes = Encoding.UTF8.GetBytes(data); var pair = _connectionsDictionary.Where(x => x.Key.Equals("pop3indexed")); var channel = pair.First().Value; channel.BasicPublish(string.Empty, "recv_pop3_indexed", null, bytes); _userMessages = null; while (_userMessages == null) { Thread.Sleep(10); } var list = new List <EmailMessage>(_userMessages); return(list); }
// TODO: Thread.Sleep(10); public async Task <List <EmailMessage> > GetMessagesPop3(EmailAddressModel info) { string data = _jsonConverter.ConvertAccontInfo(info); byte[] bytes = Encoding.UTF8.GetBytes(data); var pair = _connectionsDictionary.Where(x => x.Key.Equals("pop recv")); var channel = pair.First().Value; channel.BasicPublish(string.Empty, "recv_pop3", null, bytes); _userMessages = null; while (_userMessages == null) { await Task.Delay(10); } var list = new List <EmailMessage>(_userMessages); return(list); }
public void GetEmailAddress_ShouldReturnEmailAddressFromDb() { SeedEmailAddresses(); var repository = new EmailRepository(_context); // Test case var testEmailAddress = new EmailAddressModel() { Name = "Mike C", Email = "*****@*****.**" }; var actualEmailAddress = repository.GetEmailAddress(testEmailAddress); // Assert Assert.True(actualEmailAddress != null); Assert.True(testEmailAddress.Name != testEmailAddress.Email); Assert.True(actualEmailAddress.Name != actualEmailAddress.Email); Assert.Equal(testEmailAddress.Email, actualEmailAddress.Email); Assert.Equal(testEmailAddress.Name, actualEmailAddress.Name); }
public static EmailMessageModel ConstructConfirmationEmail(Adopter adopter) { var content = EmailContent.Confirmation(adopter.ConfirmationToken); //use razor or some file later var sender = new EmailAddressModel { Name = "Šaponja", Address = "*****@*****.**" }; var receiver = new EmailAddressModel() { Name = adopter.FirstName, Address = adopter.Email }; var email = new EmailMessageModel { Subject = "Potvrdite email", SenderAddress = sender, ReceiverAddress = receiver, Content = content }; return(email); }
public EmailAddressModel GenerateEmailAddressModelById(int emailAddressId) { try { EmailAddressModel model = new EmailAddressModel(); using (VenturadaDataContext vdc = new VenturadaDataContext()) { var table = from p in vdc.EmailAddresses.ToList() where p.EmailAddressId == emailAddressId select p; model = new EmailAddressModel(); model.EmailAddressId = table.FirstOrDefault().EmailAddressId; model.EmailAddress = table.FirstOrDefault().EmailAddress1; return(model); } } catch (Exception ex) { throw ex; } }
void TestEmailAddressInvalidRegex(string emailAddress) { Assert.False(EmailAddressModel.Validate(emailAddress)); }
public ActionResult Send() { PatientModel viewModel = new PatientModel(); viewModel.Username = "******"; viewModel.Password = "******"; viewModel.Birthday = Convert.ToDateTime("2017-04-07"); viewModel.Active = true; viewModel.InvitedToPortal = true; viewModel.LanguageName = "English"; var _lstString = new List <string>(); var _lstMainLocations = new List <LocationModel>(); var _locations = new LocationModel(); for (int i = 30; i < 31; i++) { _locations.ExternalId = i.ToString(); _lstMainLocations.Add(_locations); } foreach (var _locitem in _lstMainLocations) { _lstString.Add(_locations.ExternalId); } viewModel.Locations = _lstString; viewModel.Contact = new ContactModel(); viewModel.Contact.Id = Guid.NewGuid(); viewModel.Contact.FirstName = "changala"; viewModel.Contact.MiddleName = "e"; viewModel.Contact.LastName = "Prabhakar"; viewModel.Contact.Suffix = "suf"; viewModel.Contact.Prefix = "pre"; viewModel.Contact.FullName = "changala prabhakar"; viewModel.Contact.CompanyName = "sample string 8"; viewModel.Contact.JobTitle = "se"; viewModel.Contact.Notes = "intellegent"; viewModel.Contact.EmailAddresses = new List <EmailAddressModel>(); var _emaillist = new EmailAddressModel(); _emaillist.Id = Guid.NewGuid(); _emaillist.Address = "*****@*****.**"; _emaillist.Default = true; viewModel.Contact.EmailAddresses.Add(_emaillist); viewModel.Last4SSN = "1234"; viewModel.ExternalId = "49"; try { var success = PatientProvider.Save(Helpers.GetAuthenticator(), viewModel); //viewModel.ResultMessage = !success ? Resources.UnsuccesfullySaved : Resources.SuccesfullySaved; } catch (Exception ex) { //viewModel.ErrorMessage = ex.GetBaseException().Message; } //viewModel.Criteria.Add("FullName", string.Empty); //viewModel.Criteria.Add("Birthday", string.Empty); //viewModel.Criteria.Add("Active", string.Empty); return(View("Index", viewModel)); }
public void Receiver() { try { string conversationId = ""; string id = ""; bool notifyContactPersons = false; string emailId = ""; string emailAddress = ""; while (_client.Connected) { byte response = _reader.ReadByte(); switch (response) { case MessageDictionary.NewNotification: _writer.Write(MessageDictionary.OK); List <string> referenceFields = new List <string>(); string notificationId = _reader.ReadString(); string notificationText = _reader.ReadString(); DateTime notificationDate = DateTime.ParseExact(_reader.ReadString(), "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture); int referenceFieldCount = _reader.ReadInt32(); for (int i = 0; i < referenceFieldCount; i++) { referenceFields.Add(_reader.ReadString()); } if (_reader.Read() == MessageDictionary.EndOfMessage) { switch (_reader.ReadByte()) { #region NewMessage case MessageDictionary.NewMessage: id = _reader.ReadString(); conversationId = _reader.ReadString(); string authorId = _reader.ReadString(); string authorFrom = _reader.ReadString(); string initialDateString = _reader.ReadString(); byte[] previewData = ReceiveFile(); List <string> attachmentIds = new List <string>(); int attachmentCount = _reader.ReadInt32(); for (int j = 0; j < attachmentCount; j++) { attachmentIds.Add(_reader.ReadString()); } MemoryStream stream = new MemoryStream(previewData); BitmapImage previewImage = new BitmapImage(); previewImage.BeginInit(); previewImage.StreamSource = stream; previewImage.EndInit(); previewImage.Freeze(); byte type = _reader.ReadByte(); DateTime initialDate = DateTime.ParseExact(initialDateString, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture); ConversationMessageModel message = new ConversationMessageModel(id, conversationId, authorId, authorFrom, initialDate, true, previewImage, false, attachmentIds); switch (type) { case MessageDictionary.MessageTypeEmail: string subject = _reader.ReadString(); string content = _reader.ReadString(); ConversationEmailMessageModel emailMessage = new ConversationEmailMessageModel(message, subject, content); message = emailMessage; break; case MessageDictionary.MessageTypePhoneCall: string recipientPhoneNumber = _reader.ReadString(); string description = _reader.ReadString(); bool answered = _reader.ReadBoolean(); ConversationPhoneMessageModel phoneMessage = new ConversationPhoneMessageModel(message, recipientPhoneNumber, description, answered); message = phoneMessage; break; } NewConversationMessageArrived?.Invoke(this, new NewConversationMessageArrivedEventArgs() { Message = message, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RenameConversation case MessageDictionary.RenameConversation: conversationId = _reader.ReadString(); string oldName = _reader.ReadString(); string newName = _reader.ReadString(); ConversationRenamed?.Invoke(this, new ConversationRenamedEventArgs() { ConversationId = conversationId, OldName = oldName, NewName = newName, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RenameFile case MessageDictionary.RenameFile: conversationId = _reader.ReadString(); oldName = _reader.ReadString(); newName = _reader.ReadString(); FileRenamed?.Invoke(this, new FileRenamedEventArgs() { FileId = conversationId, OldName = oldName, NewName = newName, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region AddConversationMembers case MessageDictionary.AddConversationMembers: conversationId = _reader.ReadString(); string personId = _reader.ReadString(); string personColor = _reader.ReadString(); ConversationMembersAdded?.Invoke(this, new ConversationMembersAddedEventArgs() { ConversationId = conversationId, PersonId = personId, PersonColor = personColor, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RemoveConversationMember case MessageDictionary.RemoveConversationMember: conversationId = _reader.ReadString(); personId = _reader.ReadString(); ConversationMemberRemoved?.Invoke(this, new ConversationMemberRemovedEventArgs() { ConversationId = conversationId, PersonId = personId, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region ConversationSettingsChanged case MessageDictionary.ChangeConversationSettings: conversationId = _reader.ReadString(); notifyContactPersons = _reader.ReadBoolean(); ConversationSettingsChanged?.Invoke(this, new ConversationSettingsChangedEventArgs() { ConversationId = conversationId, NotifyContactPersons = notifyContactPersons, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region NewCompany case MessageDictionary.NewCompany: string companyId = _reader.ReadString(); string companyName = _reader.ReadString(); NewCompanyArrived?.Invoke(this, new NewCompanyEventArgs() { Company = new CompanyModel(companyId, companyName), Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RenameCompany case MessageDictionary.RenameCompany: companyId = _reader.ReadString(); newName = _reader.ReadString(); CompanyRenamed?.Invoke(this, new CompanyRenamedEventArgs() { CompanyId = companyId, NewName = newName, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RemoveCompanyEvent case MessageDictionary.RemoveCompany: companyId = _reader.ReadString(); CompanyRemoved?.Invoke(this, new CompanyRemovedEventArgs() { CompanyId = companyId, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region UpdatePersonDetails case MessageDictionary.UpdatePersonDetails: string PersonId = _reader.ReadString(); string PersonFirstName = _reader.ReadString(); string PersonLastName = _reader.ReadString(); string PersonGenderCode = _reader.ReadString(); string PersonCompanyId = _reader.ReadString(); Gender PersonGender = (Gender)Convert.ToInt32(PersonGenderCode); PersonModel contactPerson = new PersonModel(PersonId, PersonFirstName, PersonLastName, PersonGender, PersonCompanyId, true); int emailAddressCount = _reader.ReadInt32(); for (int j = 0; j < emailAddressCount; j++) { emailId = _reader.ReadString(); string emailName = _reader.ReadString(); emailAddress = _reader.ReadString(); EmailAddressModel emailAddressModel = new EmailAddressModel(emailId, emailAddress, emailName); contactPerson.EmailAddresses.Add(emailAddressModel); } int phoneNumberCount = _reader.ReadInt32(); for (int j = 0; j < phoneNumberCount; j++) { string phoneNumberId = _reader.ReadString(); string phoneName = _reader.ReadString(); string phoneNumber = _reader.ReadString(); PhoneNumberModel phoneNumberModel = new PhoneNumberModel(phoneNumberId, phoneNumber, phoneName); contactPerson.PhoneNumbers.Add(phoneNumberModel); } ContactDetailsUpdated?.Invoke(this, new ContactDetailsUpdatedEventArgs() { NewData = contactPerson, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region NewExternalContact case MessageDictionary.NewExternalContact: _writer.Write(MessageDictionary.OK); PersonId = _reader.ReadString(); PersonFirstName = _reader.ReadString(); PersonLastName = _reader.ReadString(); PersonGenderCode = _reader.ReadString(); PersonCompanyId = _reader.ReadString(); PersonGender = (Gender)Convert.ToInt32(PersonGenderCode); contactPerson = new PersonModel(PersonId, PersonFirstName, PersonLastName, PersonGender, PersonCompanyId, true); emailAddressCount = _reader.ReadInt32(); for (int j = 0; j < emailAddressCount; j++) { emailId = _reader.ReadString(); string emailName = _reader.ReadString(); emailAddress = _reader.ReadString(); EmailAddressModel emailAddressModel = new EmailAddressModel(emailId, emailAddress, emailName); contactPerson.EmailAddresses.Add(emailAddressModel); } phoneNumberCount = _reader.ReadInt32(); for (int j = 0; j < phoneNumberCount; j++) { string phoneNumberId = _reader.ReadString(); string phoneName = _reader.ReadString(); string phoneNumber = _reader.ReadString(); PhoneNumberModel phoneNumberModel = new PhoneNumberModel(phoneNumberId, phoneNumber, phoneName); contactPerson.PhoneNumbers.Add(phoneNumberModel); } NewExternalContact?.Invoke(this, new NewExternalContactEventArgs() { NewData = contactPerson, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region NewExternalContact case MessageDictionary.RemoveExternalContact: personId = _reader.ReadString(); ExternalContactRemoved?.Invoke(this, new ExternalContactRemovedEventArgs() { PersonId = personId, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion #region RemoveConversation case MessageDictionary.RemoveConversation: _writer.Write(MessageDictionary.OK); conversationId = _reader.ReadString(); ConversationRemoved?.Invoke(this, new ConversationRemovedEventArgs() { ConversationId = conversationId, Notification = new NotificationModel(notificationId, notificationText, referenceFields, notificationDate, false) }); break; #endregion } } break; #region NewFiles case MessageDictionary.NewFiles: List <FileModel> files = new List <FileModel>(); files.Clear(); _writer.Write(MessageDictionary.OK); int fileCount = _reader.ReadInt32(); for (int i = 0; i < fileCount; i++) { conversationId = _reader.ReadString(); id = _reader.ReadString(); string name = _reader.ReadString(); string contentType = _reader.ReadString(); long size = _reader.ReadInt64(); string dateAdded = _reader.ReadString(); FileModel file = new FileModel(id, name, new ContentType(contentType), size, DateTime.ParseExact(dateAdded, "dd-MM-yyyy", CultureInfo.InvariantCulture)) { ConversationId = conversationId }; files.Add(file); } NewFilesArrived?.Invoke(this, new NewFilesArrivedEventArgs() { Files = files }); break; #endregion #region NewConversation case MessageDictionary.NewConversation: _writer.Write(MessageDictionary.OK); conversationId = _reader.ReadString(); string conversationName = _reader.ReadString(); string visibleId = _reader.ReadString(); string dateCreatedString = _reader.ReadString(); notifyContactPersons = _reader.ReadBoolean(); DateTime dateCreated = DateTime.ParseExact(dateCreatedString, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture); int memberCount = _reader.ReadInt32(); List <string> memberIds = new List <string>(); List <string> memberColors = new List <string>(); for (int j = 0; j < memberCount; j++) { string memberId = _reader.ReadString(); string memberColor = _reader.ReadString(); memberIds.Add(memberId); memberColors.Add(memberColor); } List <ConversationMessageModel> messages = new List <ConversationMessageModel>(); if (_reader.Read() == MessageDictionary.OK) { int messageCount = _reader.ReadInt32(); for (int i = 0; i < messageCount; i++) { id = _reader.ReadString(); string authorId = _reader.ReadString(); string authorFrom = _reader.ReadString(); string initialDateString = _reader.ReadString(); Boolean received = _reader.ReadBoolean(); byte[] previewData = ReceiveFile(); List <string> attachmentIds = new List <string>(); int attachmentCount = _reader.ReadInt32(); for (int j = 0; j < attachmentCount; j++) { attachmentIds.Add(_reader.ReadString()); } MemoryStream stream = new MemoryStream(previewData); BitmapImage previewImage = new BitmapImage(); previewImage.BeginInit(); previewImage.StreamSource = stream; previewImage.EndInit(); previewImage.Freeze(); DateTime initialDate = DateTime.ParseExact(initialDateString, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture); ConversationMessageModel message = new ConversationMessageModel(id, conversationId, authorId, authorFrom, initialDate, received, previewImage, false, attachmentIds); byte type = _reader.ReadByte(); if (type == MessageDictionary.MessageTypeEmail) { string subject = _reader.ReadString(); string content = _reader.ReadString(); ConversationEmailMessageModel emailMessage = new ConversationEmailMessageModel(message, subject, content); message = emailMessage; } else if (type == MessageDictionary.MessageTypePhoneCall) { string recipientPhoneNumber = _reader.ReadString(); string callDescription = _reader.ReadString(); bool callAnswered = _reader.ReadBoolean(); ConversationPhoneMessageModel phoneMessage = new ConversationPhoneMessageModel(message, recipientPhoneNumber, callDescription, callAnswered); message = phoneMessage; } if (message != null) { messages.Add(message); } } if (_reader.Read() == MessageDictionary.EndOfMessage) { ConversationModel conversation = new ConversationModel(conversationId, conversationName, visibleId, dateCreated, memberIds, memberColors, notifyContactPersons); messages.ForEach(obj => conversation.AddMessage(obj)); NewConversationArrived?.Invoke(this, new NewConversationArrivedEventArgs() { Conversation = conversation }); } } break; #endregion #region RemoveConversation case MessageDictionary.RemoveConversation: _writer.Write(MessageDictionary.OK); conversationId = _reader.ReadString(); ConversationRemoved?.Invoke(this, new ConversationRemovedEventArgs() { ConversationId = conversationId }); break; #endregion #region NewEmailAddress case MessageDictionary.AddEmailAddress: _writer.Write(MessageDictionary.OK); emailId = _reader.ReadString(); emailAddress = _reader.ReadString(); string login = _reader.ReadString(); string imapHost = _reader.ReadString(); int imapPort = _reader.ReadInt32(); bool imapUseSel = _reader.ReadBoolean(); string smtpHost = _reader.ReadString(); int smtpPort = _reader.ReadInt32(); bool smtpUseSsl = _reader.ReadBoolean(); string addressName = _reader.ReadString(); NewEmailAddress?.Invoke(this, new NewEmailAddressEventArgs() { Id = emailId, Login = login, Address = emailAddress, ImapHost = imapHost, ImapPort = imapPort, ImapUseSsl = imapUseSel, SmtpHost = smtpHost, SmtpPort = smtpPort, SmtpUseSsl = smtpUseSsl, Name = addressName }); break; #endregion } } } catch (Exception ex) { MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace); ErrorHelper.LogError(ex); Logout(); } }
public string ConvertAccontInfo(EmailAddressModel accountInfo) { string data = JsonConvert.SerializeObject(accountInfo); return(data); }
public ParticipantModel(EmailAddressModel emailAddress) { EmailAddress = emailAddress; }
private void AddButton_Click(object sender, EventArgs e) { switch (ContactTabControl.SelectedMode) { case ContactTabControlMode.Contacts: PersonDetails details = new PersonDetails(_parent, null); details.ReadyButtonClicked += (s, ea) => { List <PersonDetailListItem> emailItems = details.EmailItems; List <PersonDetailListItem> phoneItems = details.PhoneItems; foreach (PersonDetailListItem detail in emailItems) { EmailAddressModel emailAdress = (EmailAddressModel)detail.ChildObject; emailAdress.Name = detail.Name; emailAdress.Address = detail.DetailValue; detail.ChildObject = emailAdress; } foreach (PersonDetailListItem detail in phoneItems) { PhoneNumberModel phoneNumber = (PhoneNumberModel)detail.ChildObject; phoneNumber.Name = detail.Name; phoneNumber.Number = detail.DetailValue; detail.ChildObject = phoneNumber; } _parent.Client.AddExternalContact(details.FirstNameTextBox.Text, details.LastNameTextBox.Text, details.GenderComboBox.SelectedItem == details.GenderComboBox.Items.First() ? Gender.Female : Gender.Male, details.Company, details.EmailItems.Select(obj => (EmailAddressModel)obj.ChildObject).ToList(), details.PhoneItems.Select(obj => (PhoneNumberModel)obj.ChildObject).ToList()); _parent.Darkened = false; _parent.mainCanvas.Children.Remove(details); }; details.CancelButtonClicked += (s, ea) => { _parent.Darkened = false; _parent.mainCanvas.Children.Remove(details); }; _parent.Darkened = true; _parent.mainCanvas.Children.Add(details); break; case ContactTabControlMode.Companies: Rename newCompany = new Rename(); _parent.Darkened = true; newCompany.CancelButtonClicked += (s, ea) => { _parent.Darkened = false; _parent.mainCanvas.Children.Remove(newCompany); }; newCompany.ReadyButtonClicked += (s, ea) => { string companyName = newCompany.NewName; _parent.Client.AddNewCompany(companyName); _parent.Darkened = false; _parent.mainCanvas.Children.Remove(newCompany); }; _parent.mainCanvas.Children.Add(newCompany); break; case ContactTabControlMode.InternalContacts: NewInternalUser newInternalUser = new NewInternalUser(_parent); newInternalUser.ReadyButtonClicked += (s, ea) => { //_parent.Client.AddExternalContact(newInternalUser.FirstNameTextBox.Text, // newInternalUser.LastNameTextBox.Text, // newInternalUser.GenderComboBox.SelectedItem == details.GenderComboBox.Items.First() // ? Gender.Female); string hashedLogin = CryptographyHelper.HashString(newInternalUser.PasswordTextBox.Text, 0); string hashedPassword = CryptographyHelper.HashString(newInternalUser.PasswordTextBox.Text); _parent.Client.AddInternalContact(newInternalUser.FirstNameTextBox.Text, newInternalUser.LastNameTextBox.Text, newInternalUser.GenderComboBox.SelectedItem == newInternalUser.GenderComboBox.Items.First() ? Gender.Female : Gender.Male, hashedLogin, hashedPassword, newInternalUser.AdministratorCheckBox.Selected); _parent.Darkened = false; _parent.mainCanvas.Children.Remove(newInternalUser); }; newInternalUser.CancelButtonClicked += (s, ea) => { _parent.Darkened = false; _parent.mainCanvas.Children.Remove(newInternalUser); }; _parent.Darkened = true; _parent.mainCanvas.Children.Add(newInternalUser); break; } }
public static EmailAddress SaveEmailAddress(EmailAddressModel emailAddressModel) { return(Mapper.Map(emailAddressModel, new EmailAddress())); }
void TestEmailAddressValidRegex(string emailAddress) { Assert.True(EmailAddressModel.Validate(emailAddress)); }