public bool SendEmailChangePlanBeforeStart(doChangePlanBeforeStartEmail templateObj) { try { if (templateObj == null) { throw new ArgumentNullException("templateObj"); } ICommonHandler common = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; var config = common.GetSystemConfig(ConfigName.C_CONFIG_CHANGEPLAN_BEFORE_START_EMAIL).FirstOrDefault(); if (config == null) { throw new ApplicationException("Missing tbs_configuration : " + ConfigName.C_CONFIG_CHANGEPLAN_BEFORE_START_EMAIL); } EmailTemplateUtil mailUtil = new EmailTemplateUtil(EmailTemplateName.C_EMAIL_TEMPLATE_NAME_CHANGEPLAN_BEFORE_START); var mailTemplate = mailUtil.LoadTemplate(templateObj); doEmailProcess mailMsg = new doEmailProcess(); mailMsg.MailFrom = CommonUtil.dsTransData.dtUserData.EmailAddress; mailMsg.MailFromAlias = null; mailMsg.MailTo = config.ConfigValue; mailMsg.Subject = mailTemplate.TemplateSubject; mailMsg.Message = mailTemplate.TemplateContent; mailMsg.IsBodyHtml = true; ICommonHandler comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; comHandler.SendMail(mailMsg); return(true); } catch (Exception) { throw; } }
public ActionResult CTP060_UpdateEmailContentOfNotifyEmail() { ObjectResultData res = new ObjectResultData(); IContractHandler conHandler = ServiceContainer.GetService <IContractHandler>() as IContractHandler; IRentralContractHandler rentalConHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; IMasterHandler masterHandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; IEmployeeMasterHandler empMasterHandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; IBillingMasterHandler billingmasterhandler = ServiceContainer.GetService <IBillingMasterHandler>() as IBillingMasterHandler; IOfficeMasterHandler officehandler = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler; IBillingHandler billinghandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; List <tbm_Customer> dtCustomer; List <doGetTbm_Site> dtSite; List <tbm_Employee> dtEmployee; decimal?contractFeeBeforeChange; decimal?ChangeContractFee; try { CommonUtil comUtil = new CommonUtil(); doNotifyChangeFeeContract doNotifyEmail = new doNotifyChangeFeeContract(); List <tbt_ContractEmail> updateContractEmailList = new List <tbt_ContractEmail>(); using (TransactionScope scope = new TransactionScope()) { List <tbt_ContractEmail> contractEmailList = conHandler.GetUnsentNotifyEmail(); foreach (tbt_ContractEmail data in contractEmailList) { List <tbt_BillingBasic> doBillingBasic = billinghandler.GetTbt_BillingBasic(data.ContractCode, "01"); List <tbt_BillingTarget> doBillingTarget = billinghandler.GetTbt_BillingTarget(doBillingBasic[0].BillingTargetCode, null, null); dsRentalContractData dsRentalContract = rentalConHandler.GetEntireContract(data.ContractCode, data.OCC); if (dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate != null) { var operationOfficeDat = officehandler.GetTbm_Office(dsRentalContract.dtTbt_RentalContractBasic[0].OperationOfficeCode); var billingOfficeDat = officehandler.GetTbm_Office(doBillingTarget[0].BillingOfficeCode); EmailTemplateUtil mailUtil = new EmailTemplateUtil(EmailTemplateName.C_EMAIL_TEMPLATE_NAME_CHANGE_FEE); dtCustomer = masterHandler.GetTbm_Customer(dsRentalContract.dtTbt_RentalContractBasic[0].ContractTargetCustCode); dtSite = masterHandler.GetTbm_Site(dsRentalContract.dtTbt_RentalContractBasic[0].SiteCode); dtEmployee = empMasterHandler.GetTbm_Employee(data.CreateBy); contractFeeBeforeChange = rentalConHandler.GetContractFeeBeforeChange(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, dsRentalContract.dtTbt_RentalSecurityBasic[0].OCC, dsRentalContract); doNotifyEmail.ContractCode = comUtil.ConvertContractCode(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); doNotifyEmail.ContractTargetNameEN = dtCustomer[0].CustFullNameEN; doNotifyEmail.ContractTargetNameLC = dtCustomer[0].CustFullNameLC; doNotifyEmail.SiteNameEN = dtSite[0].SiteNameEN; doNotifyEmail.SiteNameLC = dtSite[0].SiteNameLC; doNotifyEmail.ChangeDateOfContractFee = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ChangeImplementDate); doNotifyEmail.ContractFeeBeforeChange = CommonUtil.TextNumeric(contractFeeBeforeChange); if (dsRentalContract.dtTbt_RentalContractBasic[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_STOPPING) { ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].ContractFeeOnStop; } else { ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].OrderContractFee; } doNotifyEmail.ContractFeeAfterChange = CommonUtil.TextNumeric(ChangeContractFee); doNotifyEmail.ReturnToOriginalFeeDate = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate); doNotifyEmail.OperationOfficeEN = operationOfficeDat[0].OfficeNameEN; doNotifyEmail.OperationOfficeLC = operationOfficeDat[0].OfficeNameLC; doNotifyEmail.RegisterChangeEmpNameEN = dtEmployee[0].EmpFirstNameEN + ' ' + dtEmployee[0].EmpLastNameEN; doNotifyEmail.RegisterChangeEmpNameLC = dtEmployee[0].EmpFirstNameLC + ' ' + dtEmployee[0].EmpLastNameLC; doNotifyEmail.BillingOfficeEN = billingOfficeDat[0].OfficeNameEN; doNotifyEmail.BillingOfficeLC = billingOfficeDat[0].OfficeNameLC; var mailTemplate = mailUtil.LoadTemplate(doNotifyEmail); data.EmailContent = mailTemplate.TemplateContent; tbt_ContractEmail conEmailTemp = CommonUtil.CloneObject <tbt_ContractEmail, tbt_ContractEmail>(data); updateContractEmailList.Add(conEmailTemp); } } if (updateContractEmailList != null && updateContractEmailList.Count > 0) { conHandler.UpdateTbt_ContractEmail(updateContractEmailList); } scope.Complete(); } } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult TestSendMail() { ObjectResultData res = new ObjectResultData(); try { ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; //doEmailProcess dtEmail = new doEmailProcess(); ////dtEmail.MailFrom = "*****@*****.**"; ////dtEmail.MailFromAlias = "Narupon"; //dtEmail.MailTo = "[email protected] ; [email protected] ; [email protected] ; [email protected] ; [email protected] ; [email protected]"; //dtEmail.Message = "This is test send email process from SECOM" + Environment.NewLine + Environment.NewLine // + "ทดสอบการส่งอีกเมลจาก SECOM" + Environment.NewLine + Environment.NewLine // + "これは、テストがセコムからのメール送信処理です。" + Environment.NewLine + Environment.NewLine // + "Time stamp :" + DateTime.Now.ToString() // ; //dtEmail.Subject = "SECOM-AJIS Test send mail"; //handler.SendMail(dtEmail); string strEmailTemplateName = EmailTemplateName.C_EMAIL_TEMPLATE_NAME_AR_RETURNED; EmailTemplateUtil mailUtil = new EmailTemplateUtil(strEmailTemplateName); doEmailWithURL templateObj = new doEmailWithURL(); templateObj.ViewURL = "-LinkEN-"; templateObj.ViewURLLC = "-LinkLC-"; templateObj.ARRelatedCode = "-ARRelatedCode-"; templateObj.ARRequestNo = "-ARRequestNo-"; templateObj.ARTypeEN = "-ARTypeEN-"; templateObj.ARTypeLC = "-ARTypeLC-"; templateObj.ARTitleEN = "-ARTitleEN-"; templateObj.ARTitleLC = "-ARTitleLC-"; templateObj.ARSubtitle = "-ARSubtitle-"; templateObj.ARPurpose = "-ARPurpose-"; var mailTemplate = mailUtil.LoadTemplate(templateObj); doEmailProcess mailMsg = new doEmailProcess(); mailMsg.MailFrom = "*****@*****.**"; mailMsg.MailFromAlias = "Jutarat"; mailMsg.MailTo = "*****@*****.**"; mailMsg.Subject = mailTemplate.TemplateSubject; mailMsg.Message = mailTemplate.TemplateContent; handler.SendMail(mailMsg); ViewBag.SendEmailResult = "Send e-mail is completed."; } catch (Exception ex) { res.AddErrorMessage(ex); ViewBag.SendEmailResult = "Send e-mail is failed."; } return(View()); }