Example #1
0
 public void SetupTest()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     SignalodT.ClearSignalodTable();
     _taskListParent     = TaskListT.CreateTaskList(descript: "TaskListParent");
     _taskListChild      = TaskListT.CreateTaskList(descript: "TaskListChild", parent: _taskListParent.TaskListNum, parentDesc: _taskListParent.Descript);
     _taskListGrandchild = TaskListT.CreateTaskList(descript: "TaskListGrandchild", parent: _taskListChild.TaskListNum,
                                                    parentDesc: _taskListChild.Descript);
     _task = TaskT.CreateTask(_taskListGrandchild.TaskListNum, descript: "Test Task", fromNum: Security.CurUser.UserNum); //Starts in _taskListGrandchild
     Security.CurUser.TaskListInBox = _taskListParent.TaskListNum;                                                        //Set inbox for current user to _taskListParent.
     try {
         Userods.Update(Security.CurUser);
     }
     catch {
         Assert.Fail("Failed to update current user task list inbox.");                //Error updating user.
     }
     _userControlTasksInstance = new UserControlTasks();
     _userControlTasksAccessor = new PrivateObject(_userControlTasksInstance);
     //Artificially set that we are viewing _listTaskListParent.
     _userControlTasksAccessor.SetField("_listTaskListTreeHistory", new List <TaskList>()
     {
         _taskListParent
     });
     _userControlTasksAccessor.SetField("_dictTaskLists", new Dictionary <long, TaskList>());
 }
        private void menuItemPassword_Click(object sender, EventArgs e)
        {
            FormCentralUserPasswordEdit FormCPE = new FormCentralUserPasswordEdit(false, Security.CurUser.UserName);

            if (FormCPE.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            Security.CurUser.Password = FormCPE.HashedResult;
            Userods.Update(Security.CurUser);
        }
Example #3
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;
        }
Example #4
0
 private void butUnlock_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, true, "Users can become locked when invalid credentials have been entered several times in a row.\r\n"
                      + "Unlock this user so that more log in attempts can be made?"))
     {
         return;
     }
     UserCur.DateTFail      = DateTime.MinValue;
     UserCur.FailedAttempts = 0;
     try {
         Userods.Update(UserCur);                //This will also commit other things about the user if they've changed.  Oh well.
         MsgBox.Show(this, "User has been unlocked.");
     }
     catch (Exception) {
         MsgBox.Show(this, "There was a problem unlocking this user.  Please call support or wait the allotted lock time.");
     }
 }
 public void SetupTest()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     SignalodT.ClearSignalodTable();
     _taskListParent     = TaskListT.CreateTaskList(descript: "TaskListParent");
     _taskListChild      = TaskListT.CreateTaskList(descript: "TaskListChild", parent: _taskListParent.TaskListNum, parentDesc: _taskListParent.Descript);
     _taskListGrandchild = TaskListT.CreateTaskList(descript: "TaskListGrandchild", parent: _taskListChild.TaskListNum,
                                                    parentDesc: _taskListChild.Descript);
     _task = TaskT.CreateTask(_taskListGrandchild.TaskListNum, descript: "Test Task", fromNum: Security.CurUser.UserNum, priorityDefNum: 1); //Starts in _taskListGrandchild
     TaskSubscriptionT.CreateTaskSubscription(Security.CurUser.UserNum, _taskListParent.TaskListNum);                                        //current user subscribes to top level tasklist.
     Security.CurUser.TaskListInBox = _taskListParent.TaskListNum;                                                                           //Set inbox for current user to _taskListParent.
     try {
         Userods.Update(Security.CurUser);
         Userods.RefreshCache();
     }
     catch {
         Assert.Fail("Failed to update current user task list inbox.");                //Error updating user.
     }
     _formTaskEditInstance = new FormTaskEdit(_task);
     _formTaskEditAccessor = new PrivateObject(_formTaskEditInstance);
     _formTaskEditAccessor.Invoke("LoadTask");
 }
Example #6
0
        public static void ClearPasswords()
        {
            var users = Userods.GetAll();

            users.ForEach(x => { x.Password = ""; Userods.Update(x); });
        }
Example #7
0
        public void AlertItems_CreateAlertsForNewWebmail()
        {
            //Test Sections:
            //Create 5 users, part of 2 providers.
            //Test adding an email for each provider, then clear alerts table.
            //Test adding 4 emails for each provider
            //Test adding 3 additional emails for 1 provider
            //Test marking 2 emails as read for 1 provider
            //Test marking all emails as read for 1 provider
            EmailMessageT.ClearEmailMessageTable();            //Clear out the emailmessage table
            List <Userod> listTestUsers = new List <Userod>();

            //Create or reuse 5 users, and set their provnum to 1 or 2.  There'll be 3 provnum=1 and 2 provnum=2
            //In queries always filter by usernum because there may be users left over from other/old tests.
            for (int i = 0; i < 5; i++)
            {
                Userod user = UserodT.CreateUser();
                user.ProvNum = i % 2 + 1;
                listTestUsers.Add(user);
                Userods.Update(user);
            }
            listTestUsers = listTestUsers.Distinct().ToList();
            long examplePatnum = 2;             //Patnum can be anything, needed for webmail.

            //Create one email for each provider.
            foreach (long provnum in listTestUsers.Select(x => x.ProvNum).Distinct())
            {
                EmailMessageT.CreateWebMail(provnum, examplePatnum);
            }
            AlertItems_CreateAlertsForWebmailMethodCall();
            //Count the total # of alertitem entries, not what the description is.
            string alertCount = DataCore.GetScalar("SELECT COUNT(*) FROM alertitem WHERE UserNum IN (" + string.Join(",", listTestUsers.Select(x => POut.Long(x.UserNum)))
                                                   + ") AND Type=" + POut.Int((int)AlertType.WebMailRecieved));

            Assert.AreEqual("5", alertCount);
            //
            //Clear out ALERT table and add some new emails
            AlertItemT.ClearAlertItemTable();
            foreach (long provnum in listTestUsers.Select(x => x.ProvNum).Distinct())
            {
                EmailMessageT.CreateWebMail(provnum, examplePatnum);
                EmailMessageT.CreateWebMail(provnum, examplePatnum);
                EmailMessageT.CreateWebMail(provnum, examplePatnum);
                EmailMessageT.CreateWebMail(provnum, examplePatnum);
            }
            //This section tests adding more unread emails, and changing the description of the alertitem
            Userod selectedUser = listTestUsers.First();

            AlertItems_CreateAlertsForWebmailMethodCall();
            alertCount = DataCore.GetScalar("SELECT Description FROM alertitem WHERE Type=" + POut.Int((int)AlertType.WebMailRecieved) + " AND UserNum=" + selectedUser.UserNum);
            Assert.AreEqual("5", alertCount);
            //
            //Add 3 more unread emails.
            EmailMessageT.CreateWebMail(selectedUser.ProvNum, examplePatnum);
            EmailMessageT.CreateWebMail(selectedUser.ProvNum, examplePatnum);
            EmailMessageT.CreateWebMail(selectedUser.ProvNum, examplePatnum);
            AlertItems_CreateAlertsForWebmailMethodCall();
            alertCount = DataCore.GetScalar("SELECT Description FROM alertitem WHERE Type=" + POut.Int((int)AlertType.WebMailRecieved) + " AND UserNum=" + selectedUser.UserNum);
            Assert.AreEqual("8", alertCount);
            //
            //Mark 2 of the emails as read, to decrease the amount of unread emails
            string command = "UPDATE emailmessage SET SentOrReceived=" + POut.Int((int)EmailSentOrReceived.WebMailRecdRead) +
                             " WHERE SentOrReceived=" + POut.Int((int)EmailSentOrReceived.WebMailReceived) + " AND ProvNumWebMail=" + POut.Long(selectedUser.ProvNum) + " LIMIT 2";

            DataCore.NonQ(command);
            AlertItems_CreateAlertsForWebmailMethodCall();
            alertCount = DataCore.GetScalar("SELECT Description FROM alertitem WHERE Type=" + POut.Int((int)AlertType.WebMailRecieved) + " AND UserNum=" + selectedUser.UserNum);
            Assert.AreEqual("6", alertCount);
            //
            //Now we mark all of this user's emails as read, as if that user has read all of their webmail.
            command = "UPDATE emailmessage SET SentOrReceived=" + POut.Int((int)EmailSentOrReceived.WebMailRecdRead) +
                      " WHERE SentOrReceived=" + POut.Int((int)EmailSentOrReceived.WebMailReceived) + " AND ProvNumWebMail=" + POut.Long(selectedUser.ProvNum);
            DataCore.NonQ(command);
            AlertItems_CreateAlertsForWebmailMethodCall();
            alertCount = DataCore.GetScalar("SELECT COUNT(*) FROM alertitem WHERE Type=" + POut.Int((int)AlertType.WebMailRecieved) + " AND UserNum=" + selectedUser.UserNum);
            Assert.AreEqual("0", alertCount);
        }