public void TestEmailSend() { FastEmail email = new FastEmail(); FastEmailConfiguration config = new FastEmailConfiguration(sender: "*****@*****.**", server: "10.164.34.27", password: "******", port: 25, enableSSL: false); email.Receipients = new System.Collections.Generic.List <string>() { "*****@*****.**" }; email.CCList = new System.Collections.Generic.List <string>() { "*****@*****.**", "*****@*****.**" }; email.Subject = "Test Email"; email.HTMLBody = "<div style=\"padding-top: 5px; padding-left: 5px; padding-right: 5px; padding-bottom: 5px; width: 100%; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #666666; background-color: #e00000; \"><img width=\"200\" height=\"50\" src=\"https://dl.dropboxusercontent.com/u/97422769/Images/fastrack_brand.png\" alt=\"fastrack brand logo\" /></div>"; try { _mailer = new SMTPEmail(config, email); _mailer.SendSynchronousEmail(); Assert.IsTrue(true); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void TissueBank_Add(string TissueBankName, string ContactPersonFirstName, string ContactPersonLastName, string ContactPersonNumber, string ContactPersonEmailId, string FaxNumber, string TissueBankEmailId, string BusinessURL, string TissueBankAddress, int CityId, string ZipCode, string TissueBankStateLicense, string AATBLicenseNumber, DateTime AATBExpirationDate, DateTime AATBAccredationDate, string CreditCardNumber, int CreditCardType, string ExpiryDate, string CardCode, string CustomerProfileId, string CustomerPaymentProfileIds, string BillingAddress, int BillingCityId, string BillingZipCode, string BillingFaxNumber, string BillingEmailId, string BillingContactNumber, string BillingCity, string BillingState, string State, string City, int UserId, int TissueBankId, int TransactionId, string AuthTransactionId, string AuthCode, int StatusId, DateTime TransactionCompleteDate, string ResponseBody, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); TissueBankBusinessRule tbBusinessRule = new TissueBankBusinessRule(tbDataService); try { tbDataService.TissueBank_Add(TissueBankName, ContactPersonFirstName, ContactPersonLastName, ContactPersonNumber, ContactPersonEmailId, FaxNumber, TissueBankEmailId, BusinessURL, TissueBankAddress, CityId, ZipCode, TissueBankStateLicense, AATBLicenseNumber, AATBExpirationDate, AATBAccredationDate, CreditCardNumber, CustomerProfileId, CustomerPaymentProfileIds, BillingAddress, BillingCityId, BillingZipCode, BillingFaxNumber, BillingEmailId, BillingContactNumber, UserId, TissueBankId, TransactionId, AuthTransactionId, AuthCode, StatusId, TransactionCompleteDate, ResponseBody, out transaction); if (transaction.ReturnStatus == true) { SMTPEmail email = new SMTPEmail(); MailBody mb = new MailBody(); mb.ContactPersonName = ContactPersonFirstName + " " + ContactPersonFirstName; mb.ContactPersonEmailId = ContactPersonEmailId; mb.MailType = "TissueBank_Add"; email.sendMail(mb); } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { tbDataService.CloseSession(); } }
public void TissueBank_User_Registration(string FullName, string UserName, string EmailId, string SecurityQuestion, string SecurityAnswer, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); TissueBankBusinessRule tbBusinessRule = new TissueBankBusinessRule(tbDataService); try { tbDataService.CreateSession(); tbBusinessRule.ValidateTissueBankUserRegistration(FullName, UserName, EmailId, SecurityQuestion, SecurityAnswer); if (tbBusinessRule.ValidationStatus == true) { string Password = Utilities.RandomAlphaNumeric(6); int UserId = tbDataService.TissueBank_User_Registration(FullName, UserName, EmailId, SecurityQuestion, SecurityAnswer, Password, out transaction); if (transaction.ReturnStatus == true) { SMTPEmail email = new SMTPEmail(); MailBody mb = new MailBody(); mb.Password = Password; mb.ContactPersonEmailId = EmailId; mb.ContactPersonName = FullName; mb.UserId = UserId; mb.MailType = "VerifyUserRegistration"; email.sendMail(mb); } } else { transaction.ReturnStatus = tbBusinessRule.ValidationStatus; transaction.ReturnMessage = tbBusinessRule.ValidationMessage; transaction.ValidationErrors = tbBusinessRule.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { tbDataService.CloseSession(); } }
public void SendMailTest() { SMTPEmail email = new SMTPEmail(); email.From = ConfigurationManager.AppSettings["FromAddress"]; email.To = ConfigurationManager.AppSettings["ToAddress"]; email.SMTPClient = ConfigurationManager.AppSettings["SMTP"]; email.SMTPServer = ConfigurationManager.AppSettings["SMTP"]; email.SMTPPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); email.Password = ConfigurationManager.AppSettings["Password"]; email.Domain = ConfigurationManager.AppSettings["Domain"]; email.IsSSL = bool.Parse(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["EnableSSL"])? ConfigurationManager.AppSettings["EnableSSL"] :"false"); email.UseDefaultCredentials = bool.Parse(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UseDefaultCredentials"]) ? ConfigurationManager.AppSettings["UseDefaultCredentials"] : "false"); email.Subject = "[OSJ] SendMailTest "; email.Message = "Amigos de la Torre<br /><br />El viernes 21/03/14 comienza el curso de <b>'Astronomía Observacional'</b>, el objeto de este curso es que el alumno adquiera un conocimiento integral del cielo nocturno y aprenda paulatinamente conceptos como: sistemas de coordenadas, constelaciones, movimientos de los planetas, principales estrellas y lectura e interpretación de diferentes cartas celestes. El curso está basado principalmente en observaciones prácticas, con diferentes instrumentos, a fin de que los participantes logren familiarizarse rápidamente con el firmamento. Las observaciones con los instrumentos del observatorio se harán de acuerdo a las efemérides y a las condiciones meteorológicas." + "<br /><br /><b>Dados los contenidos y metodologías aplicadas en el curso, el mismo es para adultos y chicos de 12 años en adelante y no se necesitan conocimientos previos de matemática, física o astronomía.</b>" + "<b><br /><br /><ul><li>Comienzo: viernes 21/03/14</li><li>Duración: 4 clases</li><li>Horario: viernes de 20 a 22 hs</li><li>Arancel: $300 (se abonan el mismo día del inicio del curso) - Alumnos del Colegio San José gratis - Todo lo recaudado se destina al mantenimiento del observatorio</li><li>Dirección: Bartolomé Mitre 2455, Capital Federal (Colegio San José)</li><li>Informes e inscripción:<br />www.observatoriosanjose.com.ar<br />[email protected]<br />[email protected]</b></li></ul>"; Assert.IsTrue(MailUtils.SendEmail(email)); }
public int RegisterUser(int userID) { tracer.Info("Registering : " + userID.ToString()); Registration regData; Employee empData = _unitOfWork.Employees.GetByID(userID); string password = string.Empty; string clearPwd = string.Empty; if (empData != null) { int recordFound = _unitOfWork.Registrations.GetAllQueryable().Where(m => m.EmployeeID == userID).ToList().Count; if (recordFound == 0) { password = System.Web.Security.Membership.GeneratePassword(8, 0); clearPwd = password; password = MD5HashProvider.CreateMD5Hash(Regex.Replace(password, @"[^a-zA-Z0-9]", m => "$")); regData = new Registration() { EmployeeID = userID, Password = password, Status = 1, DateStamp = DateTime.Now }; _unitOfWork.Registrations.Insert(regData); if (_unitOfWork.Save() > 0) { tracer.Info("Registration Success. Sending Email Notification."); //send email notification to user uisng the emp email FastEmail email = new FastEmail(); email.Receipients = new List <string>() { empData.EmailAddress }; email.Subject = FASTConstant.EMAIL_SIMPLE_SUBJECT.Replace("[XXX]", "User Registration"); email.HTMLBody = Helper.EmailHelper.GenerateHTMLBody(Helper.EmailHelper.EmailType.REGISTRATION); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_RECEIPIENT_NAME, empData.FirstName + " " + empData.LastName); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_USERNAME, empData.EmployeeID.ToString()); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_PASSWORD, clearPwd); SMTPEmail emailSender = new SMTPEmail(_emailConfig, email); emailSender.SendEmail(); _unitOfWork.LogSuccess(FASTConstant.AUDIT_ACTION_USER_REG, "", employeeID: userID); return(FASTConstant.RETURN_VAL_SUCCESS); } else { tracer.Warn("Registration Failed."); return(FASTConstant.RETURN_VAL_FAILED); } } else { tracer.Warn("Registration Failed. User already registered."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_REG, "Duplicate ID", employeeID: userID); return(FASTConstant.RETURN_VAL_DUPLICATE); } } else { tracer.Warn("Registration Failed. User not found in DB."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_REG, "Not Found", employeeID: userID); return(FASTConstant.RETURN_VAL_NOT_FOUND); } }
public int ResetPassword(int userID) { tracer.Info("Reset Password : "******"[^a-zA-Z0-9]", m => "$"); password = MD5HashProvider.CreateMD5Hash(clearPassword); regData.Password = password; _unitOfWork.Registrations.Update(regData); if (_unitOfWork.Save() > 0) { tracer.Info("Reset Password Success. Sending Email Notification."); //notify through email FastEmail email = new FastEmail(); email.Receipients = new List <string>() { empData.EmailAddress }; email.Subject = FASTConstant.EMAIL_SIMPLE_SUBJECT.Replace("[XXX]", "Reset Password"); email.HTMLBody = Helper.EmailHelper.GenerateHTMLBody(Helper.EmailHelper.EmailType.RESET_PASSWORD); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_RECEIPIENT_NAME, empData.FirstName + " " + empData.LastName); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_USERNAME, empData.EmployeeID.ToString()); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_PASSWORD, clearPassword); SMTPEmail emailSender = new SMTPEmail(_emailConfig, email); emailSender.SendEmail(); _unitOfWork.LogSuccess(FASTConstant.AUDIT_ACTION_USER_RESET, "", employeeID: userID); return(FASTConstant.RETURN_VAL_SUCCESS); } else { tracer.Warn("Reset Password Failed."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_RESET, "", employeeID: userID); return(FASTConstant.RETURN_VAL_FAILED); } } else { tracer.Warn("Reset Password Failed. User Not Found."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_RESET, "Not Found", employeeID: userID); return(FASTConstant.RETURN_VAL_NOT_FOUND); } } else { tracer.Warn("Reset Password Failed. User Not Found."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_RESET, "Not Found", employeeID: userID); return(FASTConstant.RETURN_VAL_NOT_FOUND); } }
public int ChangePassword(int userID, string newHashedPassword, string oldHashedPassword) { tracer.Info("Change Password : "******"Change Password Success. Sending Email Notification."); //Notify through email FastEmail email = new FastEmail(); email.Receipients = new List <string>() { empData.EmailAddress }; email.Subject = FASTConstant.EMAIL_SIMPLE_SUBJECT.Replace("[XXX]", "Change Password"); email.HTMLBody = Helper.EmailHelper.GenerateHTMLBody(Helper.EmailHelper.EmailType.CHANGE_PASSWORD); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_RECEIPIENT_NAME, empData.FirstName + " " + empData.LastName); SMTPEmail emailSender = new SMTPEmail(_emailConfig, email); emailSender.SendEmail(); _unitOfWork.LogSuccess(FASTConstant.AUDIT_ACTION_USER_CHANGE_PWD, "", employeeID: userID); return(FASTConstant.RETURN_VAL_SUCCESS); } else { tracer.Warn("Change Password Failed."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_CHANGE_PWD, "", employeeID: userID); return(FASTConstant.RETURN_VAL_FAILED); } } else { tracer.Warn("Change Password Failed. Old Password Invalid."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_CHANGE_PWD, "Old password not match.", employeeID: userID); return(FASTConstant.RETURN_VAL_FAILED); } } else { tracer.Warn("Change Password Failed. User Not Found."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_CHANGE_PWD, "Not Found", employeeID: userID); return(FASTConstant.RETURN_VAL_NOT_FOUND); } } else { tracer.Warn("Change Password Failed. User Not Found."); _unitOfWork.LogFailure(FASTConstant.AUDIT_ACTION_USER_CHANGE_PWD, "Not Found", employeeID: userID); return(FASTConstant.RETURN_VAL_NOT_FOUND); } }
public ActionResult UploadFile() { ExcelHelper excelHelp = new ExcelHelper(); List <FixAssetExcelUploadModel> assets = new List <FixAssetExcelUploadModel>(); BulkUpload currentUpload = new Common.BulkUpload(); BulkUploadProcess bulkProcess = new BulkUploadProcess(); AssetProcess assetProcess = new AssetProcess(); EmployeeProcess employeeProcess = new EmployeeProcess(); Employee sender = new Employee(); ConfigurationProcess configProcess = new ConfigurationProcess(); FastEmailConfiguration emailConfig = configProcess.GetEmailConfiguration(); StringBuilder uploadLog = new StringBuilder(); string filename = string.Empty; string completeFileName = string.Empty; //This is for the logging bulkProcess.UserID = User.Identity.Name.ToInteger(); configProcess.UserID = User.Identity.Name.ToInteger(); employeeProcess.UserID = User.Identity.Name.ToInteger(); assetProcess.UserID = User.Identity.Name.ToInteger(); try { #region Get Request Files foreach (string upload in Request.Files) { if (!(Request.Files[upload] != null && Request.Files[upload].ContentLength > 0)) { continue; } string path = HttpContext.Server.MapPath("\\App_Data\\BulkUploads"); filename = Path.GetFileName(Request.Files[upload].FileName); //check the filename and ensure its an xlsx file if (String.Compare(filename.Substring(filename.Length - 4), "xlsx", true) != 0) { throw new Exception("Invalid file extension."); } //add the current time as unique indicator filename = DateTime.Now.ToFileTime().ToString() + "_" + filename; // If Upload folder is not yet existing, this code will create that directory. if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } completeFileName = Path.Combine(path, filename); Request.Files[upload].SaveAs(completeFileName); } #endregion BulkUpload newFile = new BulkUpload() { EmployeeID = User.Identity.Name.ToInteger(), FilePath = filename, TotalRecords = 0, TotalInserts = 0, RequestDate = DateTime.Now, Type = FASTConstant.BULKIPLOAD_TYPE_ASSET }; if (bulkProcess.Add(newFile) == FASTConstant.RETURN_VAL_SUCCESS) { //get the current upload currentUpload = bulkProcess.GetCurrentUpload(newFile.FilePath, newFile.EmployeeID); } if (currentUpload != null) { #region Process the excel file //Success! Lets process the file. System.Data.DataTable fixAssetTable = new DataTable(); fixAssetTable = excelHelp.GetExcelDataTable(completeFileName, "SELECT * FROM [FixAsset$]"); fixAssetTable = excelHelp.ConvertToFixAssetTable(fixAssetTable); if (fixAssetTable == null) { throw new Exception("The upload file contains null data."); } assets = fixAssetTable.ToList <Models.FixAssetExcelUploadModel>(); sender = employeeProcess.GetEmployeeByID(currentUpload.EmployeeID); if (assets.Count > 0) { int totalInserts = 0; currentUpload.TotalRecords = assets.Count; bulkProcess.UpdateProcessingStep(currentUpload, FASTConstant.BULKUPLOAD_STATUS_INPROGRESS); foreach (FixAssetExcelUploadModel asset in assets) { FixAsset tempAsset = new FixAsset() { AssetTag = asset.AssetTag, SerialNumber = asset.SerialNumber, Model = asset.Model, Brand = asset.Brand, AssetClassID = asset.AssetClassID, AssetTypeID = asset.AssetTypeID, AssetStatusID = asset.AssetStatusID, AcquisitionDate = asset.AcquisitionDate }; if (assetProcess.Add(tempAsset) == FASTConstant.RETURN_VAL_SUCCESS) { totalInserts++; uploadLog.AppendLine(String.Format("<p>{0} : {1} inserted.</p>", FASTConstant.SUCCESSFUL, asset.AssetTag)); } else { uploadLog.AppendLine(String.Format("<p>{0} : {1} not inserted.</p>", FASTConstant.FAILURE, asset.AssetTag)); } } currentUpload.TotalInserts = totalInserts; bulkProcess.UpdateProcessingStep(currentUpload, FASTConstant.BULKUPLOAD_STATUS_DONE); //Send email to the requestor FastEmail email = new FastEmail(); email.Receipients = new List <string>() { sender.EmailAddress }; email.Subject = FASTConstant.EMAIL_SIMPLE_SUBJECT.Replace("[XXX]", "Fix Asset Bulk Upload Result"); email.HTMLBody = FASTProcess.Helper.EmailHelper.GenerateHTMLBody(FASTProcess.Helper.EmailHelper.EmailType.BULK_UPLOAD); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_RECEIPIENT_NAME, sender.FirstName + " " + sender.LastName); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_BULKUPLOAD_INFO, bulkProcess.GenerateUploadinformationHTML(currentUpload)); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_BULKUPLOAD_LOG, uploadLog.ToString()); email.HTMLBody = email.HTMLBody.Replace(FASTConstant.EMAIL_BULKUPLOAD_SUMMARY, bulkProcess.GenerateSummaryinformationHTML(currentUpload)); SMTPEmail emailSender = new SMTPEmail(emailConfig, email); emailSender.SendEmail(); } else { bulkProcess.UpdateProcessingStep(currentUpload, FASTConstant.BULKUPLOAD_STATUS_DONE); } #endregion } TempData["Result"] = "SUCCESSFUL"; TempData["Source"] = "File Upload"; TempData["ExtraMessage"] = "An email will be sent to you containing the results of the upload process."; TempData["Action"] = "Index"; TempData["Controller"] = "FixAsset"; return(View("~/Views/Shared/Result.cshtml")); } catch (Exception ex) { TempData["Result"] = "FAILURE"; TempData["Source"] = "Fix Asset Bulk Upload"; TempData["ExtraMessage"] = ex.Message; return(View("~/Views/Shared/Result.cshtml")); } }
public BusinessLogicIP() { email = new SMTPEmail(); ConfigureMailSettings(); }
public void User_CreateUpdateDelete(int UserId, string UserName, string Password, string FullName, string MobileNumber, string EmailId, int CreatedBy, int LastModifiedBy, int InfoId, string OperationType, bool AllowLogin, DataTable TempUser_CUD, bool IsSendMail, string PasswordQuestion, string PasswordAnswer, string SecurityQuestion, string SecurityAnswer, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); UserBusinessRule userBusinessRule = new UserBusinessRule(userDataService); try { userDataService.CreateSession(); userBusinessRule.ValidateUser_CUD(UserId, UserName, Password, FullName, MobileNumber, EmailId, CreatedBy, LastModifiedBy, InfoId, OperationType, AllowLogin, TempUser_CUD, IsSendMail, PasswordQuestion, PasswordAnswer, SecurityQuestion, SecurityAnswer); if (userBusinessRule.ValidationStatus == true) { // TempUser_CUD.Columns.Remove("Disable"); if (OperationType == "changePass" || OperationType == "UserUpdate") { if (TempUser_CUD == null) { DataTable dt = new DataTable(); dt.Columns.Add("RoleID", typeof(int)); dt.Columns.Add("UserID", typeof(int)); dt.Rows.Add(0, 0); TempUser_CUD = dt; } } else { TempUser_CUD.Columns.Remove("RoleName"); TempUser_CUD.Columns.Add("UserId", typeof(int)); if (OperationType == "insert") { Password = Utility.Utilities.RandomAlphaNumeric(6); //BHASKAR SIR for (int i = 0; i < TempUser_CUD.Rows.Count; ++i) { TempUser_CUD.Rows[i]["UserId"] = 0; } } else { for (int i = 0; i < TempUser_CUD.Rows.Count; ++i) { TempUser_CUD.Rows[i]["UserId"] = UserId; } } } int EffectedUserId = userDataService.User_CreateUpdateDelete(UserId, UserName, Password, FullName, MobileNumber, EmailId, CreatedBy, LastModifiedBy, InfoId, OperationType, AllowLogin, TempUser_CUD, PasswordQuestion, PasswordAnswer, SecurityQuestion, SecurityAnswer, out transaction); //send mail if (OperationType == "changePass") { SMTPEmail email = new SMTPEmail(); MailBody mb = new MailBody(); if (IsSendMail == true) { TransactionalInformation tempTransction = new TransactionalInformation(); User user = userDataService.GetUserById(EffectedUserId, out tempTransction); mb.Password = Password; mb.ContactPersonEmailId = user.EmailId; mb.ContactPersonName = user.FullName; mb.UserId = EffectedUserId; mb.MailType = "changePass"; email.sendMail(mb); } } else if (OperationType == "insert") { SMTPEmail email = new SMTPEmail(); MailBody mb = new MailBody(); mb.Password = Password; mb.ContactPersonEmailId = EmailId; mb.ContactPersonName = FullName; mb.UserId = EffectedUserId; mb.MailType = "VerifyUserRegistration"; email.sendMail(mb); } } else { transaction.ReturnStatus = userBusinessRule.ValidationStatus; transaction.ReturnMessage = userBusinessRule.ValidationMessage; transaction.ValidationErrors = userBusinessRule.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { userDataService.CloseSession(); } }