コード例 #1
0
        public void OrthoCases_Delete_DeleteOrthoCaseAndAssociatedObjects()
        {
            Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080");
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060");
            Userod user = UserodT.CreateUser();

            Security.CurUser = user;
            Patient   pat          = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure bandingProc  = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure visitProc    = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0);
            Procedure debondProc   = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0);
            long      orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);

            OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc);
            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            OrthoCase            orthoCase        = OrthoCases.GetOne(orthoCaseNum);
            OrthoPlanLink        schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            long                 orthoscheduleNum = schedulePlanLink.FKey;
            OrthoSchedule        orthoSchedule    = OrthoSchedules.GetOne(schedulePlanLink.FKey);
            List <OrthoProcLink> listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);

            OrthoCases.Delete(orthoCase.OrthoCaseNum, orthoSchedule, schedulePlanLink, listAllProcLinks);
            orthoCase        = OrthoCases.GetOne(orthoCaseNum);
            schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule);
            orthoSchedule    = OrthoSchedules.GetOne(orthoscheduleNum);
            listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum);
            Assert.AreEqual(orthoCase, null);
            Assert.AreEqual(schedulePlanLink, null);
            Assert.AreEqual(orthoSchedule, null);
            Assert.AreEqual(listAllProcLinks.Count, 0);
        }
コード例 #2
0
        public void OrthoCases_UpdateDatesByLinkedProc_UpdateBandingAndDebondDates()
        {
            Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070");
            Userod user = UserodT.CreateUser();

            Security.CurUser = user;
            Patient   pat          = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure bandingProc  = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0);
            Procedure debondProc   = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0, procDate: DateTime.Today.AddDays(2));
            long      orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc);

            OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc);
            OrthoProcLink bandingProcLink = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Banding);
            OrthoProcLink debondProcLink  = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Debond);
            OrthoCase     orthoCase       = OrthoCases.GetOne(orthoCaseNum);

            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today);
            bandingProc.ProcDate = DateTime.Today.AddDays(1);
            OrthoCases.UpdateDatesByLinkedProc(bandingProcLink, bandingProc);
            orthoCase = OrthoCases.GetOne(orthoCaseNum);
            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1));
            Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(2));
            debondProc.ProcDate = DateTime.Today.AddDays(3);
            OrthoCases.UpdateDatesByLinkedProc(debondProcLink, debondProc);
            orthoCase = OrthoCases.GetOne(orthoCaseNum);
            Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1));
            Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(3));
        }
コード例 #3
0
ファイル: UserodCrud.cs プロジェクト: nampn/ODental
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <Userod> TableToList(DataTable table)
        {
            List <Userod> retVal = new List <Userod>();
            Userod        userod;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                userod                    = new Userod();
                userod.UserNum            = PIn.Long(table.Rows[i]["UserNum"].ToString());
                userod.UserName           = PIn.String(table.Rows[i]["UserName"].ToString());
                userod.Password           = PIn.String(table.Rows[i]["Password"].ToString());
                userod.UserGroupNum       = PIn.Long(table.Rows[i]["UserGroupNum"].ToString());
                userod.EmployeeNum        = PIn.Long(table.Rows[i]["EmployeeNum"].ToString());
                userod.ClinicNum          = PIn.Long(table.Rows[i]["ClinicNum"].ToString());
                userod.ProvNum            = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                userod.IsHidden           = PIn.Bool(table.Rows[i]["IsHidden"].ToString());
                userod.TaskListInBox      = PIn.Long(table.Rows[i]["TaskListInBox"].ToString());
                userod.AnesthProvType     = PIn.Int(table.Rows[i]["AnesthProvType"].ToString());
                userod.DefaultHidePopups  = PIn.Bool(table.Rows[i]["DefaultHidePopups"].ToString());
                userod.PasswordIsStrong   = PIn.Bool(table.Rows[i]["PasswordIsStrong"].ToString());
                userod.ClinicIsRestricted = PIn.Bool(table.Rows[i]["ClinicIsRestricted"].ToString());
                retVal.Add(userod);
            }
            return(retVal);
        }
コード例 #4
0
ファイル: UserodCrud.cs プロジェクト: nampn/ODental
 ///<summary>Inserts one Userod into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Userod userod,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         userod.UserNum=ReplicationServers.GetKey("userod","UserNum");
     }
     string command="INSERT INTO userod (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="UserNum,";
     }
     command+="UserName,Password,UserGroupNum,EmployeeNum,ClinicNum,ProvNum,IsHidden,TaskListInBox,AnesthProvType,DefaultHidePopups,PasswordIsStrong,ClinicIsRestricted) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(userod.UserNum)+",";
     }
     command+=
          "'"+POut.String(userod.UserName)+"',"
         +"'"+POut.String(userod.Password)+"',"
         +    POut.Long  (userod.UserGroupNum)+","
         +    POut.Long  (userod.EmployeeNum)+","
         +    POut.Long  (userod.ClinicNum)+","
         +    POut.Long  (userod.ProvNum)+","
         +    POut.Bool  (userod.IsHidden)+","
         +    POut.Long  (userod.TaskListInBox)+","
         +    POut.Int   (userod.AnesthProvType)+","
         +    POut.Bool  (userod.DefaultHidePopups)+","
         +    POut.Bool  (userod.PasswordIsStrong)+","
         +    POut.Bool  (userod.ClinicIsRestricted)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         userod.UserNum=Db.NonQ(command,true);
     }
     return userod.UserNum;
 }
コード例 #5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = (Userod)listUser.SelectedItem;

            if (selectedUser.Password != "")
            {
                if (!Userods.CheckPassword(textPassword.Text, selectedUser.Password))
                {
                    MsgBox.Show(this, "Incorrect password");
                    return;
                }
                //if (selectedUser.UserGroupNum == 1) this works to elevate privs to admin
                if (GroupPermissions.HasPermission(selectedUser.UserGroupNum, Permissions.AnesthesiaControlMeds))
                {
                    DialogResult     = DialogResult.OK;
                    Security.CurUser = (Userod)listUser.SelectedItem;
                    return;
                }
                else
                {
                    MessageBox.Show(this, "You must be an administrator to unlock this action");
                }
                return;
            }
        }
コード例 #6
0
ファイル: FormUserEdit.cs プロジェクト: ChemBrain/OpenDental
 ///<summary></summary>
 public FormUserEdit(Userod userCur, bool isFromAddUser = false)
 {
     InitializeComponent();
     Lan.F(this);
     UserCur        = userCur.Copy();
     _isFromAddUser = isFromAddUser;
 }
コード例 #7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = (Userod)listUser.SelectedItem;

            if (!Userods.CheckTypedPassword(textPassword.Text, selectedUser.Password))
            {
                MsgBox.Show(this, "Incorrect password");
                return;
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            Security.CurUser = selectedUser.Copy();
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                string password = textPassword.Text;
                if (Programs.UsingEcwTight())                 //ecw requires hash, but non-ecw requires actual password
                {
                    password = Userods.EncryptPassword(password, true);
                }
                Security.PasswordTyped = password;
            }
            if (PrefC.GetBool(PrefName.TasksCheckOnStartup))
            {
                int taskcount = Tasks.UserTasksCount(Security.CurUser.UserNum);
                if (taskcount > 0)
                {
                    MessageBox.Show(Lan.g(this, "There are ") + taskcount + Lan.g(this, " unread tasks on your tasklists."));
                }
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
コード例 #8
0
ファイル: FormSecurity.cs プロジェクト: steev90/opendental
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            Userod       user  = Userods.GetUser(ListUser[e.Row].UserNum);
            FormUserEdit FormU = new FormUserEdit(user);

            FormU.ShowDialog();
            if (FormU.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            if (Security.CurUser.UserNum == user.UserNum)
            {
                Security.CurUser = FormU.UserCur;              //if user changed their own password, this keeps the CurUser synched.  Needed for eCW bridge.
            }
            FillUsers();
            for (int i = 0; i < ListUser.Count; i++)
            {
                if (ListUser[i].UserNum == FormU.UserCur.UserNum)
                {
                    gridMain.SetSelected(i, true);
                    SelectedGroupNum = FormU.UserCur.UserGroupNum;
                }
            }
            FillTreePerm();
            changed = true;
        }
コード例 #9
0
ファイル: FormProviderSelect.cs プロジェクト: nampn/ODental
		///<summary>Not possible if no security admin.</summary>
		private void butCreateUsers_Click(object sender,EventArgs e) {
			if(gridMain.SelectedIndices.Length==0){
				MsgBox.Show(this,"Please select one or more providers first.");
				return;
			}
			for(int i=0;i<gridMain.SelectedIndices.Length;i++){
				if(table.Rows[i]["UserName"].ToString()!=""){
					MsgBox.Show(this,"Not allowed to create users on providers which already have users.");
					return;
				}
			}
			if(comboUserGroup.SelectedIndex==-1){
				MsgBox.Show(this,"Please select a User Group first.");
				return;
			}
			for(int i=0;i<gridMain.SelectedIndices.Length;i++){
				Userod user=new Userod();
				user.UserGroupNum=UserGroups.List[comboUserGroup.SelectedIndex].UserGroupNum;
				user.ProvNum=PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["ProvNum"].ToString());
				user.UserName=GetUniqueUserName(table.Rows[gridMain.SelectedIndices[i]]["LName"].ToString(),
					table.Rows[gridMain.SelectedIndices[i]]["FName"].ToString());
				user.Password=user.UserName;//this will be enhanced later.
				try{
					Userods.Insert(user);
				}
				catch(ApplicationException ex){
					MessageBox.Show(ex.Message);
					changed=true;
					return;
				}
			}
			changed=true;
			FillGrid();
		}
コード例 #10
0
        public void Userods_CheckUserAndPassoword_UpdateFailedAttemptsFromOtherMethods()
        {
            //First, setup the test scenario.
            long   group1 = UserGroupT.CreateUserGroup("usergroup1");
            Userod myUser = UserodT.CreateUser(MethodBase.GetCurrentMethod().Name + DateTime.Now.Ticks, "reallystrongpassword", userGroupNumbers: new List <long>()
            {
                group1
            });

            Security.CurUser       = myUser;
            Security.PasswordTyped = "passwordguess#1";
            CredentialsFailedAfterLoginEvent.Fired += CredentialsFailedAfterLoginEvent_Fired1;
            RunTestsAgainstMiddleTier(new OpenDentBusiness.WebServices.OpenDentalServerMockIIS(user: myUser.UserName, password: myUser.Password));
            //try once with the wrong password. Failed attempt should get incremented to 1.
            ODException.SwallowAnyException(() => {
                Userods.CheckUserAndPassword(myUser.UserName, "passwordguess#1", false);
            });
            //Get our updated user from the DB.
            RunTestsAgainstDirectConnection();
            myUser = Userods.GetUserByNameNoCache(myUser.UserName);
            //Assert that we only have 1 failed attempt.
            Assert.AreEqual(1, myUser.FailedAttempts);
            //now wait for another method to get called
            RunTestsAgainstMiddleTier(new OpenDentBusiness.WebServices.OpenDentalServerMockIIS(user: myUser.UserName, password: myUser.Password));
            ODException.SwallowAnyException(() => {
                Computers.UpdateHeartBeat(Environment.MachineName, false);
            });
            RunTestsAgainstDirectConnection();
            //Get our updated user from the DB.
            myUser = Userods.GetUserByNameNoCache(myUser.UserName);
            //Assert that we only have 1 failed attempt.
            Assert.AreEqual(1, myUser.FailedAttempts);
        }
コード例 #11
0
        public void Userods_CheckUserAndPassword_LockoutAfterUserHasLoggedInButPasswordIsNotCorrectAfter5Attempts()
        {
            //First, setup the test scenario.
            long   group1          = UserGroupT.CreateUserGroup("usergroup1");
            bool   isAccountLocked = false;
            Userod myUser          = UserodT.CreateUser(MethodBase.GetCurrentMethod().Name + DateTime.Now.Ticks, "reallystrongpassword", userGroupNumbers: new List <long>()
            {
                group1
            });

            //Make 5 bad password attempts
            for (int i = 1; i < 6; i++)
            {
                ODException.SwallowAnyException(() => {
                    Userods.CheckUserAndPassword(myUser.UserName, "passwordguess#" + i, false);
                });
            }
            try {
                //the 6th bad attempt should kick us with a message saying that our account has been locked.
                Userods.CheckUserAndPassword(myUser.UserName, "passwordguess#6", false);
            }
            catch (Exception e) {
                if (e.Message.Contains("Account has been locked due to failed log in attempts"))
                {
                    isAccountLocked = true;
                }
            }
            //Get our updated user from the DB.
            myUser = Userods.GetUserByNameNoCache(myUser.UserName);
            //Assert that we got to 5 failed attempts and that the account has been locked.
            Assert.AreEqual(5, myUser.FailedAttempts);
            Assert.AreEqual(true, isAccountLocked);
        }
コード例 #12
0
        ///<summary></summary>
        public static void Refresh()
        {
            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    UserodB.Refresh();
                }
                else
                {
                    DtoUserodRefresh dto = new DtoUserodRefresh();
                    DataSet          ds  = RemotingClient.ProcessQuery(dto);
                    UserodB.RawData = ds.Tables[0];
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
                return;
            }
            Listt = new List <Userod>();         //[UserB.RawData.Rows.Count];
            Userod user;

            for (int i = 0; i < UserodB.RawData.Rows.Count; i++)
            {
                user              = new Userod();
                user.UserNum      = PIn.PInt(UserodB.RawData.Rows[i][0].ToString());
                user.UserName     = PIn.PString(UserodB.RawData.Rows[i][1].ToString());
                user.Password     = PIn.PString(UserodB.RawData.Rows[i][2].ToString());
                user.UserGroupNum = PIn.PInt(UserodB.RawData.Rows[i][3].ToString());
                user.EmployeeNum  = PIn.PInt(UserodB.RawData.Rows[i][4].ToString());
                Listt.Add(user);
            }
        }
コード例 #13
0
        ///<summary>The click event for each tile. This initializes and loads the engineers schedule, jobs grid, and history of clock events. Only clickable if the engineer is the same
        ///as the current user or Allen and Nathan.</summary>
        private void button_ClickEngInfo(object sender, RoutedEventArgs e)
        {
            //reset class date variables
            startOfWeek = DateTime.Today.AddDays(-(int)(DateTime.Today.DayOfWeek));
            curWeek     = DateTime.Today.AddDays(-(int)(DateTime.Today.DayOfWeek));
            //retrieve our engineer tag based on the tile clicked
            System.Windows.Controls.Button bt = (System.Windows.Controls.Button)sender;
            if (bt.Tag.ToString().StartsWith("Total"))
            {
                return;
            }
            selectedEng = Userods.GetWhere(x => x.UserName == bt.Tag.ToString(), true).First();
            if ((Security.CurUser.UserNum != 58 && Security.CurUser.UserNum != 9) && Security.CurUser.UserNum != selectedEng.UserNum)       //if you aren't Nathan or Allen and are not the engineer you selected, you can't view their information.
            {
                System.Windows.MessageBox.Show(Lans.g("Security", "Not authorized for viewing"));
                return;
            }
            buttonGrid.Visibility        = Visibility.Collapsed;
            EngSpecificInfo.Visibility   = Visibility.Visible;
            GridToolbar.Visibility       = Visibility.Visible;
            _listAllWriteJobsForEngineer = _listJobsAll.Where(x => x.UserNumEngineer == selectedEng.UserNum).ToList();
            LabelEngName.Content         = selectedEng.UserName;
            long engUserNum = selectedEng.UserNum;

            //Fill our controls for the next view
            FillActiveJobs(engUserNum);
            ClockEventsInRange(startOfWeek, startOfWeek.AddDays(6));
            FillEngineerMetrics(engUserNum);
            FillEngineerCalendar(startOfWeek, startOfWeek.AddDays(6));
            //TODO: Call the today click here, however this will require waiting for the UI to draw first otherwise the height value we animate to is 0.
            //This will require additional research on methods/techniques to wait for the UI to draw.
        }
コード例 #14
0
        public void Authentication_CheckUserodPassword()
        {
            Userod user = Security.CurUser;

            user.LoginDetails = Authentication.GenerateLoginDetails("awesomePassword", HashTypes.SHA3_512);
            bool result = Authentication.CheckPassword(user, "awesomePassword");

            Assert.IsTrue(result);
            Authentication.UpdatePasswordUserod(user, "awesomePassword");
            //If this is middletier, we need the password to match in our current user object to refill the cache
            Security.PasswordTyped = "awesomePassword";
            //Refresh our user object;
            Userods.RefreshCache();
            user = Userods.GetUser(user.UserNum);
            Assert.AreEqual(88, user.PasswordHash.Length);
            string passhash = Authentication.HashPasswordSHA512("awesomePassword", user.LoginDetails.Salt);

            Assert.IsTrue(Authentication.ConstantEquals(passhash, user.PasswordHash));
            //Reset Security.CurUser password back to the unit test password
            Authentication.UpdatePasswordUserod(user, UnitTestPassword);
            //Reset typed password
            Security.PasswordTyped = UnitTestPassword;
            Userods.RefreshCache();
            Security.CurUser = Userods.GetUser(user.UserNum);
        }
コード例 #15
0
        private void butOK_Click(object sender, EventArgs e)
        {
            Userod user = Userods.GetUserByName(textUserName.Text, false);

            if (!_isCreate && !IsInSecurityWindow)
            {
                string userPassCur = "";
                if (user != null)
                {
                    userPassCur = user.PasswordHash;
                }
                //If user's current password is blank we dont care what they put for the old one.
                if (userPassCur != "" && !Authentication.CheckPassword(user, textCurrent.Text))
                {
                    MessageBox.Show(this, "Current password incorrect.");
                    return;
                }
            }
            if (textPassword.Text == "")
            {
                MessageBox.Show(this, "Passwords cannot be blank.");
                return;
            }
            else
            {
                LoginDetails = Authentication.GenerateLoginDetailsSHA512(textPassword.Text);
                if (user?.UserName == Security.CurUser.UserName || IsInSecurityWindow)
                {
                    Security.PasswordTyped = textPassword.Text;
                    //They're updating the password for the logged in user.  Update CurUser for when they sync then attempt to log into remote DB.
                }
            }
            DialogResult = DialogResult.OK;
        }
コード例 #16
0
ファイル: UserodCrud.cs プロジェクト: royedwards/DRDNet
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Userod> TableToList(DataTable table)
        {
            List <Userod> retVal = new List <Userod>();
            Userod        userod;

            foreach (DataRow row in table.Rows)
            {
                userod                         = new Userod();
                userod.UserNum                 = PIn.Long(row["UserNum"].ToString());
                userod.UserName                = PIn.String(row["UserName"].ToString());
                userod.Password                = PIn.String(row["Password"].ToString());
                userod.UserGroupNum            = PIn.Long(row["UserGroupNum"].ToString());
                userod.EmployeeNum             = PIn.Long(row["EmployeeNum"].ToString());
                userod.ClinicNum               = PIn.Long(row["ClinicNum"].ToString());
                userod.ProvNum                 = PIn.Long(row["ProvNum"].ToString());
                userod.IsHidden                = PIn.Bool(row["IsHidden"].ToString());
                userod.TaskListInBox           = PIn.Long(row["TaskListInBox"].ToString());
                userod.AnesthProvType          = PIn.Int(row["AnesthProvType"].ToString());
                userod.DefaultHidePopups       = PIn.Bool(row["DefaultHidePopups"].ToString());
                userod.PasswordIsStrong        = PIn.Bool(row["PasswordIsStrong"].ToString());
                userod.ClinicIsRestricted      = PIn.Bool(row["ClinicIsRestricted"].ToString());
                userod.InboxHidePopups         = PIn.Bool(row["InboxHidePopups"].ToString());
                userod.UserNumCEMT             = PIn.Long(row["UserNumCEMT"].ToString());
                userod.DateTFail               = PIn.DateT(row["DateTFail"].ToString());
                userod.FailedAttempts          = PIn.Byte(row["FailedAttempts"].ToString());
                userod.DomainUser              = PIn.String(row["DomainUser"].ToString());
                userod.IsPasswordResetRequired = PIn.Bool(row["IsPasswordResetRequired"].ToString());
                retVal.Add(userod);
            }
            return(retVal);
        }
コード例 #17
0
 public FormRadOrderList(Userod user)
 {
     InitializeComponent();
     Lan.F(this);
     gridMain.ContextMenu = menuRightClick;
     _user = user;
 }
コード例 #18
0
ファイル: UserodCrud.cs プロジェクト: royedwards/DRDNet
 ///<summary>Inserts one Userod into the database.  Returns the new priKey.</summary>
 public static long Insert(Userod userod)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         userod.UserNum = DbHelper.GetNextOracleKey("userod", "UserNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(userod, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     userod.UserNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(userod, false));
     }
 }
コード例 #19
0
ファイル: UserodCrud.cs プロジェクト: royedwards/DRDNet
        ///<summary>Updates one Userod in the database.</summary>
        public static void Update(Userod userod)
        {
            string command = "UPDATE userod SET "
                             + "UserName               = '******', "
                             + "Password               = '******', "
                             + "UserGroupNum           =  " + POut.Long(userod.UserGroupNum) + ", "
                             + "EmployeeNum            =  " + POut.Long(userod.EmployeeNum) + ", "
                             + "ClinicNum              =  " + POut.Long(userod.ClinicNum) + ", "
                             + "ProvNum                =  " + POut.Long(userod.ProvNum) + ", "
                             + "IsHidden               =  " + POut.Bool(userod.IsHidden) + ", "
                             + "TaskListInBox          =  " + POut.Long(userod.TaskListInBox) + ", "
                             + "AnesthProvType         =  " + POut.Int(userod.AnesthProvType) + ", "
                             + "DefaultHidePopups      =  " + POut.Bool(userod.DefaultHidePopups) + ", "
                             + "PasswordIsStrong       =  " + POut.Bool(userod.PasswordIsStrong) + ", "
                             + "ClinicIsRestricted     =  " + POut.Bool(userod.ClinicIsRestricted) + ", "
                             + "InboxHidePopups        =  " + POut.Bool(userod.InboxHidePopups) + ", "
                             + "UserNumCEMT            =  " + POut.Long(userod.UserNumCEMT) + ", "
                             + "DateTFail              =  " + POut.DateT(userod.DateTFail) + ", "
                             + "FailedAttempts         =  " + POut.Byte(userod.FailedAttempts) + ", "
                             + "DomainUser             = '******', "
                             + "IsPasswordResetRequired=  " + POut.Bool(userod.IsPasswordResetRequired) + " "
                             + "WHERE UserNum = " + POut.Long(userod.UserNum);

            Db.NonQ(command);
        }
コード例 #20
0
 public FormUserPrefAdditional(List <UserOdPref> listUserPref, Userod userCur)
 {
     InitializeComponent();
     Lan.F(this);
     _listUserPref = listUserPref.Select(x => x.Clone()).ToList();
     _userCur      = userCur.Copy();
 }
コード例 #21
0
        private void butPickPresenter_Click(object sender, EventArgs e)
        {
            FormUserPick  FormUP    = new FormUserPick();
            List <Userod> listUsers = Userods.GetWhere(x => x.ClinicIsRestricted == false || x.ClinicNum == Clinics.ClinicNum, true);

            FormUP.ListUserodsFiltered = listUsers;
            if (_presenterCur != null)
            {
                FormUP.SuggestedUserNum = _presenterCur.UserNum;
            }
            FormUP.IsPickNoneAllowed = true;
            FormUP.ShowDialog();
            if (FormUP.DialogResult != DialogResult.OK)
            {
                return;
            }
            _presenterCur = Userods.GetUser(FormUP.SelectedUserNum);          //can be null
            if (_presenterCur != null)
            {
                textPresenter.Text = _presenterCur.UserName;
            }
            else
            {
                textPresenter.Text = "";
            }
        }
コード例 #22
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = null;

            if (IsMiddleTierSync)
            {
                selectedUser              = new Userod();
                selectedUser.UserName     = textUser.Text;
                selectedUser.LoginDetails = Authentication.GenerateLoginDetails(textPassword.Text, HashTypes.SHA3_512);
                Security.CurUser          = selectedUser;
                Security.PasswordTyped    = textPassword.Text;
            }
            else
            {
                if (PrefC.GetBool(PrefName.UserNameManualEntry))
                {
                    for (int i = 0; i < listUser.Items.Count; i++)
                    {
                        //Check the user name typed in using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names.
                        if (textUser.Text.Trim().ToLower() == listUser.Items[i].ToString().Trim().ToLower())
                        {
                            selectedUser = (Userod)listUser.Items[i];                          //Found the typed username
                            break;
                        }
                    }
                    if (selectedUser == null)
                    {
                        MessageBox.Show(this, "Login failed");
                        return;
                    }
                }
                else
                {
                    selectedUser = (Userod)listUser.SelectedItem;
                }
                try {
                    Userods.CheckUserAndPassword(selectedUser.UserName, textPassword.Text, false);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
                if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.PasswordHash == "" && textPassword.Text == "")
                {
                    MessageBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                    return;
                }
                Security.CurUser       = selectedUser.Copy();
                Security.PasswordTyped = textPassword.Text;
                UserOdPrefs.SetThemeForUserIfNeeded();
            }
            //if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){//Not sure we need this when connecting to CEMT, but not sure enough to delete.
            //	string password=textPassword.Text;
            //	if(Programs.UsingEcwTightOrFullMode()) {//ecw requires hash, but non-ecw requires actual password
            //		password=Userods.EncryptPassword(password,true);
            //	}
            //	Security.PasswordTyped=password;
            //}
            DialogResult = DialogResult.OK;
        }
コード例 #23
0
 ///<summary>Used for existing Reviews. Pass in the jobNum and the jobReviewNum.</summary>
 public FormJobReviewEdit(JobReview jobReview)
 {
     secUser       = Security.CurUser;
     _jobReviewCur = jobReview.Copy();
     InitializeComponent();
     Lan.F(this);
 }
コード例 #24
0
        ///<summary>Fills listUserTabUsers. Public so that it can be called from the Form that implements this control.</summary>
        public void FillUserTabUsers()
        {
            _isFillingList = true;
            Userod selectedUser = SelectedUser;            //preserve user selection.

            listUserTabUserGroups.Enabled = true;
            listUserTabUsers.Items.Clear();
            foreach (Userod userCur in GetFilteredUsersHelper())
            {
                ODBoxItem <Userod> boxItemCur = new ODBoxItem <Userod>(userCur.UserName, userCur);
                listUserTabUsers.Items.Add(boxItemCur);
                if (selectedUser != null && userCur.UserNum == selectedUser.UserNum)
                {
                    listUserTabUsers.SelectedItem = boxItemCur;
                }
            }
            if (listUserTabUsers.Items.Count == 0)
            {
                listUserTabUserGroups.Enabled = false;
                listUserTabUserGroups.ClearSelected();
                RefreshUserTree();
            }
            else if (SelectedUser == null)
            {
                _isFillingList = false;               //We want the listUsers_SelectedIndexChanged method to get called to refresh the tree.
                listUserTabUsers.SelectedIndex = 0;
            }
            _isFillingList = false;
        }
コード例 #25
0
        public void Userods_CheckUserAndPassoword_UpdateFailedAttemptsTo5()
        {
            //First, setup the test scenario.
            long   group1 = UserGroupT.CreateUserGroup("usergroup1");
            Userod myUser = UserodT.CreateUser(MethodBase.GetCurrentMethod().Name + DateTime.Now.Ticks, "reallystrongpassword", userGroupNumbers: new List <long>()
            {
                group1
            });

            CredentialsFailedAfterLoginEvent.Fired += CredentialsFailedAfterLoginEvent_Fired1;
            Security.CurUser       = myUser;
            Security.PasswordTyped = "passwordguess#1";
            RunTestsAgainstMiddleTier();
            //try with 5 incorrect passwords. Failed attempt should get incremented to 5.
            for (int i = 1; i < 6; i++)
            {
                ODException.SwallowAnyException(() => {
                    try {
                        Userods.CheckUserAndPassword(myUser.UserName, "passwordguess#" + i, false);
                    }
                    catch (Exception e) {
                    }
                });
            }
            //Get our updated user from the DB.
            RunTestsAgainstDirectConnection();
            myUser = Userods.GetUserByNameNoCache(myUser.UserName);
            //Assert that there are 5 failed attempts.
            Assert.AreEqual(5, myUser.FailedAttempts);
        }
コード例 #26
0
        private void butESign_Click(object sender, EventArgs e)
        {
            Userod   curUser          = _userSig ?? Security.CurUser;
            Provider provCur          = Providers.GetProv(curUser.ProvNum);
            string   digitalSignature = Lan.g(this, "Digitally Signed by ");

            if (provCur != null)
            {
                digitalSignature += provCur.GetLongDesc();
            }
            else if (curUser != null)
            {
                digitalSignature += curUser.UserName + " (UserNum:" + curUser.UserNum + ")";
            }
            else
            {
                //should never happen
                digitalSignature = Lan.g(this, "Digitally signed by unknown user.");
            }
            digitalSignature += "\r\n" + Lan.g(this, "Date Signed") + ": " + MiscData.GetNowDateTime().ToString();
            List <Point> pList = sigBox.EncryptString(digitalSignature);

            sigBox.SetPointList(pList);
            OnSignatureChanged();
            sigBox.Enabled = false;
        }
コード例 #27
0
ファイル: UserodCrud.cs プロジェクト: nampn/ODental
 ///<summary>Inserts one Userod into the database.  Returns the new priKey.</summary>
 internal static long Insert(Userod userod)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         userod.UserNum=DbHelper.GetNextOracleKey("userod","UserNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(userod,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     userod.UserNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(userod,false);
     }
 }
コード例 #28
0
ファイル: FormUnitTests.cs プロジェクト: steev90/opendental
 private void butWebService_Click(object sender, EventArgs e)
 {
     RemotingClient.ServerURI = "http://localhost:49262/ServiceMain.asmx";
     Cursor = Cursors.WaitCursor;
     try{
         if (!isOracle)
         {
             Userod user = Security.LogInWeb("Admin", "", "", Application.ProductVersion, false);              //Userods.EncryptPassword("pass",false)
             Security.CurUser            = user;
             RemotingClient.RemotingRole = RemotingRole.ClientWeb;
         }
         else if (isOracle)
         {
             MsgBox.Show(this, "Oracle does not have unit test for web service yet.");
             Cursor = Cursors.Default;
             return;
         }
     }
     catch (Exception ex) {
         Cursor = Cursors.Default;
         MessageBox.Show(ex.Message);
         return;
     }
     textResults.Text = "";
     Application.DoEvents();
     textResults.Text += WebServiceT.RunAll();
     Cursor            = Cursors.Default;
 }
コード例 #29
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            //Logout
            if (secUser.UserNum != Security.CurUser.UserNum)
            {
                butLogin.Text = Lan.g(this, "Login as...");
                this.Text     = Lan.g(this, "Job Review Edit");
                secUser       = Security.CurUser;
                CheckPermissions();
                return;
            }
            //Otherwise login
            FormLogOn FormLO = new FormLogOn()
            {
                IsSimpleSwitch = true
            };

            if (JobReviewCur != null)
            {
                FormLO.UserNumPrompt = JobReviewCur.ReviewerNum;
            }
            FormLO.ShowDialog();
            if (FormLO.DialogResult != DialogResult.OK)
            {
                return;
            }
            secUser = FormLO.CurUserSimpleSwitch;
            CheckPermissions();
            if (secUser.UserNum != Security.CurUser.UserNum)
            {
                butLogin.Text = Lan.g(this, "Logout");
                this.Text     = Lan.g(this, "Job Review Edit") + " - Logged in as " + secUser.UserName;
            }
        }
コード例 #30
0
 private void FormProvStudentEdit_Load(object sender, EventArgs e)
 {
     _existingUser = new Userod();
     //Load the Combo Box
     _listSchoolClasses = SchoolClasses.GetDeepCopy();
     for (int i = 0; i < _listSchoolClasses.Count; i++)
     {
         comboClass.Items.Add(SchoolClasses.GetDescript(_listSchoolClasses[i]));
     }
     comboClass.SelectedIndex = 0;
     //Create a provider object if none has been provided
     if (ProvStudent == null)
     {
         ProvStudent = new Provider();
     }
     //From the add button - Select as much pre-given info as possible
     if (ProvStudent.IsNew)
     {
         labelPassDescription.Visible = false;
         _autoUserName     = Providers.GetNextAvailableProvNum();
         textUserName.Text = POut.Long(_autoUserName);              //User-names are suggested to be the ProvNum of the provider.  This can be changed at will.
         for (int i = 0; i < _listSchoolClasses.Count - 1; i++)
         {
             if (_listSchoolClasses[i].SchoolClassNum != ProvStudent.SchoolClassNum)
             {
                 continue;
             }
             comboClass.SelectedIndex = i;
             break;
         }
         textFirstName.Text = ProvStudent.FName;
         textLastName.Text  = ProvStudent.LName;
     }
     //Double-Clicking an existing student
     else
     {
         _isGeneratingAbbr = false;
         for (int i = 0; i < _listSchoolClasses.Count - 1; i++)
         {
             if (_listSchoolClasses[i].SchoolClassNum != ProvStudent.SchoolClassNum)
             {
                 continue;
             }
             comboClass.SelectedIndex = i;
             break;
         }
         textAbbr.Text      = ProvStudent.Abbr;
         textFirstName.Text = ProvStudent.FName;
         textLastName.Text  = ProvStudent.LName;
         List <Userod> userList = Providers.GetAttachedUsers(ProvStudent.ProvNum);
         if (userList.Count > 0)
         {
             textUserName.Text = userList[0].UserName;                  //Should always happen if they are a student.
             _existingUser     = userList[0];
         }
         textProvNum.Text = POut.Long(ProvStudent.ProvNum);
     }
 }
コード例 #31
0
ファイル: FormUserEdit.cs プロジェクト: nampn/ODental
 ///<summary></summary>
 public FormUserEdit(Userod userCur)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     UserCur = userCur.Copy();
 }
コード例 #32
0
        ///<summary></summary>
        private static void Insert(Userod user)
        {
            string command = "INSERT INTO userod (UserName,Password,UserGroupNum,EmployeeNum) VALUES("
                             + "'" + POut.PString(user.UserName) + "', "
                             + "'" + POut.PString(user.Password) + "', "
                             + "'" + POut.PInt(user.UserGroupNum) + "', "
                             + "'" + POut.PInt(user.EmployeeNum) + "')";

            user.UserNum = General.NonQ(command, true);
        }
コード例 #33
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Userod> TableToList(DataTable table){
			List<Userod> retVal=new List<Userod>();
			Userod userod;
			for(int i=0;i<table.Rows.Count;i++) {
				userod=new Userod();
				userod.UserNum           = PIn.Long  (table.Rows[i]["UserNum"].ToString());
				userod.UserName          = PIn.String(table.Rows[i]["UserName"].ToString());
				userod.Password          = PIn.String(table.Rows[i]["Password"].ToString());
				userod.UserGroupNum      = PIn.Long  (table.Rows[i]["UserGroupNum"].ToString());
				userod.EmployeeNum       = PIn.Long  (table.Rows[i]["EmployeeNum"].ToString());
				userod.ClinicNum         = PIn.Long  (table.Rows[i]["ClinicNum"].ToString());
				userod.ProvNum           = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				userod.IsHidden          = PIn.Bool  (table.Rows[i]["IsHidden"].ToString());
				userod.TaskListInBox     = PIn.Long  (table.Rows[i]["TaskListInBox"].ToString());
				userod.AnesthProvType    = PIn.Int   (table.Rows[i]["AnesthProvType"].ToString());
				userod.DefaultHidePopups = PIn.Bool  (table.Rows[i]["DefaultHidePopups"].ToString());
				userod.PasswordIsStrong  = PIn.Bool  (table.Rows[i]["PasswordIsStrong"].ToString());
				userod.ClinicIsRestricted= PIn.Bool  (table.Rows[i]["ClinicIsRestricted"].ToString());
				retVal.Add(userod);
			}
			return retVal;
		}
コード例 #34
0
ファイル: UserodCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one Userod in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Userod userod,Userod oldUserod){
			string command="";
			if(userod.UserName != oldUserod.UserName) {
				if(command!=""){ command+=",";}
				command+="UserName = '******'";
			}
			if(userod.Password != oldUserod.Password) {
				if(command!=""){ command+=",";}
				command+="Password = '******'";
			}
			if(userod.UserGroupNum != oldUserod.UserGroupNum) {
				if(command!=""){ command+=",";}
				command+="UserGroupNum = "+POut.Long(userod.UserGroupNum)+"";
			}
			if(userod.EmployeeNum != oldUserod.EmployeeNum) {
				if(command!=""){ command+=",";}
				command+="EmployeeNum = "+POut.Long(userod.EmployeeNum)+"";
			}
			if(userod.ClinicNum != oldUserod.ClinicNum) {
				if(command!=""){ command+=",";}
				command+="ClinicNum = "+POut.Long(userod.ClinicNum)+"";
			}
			if(userod.ProvNum != oldUserod.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(userod.ProvNum)+"";
			}
			if(userod.IsHidden != oldUserod.IsHidden) {
				if(command!=""){ command+=",";}
				command+="IsHidden = "+POut.Bool(userod.IsHidden)+"";
			}
			if(userod.TaskListInBox != oldUserod.TaskListInBox) {
				if(command!=""){ command+=",";}
				command+="TaskListInBox = "+POut.Long(userod.TaskListInBox)+"";
			}
			if(userod.AnesthProvType != oldUserod.AnesthProvType) {
				if(command!=""){ command+=",";}
				command+="AnesthProvType = "+POut.Int(userod.AnesthProvType)+"";
			}
			if(userod.DefaultHidePopups != oldUserod.DefaultHidePopups) {
				if(command!=""){ command+=",";}
				command+="DefaultHidePopups = "+POut.Bool(userod.DefaultHidePopups)+"";
			}
			if(userod.PasswordIsStrong != oldUserod.PasswordIsStrong) {
				if(command!=""){ command+=",";}
				command+="PasswordIsStrong = "+POut.Bool(userod.PasswordIsStrong)+"";
			}
			if(userod.ClinicIsRestricted != oldUserod.ClinicIsRestricted) {
				if(command!=""){ command+=",";}
				command+="ClinicIsRestricted = "+POut.Bool(userod.ClinicIsRestricted)+"";
			}
			if(userod.InboxHidePopups != oldUserod.InboxHidePopups) {
				if(command!=""){ command+=",";}
				command+="InboxHidePopups = "+POut.Bool(userod.InboxHidePopups)+"";
			}
			if(userod.UserNumCEMT != oldUserod.UserNumCEMT) {
				if(command!=""){ command+=",";}
				command+="UserNumCEMT = "+POut.Long(userod.UserNumCEMT)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE userod SET "+command
				+" WHERE UserNum = "+POut.Long(userod.UserNum);
			Db.NonQ(command);
			return true;
		}
コード例 #35
0
ファイル: UserodCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one Userod in the database.</summary>
		public static void Update(Userod userod){
			string command="UPDATE userod SET "
				+"UserName          = '******', "
				+"Password          = '******', "
				+"UserGroupNum      =  "+POut.Long  (userod.UserGroupNum)+", "
				+"EmployeeNum       =  "+POut.Long  (userod.EmployeeNum)+", "
				+"ClinicNum         =  "+POut.Long  (userod.ClinicNum)+", "
				+"ProvNum           =  "+POut.Long  (userod.ProvNum)+", "
				+"IsHidden          =  "+POut.Bool  (userod.IsHidden)+", "
				+"TaskListInBox     =  "+POut.Long  (userod.TaskListInBox)+", "
				+"AnesthProvType    =  "+POut.Int   (userod.AnesthProvType)+", "
				+"DefaultHidePopups =  "+POut.Bool  (userod.DefaultHidePopups)+", "
				+"PasswordIsStrong  =  "+POut.Bool  (userod.PasswordIsStrong)+", "
				+"ClinicIsRestricted=  "+POut.Bool  (userod.ClinicIsRestricted)+", "
				+"InboxHidePopups   =  "+POut.Bool  (userod.InboxHidePopups)+", "
				+"UserNumCEMT       =  "+POut.Long  (userod.UserNumCEMT)+" "
				+"WHERE UserNum = "+POut.Long(userod.UserNum);
			Db.NonQ(command);
		}