private bool ValidateSchedule(UploadedFile attachment, FlightScheduleEngine scheduleEngine, User user, string[] emails) { bool valid = true; //validate before upload var missingEquipmentCode = scheduleEngine.ValidateSchedulePlan(attachment.InputStream); if (missingEquipmentCode.Count > 0) { //Loop with comma separated value var missingCode = string.Empty; for (int j = 0; j < missingEquipmentCode.Count; j++) { missingCode += missingEquipmentCode[j] + ","; } //send email var misingEquipmentMessage = EmailHelper.MissingEquipmentEmailTemplate; misingEquipmentMessage = EmailHelper.ConvertMail2(misingEquipmentMessage, missingCode, "\\[EQUIPMENTS\\]"); EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- Flight Schedule Validation - " + attachment.FileName, misingEquipmentMessage); foreach (var email in emails) { if (!string.IsNullOrEmpty(email)) { EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Flight Schedule Validation - " + attachment.FileName, misingEquipmentMessage); } } valid = false; } return(valid); }
private bool ValidateSchedule() { bool valid = true; FlightScheduleEngine scheduleEngine = new FlightScheduleEngine(); //validate before upload Stream stream = System.IO.File.OpenRead(txtBoxFileName.Text); var missingEquipmentCode = scheduleEngine.ValidateSchedulePlan(stream); if (missingEquipmentCode.Count > 0) { //Loop with comma separated value var missingCode = string.Empty; for (int j = 0; j < missingEquipmentCode.Count; j++) { missingCode += missingEquipmentCode[j] + ","; } MessageBox.Show("Invalid schedule - Missing Equipments: " + missingCode); valid = false; } return(valid); }
/// <summary> /// Upload excel for flight schedule /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void UploadScheduleBtnClicked(object sender, EventArgs e) { if (RadAsyncUploadSchedule.UploadedFiles.Count == 0) { return; } UploadedFile attachment = RadAsyncUploadSchedule.UploadedFiles[0]; bool validInput = InvalidUploadInput(); if (!validInput) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "InValidUploadFile", "InValidUploadFile();", true); return; } int userId = Convert.ToInt32(Session["USERID"]); var user = _accountManagement.GetUserById(userId); FlightScheduleEngine scheduleEngine = new FlightScheduleEngine(); string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]); var emails = notificationEmails.Split(new char[] { ';' }); //validate before upload bool valid = ValidateSchedule(attachment, scheduleEngine, user, emails); if (!valid) { return; } //valid schedule, upload it scheduleEngine.UploadFlightSchedule(attachment.InputStream, chkClearFlightSchedule.Checked); var defaultMessage = EmailHelper.FlightScheduleUploadTemplate; EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- Flight Schedule Upload - " + attachment.FileName, defaultMessage); foreach (var email in emails) { if (!string.IsNullOrEmpty(email)) { EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Flight Schedule Upload - " + attachment.FileName, defaultMessage); } } ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "UploadCompleted", "UploadCompleted();", true); }