public bool AccountConfirmation(string username)
 {
     CriticalResultsEntityManager manager = new CriticalResultsEntityManager();
     UserEntity ue = manager.GetUser(username);
     if (!ue.UserTransports.IsLoaded)
     {
         ue.UserTransports.Load();
     }
     foreach (UserTransportEntity ute in ue.UserTransports)
     {
         if (!ute.TransportReference.IsLoaded)
         {
             ute.TransportReference.Load();
         }
         if (ute.Transport.Name == EMAIL_TRANSPORT && !String.IsNullOrEmpty(ute.Address))
         {
             SystemMailer = new SystemEmailer();
             SettingEntity[] settings = new CriticalResultsEntityManager().GetSettings("System");
             string message = "";
             foreach (SettingEntity setting in settings)
             {
                 if (setting.EntryKey == "AccountConfirmationMessage")
                 {
                     message = setting.Value;
                 }
             }
             message = String.Format(message, ue.UserName);
             BackgroundWorker bgw = new BackgroundWorker();
             bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
             bgw.RunWorkerAsync(message + "|" + ute.Address);
         }
     }
     return true;
 }
 public bool CreatePassword(string userName)
 {
     string password = Guid.NewGuid().ToString().Substring(0, 6);
     string passwordHash = BitConverter.ToString(HashAlgorithm.Create("SHA256").ComputeHash(Encoding.ASCII.GetBytes(password))).ToLower().Replace("-", "");
     bool setPassSuccess = new CriticalResultsEntityManager().UpdateUserEntryEntity(userName, "AuthExt", "ANCR", passwordHash, true);
     if (setPassSuccess)
     {
         UserEntity user = new CriticalResultsEntityManager().GetUser(userName);
         foreach (UserTransportEntity transport in user.UserTransports)
         {
             if (transport.Transport.Name == EMAIL_TRANSPORT && !String.IsNullOrEmpty(transport.Address))
             {
                 SystemMailer = new SystemEmailer();
                 BackgroundWorker worker = new BackgroundWorker();
                 worker.DoWork += new DoWorkEventHandler(worker_DoWork);
                 worker.RunWorkerAsync(transport.Address + "|" + password);
             }
         }
     }
     return setPassSuccess;
 }