private void Button_SendEmail_Click(object sender, EventArgs e) { if (mainWindow.companyData.emailUsername.Length == 0 || mainWindow.companyData.emailUsername.Length == 0) { messageBoxHelper.showWarning(this, "You cannot send email because you have not entered " + "your email credentials, which are mandatory to send email. Go to Main Window -> Settings -> Add/" + "Change company information to fill email credentials", "Warning"); } else { cancelationTokenSource = new CancellationTokenSource(); Button_Send.Enabled = false; generateSendInfoWindow = new GenerateSendInfoWindow(this); sendingStatus = "GeneratingDocuments"; Timer_StringChanged.Enabled = true; generateSendInfoWindow.Show(); generateSendInfoWindow.BringToFront(); var tasks = new[] { Task.Factory.StartNew(() => GenerateDocumentsAndSendEmails(), cancelationTokenSource.Token) }; //mainWindow.Enabled = true; //this.Dispose(); } }
private async void Button_SendTickets_Click(object sender, EventArgs e) { if (companyData.emailUsername.Length == 0 || companyData.emailUsername.Length == 0) { metroMessageBoxHelper.showWarning(this, "You cannot send email because you have not entered " + "your email credentials, which are mandatory to send email. Go to Main Window -> Settings -> Add/" + "Change company information to fill email credentials", "Warning"); } else { for (int i = 0; i < SendCheckBoxes.Count; i++) { if (SendCheckBoxes[i].Checked) { checkedParticipants.Add(filteredParticipants[i]); } } if (checkedParticipants.Count > 0) { cancelationTokenSource = new CancellationTokenSource(); Button_SendTickets.Enabled = false; generateSendInfoWindow = new GenerateSendInfoWindow(this); sendingStatus = "GeneratingDocuments"; Timer_StringChanged.Enabled = true; generateSendInfoWindow.Show(); generateSendInfoWindow.BringToFront(); var tasks = new[] { Task.Factory.StartNew(() => GenerateDocumentsAndSendEmailsWithTickets(), cancelationTokenSource.Token) }; foreach (Task t in tasks) { await t; } foreach (Participant p in checkedParticipants) { p.ticketSent = true; Participant participant = await participantServices.editParticipant(p); if (participant != null) { int allParticipantsIndex = mainWindow.allParticipants.FindIndex(par => par.participantId.Equals(p.participantId)); int selectedEventParticipantsIndex = 0; int filteredEventParticipantsIndex = 0; if (mainWindow.selectedEventParticipants.Count > 0) { selectedEventParticipantsIndex = mainWindow.selectedEventParticipants.FindIndex(par => par.participantId.Equals(p.participantId)); filteredEventParticipantsIndex = mainWindow.filteredParticipants.FindIndex(par => par.participantId.Equals(p.participantId)); } mainWindow.allParticipants[allParticipantsIndex] = p; if (mainWindow.selectedEventParticipants.Count > 0) { mainWindow.selectedEventParticipants[selectedEventParticipantsIndex] = p; mainWindow.filteredParticipants[filteredEventParticipantsIndex] = p; mainWindow.editParticipantTableRow(participant, filteredEventParticipantsIndex); } } } } else { metroMessageBoxHelper.showWarning(this, "You have not choosen any particicipants, to send emails!", "Warning"); } } //mainWindow.Enabled = true; //this.Dispose(); }