public ActionResult ForgotPassword(AuthForgottenPasswordModel model) { if (!ModelState.IsValid) { return(View()); } var user = FindUser(model.Email); if (user == null) { ModelState.AddModelError("", "The e-mail address you entered does not match any accounts on record."); return(View()); } var resetToken = user.GenerateResetToken(TimeSpan.FromHours(24)); var emailTemplate = _emailTemplatesRepository.GetTemplateByName(Utilities.ToDescriptionString(EmailTemplateCode.ForgotPassword)); model.ResetPasswordUrl = $"{Request.Url.Authority}/auth/resetpassword?email={model.Email}&resettoken={resetToken}"; emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, model); var mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); var sent = EmailServiceFactory.GetEmailService().SendMail(mailMessage); return(RedirectToAction("forgotpasswordemail")); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize(); BootStrapper.ConfigureDependencies(); Controllers.AutoMapperBootStrapper.ConfigureAutoMapper(); Services.AutoMapperBootStrapper.ConfigureAutoMapper(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); EmailServiceFactory.InitializeEmailServiceFactory(ObjectFactory.GetInstance <IEmailService>()); ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory()); DomainEvents.DomainEventHandlerFactory = ObjectFactory.GetInstance <IDomainEventHandlerFactory>(); Repository.NHibernate.SessionFactory.Init(); Services.Presentation.SessionFactory.Init(); LoggingFactory.GetLogger().Log("Application Started"); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); BootStrapper.ConfigureDependencies(); //DependencyResolver.SetResolver(new NinjectDependencyResolver()); Controllers.AutoMapperBootStrapper.ConfigureAutoMapper(); Services.AutoMapperBootStrapper.ConfigureAutoMapper(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory (ObjectFactory.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); EmailServiceFactory.InitializeEmailServiceFactory (ObjectFactory.GetInstance <IEmailService>()); ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory()); LoggingFactory.GetLogger().Log("Application Started"); GlobalConfiguration.Configuration.Formatters.Clear(); GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); StructureMapConfig.Register(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, ObjectFactory.Container); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); AutoMapperConfig.Register(); EmailServiceFactory.InitializeEmailServiceFactory(ObjectFactory.GetInstance <IMailService>()); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); StripeFactory.InitializeStripeFactory(ObjectFactory.GetInstance <IStripeService>()); XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/log4net.config"))); BundleTable.EnableOptimizations = ApplicationSettingsFactory.GetApplicationSettings().EnableOptimizations; #if DEBUG // HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize(); #endif }
protected void Application_Start() { GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; GlobalConfiguration.Configuration.DependencyResolver = new WebApiContrib.IoC.StructureMap.StructureMapResolver(BootStrapper.ConfigureStructureMapWebAPI()); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); BootStrapper.ConfigureStructureMap(); Services.AutoMapperBootStrapper.ConfigureAutoMapper(); RAM.Controllers.AutoMapperBootStrapper.ConfigureAutoMapper(); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); EmailServiceFactory.InitializeEmailServiceFactory (ObjectFactory.GetInstance <IEmailService>()); ControllerBuilder.Current.SetControllerFactory(new IOCControllerFactory()); LoggingFactory.GetLogger().Log("Application Started"); ModelBinders.Binders.DefaultBinder = new App_Start.GenericModelBinder(); }
public override void Initialize() { AppConfigManagerFactory.Initialize(IocManager.Resolve <IAppConfigManager>()); IocManager.RegisterType <ILogger, Log4NetAdapter>(DependencyLifeStyle.Singleton); LoggingFactory.Initialize(IocManager.Resolve <ILogger>()); IocManager.RegisterType <IEmailService, SmtpMailService>(DependencyLifeStyle.Singleton); EmailServiceFactory.Initialize(IocManager.Resolve <IEmailService>()); }
public EmailApp() { InitializeComponent(); IEmailServiceFactory emailServiceFactory = new EmailServiceFactory(); mailService = emailServiceFactory.GetMailServiceInstance(); logger = LoggerFactory <FileLogger> .GetInstance(new FileConfigBase() { filePath = ConfigurationManager.AppSettings["LoggerFolderPath"].ToString() }); ReBindValues(); }
public ActionResult SignUp(string plan, SignUpModel model) { if (ModelState.IsValid) { try { PlanSignUpRequest request = new PlanSignUpRequest { PlanName = Request.QueryString["plan"], SignUpModel = model }; PlanSignUpResponse response = _planService.PlanSignUp(request); if (response.HasError && response.ErrorCode == ErrorCode.PlanNotFound) { return(RedirectToAction("Pricing", "Plans")); } if (response.HasError && response.ErrorCode == ErrorCode.DomainAlreadyExists) { ModelState.AddModelError("Domain", "Domain already exists"); } var domainURL = "https://" + $"{model.Domain}{ConfigurationManager.AppSettings["HostnameBase"]}"; var emailTemplate = _emailTemplatesRepository.GetTemplateByName(Common.Helpers.Utilities.ToDescriptionString(EmailTemplateCode.SignUpGreeting)); model.PlanName = plan; emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, model); var mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); EmailServiceFactory.GetEmailService().SendMail(mailMessage); TempData["Domain"] = domainURL; return(RedirectToAction("thank-you")); } catch (Exception ex) { var errMsg = ex.Message; if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message)) { errMsg += ", " + ex.InnerException.Message; } LoggingFactory.GetLogger().Log(errMsg, EventLogSeverity.Error); ModelState.AddModelError("", errMsg); } } return(View(model)); }
public void SendMail(string from, string to, string subject, string body) { try { EmailServiceFactory.GetEmailService().SendMail(from, to, subject, body); } catch (MailMessageException mailEx) { LoggerFactory.CreateLog().LogError("Terminal server cannot sent email.", mailEx); throw new FaultException(mailEx.Message); } catch (Exception ex) { throw new FaultException(ex.Message); } }
//Can't get IAS.Common.Configuration solved protected void Application_Start(object sender, EventArgs e) { BootStrapper.ConfigureDependencies(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory (ObjectFactory.GetInstance <IApplicationSettings>()); LoggerFactory.SetCurrent(new Log4NetOICLogFactory()); EmailServiceFactory.InitializeEmailServiceFactory (ObjectFactory.GetInstance <IEmailService>()); EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory()); LoggerFactory.CreateLog().LogInfo("WebServiceStart Started"); }
public void SendMailWithAttachment(string from, string to, string subject, string body, IEnumerable <AttachStream> attachFiles) { try { EmailServiceFactory.GetEmailService().SendMail(from, to, subject, body, attachFiles); } catch (MailMessageException mailEx) { LoggerFactory.CreateLog().LogError("Terminal server cannot sent email.", mailEx); throw new FaultException(mailEx.Message); } catch (Exception ex) { throw new FaultException(ex.Message); } }
protected void Application_Start() { //注册autofac AutoFacBootStrapper.Register(); //初始化邮件 EmailServiceFactory.InitializeEmailServiceFactory(new SmtpService()); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //添加拦截器 DbInterception.Add(new EfInterceptorLogging()); DbInterception.Add(new EfInterceptorTransientErrors()); }
public void Handle(OrderSubmittedEvent domainEvent) { StringBuilder emailBody = new StringBuilder(); string emailAddress = domainEvent.Order.Customer.Email.Address; string emailSubject = String.Format("Agatha Order #{0}", domainEvent.Order.Id); emailBody.AppendLine(String.Format("Hello {0},", domainEvent.Order.Customer.Name.FirstName)); emailBody.AppendLine(); emailBody.AppendLine("The following order will be packed and dispatched as soon as possible."); emailBody.AppendLine(domainEvent.Order.ToString()); emailBody.AppendLine(); emailBody.AppendLine("Thank you for your custom."); emailBody.AppendLine("Agatha's"); EmailServiceFactory.GetEmailService().SendMail("*****@*****.**", emailAddress, emailSubject, emailBody.ToString()); }
protected void Application_Start(object sender, EventArgs e) { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); var container = IoC.Initialize(); Services.AutoMapperBootStrapper.ConfigureAutoMapper(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory (container.GetInstance <IApplicationSettings>()); LoggerFactory.InitializeLogFactory(container.GetInstance <ILogger>()); EmailServiceFactory .InitializeEmailServiceFactory(container.GetInstance <IEmailService>()); LoggerFactory.GetLogger().Log($"Application Started in {DateTime.Now}"); }
public static void ClassInitialize() { _dataBaseConfiguration = new TestsDataBaseConfiguration(); Container = new Container(c => { c.For <EFDbContext>().Use(_dataBaseConfiguration.DbContext).LifecycleIs <SingletonLifecycle>(); c.AddRegistry <TestsRegister>(); c.For <ICustomerResolver>().Use(new DatabaseCustomerResolver(_dataBaseConfiguration.ConnectionString)); }); TestsAutoMapperConfig.Register(); EmailServiceFactory.InitializeEmailServiceFactory(Container.GetInstance <IMailService>()); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(Container.GetInstance <IApplicationSettings>()); StripeFactory.InitializeStripeFactory(Container.GetInstance <IStripeService>()); }
public ActionResult ContactUs(ContactModel model) { if (ModelState.IsValid) { model.MailTo = ConfigurationManager.AppSettings["SendEmailTo"]; var emailTemplate = _emailTemplatesRepository.GetTemplateByName(Utilities.ToDescriptionString(EmailTemplateCode.ContactRequest)); emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, model); var mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); var sent = EmailServiceFactory.GetEmailService().SendMail(mailMessage); return(PartialView("_ContactUsSuccess")); } return(PartialView("_ContactUs", model)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //实现控制器依赖注入 ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory()); //调用AutoMapper配置 Configuration.Configure(); //初始化ApplicationSettingsFactory ApplicationSettingsFactory.InitApplicationSettingsFactory(new WebConfigApplicationSettings()); //初始化日志 LoggingFactory.InitLogFactory(new Log4NetWebAdapter()); //初始化邮件服务 EmailServiceFactory.InitEmailServiceFactory(new SMTPService()); //设置SQL缓存依赖的数据表 //var connectionStringName = ApplicationSettingsFactory.GetApplicationSettings().DBConnectionName; //var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; //SqlCacheDependencyAdmin.EnableNotifications(connectionString); //SqlCacheDependencyAdmin.EnableTableForNotifications(connectionString, new string[] //{ // "Users", // "UserStates", // "MonitoringTestTypes", // "MonitoringPointsPositions", // "MonitoringPointsNumbers" //}); var ninjectFactory = new NinjectControllerFactory(); IPreloadDataSet dataset = new GeneralPreloadDataSet( ninjectFactory.GetInstance <IMonitoringTestTypeService>(), ninjectFactory.GetInstance <IMonitoringPointsPositionService>(), ninjectFactory.GetInstance <IMonitoringPointsNumberService>()); var mornitoringTestTypeDatas = dataset.Load(PreloadDataSetType.MornitoringTestType); CacheHelper.SetCache(nameof(PreloadDataSetType.MornitoringTestType), mornitoringTestTypeDatas); var monitoringPointsPositionDatas = dataset.Load(PreloadDataSetType.MonitoringPointsPositionType); CacheHelper.SetCache(nameof(PreloadDataSetType.MonitoringPointsPositionType), monitoringPointsPositionDatas); var monitoringPointsNumberDatas = dataset.Load(PreloadDataSetType.MonitoringPointsNumberType); CacheHelper.SetCache(nameof(PreloadDataSetType.MonitoringPointsNumberType), monitoringPointsNumberDatas); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AutoMapperBootStrapper.ConfigureAutoMapper(); // Services.AutoMapper.AutoMapperBootStrapper.ConfigureAutoMapper(); EmailServiceFactory.InitializeEmailServiceFactory (DependencyResolver.Current.GetService <IEmailService>()); ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory()); _logger = DependencyResolver.Current.GetService <IErrorLogService>(); _logger.LogInfo(this, $"Application start: [ {DateTime.Now} ]"); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); StructureMapConfig.Register(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, ObjectFactory.Container); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AutoMapperConfig.Register(); AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.PrimarySid; MvcHandler.DisableMvcResponseHeader = true; EmailServiceFactory.InitializeEmailServiceFactory(ObjectFactory.GetInstance <IMailService>()); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); StripeFactory.InitializeStripeFactory(ObjectFactory.GetInstance <IStripeService>()); }
void Application_Start(object sender, EventArgs e) { // OfflineAll(); BootStrapper.ConfigureDependencies(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory (ObjectFactory.GetInstance <IApplicationSettings>()); LoggerFactory.SetCurrent(new Log4NetServiceLogFactory()); EmailServiceFactory.InitializeEmailServiceFactory (ObjectFactory.GetInstance <IEmailService>()); EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory()); LoggerFactory.CreateLog().LogInfo("Web Soria Started" + DateTime.Now.Minute); Thread thread = new Thread(new ThreadStart(ThreadFunc)); thread.IsBackground = true; thread.Name = "ThreadFunc"; thread.Start(); }
public static Boolean Sent(this MailMessage mailMessage) { try { using (SmtpClient SmtpServer = new SmtpClient()) { //if (mailMessage != null) // SmtpServer.Send(mailMessage); //else // return false; EmailServiceFactory.GetEmailService().SendMail(mailMessage); return(true); } } catch (Exception) { return(false); } }
protected void Application_Start() { IOCContainer.ConfigureDependencies(); RegisterRoutes(RouteTable.Routes); Services.AutoMapperBootStrapper.ConfigureAutoMapper(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory (IOCContainer.Container.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(IOCContainer.Container.GetInstance <ILogger>()); EmailServiceFactory.InitializeEmailServiceFactory (IOCContainer.Container.GetInstance <IEmailService>()); ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory()); LoggingFactory.GetLogger().Log("Application Started"); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); StructureMapConfig.Register(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, ObjectFactory.Container); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/log4net.config"))); AutoMapperConfig.Register(); EmailServiceFactory.InitializeEmailServiceFactory(ObjectFactory.GetInstance <IMailService>()); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>()); StripeFactory.InitializeStripeFactory(ObjectFactory.GetInstance <IStripeService>()); ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder()); }
public static void Send(DataTable table, string fromemail, string address, string comcode, string name, string email) { int count = table.Rows.Count; IASPersonEntities ctx = new IASPersonEntities(); //var ent = ctx.VW_IAS_COM_CODE.SingleOrDefault(s => s.ID == comcode).NAME; string comname = ctx.VW_IAS_COM_CODE.SingleOrDefault(s => s.ID == comcode).NAME; string emailSubject = "ระบบลงทะเบียนระบบช่องทางการบริหารตัวแทนหรือนายหน้าประกันภัย"; StringBuilder emailBody = new StringBuilder(); // emailBody.AppendLine("<div style='font-family: Verdana;font-size: 12px;'>"); emailBody.AppendLine(String.Format("{0} ขอจัดส่งข้อมูลรายชื่อผู้สมัครสอบ ระบบลงทะเบียนระบบช่องทางการบริหารตัวแทนหรือนายหน้าประกันภัย ", comname)); emailBody.AppendLine("ตามเอกสารแนบ"); emailBody.AppendLine(string.Format("ชื่อผู้นำส่งข้อมูล {0} email {1} ", name, email)); emailBody.AppendLine(string.Format("นำส่งข้อมูลเมื่อวันที่ {0} ", DateTime.Now.ToLongDateString())); emailBody.AppendLine(string.Format("ด้วยความเคารพ {0} ", comname)); // emailBody.AppendLine("</div>"); MailMessage _mailMessage = new MailMessage(fromemail, address) { IsBodyHtml = true, Subject = emailSubject, Body = emailBody.ToString() }; Attachment attachment = new Attachment(SendMailExel.CreateExel(table), comcode + DateTime.Now.ToLongDateString() + ".xlsx"); //_mailMessage.Attachments.Add(attachment); //using (SmtpClient SmtpServer = new SmtpClient()) //{ // if (_mailMessage != null) // { // SmtpServer.Send(_mailMessage); // } //} AttachStream attachFile = new AttachStream() { FileName = comcode + DateTime.Now.ToLongDateString() + ".xlsx", FileStream = SendMailExel.CreateExel(table) }; IList <AttachStream> listattach = new List <AttachStream>(); listattach.Add(attachFile); EmailServiceFactory.GetEmailService().SendMail(fromemail, address, "ระบบลงทะเบียนระบบช่องทางการบริหารตัวแทนหรือนายหน้าประกันภัย", emailBody.ToString(), listattach); }
public ActionResult SendRequest(ContactUsSupportModel model) { if (ModelState.IsValid) { try { model.MailTo = ConfigurationManager.AppSettings["SendEmailTo"]; var emailTemplate = _emailTemplatesRepository.GetTemplateByName(Utilities.ToDescriptionString(EmailTemplateCode.SupportContactUs)); emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, model); var mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); var sent = EmailServiceFactory.GetEmailService().SendMail(mailMessage); if (sent == true) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } } catch (Exception ex) { var errMsg = ex.Message; if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message)) { errMsg += ", " + ex.InnerException.Message; } LoggingFactory.GetLogger().Log(errMsg, EventLogSeverity.Error); return(Json(new { success = false })); } } return(Json(new { success = false })); }
public ActionResult Index(string plan, ContactModel model) { if (ModelState.IsValid) { try { // send email EmailTemplate emailTemplate = _emailTemplatesRepository.GetTemplateByName( SaaSPro.Common.Helpers.Utilities.ToDescriptionString(EmailTemplateCode.ContactRequest)); model.MailTo = ConfigurationManager.AppSettings["MailTo"]; emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, model); MailMessage mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); bool emailResult = EmailServiceFactory.GetEmailService().SendMail(mailMessage); if (emailResult) { return(RedirectToAction("thank-you")); } ModelState.AddModelError("", "There was a problem "); } catch (Exception ex) { var errMsg = ex.Message; if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message)) { errMsg += ", " + ex.InnerException.Message; } LoggingFactory.GetLogger().Log(errMsg, EventLogSeverity.Error); ModelState.AddModelError("", errMsg); } } return(View(model)); }
public static void SendMailAddOwnerToExamRoom(DTO.EmailAddOwnerToExamRoom Data) { String emailOut = ConfigurationManager.AppSettings["EmailOut"].ToString(); StringBuilder emailBody = new StringBuilder(); string title = "แจ้งข้อมูลการสอบของตัวแทน/นายหน้า ในระบบช่องทางการบริการตัวแทน/นายหน้าประกันภัยแบบเบ็ดเสร็จ"; emailBody.AppendLine(" สำนักงานคณะกรรมการกำกับและส่งเสริมการประกอบธุรกิจประกันภัย (คปภ.) <br/>"); emailBody.AppendLine(string.Format(" เรื่อง <strong>{0}</strong>", title)); emailBody.AppendLine("<br/><br/>"); emailBody.AppendLine("ระบบทำการจัดห้องสอบเรียบร้อยแล้ว<br/>"); emailBody.AppendLine("โดยมีรายละเอียดดังนี้<br/><br/>"); emailBody.AppendLine(string.Format("รหัสสอบ : <strong>{0}</strong><br/>", Data.TESTING_NO)); emailBody.AppendLine(string.Format("สอบวันที่ : <strong>{0} {1} น.</strong><br/>", Data.TESTING_DATE.Value.ToShortDateString(), Data.TEST_TIME)); emailBody.AppendLine(string.Format("ห้องสอบ : <strong>{0}</strong><br/>", Data.EXAM_ROOM_NAME)); foreach (string email in Data.EMAIL) { try { EmailServiceFactory.GetEmailService().SendMail(emailOut, email.Trim(), title, emailBody.ToString()); } catch { } } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Bootstrap.ConfigureDependencies(); ControllerBuilder.Current.SetControllerFactory(new StructuremapControllerFactory()); // Services.AutoMapperBootStrapper.ConfigureAutoMapper(); ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance<IApplicationSettings>()); LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance<ILogger>()); EmailServiceFactory.InitializeEmailServiceFactory (ObjectFactory.GetInstance<IEmailService>()); LoggingFactory.GetLogger().Log("Application Started"); }
/// <summary> /// Sign up a user to a plan /// </summary> /// <param name="request">Sign up request</param> public PlanSignUpResponse PlanSignUp(PlanSignUpRequest request) { try { // Begin transaction _unitOfWork.Begin("PlanSignUp"); var response = new PlanSignUpResponse(); var dbPlan = _planRepository.Query().FirstOrDefault(p => p.PlanCode.ToLower() == request.PlanName.ToLower()); if (dbPlan == null) { response.HasError = true; response.ErrorCode = ErrorCode.PlanNotFound; return(response); } if (request.SignUpModel.Domain != null) { if ( _customerRepository.Query().Any( t => t.Hostname.ToLower() == request.SignUpModel.Domain.ToLower())) { response.ErrorCode = ErrorCode.DomainAlreadyExists; response.HasError = true; return(response); } } // Customer var customer = new Customer(request.SignUpModel.FullName, request.SignUpModel.Domain, request.SignUpModel.Company); _customerRepository.Add(customer); // Role var role = new Role(customer, "Administrator", true, UserType.SystemUser); _roleRepository.Add(role); // Setup the User var user = new User(customer, request.SignUpModel.Email, request.SignUpModel.FirstName, request.SignUpModel.LastName, request.SignUpModel.Password); _userRepository.Add(user); role.AddUser(user); customer.UpdateAdminUser(user); // Security questions var referenceList = _referenceListRepository.Query().FirstOrDefault(l => l.SystemName == "Security Questions"); if (referenceList == null) { throw new NullReferenceException("Security questions reference list is null"); } foreach (var securityQuestion in SecurityQuestions.Questions) { referenceList.AddItem(customer, securityQuestion); } // User security questions user.AddSecurityQuestion("a", "a"); user.AddSecurityQuestion("b", "b"); user.AddSecurityQuestion("c", "c"); // Create customer in stripe var stripeCustomer = StripeFactory.GetStripeService().CreateCustomer(request.SignUpModel.FullName, request.SignUpModel.Email); customer.PaymentCustomerId = stripeCustomer.Id; // Associate plan var result = StripeFactory.GetStripeService().AssignCustomerPlan(customer.PaymentCustomerId, dbPlan.PlanCode, request.SignUpModel.CardNumber, request.SignUpModel.SecurityCode, int.Parse( request.SignUpModel.Expiration. Substring(0, 2)), int.Parse( request.SignUpModel.Expiration. Substring(3, 2))); if (result != "active") { throw new Exception($"Incorrect assigning plan result for Customer {customer.FullName}"); } customer.UpdatePlan(dbPlan); _customerRepository.Update(customer); // End transaction _unitOfWork.End(); // Send email var emailTemplate = _emailTemplatesRepository.GetTemplateByName( EmailTemplateCode.SignUpGreeting.ToDescriptionString()); emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, customer); var mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate); var emailResult = EmailServiceFactory.GetEmailService().SendMail(mailMessage); if (!emailResult) { throw new Exception("Problem sending email"); } return(response); } catch (StripeException ex) { LoggingFactory.GetLogger().LogError(ex); throw new Exception("Assigning customer plan error", ex); } catch (Exception ex) { LoggingFactory.GetLogger().LogError(ex); throw; } }
protected void btnSendMail_Click(object sender, EventArgs e) { EmailServiceFactory.GetEmailService().SendMail("*****@*****.**", "*****@*****.**", "TestSendMail", "Hello World!!!!"); //AttachStream attachFile = new AttachStream(){ FileName="ddd", FileStream= //EmailServiceFactory.GetEmailService().SendMail( }