public JsonResult SendContactUs(string fullname, string email, string subject, string content) { //TODO: Issue Respone all error 403 Response.Status = "200 OK"; Response.StatusCode = 200; //TODO: Issue Respone all error 403 var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); //send email var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var emailContactUs = AppSettingsReader.GetValue("EmailContactUs", typeof(String)) as string; var weblink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.ContactUsTemplate, true), new { fullname_t = fullname, email_t = email, subject_t = subject, content_t = content, web_link = weblink }); var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0]; _emailHandler.SendEmailSsl(fromEmail, new[] { emailContactUs }, "Email from Contact Us", emailContent, logo, true, displayName); var clientsJson = Json(true, JsonRequestBehavior.AllowGet); return(clientsJson); }
private void GetContentHtml(RequestAssessmentPcsVo objAssessmentPcs, AssessmentDataVo assessmentDataVo) { if (objAssessmentPcs.Sections != null && objAssessmentPcs.Sections.Count > 0) { var header = objAssessmentPcs.Sections.FirstOrDefault(o => o.Order == 0); if (header != null) { for (int i = 1; i < 16; i++) { var field = "ContentHtml" + (i > 9 ? i.ToString() : "0" + i); var contentHtmlSection = GetPropValue(objAssessmentPcs.Sections[i], "ResultContent"); if (contentHtmlSection != null && !string.IsNullOrEmpty(contentHtmlSection.ToString())) { SetPropValue(assessmentDataVo, field, contentHtmlSection); } else { var contentSelected = GetPropValue(assessmentDataVo, field); if (contentSelected == null) { objAssessmentPcs.Sections[i].ResultContent = GetRootContentSection(objAssessmentPcs.Sections[i].Content, objAssessmentPcs, i); } else { objAssessmentPcs.Sections[i].ResultContent = assessmentDataVo.ContentHtml15; } } } assessmentDataVo.ContentHtml = CreateFileHtmlContent(TemplateHelpper.FormatTemplateWithContentTemplate(WebUtility.HtmlDecode(header.Content), new { section1 = string.IsNullOrEmpty(objAssessmentPcs.Sections[1].ResultContent) ? "" : objAssessmentPcs.Sections[1].ResultContent, section2 = string.IsNullOrEmpty(objAssessmentPcs.Sections[2].ResultContent) ? "" : objAssessmentPcs.Sections[2].ResultContent, section3 = string.IsNullOrEmpty(objAssessmentPcs.Sections[3].ResultContent) ? "" : objAssessmentPcs.Sections[3].ResultContent, section4 = string.IsNullOrEmpty(objAssessmentPcs.Sections[4].ResultContent) ? "" : objAssessmentPcs.Sections[4].ResultContent, section5 = string.IsNullOrEmpty(objAssessmentPcs.Sections[5].ResultContent) ? "" : objAssessmentPcs.Sections[5].ResultContent, section6 = string.IsNullOrEmpty(objAssessmentPcs.Sections[6].ResultContent) ? "" : objAssessmentPcs.Sections[6].ResultContent, section7 = string.IsNullOrEmpty(objAssessmentPcs.Sections[7].ResultContent) ? "" : objAssessmentPcs.Sections[7].ResultContent, section8 = string.IsNullOrEmpty(objAssessmentPcs.Sections[8].ResultContent) ? "" : objAssessmentPcs.Sections[8].ResultContent, section9 = string.IsNullOrEmpty(objAssessmentPcs.Sections[9].ResultContent) ? "" : objAssessmentPcs.Sections[9].ResultContent, section10 = string.IsNullOrEmpty(objAssessmentPcs.Sections[10].ResultContent) ? "" : objAssessmentPcs.Sections[10].ResultContent, section11 = string.IsNullOrEmpty(objAssessmentPcs.Sections[11].ResultContent) ? "" : objAssessmentPcs.Sections[11].ResultContent, section12 = string.IsNullOrEmpty(objAssessmentPcs.Sections[12].ResultContent) ? "" : objAssessmentPcs.Sections[12].ResultContent, section13 = string.IsNullOrEmpty(objAssessmentPcs.Sections[13].ResultContent) ? "" : objAssessmentPcs.Sections[13].ResultContent, section14 = string.IsNullOrEmpty(objAssessmentPcs.Sections[14].ResultContent) ? "" : objAssessmentPcs.Sections[14].ResultContent, section15 = string.IsNullOrEmpty(objAssessmentPcs.Sections[15].ResultContent) ? "" : objAssessmentPcs.Sections[15].ResultContent, })); } } }
public IHttpActionResult SendEmailForgotPassword(ForgotPasswordDto dtoForgotPassword) { var dtoBase = new DtoBase(); const string randomPassword = "******"; var user = _userService.FirstOrDefault(o => o.Email == dtoForgotPassword.Email); if (user != null) { var courier = _courierService.GetById(user.Id); if (courier != null) { var webLink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var urlSignIn = webLink + "/Authentication/SignIn"; var imgSrc = webLink + "/Content/quickspatch/img/logo-o.svg"; var urlChangePass = webLink + "/Authentication/ChangeRestorePassword?code=" + PasswordHelper.HashString(user.Id.ToString(), user.UserName); var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : ""; var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePassword, true), new { img_src = imgSrc, full_name = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName), web_link = webLink, user_name = user.UserName, url_change_pass = urlChangePass, franchisee_Name = franchiseeName, url_sign_in = urlSignIn }); // send email _emailHandler.SendEmail(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"), emailContent, true, displayName); dtoBase.Id = 1; } } else { dtoBase.Id = 2; } return(Ok(dtoBase)); //return Json(new { }, JsonRequestBehavior.AllowGet); }
private string _getHtmlDeliveryAgreementReport(RequestQueryInfo queryInfo) { var data = _requestRepository.GetListDeliveryAgreementVo(queryInfo); var fileByte = Convert.FromBase64String(data.Signature); var pathDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileUpload"); if (!Directory.Exists(pathDir)) { Directory.CreateDirectory(pathDir); } pathDir = Path.Combine(pathDir, "Temps"); if (!Directory.Exists(pathDir)) { Directory.CreateDirectory(pathDir); } var fileName = Guid.NewGuid().ToString("N") + ".jpg"; _pathTempFile = Path.Combine(pathDir, fileName); File.WriteAllBytes(_pathTempFile, fileByte); var imageName = data.IsAgreed.GetValueOrDefault() ? "accepted" : "rejected"; var html = TemplateHelpper.FormatTemplateWithContentTemplate(TemplateHelpper.ReadContentFromFile(TemplateConfigFile.DeliveryAgreementReportTemplate, true), new { data.RequestNo, fileName, imageName, data.RequestAgreed, data.RequestFrom, data.RequestTo, data.RequestTimes, data.RequestDistance, data.RequestFromName, data.RequestToName }); return(string.Format(htmlFormat, html)); }
public ActionResult ResetPassword(int id, string password, string username) { var user = _userService.GetById(id); if (user != null) { string randomPassword = password; user.Password = PasswordHelper.HashString(randomPassword, user.UserName); _userService.Update(user); var webLink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var imgSrc = webLink + "/Content/quickspatch/img/logo-o.svg"; var urlChangePass = webLink + "/Authentication/ChangePasswordCourier?code=" + PasswordHelper.HashString(id.ToString(), user.UserName); var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var webapi = AppSettingsReader.GetValue("WebApiUrlFranchisee", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : ""; var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePasswordCourierTemplate, true), new { img_src = imgSrc, full_name = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName), web_link = webLink, user_name = user.UserName, password = randomPassword, url_change_pass = urlChangePass, franchisee_Name = franchiseeName, web_api = webapi }); // send email var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0]; _emailHandler.SendEmailSsl(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"), emailContent, logo, true, displayName); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public JsonResult RestorePassword(string email) { var user = _userService.FirstOrDefault(o => o.Email == email); if (user != null) { var webLink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var urlSignIn = webLink + "/Authentication/SignIn"; var imgSrc = webLink + "/Content/quickspatch/img/logo-o.svg"; var urlChangePass = webLink + "/Authentication/ChangeRestorePassword?code=" + PasswordHelper.HashString(user.Id.ToString(), user.UserName); var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : ""; var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePassword, true), new { img_src = imgSrc, full_name = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName), web_link = webLink, user_name = user.UserName, url_change_pass = urlChangePass, franchisee_Name = franchiseeName, url_sign_in = urlSignIn }); // send email var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0]; _emailHandler.SendEmailSsl(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"), emailContent, logo, true, displayName); } else { throw new UserVisibleException("EmailInvalidText"); } return(Json(new { }, JsonRequestBehavior.AllowGet)); }
public string GetContentRequestReport(int courierId, DateTime fromDate, DateTime toDate, string displayName) { var data = _requestRepository.GetListRequestForReport(courierId, fromDate, toDate); var listContent = ""; double totalDistance = 0; if (data.Count > 0) { listContent += "<table width='100%' border-collapse: collapse; border: 1px solid #ddd;' cellspacing='0' cellpadding='0'>"; listContent += " <tr ><th style='padding: 10px; border: 1px solid #ddd;background: #ccc;'>Request #</th>"; if (courierId == 0) { listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Name</th>"; } listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>From</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>To</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Request Date</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Estimate Time (hours)</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Real Time (hours)</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Estimate Distance (miles)</th>"; listContent += " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Real Distance (miles)</th>"; listContent += "</tr>"; if (data.Count > 0) { foreach (var item in data) { totalDistance = totalDistance + item.ActualDistance.MetersToMiles(2); listContent += " <tr ><td style='padding: 10px;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.RequestNo + "</td>"; if (courierId == 0) { listContent += "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.FullName + "</td>"; } listContent += "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.LocationFrom + "</td>"; listContent += "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.LocationTo + "</td>"; listContent += "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' >" + item.RequestDateFormat + "</td>"; listContent += "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.EstimateTime + "</td>"; listContent += "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.RealTime + "</td>"; listContent += "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.TextEstimateDistance + "</td>"; listContent += "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + item.TextActualDistance + "</td>"; listContent += "</tr>"; } } if (courierId == 0) { listContent += "<tr ><th style='padding: 10px;text-align: right;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' colspan='8'>Total: </th>"; } else { listContent += "<tr ><th style='padding: 10px;text-align: right;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' colspan='7'>Total: </th>"; } listContent += "<th style='padding: 10px; text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" + String.Format("{0:0.00}", totalDistance) + " miles</th>"; listContent += " </tr>"; listContent += " </table>"; } else { listContent += "There isn't request in list."; } //tao file logo temp from byte[] var pathDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileUpload"); if (!Directory.Exists(pathDir)) { Directory.CreateDirectory(pathDir); } pathDir = Path.Combine(pathDir, "Temps"); if (!Directory.Exists(pathDir)) { Directory.CreateDirectory(pathDir); } var franchisee = _franchiseeConfigurationRepository.GetFranchiseeConfiguration(); //var logoFranchisee = new FileContentResult(franchisee.Logo, "image/jpeg"); var fileName = Guid.NewGuid().ToString("N") + ".jpg"; _pathTempFile = Path.Combine(pathDir, fileName); File.WriteAllBytes(_pathTempFile, franchisee.Logo); if (courierId == 0) { var reportTemplate1 = _templateRepository.FirstOrDefault(o => o.TemplateType == (int)TemplateType.ReportOfAllDriver); var html1 = TemplateHelpper.FormatTemplateWithContentTemplate(WebUtility.HtmlDecode(reportTemplate1.Content), new { nameDisplay = displayName, logo = fileName, reportDate = DateTime.Now.ToShortDateString(), fromDate = fromDate.ToShortDateString(), toDate = toDate.ToShortDateString(), listData = listContent }); return(html1); } //var displayNameCourier = var courierInfo = _courierRepository.GetById(courierId); var reportTemplate = _templateRepository.FirstOrDefault(o => o.TemplateType == (int)TemplateType.ReportOfDriver); var html = TemplateHelpper.FormatTemplateWithContentTemplate(WebUtility.HtmlDecode(reportTemplate.Content), new { nameDisplay = displayName, logo = fileName, reportDate = DateTime.Now.ToShortDateString(), fromDate = fromDate.ToShortDateString(), toDate = toDate.ToShortDateString(), name = CaculatorHelper.GetFullName(courierInfo.User.FirstName, courierInfo.User.MiddleName, courierInfo.User.LastName), email = courierInfo.User.Email, homePhone = courierInfo.User.HomePhone.ApplyFormatPhone(), mobliePhone = courierInfo.User.MobilePhone.ApplyFormatPhone(), listData = listContent }); return(html); //return "NO DATA"; }