Esempio n. 1
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textUserName.Text == "")
            {
                OpenDental.MessageBox.Show(this, "Please enter a username.");
                return;
            }
            if (listUserGroup.SelectedItems.Count == 0)
            {
                OpenDental.MessageBox.Show(this, "Every user must be associated to at least one User Group.");
                return;
            }
            List <AlertSub> listAlertSubsCur = new List <AlertSub>();

            foreach (int index in listAlertSubMulti.SelectedIndices)
            {
                AlertSub alertSub = new AlertSub();
                alertSub.ClinicNum = 0;
                alertSub.UserNum   = Security.CurUser.UserNum;
                alertSub.Type      = (AlertType)index;
                listAlertSubsCur.Add(alertSub);
            }
            AlertSubs.Sync(listAlertSubsCur, _listAlertSubsOld);
            UserCur.IsHidden = checkIsHidden.Checked;
            UserCur.UserName = textUserName.Text;
            if (UserCur.UserNum == Security.CurUser.UserNum)
            {
                Security.CurUser.UserName = textUserName.Text;
                //They changed their logged in user's information.  Update for when they sync then attempt to connect to remote DB.
            }
            UserCur.EmployeeNum        = 0;
            UserCur.ProvNum            = 0;
            UserCur.ClinicNum          = 0;
            UserCur.ClinicIsRestricted = false;
            try{
                if (UserCur.IsNew)
                {
                    //also updates the user's UserNumCEMT to be the user's usernum.
                    long userNum = Userods.Insert(UserCur, listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag.UserGroupNum).ToList(), true);
                }
                else
                {
                    Userods.Update(UserCur, listUserGroup.SelectedItems.OfType <ODBoxItem <UserGroup> >().Select(x => x.Tag.UserGroupNum).ToList());
                }
            }
            catch (Exception ex) {
                OpenDental.MessageBox.Show(ex.Message);
                return;
            }
            Cache.Refresh(InvalidType.Security);
            DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
 public static void CreateUnitTestUser()
 {
     if (Userods.GetUserByName(UnitTestUserName, false) == null)
     {
         Userod newUser = new Userod()
         {
             UserName = UnitTestUserName,
             Password = Userods.HashPassword(UnitTestPassword),
         };
         try {
             Userods.Insert(newUser, new List <long> {
                 1
             });
             Userods.RefreshCache();
         }
         catch (Exception e) {
             throw new Exception("Unable to create the default Unit Test user.", e);
         }
     }
 }
Esempio n. 3
0
        ///<summary>Inserts the new user, refreshes the cache and then returns UserNum</summary>
        public static Userod CreateUser(string userName = "", string password = "", List <long> userGroupNumbers = null, long clinicNum = 0, bool isClinicIsRestricted = false)
        {
            if (userName == "")
            {
                userName = "******" + MiscUtils.CreateRandomAlphaNumericString(8);
            }
            if (password == "")
            {
                password = "******";
            }
            if (userGroupNumbers == null)
            {
                userGroupNumbers = new List <long> {
                    1
                };
            }
            Userod newUser = new Userod();

            newUser.UserName           = userName;
            newUser.LoginDetails       = Authentication.GenerateLoginDetails(password, HashTypes.SHA3_512);
            newUser.ClinicNum          = clinicNum;
            newUser.ClinicIsRestricted = isClinicIsRestricted;
            do
            {
                //In case the username is already taken
                try {
                    newUser.UserNum = Userods.Insert(newUser, userGroupNumbers);
                }
                catch {
                    newUser.UserName = "******" + MiscUtils.CreateRandomAlphaNumericString(8);
                }
            }while(newUser.UserNum == 0);
            Userods.RefreshCache();
            UserGroupAttaches.RefreshCache();
            return(newUser);
        }