public bool SendMail(FlightWeatherResponse flightWeatherResponse) { string body = GetBody(flightWeatherResponse); var subject = MailText.EmailSubject(flightWeatherResponse); using (MMT_WEBS_InteractionManagerSoapClient client = new MMT_WEBS_InteractionManagerSoapClient()) { if (string.IsNullOrWhiteSpace(body)) { return(false); } EMailAttachment[] attachments = null; if (flightWeatherResponse.ItineraryFlightStatus.FlightStatus == "S") { try { attachments = new EMailAttachment[1]; EMailAttachment attachment = new EMailAttachment { Content = MailManager.GetETicketBytes(flightWeatherResponse.ItineraryQueue), ContentId = "E-Ticket", FileName = flightWeatherResponse.ItineraryQueue.BookingID + ".E-Ticket.pdf" }; attachments[0] = attachment; } catch (Exception exception) { ErrorLog.WriteErrorLog(exception, flightWeatherResponse.ItineraryQueue.BookingID, "MMT_WS_FlightWeather"); } } EMailMessage mailMessage = new EMailMessage { To = new[] { flightWeatherResponse.ItineraryQueue.BookingDetails.Email }, Subject = subject, Source = MailText.Source, ReferenceNo = flightWeatherResponse.ItineraryQueue.BookingID, IsBodyHtml = true, Body = body, From = MailText.From, ReferenceType = "BookingID", RequestDate = DateTime.Now, Attachment = attachments, emailType = EmailType.General }; string errorMessage = string.Empty; return(client.SendEmail(mailMessage, ref errorMessage)); } }
public bool[] SendSMS(List <FlightWeatherResponse> flightWeatherResponses) { bool[] isSMSSent = new bool[flightWeatherResponses.Count]; int i = 0; var connectionString = StaticHelperValues.MMTLiveEntitiesConnectionString; using (MMTLiveEntities entities = new MMTLiveEntities(connectionString)) { foreach (SMS_Queue smsQueue in from flightWeatherResponse in flightWeatherResponses let smsText = MailText.GetSMSText(flightWeatherResponse) select new SMS_Queue { Message_ID = Guid.NewGuid().ToString(), Request_Date_Time = DateTime.Now, Sender_Name = MailText.SenderName, //menan TODO: Use ur no menan //Mobile_No_ = "7827334489", Mobile_No_ = flightWeatherResponse.ItineraryQueue.BookingDetails.MobileNo, Message_Text = smsText, Document_No_ = flightWeatherResponse.ItineraryQueue.BookingID, Trigger_Point = MailText.TriggerPoint, Schedule_SMS = 0, LOBID = flightWeatherResponse.ItineraryQueue.BookingDetails.LOBCode, BodyDocument = "", AttachmentDocument = "", Acknowledgement_No_ = "", From = "", To = "", CC = "", BCC = "", Subject = "", Source = MailText.Source, RefrenceType = MailText.ReferenceTypeSMS }) { entities.SMS_Queues.Add(smsQueue); } try { entities.SaveChanges(); isSMSSent[i++] = true; } catch (DbEntityValidationException dbEx) { foreach ( DbValidationError error in dbEx.EntityValidationErrors.SelectMany(entityErr => entityErr.ValidationErrors)) { string errorMessage = string.Format("Error Property Name {0} : Error Message: {1}", error.PropertyName, error.ErrorMessage); ErrorLog.WriteErrorLog(errorMessage, "", "MMT_WS_FlightWeather"); } isSMSSent[i++] = false; } catch (Exception exception) { isSMSSent[i++] = false; foreach (var flightWeatherResponse in flightWeatherResponses) { ErrorLog.WriteErrorLog(exception, flightWeatherResponse.ItineraryQueue.BookingID, "MMT_WS_FlightWeather"); } } } return(isSMSSent); }