コード例 #1
0
ファイル: Clinics.cs プロジェクト: kjb7749/testImport
        ///<summary>Sets Clinics.ClinicNum. Used when logging on to determines what clinic to start with based on user and workstation preferences.</summary>
        public static void LoadClinicNumForUser()
        {
            _clinicNum = 0;          //aka headquarters clinic when clinics are enabled.
            if (!PrefC.HasClinicsEnabled || Security.CurUser == null)
            {
                return;
            }
            List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser);

            switch (PrefC.GetString(PrefName.ClinicTrackLast))
            {
            case "Workstation":
                if (Security.CurUser.ClinicIsRestricted && Security.CurUser.ClinicNum != ComputerPrefs.LocalComputer.ClinicNum)                       //The user is restricted and it's not the clinic this computer has by default
                //User's default clinic isn't the LocalComputer's clinic, see if they have access to the Localcomputer's clinic, if so, use it.
                {
                    Clinic clinic = listClinics.Find(x => x.ClinicNum == ComputerPrefs.LocalComputer.ClinicNum);
                    if (clinic != null)
                    {
                        _clinicNum = clinic.ClinicNum;
                    }
                    else
                    {
                        _clinicNum = Security.CurUser.ClinicNum;                              //Use the user's default clinic if they don't have access to LocalComputer's clinic.
                    }
                }
                else                          //The user is not restricted, just use the clinic in the ComputerPref table.
                {
                    _clinicNum = ComputerPrefs.LocalComputer.ClinicNum;
                }
                return;                        //Error

            case "User":
                List <UserOdPref> prefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.ClinicLast);                      //should only be one or none.
                if (prefs.Count == 0)
                {
                    UserOdPref pref =
                        new UserOdPref()
                    {
                        UserNum  = Security.CurUser.UserNum,
                        FkeyType = UserOdFkeyType.ClinicLast,
                        Fkey     = Security.CurUser.ClinicNum                                  //default clinic num
                    };
                    UserOdPrefs.Insert(pref);
                    prefs.Add(pref);
                }
                if (listClinics.Any(x => x.ClinicNum == prefs[0].Fkey))                       //user is restricted and does not have access to the computerpref clinic
                {
                    _clinicNum = prefs[0].Fkey;
                }
                return;

            case "None":
            default:
                if (listClinics.Any(x => x.ClinicNum == Security.CurUser.ClinicNum))
                {
                    _clinicNum = Security.CurUser.ClinicNum;
                }
                break;
            }
        }
コード例 #2
0
ファイル: Clinics.cs プロジェクト: kjb7749/testImport
        ///<summary>Called when logging user off or closing opendental.</summary>
        public static void LogOff()
        {
            if (!PrefC.HasClinicsEnabled)
            {
                _clinicNum = 0;
                return;
            }
            switch (PrefC.GetString(PrefName.ClinicTrackLast))
            {
            case "Workstation":
                ComputerPref compPref = ComputerPrefs.LocalComputer;
                compPref.ClinicNum = Clinics.ClinicNum;
                ComputerPrefs.Update(compPref);
                break;

            case "User":
                List <UserOdPref> UserPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.ClinicLast);                      //should only be one or none.
                if (UserPrefs.Count == 0)
                {
                    //this situation should never happen.
                    UserOdPref pref =
                        new UserOdPref()
                    {
                        UserNum  = Security.CurUser.UserNum,
                        FkeyType = UserOdFkeyType.ClinicLast,
                        Fkey     = Clinics.ClinicNum
                    };
                    UserOdPrefs.Insert(pref);
                    break;
                }
                UserPrefs.ForEach(x => x.Fkey = Clinics.ClinicNum);
                UserPrefs.ForEach(UserOdPrefs.Update);
                break;

            case "None":
            default:
                break;
            }
            _clinicNum = 0;
        }
コード例 #3
0
        ///<summary>Called when logging user off or closing opendental.</summary>
        public static void LogOff()
        {
            if (!PrefC.HasClinicsEnabled)
            {
                _clinicNum = 0;
                return;
            }
            switch (PrefC.GetString(PrefName.ClinicTrackLast))
            {
            case "Workstation":
                ComputerPrefs.LocalComputer.ClinicNum = Clinics.ClinicNum;
                ComputerPrefs.Update(ComputerPrefs.LocalComputer);
                break;

            case "User":                    //handled below
            case "None":
            default:
                break;
            }
            //We want to always upsert a user pref for the user because we will be looking at it for MobileWeb regardless of the preference for
            //ClinicTrackLast.
            List <UserOdPref> UserPrefs = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.ClinicLast);        //should only be one or none.

            if (UserPrefs.Count == 0)
            {
                UserOdPref pref = new UserOdPref()
                {
                    UserNum  = Security.CurUser.UserNum,
                    FkeyType = UserOdFkeyType.ClinicLast,
                    Fkey     = Clinics.ClinicNum
                };
                UserOdPrefs.Insert(pref);
            }
            UserPrefs.ForEach(x => {
                x.Fkey = Clinics.ClinicNum;
                UserOdPrefs.Update(x);
            });
            _clinicNum = 0;
        }