Exemplo n.º 1
0
        public static void SendBookingRequestNotificationTo_InCC(EmailNotificationModel objEMailDac, string senderEmailId, string[] senderEmailIdCC)
        {
            string[] senderEmailIds   = new string[] { senderEmailId };
            string[] senderEmailIdCCs = senderEmailIdCC;

            string MailApi         = ConfigurationManager.AppSettings["MailApi"];
            var    _jsonSerialiser = new JavaScriptSerializer();
            var    _jsonRequest    = _jsonSerialiser.Serialize
                                         (new Mail()
            {
                applicationKey   = ConfigurationManager.AppSettings["MailApiKey"],
                cc               = senderEmailIdCCs,
                from             = objEMailDac.SmtpUser,
                plainTextContent = string.Empty,
                htmlContent      = objEMailDac.TemplateFilePath.Trim(),
                subject          = objEMailDac.EmailSubjectName,
                to               = senderEmailIds
            }
                                         );

            try
            {
                var s = SendEmailThroughAPI(MailApi, _jsonRequest);
            }
            catch (Exception ex)
            {
                ErrorLog.AddEmailLogg(ex);
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send Email Notification to Requester with attachment
        /// </summary>
        /// <param name="objEMailDac"></param>
        public static void SendBookingRequestNotificationTo_Requester_Attachment(EmailNotificationModel objEMailDac, string senderEmailId, string attachment_path)
        {
            var client = new SmtpClient
            {
                DeliveryMethod = SmtpDeliveryMethod.Network,
                //EnableSsl = true,//for local it should true
                EnableSsl = false,//For Production it shpuld false
                Host      = objEMailDac.SmtpServer,
                Port      = Convert.ToInt32(objEMailDac.SmtpPort),
            };
            var credentials = new NetworkCredential(objEMailDac.SmtpUser, objEMailDac.SmtpPass);

            client.UseDefaultCredentials = false;
            client.Credentials           = credentials;
            var body = objEMailDac.TemplateFilePath;
            var msg  = new MailMessage
            {
                From       = new MailAddress(objEMailDac.SmtpUser),
                IsBodyHtml = true,
                Subject    = objEMailDac.EmailSubjectName,
                Body       = body,
            };

            msg.Attachments.Add(new Attachment(attachment_path));
            msg.To.Add(senderEmailId);
            try
            {
                client.Send(msg);
            }
            catch (Exception ex)
            {
                ErrorLog.AddEmailLogg(ex);
                return;
            }
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            EmailNotificationModel  emailNotificationModel = new EmailNotificationModel();
            EmailNotificationHelper _Helper = new EmailNotificationHelper();

            emailNotificationModel = _Helper.GetEmailNotificationDetails(emailNotificationModel);
            return(View(emailNotificationModel));
        }
        public async Task Send(EmailNotificationModel emailModel)
        {
            var connectionId = GetAllActiveConnections()
                .Where(x => x.UserName == emailModel.UserId.ToString())
                .FirstOrDefault()
                .ConnectionId;

            await Clients.Client(connectionId)
                .SendAsync("transfernotifications", emailModel);
        }
        public EmailNotificationModel GetEmailNotificationDetails(EmailNotificationModel emailNotificationModel)
        {
            var adminEmailNotificationdb = context.tblAdminEmailNotificationSettings.Where(m => m.Status == 1).SingleOrDefault();

            if (adminEmailNotificationdb != null)
            {
                emailNotificationModel.AdminEmailNotificationSettingId = adminEmailNotificationdb.AdminEmailNotificationSettingId;
                emailNotificationModel.EmailAddress = adminEmailNotificationdb.EmailAddress;
                emailNotificationModel.Status       = adminEmailNotificationdb.Status;
            }
            return(emailNotificationModel);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentials(string subjectName, string emailTemplateName, List <BulkUploadModels> blist, string bbReqNo, string ReqName)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFile(emailTemplateName, blist, bbReqNo, ReqName),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentialsOatUser(string subjectName, string emailTemplateName, List <OATTravelRequestMasterModal> personalInfo, List <OATTravelRequestPassengerDetailModal> passangerInfo, List <OATTravelRequestFlightDetailModal> flightInfo, List <BulkUploadModels> hotelDetailList, string oatReqNo)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFileForOatUser(emailTemplateName, personalInfo, passangerInfo, flightInfo, hotelDetailList, oatReqNo),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentialsHotelHod(String subjectName, String emailTemplateName, List <OATTravelRequestMasterModal> personalInfo, List <BulkUploadModels> blist, String bbReqNo, String HodName, List <BulkUploadModels> hoteldetails, List <TravelRequestMasterModels> bookingInfo, List <FlightDetailModels> flightinfo)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFileHotelHod(emailTemplateName, personalInfo, blist, bbReqNo, HodName, hoteldetails, bookingInfo, flightinfo),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentials(string subjectName, string emailTemplateName, SJSCUserMasterModels UserData)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFile(emailTemplateName, UserData),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentials(string subjectName, string emailTemplateName, List <TravelRequestMasterModels> sodRequestsList, List <FlightDetailModels> sodflightList, List <PassengerDetailModels> sodPassList, List <PassengerMealAllocationModels> sodPassMealsList, List <TravelRequestHotelDetailModels> hotelList, string reqNo, string strHoldPNRMessage)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFile(emailTemplateName, sodRequestsList, sodflightList, sodPassList, sodPassMealsList, hotelList, reqNo, strHoldPNRMessage),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 11
0
        public EmailNotificationModel EmailCredentials(string subjectName, string VendoremailTemplateName, List <VendorModels> mailerlist)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFile(subjectName, VendoremailTemplateName, mailerlist),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 12
0
        /// <summary>
        /// email credentials for hod financial approval
        /// </summary>
        /// <param name="subjectName"></param>
        /// <param name="emailTemplateName"></param>
        /// <param name="ithlist"></param>
        /// <param name="plist"></param>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentialsHODApproval(string subjectName, string emailTemplateName, List <ITHResponseDetailModels> ithlist, List <OALPassengerModel> plist)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtptdUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtptdPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtptdServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtptdPort"].Trim(),
                TemplateFilePath = ReadFileHODApproval(emailTemplateName, ithlist, plist),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initialized Email Credentials to Property
        /// </summary>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentials(string subjectName, string emailTemplateName, List <OALTravelRequestMasterModel> sodRequestsList, List <OALModels> sodflightList, List <OALPassengerModel> sodPassList, List <OALHotelModel> sodhotelList, string reqNo)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtpPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtpServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtpPort"].Trim(),
                TemplateFilePath = ReadFile(emailTemplateName, sodRequestsList, sodflightList, sodPassList, sodhotelList, reqNo),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Email Credentails
        /// </summary>
        /// <param name="subjectName"></param>
        /// <param name="emailTemplateName"></param>
        /// <param name="sod_data"></param>
        /// <param name="sodChangeDetails"></param>
        /// <param name="reqtypeId"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentials(string subjectName, string emailTemplateName, SODEmployeeChangeRequestMaster sod_data, SODEmployeeChangeRequestDetails sodChangeDetails, int reqtypeId, Int16 criteria)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtptdPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtptdServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtptdPort"].Trim(),
                TemplateFilePath = ReadFile(emailTemplateName, sod_data, sodChangeDetails, reqtypeId, criteria),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Email Credentials Hotel Hod
        /// </summary>
        /// <param name="subjectName"></param>
        /// <param name="emailTemplateName"></param>
        /// <param name="hoteldetails"></param>
        /// <param name="bookingInfo"></param>
        /// <param name="flightinfo"></param>
        /// <param name="reqNo"></param>
        /// <param name="hodemailID"></param>
        /// <returns></returns>
        public EmailNotificationModel EmailCredentialsHotelHod(string subjectName, string emailTemplateName, List <TravelRequestHotelDetailModels> hoteldetails, List <TravelRequestMasterModels> bookingInfo, List <FlightDetailModels> flightinfo, string reqNo, string hodemailID)
        {
            var objEmailServices = new EmailNotificationModel
            {
                SmtpUser         = ConfigurationManager.AppSettings["smtpHotelUser"].Trim(),
                SmtpPass         = ConfigurationManager.AppSettings["smtptdPass"].Trim(),
                SmtpServer       = ConfigurationManager.AppSettings["smtptdServer"].Trim(),
                SmtpPort         = ConfigurationManager.AppSettings["smtptdPort"].Trim(),
                TemplateFilePath = ReadFileHotelHod(emailTemplateName, hoteldetails, bookingInfo, flightinfo, reqNo, hodemailID),
                EmailSubjectName = subjectName
            };

            return(objEmailServices);
        }
Exemplo n.º 16
0
        public async Task SendEmail(EmailNotificationModel model)
        {
            string  apiKey = _config.SendGridApiKey;
            dynamic sg     = new SendGridAPIClient(apiKey);

            Email from = new Email(model.from);
            //string subject = "Sending with SendGrid is Fun";
            string subject = model.subject;
            Email  to      = new Email(model.to);
            //Content content = new Content("text/plain", "and easy to do anywhere, even with C#");
            Content content = new Content("text/plain", model.content);
            Mail    mail    = new Mail(from, subject, to, content);

            dynamic response = await sg.client.mail.send.post(requestBody : mail.Get());
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Post([FromBody] EmailNotificationModel model)
        {
            var entity = new EmailNotification();

            entity.To      = model.To;
            entity.Subject = model.Subject;
            entity.Body    = model.Body;

            await this.notificationService.InsertEmailNotification(entity);

            return(this.Ok(new BaseModel()
            {
                Id = entity.Id
            }));
        }
Exemplo n.º 18
0
        private void HandleMessage(string content)
        {
            try
            {
                EmailNotificationModel emailObj = new EmailNotificationModel();
                emailObj = JsonConvert.DeserializeObject <EmailNotificationModel>(content);


                NotificationClass.SendEmail(emailObj);

                // Send Update to Log Service.
                ApplicationLogs applogs = new ApplicationLogs();
                applogs.LogMessage = emailObj.Emailfrom + "\t" + emailObj.Emailto + "\t" + emailObj.CC + "\t" + emailObj.Content;
                _queueProvider.RegisterApplicationLog(applogs);
            }
            catch
            { }
        }
Exemplo n.º 19
0
 public ActionResult Index(EmailNotificationModel emailNotificationModel)
 {
     if (ModelState.IsValid)
     {
         EmailNotificationHelper _Helper = new EmailNotificationHelper();
         int result = _Helper.UpdateEmailNotificationSetting(emailNotificationModel);
         if (result >= 1)
         {
             TempData["CommonMessage"] = AppLogic.setMessage(0, "Record updated successfully.");
             return(RedirectToAction("Index"));
         }
         else
         {
             TempData["CommonMessage"] = AppLogic.setMessage(result, "Error: Please try again.");
             return(RedirectToAction("Index"));
         }
     }
     return(View(emailNotificationModel));
 }
Exemplo n.º 20
0
        public int UpdateEmailNotificationSetting(EmailNotificationModel emailNotificationModel)
        {
            int result = -1;

            try
            {
                using (var db = new StratasFairDBEntities())
                {
                    if (emailNotificationModel.AdminEmailNotificationSettingId > 0)
                    {
                        // update the data
                        var adminEmailNotificationdb = db.tblAdminEmailNotificationSettings.FirstOrDefault(m => m.AdminEmailNotificationSettingId == emailNotificationModel.AdminEmailNotificationSettingId);
                        adminEmailNotificationdb.EmailAddress    = emailNotificationModel.EmailAddress;
                        adminEmailNotificationdb.ModifiedBy      = AdminSessionData.AdminUserId;
                        adminEmailNotificationdb.ModifiedOn      = DateTime.Now;
                        adminEmailNotificationdb.ModifiedFromIP  = HttpContext.Current.Request.UserHostAddress;
                        db.Entry(adminEmailNotificationdb).State = EntityState.Modified;
                    }
                    else
                    {
                        // insert the new data
                        var adminEmailNotificationdb = new tblAdminEmailNotificationSetting();
                        adminEmailNotificationdb.EmailAddress  = emailNotificationModel.EmailAddress;
                        adminEmailNotificationdb.CreatedBy     = AdminSessionData.AdminUserId;
                        adminEmailNotificationdb.CreatedOn     = DateTime.Now;
                        adminEmailNotificationdb.CreatedFromIP = HttpContext.Current.Request.UserHostAddress;
                        adminEmailNotificationdb.Status        = 1;
                        db.tblAdminEmailNotificationSettings.Add(adminEmailNotificationdb);
                    }
                    db.SaveChanges();
                    result = 1;
                }
                return(result);
            }
            catch
            {
            }
            return(result);
        }
        public async Task TestSendMessageNotifications()
        {
            var sgLoggerMock    = new Mock <ISendGridLogger>();
            var sgTransportMock = new Mock <ISendGridTransport>();
            var sgValidatorMock = new Mock <IEmailQuotaValidator>();

            sgValidatorMock.Setup(v => v.ValidateQuota(It.IsAny <EmailTypes>(), It.IsAny <SendGridMessage>(), It.IsAny <int>())).Returns(QuotaValidationResult.Success).Verifiable();
            var sgClient          = new EmailSender(sgLoggerMock.Object, sgTransportMock.Object, sgValidatorMock.Object);
            var emailNotification = new EmailNotificationModel
            {
                FirstNameFrom = "Andriy",
                FirstNameTo   = "Andriy",
                EmailTo       = "*****@*****.**",
                LastNameFrom  = "SomeLastName",
                LastNameTo    = "SomeLastName",
                UserIdTo      = 1,
                UserIdFrom    = 2,
                TargetCulture = "en"
            };
            await sgClient.SendMessageNotifications(new EmailNotificationModel[] { emailNotification });

            sgTransportMock.Verify(t => t.DeliverAsync(It.IsAny <SendGridMessage>()), Times.Once);
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Put(int id, [FromBody] EmailNotificationModel model)
        {
            var notification = await this.notificationService.GetEmailNotificationById(id);

            if (notification == null)
            {
                return(this.NotFound());
            }

            if (!notification.SentDate.HasValue)
            {
                notification.To      = model.To;
                notification.Body    = model.Body;
                notification.Subject = model.Subject;

                await this.notificationService.UpdateEmailNotification(notification);

                return(this.Ok());
            }
            else
            {
                return(this.BadRequest(HostaliandoExceptionCode.CantUpdateEmailNotification, "No se puede modificar una notificación ya enviada"));
            }
        }
Exemplo n.º 23
0
        // GET: ResendMail
        public JsonResult ResendMailToHod()
        {
            string hodEmailId = string.Empty;
            IList <EmployeeModel> empInfo;
            var controller = DependencyResolver.Current.GetService <EmployeeBookingDetailController>();
            var trId       = Request.QueryString["trId"].ToString();
            //Get Booking Detail
            var dicList            = GetDetailOfBookingHistoryByTrId(trId);
            var sodRequestsList    = dicList["bookingInfo"] as List <TravelRequestMasterModels>;
            var sodflightList      = dicList["flightInfo"] as List <FlightDetailModels>;
            var passengerList      = dicList["passInfo"] as List <PassengerDetailModels>;
            var passengerMealsList = dicList["mealsInfo"] as List <PassengerMealAllocationModels>;
            var cabList            = dicList["cabInfo"] as List <TravelRequestCabDetailModels>;
            var hotelList          = dicList["hotelInfo"] as List <TravelRequestHotelDetailModels>;

            //This is for SJSC-Hotel Booking
            if (sodRequestsList[0].TravelRequestTypeId == 5 || sodRequestsList[0].TravelRequestCode.Contains("SOD SJSC"))
            {
                //string UserDetails=""//will come from SJSCUserInfor table//Nee to check from SJSC Controller Link Gnereation
                var hodEmaildata = _sJsisConcernRepository.GetHodDetails(Session["HodEmailId"].ToString());
                hodEmailId = hodEmaildata[0].HodEmail + "," + hodEmaildata[0].HoDTitle + " " + hodEmaildata[0].HoDName + "," + "000" + "," + hodEmaildata[0].HodMobileNo + "," + "00113581";
            }
            else
            {
                empInfo    = _userRepository.GetEmployeeList(int.Parse(Session["EmpId"].ToString()));
                hodEmailId = _userRepository.GetHODEmailId(empInfo[0].EmployeeVertical);
            }

            if (hodEmailId.Length > 0)
            {
                //Mail Template
                var strHoldPNR        = "";
                var BookingFor        = "";
                var emailSubject      = "";
                var emailTemplateName = "";
                var BookingType       = (sodRequestsList[0].SodBookingTypeId == (short)2) ? "NON-SOD" : "SOD";

                EmailNotificationModel emailCredentials = new EmailNotificationModel();
                if (sodRequestsList[0].BookingFor == "Only Hotel")
                {
                    BookingFor        = sodRequestsList[0].BookingFor;
                    emailSubject      = "SOD Only-Hotel Booking Request Notification :" + System.DateTime.Now.ToString();
                    emailTemplateName = "SodHotelBookingRequestFor_HodHotelApproval.html";
                    emailCredentials  = controller.EmailCredentialsHotelHod(emailSubject, emailTemplateName, hotelList, sodRequestsList, trId, hodEmailId.Split(',')[0]);
                }
                else
                {
                    if (sodRequestsList[0].TravelRequestCode.Contains("SOD SJSC"))
                    {
                        BookingFor   = (sodRequestsList[0].BookingFor.Trim().ToLower() == "standby") ? "Standby" : "Confirm";
                        emailSubject = BookingType + " " + "SJSC" + " " + BookingFor + " " + "Booking Request Notification :" + System.DateTime.Now.ToString();
                    }
                    else
                    {
                        BookingFor   = (sodRequestsList[0].BookingFor.Trim().ToLower() == "standby") ? "Standby" : "Confirm";
                        emailSubject = BookingType + " " + BookingFor + " " + "Booking Request Notification :" + System.DateTime.Now.ToString();
                    }
                    emailTemplateName = "SodBookingRequestNotificationTemplate_HOD.html";
                    emailCredentials  = controller.EmailCredentials(emailSubject, emailTemplateName, sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelList, trId, strHoldPNR);
                }
                TempData["emailData_hod"] = emailCredentials;
                TempData["emailId_hod"]   = hodEmailId.Split(',')[0].ToString().Trim();

                var templateData = emailCredentials.TemplateFilePath;
                var appLink      = string.Empty;
                var approvaltype = string.Empty;
                var uri1         = string.Empty;
                var uri2         = string.Empty;
                if (hodEmailId.Length > 0)
                {
                    var skey = new StringBuilder();
                    skey.Append(sodRequestsList[0].TravelRequestId.ToString() + ",");
                    skey.Append(sodRequestsList[0].EmailId.Trim() + ",");
                    skey.Append(sodRequestsList[0].SodBookingTypeId.ToString() + ",");
                    skey.Append(sodRequestsList[0].BookingFor.Trim() + ",");
                    skey.Append(hodEmailId.Split(',')[2] + ",");
                    skey.Append(sodRequestsList[0].IsMandatoryTravel.ToString());
                    if (sodRequestsList[0].BookingFor == "Only Hotel" || sodRequestsList[0].TravelRequestTypeId == 5)
                    {
                        uri1 = ConfigurationManager.AppSettings["emailOnlyHotelApprovalPathHod"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=a");
                        uri2 = ConfigurationManager.AppSettings["emailOnlyHotelApprovalPathHod"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=r");
                    }
                    else
                    {
                        uri1 = ConfigurationManager.AppSettings["emailApprovalPath"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=a");
                        uri2 = ConfigurationManager.AppSettings["emailApprovalPath"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=r");
                    }

                    if (sodRequestsList[0].IsMandatoryTravel.Equals(1))
                    {
                        approvaltype = "Please help to accord your Acceptance or Rejection or Mandatory Travel – Approval.";
                        appLink      = "<table><tr style='font-family:Arial;'><td style='width:110px; height:25px; background-color:#04B431;text-align:center;border-radius:5px'><a name='app' style='color:#fff; text-decoration:none;' href='" + uri1 + "'>Acceptance</a></td> <td>&nbsp;</td> <td style='width:110px; height:25px; background-color:#b33;text-align:center;border-radius:5px'><a name='rej'  style='color:#fff; text-decoration:none;' href='" + uri2 + "'>Rejection</a> </td><td>&nbsp;</td> <td style='width:275x; height:25px; background-color:#01DF3A;text-align:center;border-radius:5px'><a name='mapp'  style='color:#fff; text-decoration:none;' href='" + uri1 + "'>Mandatory Travel – Approve</a></td></tr></table>";
                    }
                    else
                    {
                        approvaltype = "Please help to accord your Acceptance or Rejection.";
                        appLink      = "<table><tr style='font-family:Arial;'><td style='width:110px; height:25px; background-color:#04B431;text-align:center;border-radius:5px'><a name='app' style='color:#fff; text-decoration:none;' href='" + uri1 + "'>Acceptance</a></td> <td>&nbsp;</td> <td style='width:110px; height:25px; background-color:#b33;text-align:center;border-radius:5px'><a name='rej' style='color:#fff; text-decoration:none;' href='" + uri2 + "'>Rejection</a> </td></tr></table>";
                    }

                    templateData = templateData.Replace("[approvaltype]", approvaltype);
                    templateData = templateData.Replace("[appLink]", appLink);
                    templateData = templateData.Replace("[hodName]", hodEmailId.Split(',')[1]);
                    templateData = templateData.Replace("[RequesterName]", sodRequestsList[0].RequestedEmpName);
                    emailCredentials.TemplateFilePath = templateData;
                }
                var emaildata = TempData["emailData_hod"] as EmailNotificationModel;
                var emailid   = TempData["emailId_hod"].ToString();
                EmailNotification.EmailNotifications.SendBookingRequestNotificationTo_Requester(emailCredentials, emailid);
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Fail", JsonRequestBehavior.AllowGet));
            }
        }
 public static void SendEmail(EmailNotificationModel obj)
 {
 }
Exemplo n.º 25
0
        public Task Notify(int eventTaskId, int userId)
        {
            var userNotification = _context.UserNotifications
                                   .Where(uN => uN.UserId == userId)
                                   .FirstOrDefault();

            var eventTaskNotification = _context.EventTaskNotifications
                                        .Where(eTN => eTN.EventTaskId == eventTaskId)
                                        .FirstOrDefault();

            if (eventTaskNotification != null)
            {
                return(null);
            }
            var    eventTask   = _eventTaskService.GetById(eventTaskId);
            string endDateTime = "";

            if (eventTask.EndDt != null)
            {
                endDateTime = eventTask.EndDt.ToString();
            }

            var user = _userService.GetById(userId);


            EmailNotificationModel emailModel = new EmailNotificationModel()
            {
                UserId        = userId,
                EventTaskId   = eventTaskId,
                EndDateTime   = endDateTime,
                StartDateTime = eventTask.StartDt.ToString(),
                Recipient     = user.Username,
                Subject       = "Task Id " + eventTask.Id.ToString(),
                Text          = $"Dear {user.FirstName}" +
                                '\n' +
                                $"Your Event Task titled {eventTask.Title} " +
                                $" will start in {userNotification.Hours.ToString()} hours." +
                                '\n' +
                                ".o Team",
                Hours = userNotification.Hours
            };
            var result = SendEmailAsync(emailModel);

            if (result.IsCompleted)
            {
                EventTaskNotification newEventTaskNotification = new EventTaskNotification()
                {
                    UserId             = userId,
                    EventTaskId        = eventTaskId,
                    User               = user,
                    EventTask          = eventTask,
                    EmailNotification  = 1,
                    UserNotification   = userNotification,
                    UserNotificationId = userNotification.Id
                };

                if (userNotification.AppNotification == true)
                {
                    HubConnection connection = new HubConnectionBuilder()
                                               .WithUrl("http://localhost:57541/notification")
                                               .WithAutomaticReconnect()
                                               .Build();

                    connection.StartAsync().ContinueWith(task =>
                    {
                        if (task.IsFaulted)
                        {
                            //aaaaa
                        }
                        else
                        {
                            connection.InvokeAsync("transfernotifications", emailModel);
                        }
                    }).Wait();
                    connection.DisposeAsync();
                    newEventTaskNotification.AppNotification = 1;
                }


                _context.EventTaskNotifications.Add(newEventTaskNotification);
                _context.SaveChanges();
            }
            return(result);
        }
Exemplo n.º 26
0
 public Task SendEmailAsync(EmailNotificationModel emailModel)
 {
     Execute(emailModel.Recipient, emailModel.Subject, emailModel.Text).Wait();
     return(Task.FromResult(0));
 }