コード例 #1
0
        public static void RecoverPassword(RecoverModel model, out string errorMessage, bool isTest = false)
        {
            try
            {
                IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                IEmailTools      emailTools      = AppTools.InitEmailTools(isTest);
                errorMessage = string.Empty;

                if (model.Email == membershipTools.GetUserEmail(model.UserName))
                {
                    string tempPassword = Membership.GeneratePassword(9, 1);
                    if (membershipTools.SetTempPassword(model.UserName, tempPassword) == false)
                    {
                        errorMessage = "Error updating account";
                    }

                    string emailBody = BuildRecoverBody(model.UserName, tempPassword);
                    if (emailTools.SendEmail(emailBody, model.Email) == false)
                    {
                        errorMessage = "Error sending recover email.";
                    }
                }
                else
                {
                    errorMessage = "Email and username is not valid.";
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }
コード例 #2
0
        public static int FeatureInsert(Features feature, out string errorMessage, bool isUnitTest = false)
        {
            int id = -1;

            try
            {
                ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest);
                IEmailTools emailTools = AppTools.InitEmailTools(isUnitTest);
                errorMessage = ValidateFeature(feature);

                if (string.IsNullOrEmpty(errorMessage))
                {
                    id = sprocCalls.FeaturesInsert(feature);
                    if (id <= 0)
                    {
                        errorMessage = "Error inserting new feature " + feature.FeatureName + ".";
                    }
                    //else
                    //    emailTools.SendToAll("New Feature created : " + feature.FeatureName + "<br />Description : " + feature.FeatureDescription);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                DBCommands.RecordError(ex);
            }

            return(id);
        }
コード例 #3
0
        public static void SendEmail(ContactModel model, out string errorMessage)
        {
            IEmailTools emailTools = AppTools.InitEmailTools(false);

            if (emailTools.SendEmail(model.EmailTo, model.EmailBody) == false)
            {
                errorMessage = "Error sending email";
            }
            else
            {
                errorMessage = string.Empty;
            }
        }
コード例 #4
0
 public static void SendAlertToWorkers(bool isTest = false)
 {
     try
     {
         IEmailTools emailTools = AppTools.InitEmailTools(isTest);
         emailTools.SendToGroup(2, "A new request has been sent.");
         emailTools.SendToGroup(3, "A new request has been sent.");
     }
     catch (Exception ex)
     {
         DBCommands.RecordError(ex);
     }
 }
コード例 #5
0
        private static bool SendRecoverEmail(UserInfo user, string location, bool isTest)
        {
            try
            {
                StringBuilder builder = new StringBuilder();

                builder.Append("Hello, we have received your message that your password has been forgotten.  To reset your password please click the link below.<br />");
                builder.Append(@"http://localhost:61860/" + location + "/CompeRec/" + user.RecoverCode);

                IEmailTools emailTools = AppTools.InitEmailTools(isTest);
                if (emailTools.SendEmail(user.Email, builder.ToString()) == false)
                {
                    throw new Exception("Error sending email.");
                }

                return(true);
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                return(false);
            }
        }