public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); var lastNowTime = lastNow.TimeOfDay; if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { if (scheduleItem.StartTime < scheduleItem.EndTime) { var tempEndDate = new DateTime(lastNow.Year, lastNow.Month, lastNow.Day, scheduleItem.EndTime.Hours, scheduleItem.EndTime.Minutes, scheduleItem.EndTime.Seconds); var minEndTime = new DateTime[] { now.AddMinutes(notificationDefinition.SendEndDuration), tempEndDate }.Min(); if (lastNowTime.IsBetween(scheduleItem.StartTime, scheduleItem.EndTime) && scheduleItem.Days.Contains((int)lastNow.DayOfWeek)) { startTime = lastNow; endTime = minEndTime; isValid = true; break; } } } } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); //lastNow degerini kullaniyoruz. DateTime.Now'a eklenen sure ile gun bilgisi degisebilir var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); var lastNowTime = lastNow.TimeOfDay; if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { if (scheduleItem.StartTime < scheduleItem.EndTime) { var residualMinutes = scheduleItem.StartTime.Subtract(now.TimeOfDay).TotalMinutes; residualMinutes = Math.Abs(residualMinutes); if (residualMinutes < notificationDefinition.SendEndDuration && scheduleItem.Days.Contains((int)lastNow.DayOfWeek)) { startTime = lastNow.AddMinutes(residualMinutes); endTime = lastNow.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } } } } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public void Constructor_Allows_Valid_Input(string topic, Type bodyType, Enum enumValue) { var definition = new NotificationDefinition(topic, bodyType, enumValue); Assert.Equal(definition.Topic, topic); Assert.Equal(definition.BodyType, bodyType); Assert.Equal(definition.EnumValue, enumValue); }
// Read smtp server configuration from config file. internal SmtpClient ReadSMTPConfigurationInfo(NotificationDefinition message) { SmtpClient SmtpServer = new SmtpClient(message.SMTPServer); SmtpServer.Credentials = new NetworkCredential(message.SMTPServerCredentialID, message.SMTPServerCredentialPwd); SmtpServer.Timeout = 20000000; SmtpServer.EnableSsl = false; return(SmtpServer); }
public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); NotificationDateValidationInfo validDateInfo = new NotificationDateValidationInfo(); validDateInfo.SendStartTime = startTime; validDateInfo.SendEndTime = endTime; validDateInfo.isValid = isValid; var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); int today = (int)lastNow.DayOfWeek; List <int> combinedScheduleDays = new List <int>(); int scheduleLoopCount = 0; if (NotificationDateValidator.GetSchedulingWaitingStatus(notificationDefinition)) { if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { scheduleLoopCount++; if (notificationDefinition.Schedules.Count == 1) { if (!scheduleItem.Days.Contains(today)) // 1,2,3,4,5,6,0 { validDateInfo = SetStartAndEndTime(scheduleItem.Days.ToList(), scheduleItem, today, lastNow, startTime, endTime, isValid, notificationDefinition); } } else { if (notificationDefinition.Schedules.Count > 1) { if (!scheduleItem.Days.Contains(today)) { combinedScheduleDays = combinedScheduleDays.Union(scheduleItem.Days.ToList()).ToList(); if (scheduleLoopCount == notificationDefinition.Schedules.Count) { validDateInfo = SetStartAndEndTime(combinedScheduleDays, scheduleItem, today, lastNow, startTime, endTime, isValid, notificationDefinition); } } else { break;// O gün takvimde varsa bu class'dan çýk yoluna devam et, burayla iþin yok } } } } } } return(validDateInfo); }
public static bool IsOutOfScheduleRequest(NotificationDefinition notificationDefinition, DateTime requestDate, DateTime now) { var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); var lastNowTime = lastNow.TimeOfDay; int today = (int)lastNow.DayOfWeek; bool result = true; if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { bool isDayExistInSchedule = false; bool isNowValidScheduletTime = false; if (scheduleItem.StartTime == scheduleItem.EndTime) { isNowValidScheduletTime = true; } if (scheduleItem.StartTime < scheduleItem.EndTime) { if (lastNowTime.IsBetween(scheduleItem.StartTime, scheduleItem.EndTime)) { isNowValidScheduletTime = true; } } if (scheduleItem.StartTime > scheduleItem.EndTime) { if (!lastNowTime.IsBetween(scheduleItem.EndTime, scheduleItem.StartTime)) { isNowValidScheduletTime = true; } } if (scheduleItem.Days.Contains(today)) { isDayExistInSchedule = true; } if (isNowValidScheduletTime && isDayExistInSchedule) { result = false; break; } } } return(result); }
public static bool GetSchedulingWaitingStatus(NotificationDefinition notificationDefinition) { bool isWaitingForSchedulingActive = ConfigurationHelper.GetConfiguration <bool>(Constants.IsWaitingForSchedulingActiveKey, true); if (!isWaitingForSchedulingActive) { return(false); } if (notificationDefinition.IsContinueSendingOtherDay) { return(true); } return(false); }
public static bool CheckNotificationValidOptions(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate, out NotificationOptions validOptions) { var isValid = false; var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); var lastNowTime = lastNow.TimeOfDay; NotificationDateValidationInfo DateValidInfo = new NotificationDateValidationInfo(); foreach (var rule in Rules) { DateValidInfo = rule.DecideNotificationTimeValidation(notificationDefinition, notificationOptions, now, requestDate); if (DateValidInfo.isValid || IsRequestDateLessThanNow(notificationDefinition, requestDate, now)) { break; } } validOptions = new NotificationOptions() { SendStartTime = DateTime.MinValue, SendEndTime = DateTime.MinValue }; //Control if decision starttime expire options endTime if (!NotificationDateValidator.IsNotificationOptionsNullOrEmpty(notificationOptions) && notificationOptions.ControlWithNotificationSchedule) { if (!DateValidInfo.SendStartTime.IsLessThan(notificationOptions.SendEndTime) && DateValidInfo.SendStartTime != DateTime.MinValue) { return(isValid); } if (DateValidInfo.isValid) { validOptions.SendEndTime = notificationOptions.SendEndTime; } } validOptions.SendStartTime = DateValidInfo.SendStartTime; if (validOptions.SendEndTime == DateTime.MinValue) { validOptions.SendEndTime = DateValidInfo.SendEndTime; } isValid = DateValidInfo.isValid; //validOptions.SendEndTime = ControlProcessTimeDayOut(validOptions, isValid, notificationDefinition, now); return(isValid); }
public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); if (!NotificationDateValidator.IsNotificationDateDefinitionEmpty(notificationDefinition)) { startTime = notificationDefinition.SendStartTime; endTime = notificationDefinition.SendEndTime; isValid = now.IsLessThanOrEquals(endTime); } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); if (!NotificationDateValidator.IsRequestDateNullOrEmpty(requestDate)) { if (requestDate.AddMinutes(notificationDefinition.SendEndDuration).IsLessThan(now)) { startTime = DateTime.MinValue; endTime = DateTime.MinValue; isValid = false; } } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { if (scheduleItem.StartTime == scheduleItem.EndTime && scheduleItem.Days.Contains((int)lastNow.DayOfWeek)) { startTime = lastNow; endTime = startTime.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } } } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public static DateTime ControlProcessTimeDayOut(NotificationOptions timeOptions, bool isValid, NotificationDefinition notificationDefinition, DateTime now) { var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { if (isValid) { if (timeOptions.SendEndTime.Day != lastNow.Day && !scheduleItem.Days.Contains((int)timeOptions.SendEndTime.DayOfWeek)) { //endTime hesabi yapilirken bir sonraki gune gecildi //ve bir sonraki gun valid gunlerden degil ise bir onceki gunun 23:59'u end time'dir. timeOptions.SendEndTime = new DateTime(lastNow.Year, lastNow.Month, lastNow.Day, 23, 59, 59); } } } } return(timeOptions.SendEndTime); }
public static bool IsExistSchedule(NotificationDefinition notificationDefinition) { return(notificationDefinition.Schedules.Count > 0); }
public ActionResult SendEmail(string id) { try { if (string.IsNullOrEmpty(id)) { throw new Exception("Email send failed due to scale ID not found."); } ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Scale scale = scaleLib.GetByID(id, new string[] { "Party_ID" }); if (scale == null || scale.Party_ID == null || scale.Ticket_Type != "Receiving Ticket" || scale.Ticket_Status != "Close") { throw new Exception("Email send failed."); } IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(scale.Party_ID.ID); if (contacts.Count() <= 0) { throw new Exception("There is no email contact exists."); } NotificationDefinition notDef = new NotificationDefinition(); notDef.ToRecipients = new System.Net.Mail.MailAddressCollection(); foreach (var item in contacts) { notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText)); } EmployeeHelper employeeHelper = new EmployeeHelper(); Employee employee = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name); if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password)) { throw new Exception("Sender email and password is required."); } string xslPath = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ScaleEmailBody.xslt"); string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer(); Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("ScaleID", id); SSRSReport ssrsHelper = new SSRSReport("ScaleReceiveTicket.rdl", parameter); string attachment = ssrsHelper.ExportReportToPDF(); if (string.IsNullOrEmpty(attachment)) { throw new Exception("There is no attachment found."); } notDef.Attachments = new List <System.Net.Mail.Attachment>(); notDef.Attachments.Add(new System.Net.Mail.Attachment(attachment)); notDef.DeliveryType = EnumNotificationDeliveryType.Email; notDef.FormatType = EnumFormatType.HTML; notDef.Sender = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name); notDef.SMTPServer = smtpAddress; notDef.SMTPServerCredentialID = employee.Email; notDef.SMTPServerCredentialPwd = employee.Email_Password; notDef.Subject = "Ticket#" + id.ToString(); NotificationHelper.StartNotificationWF(id, scale.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted); //return Display(command, container); if (_sendMail == true) { return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet)); } }
// If your activity returns a value, derive from CodeActivity<TResult> // and return the value from the Execute method. protected override void Execute(CodeActivityContext context) { try { // Can read this information from config file. NotificationDefinition message = NotificationDef.Get(context) as NotificationDefinition; SmtpClient SmtpServer = ReadSMTPConfigurationInfo(message); MailMessage mail = new MailMessage(); // Sender mail.From = message.Sender; // Add attachments foreach (var attachment in message.Attachments) { mail.Attachments.Add(attachment); } // To Receipients foreach (var toRecept in message.ToRecipients) { mail.To.Add(toRecept); } // Cc Receipients if (message.CCRecipients != null) { foreach (var ccRecept in message.CCRecipients) { mail.To.Add(ccRecept); } } // Bcc Receipients if (message.BCCRecipients != null) { foreach (var bccRecept in message.BCCRecipients) { mail.To.Add(bccRecept); } } // Subject. mail.Subject = message.Subject; // Body. mail.Body = NotificationHelper.XSLTransform(XSLPath.Get(context), CustomerName.Get(context), EntityID.Get(context), CompanyName.Get(context), UserName.Get(context), BookingID.Get(context), SOID.Get(context)); // Body Type mail.IsBodyHtml = message.FormatType == EnumFormatType.HTML; // Send email. SmtpServer.Send(mail); Result.Set(context, EntityID.Get(context)); } catch (Exception ex) { ExceptionFormatter formater = new ExceptionFormatter(); string formatedException = formater.Format("Send mail error", ex); Common.MessageLogger.Instance.LogMessage(ex, formatedException, Common.Priority.High, 0, System.Diagnostics.TraceEventType.Critical, "WF Email Error", "Email"); throw ex; } }
// Start the notification workflow to send notification for provided list of events. public static void StartNotificationWF(string id, string partyName, string compName, string userName, NotificationDefinition notificationDef, string xslPath, NotificationWFCompleted handler, string bookingID = "", string soID = "") { IDictionary <string, object> input = new Dictionary <string, object> { { "CustomerName", partyName }, { "CompanyName", compName }, { "UserName", userName }, { "EntityID", id.ToString() }, { "NotificationDef", notificationDef }, { "XSLPath", xslPath }, { "NotificationType", (int)EnumNotificationEntity.Scale }, { "BookingID", bookingID }, { "SOID", soID } }; // Start workflow. StartWorkflow(input, handler); }
public static bool IsRequestDateLessThanNow(NotificationDefinition notificationDefinition, DateTime requestDate, DateTime now) { return(requestDate.AddMinutes(notificationDefinition.SendEndDuration).IsLessThan(now)); }
public static bool IsNotificationDateDefinitionEmpty(NotificationDefinition notificationDefinition) { return(notificationDefinition.SendStartTime == DateTime.MinValue && notificationDefinition.SendEndTime == DateTime.MinValue); }
/// <summary> /// Send notification. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='properties'> /// Notification specifications. /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> public static NotificationSendSucceededResult Send(this IPush operations, NotificationDefinition properties, string ownerName, string appName) { return(operations.SendAsync(properties, ownerName, appName).GetAwaiter().GetResult()); }
public NotificationDateValidationInfo SetStartAndEndTime(List <int> days, NotificationSchedule scheduleItem, int today, DateTime lastNow, DateTime startTime, DateTime endTime, bool isValid, NotificationDefinition notificationDefinition) { NotificationDateValidationInfo validDateInfo = new NotificationDateValidationInfo(); var lastNowTime = lastNow.TimeOfDay; int daysOfWeek = 7; int counter = 0; int day = 0; while (day < daysOfWeek) { if (today < 6) { today++; } else { today = 0; } counter++;//Saysýn ki arada kaç gün var bilelim if (days.Contains(today)) { lastNow = lastNow.AddDays(counter); lastNowTime = lastNow.TimeOfDay; startTime = lastNow.Date + scheduleItem.StartTime; endTime = startTime.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } day++; } if (isValid) { validDateInfo.SendStartTime = startTime; validDateInfo.SendEndTime = endTime; validDateInfo.isValid = isValid; } return(validDateInfo); }
/// <summary> /// Send notification. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='properties'> /// Notification specifications. /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <NotificationSendSucceededResult> SendAsync(this IPush operations, NotificationDefinition properties, string ownerName, string appName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.SendWithHttpMessagesAsync(properties, ownerName, appName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
//Takvim saatleri dýþýnda öncesinde ve sonrasýnda gelen istekleri yönet public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate) { bool isValid = false; DateTime startTime = new DateTime(); DateTime endTime = new DateTime(); //lastNow degerini kullaniyoruz. DateTime.Now'a eklenen sure ile gun bilgisi degisebilir var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration); var lastNowTime = lastNow.TimeOfDay; TimeSpan midNight = new TimeSpan(23, 59, 59); if (NotificationDateValidator.IsExistSchedule(notificationDefinition)) { if (NotificationDateValidator.GetSchedulingWaitingStatus(notificationDefinition)) { foreach (var scheduleItem in notificationDefinition.Schedules) { if (!lastNowTime.IsBetween(scheduleItem.StartTime, scheduleItem.EndTime)) { //16:00-21:00 takvimi için ör istek saati : 15:00 //08:00-17:00 takvimi için ör istek saati : 07:00 if (lastNowTime < scheduleItem.StartTime) { var newDate = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00); startTime = newDate + scheduleItem.StartTime; endTime = startTime.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } if (lastNowTime > scheduleItem.EndTime) { //16:00-21:00 takvimi için ör istek saati : 22:00 //08:00-17:00 takvimi için ör istek saati : 18:00 if (lastNowTime.IsBetween(scheduleItem.EndTime, midNight)) { var newDate = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00); newDate = newDate.AddDays(1); startTime = newDate + scheduleItem.StartTime; endTime = startTime.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } //16:00-21:00 takvimi için ör istek saati : 00:00 'dan sonra 16:00'a kadar. Ör: 00:40 veya 02:00 //08:00-17:00 takvimi için ör istek saati : 00:00 'dan sonra 08:00'a kadar. Ör: 00:40 veya 02:00 if (lastNowTime.IsLessThanOrEquals(midNight)) { var newDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 00, 00, 00); startTime = newDate + scheduleItem.StartTime; endTime = startTime.AddMinutes(notificationDefinition.SendEndDuration); isValid = true; break; } } } } } } return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid)); }
public ActionResult SendEmail(string id) { string destinationFilePath = string.Empty; FilelHelper fileHelper = new FilelHelper(); try { if (string.IsNullOrEmpty(id)) { throw new Exception("Email send failed due to Container# not found."); } ContainerLibrary containerLib = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Container container = containerLib.GetByID(id, new string[] { "Booking.Sales_Order_No.Party" }); if (container == null || container.Booking == null || container.Booking.Sales_Order_No == null || container.Booking.Sales_Order_No.Party == null) { throw new Exception("Email send failed."); } IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(container.Booking.Sales_Order_No.Party.ID); if (contacts.Count() <= 0) { throw new Exception("There is no email contact exists."); } NotificationDefinition notDef = new NotificationDefinition(); notDef.ToRecipients = new System.Net.Mail.MailAddressCollection(); foreach (var item in contacts) { notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText)); } EmployeeHelper employeeHelper = new EmployeeHelper(); Employee employee = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name); if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password)) { throw new Exception("Sender email and password is required."); } ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Scale scale = scaleLib.GetScalesByContainerId(container.ID); ScaleAttachmentsLibrary scaleAttachLib = new ScaleAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ScaleAttachments> scaleAttachments = scaleAttachLib.GetAllByParentID(scale.ID); if (scaleAttachments == null || scaleAttachments.Count() <= 0) { throw new Exception("There is no attachment found."); } destinationFilePath = Path.Combine(Path.GetTempPath(), container.ID.ToString()); fileHelper.CreateDirectory(destinationFilePath); fileHelper.DeleteFiles(destinationFilePath); string imageFilePath = Path.Combine(destinationFilePath, "Images"); fileHelper.CreateDirectory(imageFilePath); string zipFilePath = Path.Combine(destinationFilePath, container.ID.ToString() + ".zip"); foreach (var item in scaleAttachments) { string sourceFilePath = fileHelper.GetFilePathByFileRefId(item.Document_RefId.ToString()); string imageFileFullPath = Path.Combine(imageFilePath, item.Document_Name); System.IO.File.Copy(sourceFilePath, imageFileFullPath); } new smART.Common.FilelHelper().CreateZip(imageFilePath, zipFilePath); if (!fileHelper.FileExits(zipFilePath)) { throw new Exception("There is no attachment found."); } string xslPath = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ContainerEmailBody.xslt"); string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer(); notDef.Attachments = new List <System.Net.Mail.Attachment>(); notDef.Attachments.Add(new System.Net.Mail.Attachment(zipFilePath)); notDef.DeliveryType = EnumNotificationDeliveryType.Email; notDef.FormatType = EnumFormatType.HTML; notDef.Sender = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name); notDef.SMTPServer = smtpAddress; notDef.SMTPServerCredentialID = employee.Email; notDef.SMTPServerCredentialPwd = employee.Email_Password; notDef.Subject = "Booking#/Container#: " + container.Booking.Booking_Ref_No + "/" + container.Container_No; NotificationHelper.StartNotificationWF(id, container.Booking.Sales_Order_No.Party.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted, container.Booking.Booking_Ref_No, container.Booking.Sales_Order_No.ID.ToString()); //return Display(command, container); if (_sendMail == true) { return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet)); } //return Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { //var script = @"ShowAlertMessage(""Send mail failed"");"; //return JavaScript(script); return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet)); } finally { //fileHelper.DeleteDirectory(destinationFilePath); } }