public void SendAndLogTest() { EmailGateway target = new EmailGateway(); // TODO: Initialize to an appropriate value string messageToLog = string.Empty; // TODO: Initialize to an appropriate value messageToLog = "Message1"; target.SendAndLog(messageToLog); // Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public async Task <string> Promote_with_async_methods_in_the_beginning_and_in_the_middle_of_the_chain_using_compensate(long id) { var gateway = new EmailGateway(); return(await GetByIdAsync(id) .ToResult("Customer with such Id is not found: " + id) .Ensure(customer => customer.CanBePromoted(), "Need to ask manager") .OnFailure(error => Log(error)) .OnFailureCompensate(() => AskManager(id)) .Tap(customer => Log("Manager approved promotion")) .Tap(customer => customer.PromoteAsync()) .Bind(customer => gateway.SendPromotionNotificationAsync(customer.Email)) .Finally(result => result.IsSuccess ? "Ok" : result.Error)); }
public ActionResult Register(RegisterModel model) { // ViewBag.Popup = false; if (ModelState.IsValid) { //Create a new user MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.CreateUser(model.UserID, model.Password, model.Email, null, null, false, out status); switch (status) { case MembershipCreateStatus.Success: //Add user to the guest role Roles.AddUserToRole(model.UserID, "guests"); //Create user profile and set properties value System.Web.Profile.ProfileBase profile = System.Web.Profile.ProfileBase.Create(model.UserID); profile.PropertyValues["Company"].PropertyValue = model.Company.Trim(); profile.PropertyValues["UserFullName"].PropertyValue = model.FullName.Trim(); profile.PropertyValues["WebServiceUser"].PropertyValue = false; profile.Save(); //Send notification to the administrator EmailGateway svcs = new EmailGateway(); svcs.SendRegistrationMessage(model.FullName.Trim(), model.Email.Trim()); //Disply confirmation to user ViewBag.Popup = true; break; case MembershipCreateStatus.DuplicateEmail: ModelState.AddModelError("", EMAIL_NOT_UNIQUE); break; case MembershipCreateStatus.DuplicateUserName: ModelState.AddModelError("", USERID_NOT_UNIQUE); break; case MembershipCreateStatus.InvalidPassword: ModelState.AddModelError("", PASSWORD_MIN_LENGHT); break; case MembershipCreateStatus.UserRejected: break; } } return(View(model)); }
private void sendPODRequest() { //Send a POD request to Argix, send confirmation to user, and display confirmation TrackingItem item = null; if (ViewState["PODRequestItem"] is TrackingItem) { item = (TrackingItem)ViewState["PODRequestItem"]; } if (item != null) { EmailGateway svcs = new EmailGateway(); svcs.SendPODRequest(Membership.GetUser(), item); svcs.SendPODRequestConfirm(Membership.GetUser(), item); Master.ShowMessageBox("Thank you. Your POD request has been submitted. You will receive an email confirming your request."); } }
public Adminsettings() { adminSecondaryEmail = new AdminSecondaryEmail(); countryCode = new CountryCode(); creationTime = new CreationTime(); currentUsers = new CurrentUsers(); customLogo = new CustomLogo(); customerPin = new CustomerPin(); defaultLanguage = new DefaultLanguage(); emailGateway = new EmailGateway(); emailRouting = new EmailRouting(); maximumUsers = new MaximumUsers(); mxVerificationStatus = new MxVerificationStatus(); organizationName = new OrganizationName(); productVersion = new ProductVersion(); ssoSettings = new SsoSettings(); ssoSigningKey = new SsoSigningKey(); }
public ActionResult EditEmailGateway(EmailGateway model) { try { using (var con = new SqlConnection(_connectionString)) { var result = con.Query <int>("Add_Edit_Delete_EmailGateway", new { model.ProcessName, model.SettingName, model.SettingID, model.FromID, model.FromName, model.UserName, model.Paswrd, model.ServerName, model.PortNumber, model.SSLEnable, model.IsDefault, model.IsActive, model.Comments, User = "******", Action = "edit" }, commandType: CommandType.StoredProcedure).FirstOrDefault(); if (result == 2) { TempData["Message"] = "Successfully Update"; } else { TempData["Message"] = "Something Went Wrong"; } } } catch (Exception) { throw; } return(RedirectToAction("EmailGatewayIndex")); }
protected AdminsettingsBase() { mainBase = new gAdminsettings(); ServiceWrapperDictionary[mainBaseType] = mainBase; adminSecondaryEmail = new AdminSecondaryEmail(); countryCode = new CountryCode(); creationTime = new CreationTime(); currentUsers = new CurrentUsers(); customLogo = new CustomLogo(); customerPin = new CustomerPin(); defaultLanguage = new DefaultLanguage(); emailGateway = new EmailGateway(); emailRouting = new EmailRouting(); maximumUsers = new MaximumUsers(); mxVerificationStatus = new MxVerificationStatus(); organizationName = new OrganizationName(); productVersion = new ProductVersion(); ssoSettings = new SsoSettings(); ssoSigningKey = new SsoSigningKey(); }
public ActionResult RecoverPassword(RecoverPasswordModel model) { // ViewBag.Popup = false; if (ModelState.IsValid) { MembershipUser user = Membership.GetUser(model.UserID); string password = Membership.GeneratePassword(6, 0); user.ChangePassword(user.GetPassword(), password); //Set flag that forces user to change password on next login System.Web.Profile.ProfileBase profile = System.Web.Profile.ProfileBase.Create(model.UserID); profile.PropertyValues["PasswordReset"].PropertyValue = true; profile.Save(); //Send an email EmailGateway esvcs = new EmailGateway(); esvcs.SendPasswordResetMessage(user.UserName, user.Email, password); ViewBag.Popup = true; } return(View(model)); }
/// <summary> /// Change email with the password to the user. /// </summary> /// <param name="email"></param> public static bool SendRemindPasswordEmail(string email) { Canon.Data.User user = GetUserByEmail(email); if (user != null) { string password = ((CanonMembershipProvider)Membership.Provider).ChangePassword(user.UserId); string changePasswordUrl = String.Concat( HttpContext.Current.Request.Url.Scheme, "://", HttpContext.Current.Request.Url.Host, ":", HttpContext.Current.Request.Url.Port, HttpContext.Current.Request.ApplicationPath, "/Default.aspx?changepassword=yes"); try { EmailGateway.Send( String.Empty, email, Utilities.GetResourceString("Common", "EmailRemindEmailSubject"), String.Format(Utilities.GetResourceString("Common", "EmailRemindEmailText"), password, changePasswordUrl, user.UserName), new List <Attachment>(), true); } catch { return(false); } return(true); } return(false); }
/// <summary> /// Change password. /// </summary> /// <param name="userID"></param> /// <param name="oldPassword"></param> /// <param name="newPassword"></param> /// <returns></returns> public void ChangePassword(int userID, string oldPassword, string newPassword) { CanonDataContext db = Cdb.Instance; var user = (from u in db.Users where u.UserId == userID select u).Single(); if (!CheckPassword(oldPassword, user.Password)) { throw new InvalidOldPasswordException(userID, oldPassword); } user.Password = EncodePassword(newPassword); db.SubmitChanges(); EmailGateway.Send( String.Empty, user.Email, Utilities.GetResourceString("Common", "EmailPasswordChangingSubject"), String.Format(Utilities.GetResourceString("Common", "EmailPasswordChangingText"), newPassword), new List <Attachment>()); }
public void TestConstructorWithNullMessage() { IEmailGateway service = new EmailGateway(null); Assert.IsNull(service); }
public void TestConstructor() { IEmailGateway service = new EmailGateway(); Assert.IsNotNull(service); }
public void TestSend() { EmailGateway service = new EmailGateway(HOST); service.From = FROM; service.To = TO; service.IsHtmlBody = true; service.Send("Send Test (Statefull)", "Success"); }
public void SendTest() { EmailGateway target = new EmailGateway(); // TODO: Initialize to an appropriate value target.Send(); // Assert.Inconclusive("A method that does not return a value cannot be verified."); }
protected void OnCommand(object sender, CommandEventArgs e) { //Event handler for cancel button clicked switch (e.CommandName) { case "Close": Response.Redirect("~/Members/Profile.aspx", false); break; case "Reject": bool deleted = false, sent = false; try { deleted = Membership.DeleteUser(this.cboGuest.SelectedValue, true); if (deleted) { if (this.txtComments.Text.Trim().Length > 0) { sent = new EmailGateway().SendRejectRegistrationMessage(this.txtUserID.Text, this.txtEmail.Text, this.txtComments.Text); } Master.ShowMessageBox(this.txtUserID.Text + " has been deleted" + (sent ? " and a rejection email has been sent." : ".")); } else { Master.ShowMessageBox(this.txtUserID.Text + " has not been deleted."); } } catch (Exception ex) { string msg = this.txtUserID.Text + (deleted ? " has been deleted but an unexpected error occurred." : " has not been deleted and an unexpected error occurred."); Master.ReportError(new ApplicationException(msg, ex), 4); } finally { //this.cboGuest.DataBind(); refreshGuestList(); if (this.cboGuest.Items.Count > 0) { this.cboGuest.SelectedIndex = 0; } OnGuestChanged(null, EventArgs.Empty); } break; case "Approve": try { MembershipUser user = Membership.GetUser(this.cboGuest.SelectedValue); ProfileCommon profile = Profile.GetProfile(user.UserName); profile.UserFullName = this.txtUserName.Text; profile.Company = this.cboCustomer.SelectedItem.Text; profile.WebServiceUser = false; profile.Type = this.cboType.SelectedValue.ToLower(); profile.ClientVendorID = this.cboCustomer.SelectedValue; profile.Save(); Roles.RemoveUserFromRole(user.UserName, MembershipServices.GUESTROLE); Roles.AddUserToRole(user.UserName, MembershipServices.TRACKINGROLE); user.Email = this.txtEmail.Text; user.IsApproved = true; Membership.UpdateUser(user); new EmailGateway().SendWelcomeMessage(profile.UserFullName, this.cboGuest.SelectedValue, user.Email); Master.ShowMessageBox(this.txtUserID.Text + " has been approved and a welcome email has been sent."); } catch (Exception ex) { string msg = "An unexpected error occurred while approving " + this.txtUserID.Text + "."; Master.ReportError(new ApplicationException(msg, ex), 4); } finally { //this.cboGuest.DataBind(); refreshGuestList(); if (this.cboGuest.Items.Count > 0) { this.cboGuest.SelectedIndex = 0; } OnGuestChanged(null, EventArgs.Empty); } break; } }
public void EmailGatewayConstructorTest() { EmailGateway target = new EmailGateway(); //Assert.Inconclusive("TODO: Implement code to verify target"); }
protected void OnRegister(object sender, EventArgs e) { //Validate control states if (!Page.IsValid) { return; } try { //Create a new user MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.CreateUser(this.txtUserID.Text.Trim(), this.txtPassword.Text.Trim(), this.txtEmail.Text.Trim(), null, null, false, out status); switch (status) { case MembershipCreateStatus.Success: //Add user to the guest role Roles.AddUserToRole(this.txtUserID.Text.Trim(), MembershipServices.GUESTROLE); //Create user profile and set properties value ProfileCommon profile = Profile.GetProfile(this.txtUserID.Text.Trim()); profile.Company = this.txtCompany.Text.Trim(); profile.UserFullName = this.txtFullName.Text.Trim(); profile.WebServiceUser = false; profile.Save(); try { //Send notification to the administrator EmailGateway svcs = new EmailGateway(); svcs.SendRegisterReceiptEmail(this.txtFullName.Text.Trim(), this.txtEmail.Text.Trim()); //Disply confirmation to user string msg = "Thank you. Your registration request has been received. "; msg += "You will receive email confirmation when your account becomes active. "; msg += "If you dont receive confirmation in the next 2 business days then "; msg += "contact customer support at [email protected] or 800-274-4582."; System.Text.StringBuilder script = new System.Text.StringBuilder(); script.Append("<script language='javascript'>"); script.Append("\talert('" + msg + "');"); script.Append("\twindow.navigate('Account/Login.aspx');"); script.Append("</script>"); Page.ClientScript.RegisterStartupScript(typeof(Page), "Registered", script.ToString()); } catch (Exception ex) { string msg = "Thank you. Your registration request has been received. "; msg += "Unfortunately, an error has occurred while sending you a conformation email. "; msg += "Please contact customer support at [email protected] or 800-274-4582."; Master.ReportError(new ApplicationException(msg, ex), 4); } break; case MembershipCreateStatus.DuplicateEmail: revEmail.IsValid = false; revEmail.ErrorMessage = EMAIL_NOT_UNIQUE; break; case MembershipCreateStatus.DuplicateUserName: rfvUserID.IsValid = false; rfvUserID.ErrorMessage = USERID_NOT_UNIQUE; break; case MembershipCreateStatus.InvalidPassword: rfvPassword.IsValid = false; rfvPassword.ErrorMessage = PASSWORD_MIN_LENGHT; break; case MembershipCreateStatus.UserRejected: break; } } catch (Exception ex) { Master.ReportError(new ApplicationException(ex.Message), 3); } }
private void MainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { lock (padlock) { if (IsAlreadyWork) { return; } IsAlreadyWork = true; } try { logger.Debug(string.Format("New elapsation started-{0}", DateTime.Now)); //log maintainance this.DeleteOldLogs(); //go through items in Manual Mapping Import Queue this.ProcessImportQueue(); //check current time against defined in config if (!CanonConfigManager.ForceStart) { DateTime start = CanonConfigManager.TimeToStart; DateTime now = DateTime.Now; logger.Debug(string.Format("now-{0}, start-{1}", now, start)); if (start > now) { return; } else if ((now - start).TotalMinutes > 30) { return; } } //Clear manual import queue and subsribers CanonDataContext db = Cdb.Instance; if (!CanonConfigManager.ForceStart) { //delete all complete every night var allManuals = db.ManualImportQueues.Where(p => p.Status == (int)ManualImportStatusEnum.ImportComplete || p.Status == (int)ManualImportStatusEnum.InProgress); db.ManualImportQueues.DeleteAllOnSubmit(allManuals); db.SubmitChanges(); } else { //delete all old var allManualsA = db.ManualImportQueues.Where(p => p.PostDate.Date < DateTime.Now.Date); db.ManualImportQueues.DeleteAllOnSubmit(allManualsA); db.SubmitChanges(); } //application maintainance db.MaintainDatabase(); //go through all channels foreach (Channel channel in db.Channels) { try { if (!channel.IsActive) { logger.Info(string.Format("Channel is disabled: {0}, {1}, {2}", channel.ChannelId, channel.ChannelName, channel.Url)); continue; } logger.Info(string.Format("Starting new export: {0}, {1}, {2}", channel.ChannelId, channel.ChannelName, channel.Url)); if (!ShouldRun(channel)) { logger.Info(string.Format("Data already imported today or there was a error during import.")); continue; } this.ProcessChannel(channel); } catch (Exception ex) { logger.Warn(string.Format("Import for channel {0} failed", channel.ChannelName), ex); } } //send daily emails if (CanonImportService.LastEmailSent.Date < DateTime.Now.Date) { List <User> users = db.Users.Where(u => u.IsDailyEmail && u.Email.Length > 0).ToList(); string text = this.CreateEmailText(null).Trim(); logger.Info("Email text:" + text); if (!string.IsNullOrEmpty(text)) { foreach (User user in users) { try { EmailGateway email = new EmailGateway(user.Email, "Daily Log", text); email.Send(); CanonImportService.LastEmailSent = DateTime.Now; } catch (Exception ex) { logger.Fatal(ex); } } } //send daily email for users in channels List <Channel> repChannels = db.Channels.ToList(); foreach (Channel repChannel in repChannels) { if (!repChannel.IsActive) { continue; } if (!string.IsNullOrEmpty(repChannel.ReportingTo)) { string[] emails = repChannel.ReportingTo.Split(';'); string emailText = this.CreateEmailText(repChannel).Trim(); foreach (string email in emails) { try { EmailGateway emailG = new EmailGateway(email, "Průzkum trhu", emailText); logger.Info(string.Format("Sending: {0}, text={1}", email, emailText)); emailG.Send(); CanonImportService.LastEmailSent = DateTime.Now; } catch (Exception ex) { logger.Fatal(ex); } } } } } } catch (Exception ex) { logger.Fatal(ex); } finally { IsAlreadyWork = false; } }
public EmailBuffer(EmailGateway gateway) { _gateway = gateway; }