コード例 #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
ファイル: WikiPages.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Creates historical entry of deletion into wikiPageHist, and deletes current non-draft page from WikiPage.
        ///For middle tier purposes we need to have the currently logged in user passed into this method.</summary>
        public static void Archive(string pageTitle, long userNumCur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), pageTitle, userNumCur);
                return;
            }
            WikiPage wikiPage = GetByTitle(pageTitle);

            if (wikiPage == null)
            {
                return;                //The wiki page could not be found by the page title, nothing to do.
            }
            WikiPageHist wikiPageHist = PageToHist(wikiPage);

            //preserve the existing page with user credentials
            WikiPageHists.Insert(wikiPageHist);
            //make entry to show who deleted the page
            wikiPageHist.IsDeleted     = true;
            wikiPageHist.UserNum       = userNumCur;
            wikiPageHist.DateTimeSaved = MiscData.GetNowDateTime();
            WikiPageHists.Insert(wikiPageHist);
            //Now mark the wikipage as IsDeleted
            wikiPage.IsDeleted     = true;
            wikiPage.DateTimeSaved = MiscData.GetNowDateTime();
            Crud.WikiPageCrud.Update(wikiPage);
            //Remove all associated home pages for all users.
            UserOdPrefs.DeleteForValueString(0, UserOdFkeyType.WikiHomePage, pageTitle);
        }
コード例 #3
0
        ///<summary>This should be called when the user is changed (excluding temporay logins such as job review logins).
        ///In the future, we could also call this if we detect the office theme has changed via signal preference cache refresh or if
        ///another person using the same login information changes the theme for a group of users.</summary>
        public static void SetThemeForUserIfNeeded()
        {
            OdTheme themeDefault = OdTheme.Standard;

            try {
                themeDefault = (OdTheme)PrefC.GetInt(PrefName.ColorTheme);
            }
            catch {
                //try/catch in case you are trying to convert from an older version of OD and need to update the DB.
            }
            if (Security.CurUser == null)           //no current user, set to the default practice theme.
            {
                ODColorTheme.SetTheme(themeDefault);
                return;
            }
            UserOdPref themePref = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.UserTheme).FirstOrDefault();

            //user theme not allowed or hasn't been set
            if (!PrefC.GetBool(PrefName.ThemeSetByUser) || themePref == null)
            {
                ODColorTheme.SetTheme(themeDefault);
            }
            else if (themePref != null)           //user theme allowed but needs to update for user pref
            {
                ODColorTheme.SetTheme((OdTheme)themePref.Fkey);
            }
        }
コード例 #4
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;
        }
コード例 #5
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;
        }
コード例 #6
0
 ///<summary>Throws an exception to display to the user if anything goes wrong.</summary>
 public static void TryToConnect(CentralConnection centralConnection, DatabaseType dbType, string connectionString = "", bool noShowOnStartup = false,
                                 List <string> listAdminCompNames = null, bool isCommandLineArgs = false, bool useDynamicMode = false, bool allowAutoLogin = true)
 {
     if (!string.IsNullOrEmpty(centralConnection.ServiceURI))
     {
         LoadMiddleTierProxySettings();
         string originalURI = RemotingClient.ServerURI;
         RemotingClient.ServerURI = centralConnection.ServiceURI;
         bool         useEcwAlgorithm = centralConnection.WebServiceIsEcw;
         RemotingRole originalRole    = RemotingClient.RemotingRole;
         RemotingClient.RemotingRole = RemotingRole.ClientWeb;
         try {
             string password = centralConnection.OdPassword;
             if (useEcwAlgorithm)
             {
                 //It doesn't matter what Security.CurUser is when it is null because we are technically trying to set it for the first time.
                 //It cannot be null before invoking HashPassword for Middle Tier for creating credentials for DTOs.
                 if (Security.CurUser == null)
                 {
                     Security.CurUser = new Userod();
                 }
                 //Utilize the custom eCW MD5 hashing algorithm if no password hash was passed in via command line arguments.
                 if (string.IsNullOrEmpty(centralConnection.OdPassHash))
                 {
                     password = Authentication.HashPasswordMD5(password, true);
                 }
                 else                          //eCW gave us the password already hashed via command line arguments, simply use it.
                 {
                     password = centralConnection.OdPassHash;
                 }
             }
             string username = centralConnection.OdUser;
             //ecw requires hash, but non-ecw requires actual password
             Security.CurUser       = Security.LogInWeb(username, password, "", Application.ProductVersion, useEcwAlgorithm);
             Security.PasswordTyped = password;                  //for ecw, this is already encrypted.
             UserOdPrefs.SetThemeForUserIfNeeded();
         }
         catch (Exception ex) {
             RemotingClient.ServerURI    = originalURI;
             RemotingClient.RemotingRole = originalRole;
             throw ex;
         }
     }
     else
     {
         DataConnection.DBtype = dbType;
         DataConnection dcon = new DataConnection();
         if (connectionString.Length > 0)
         {
             dcon.SetDb(connectionString, "", DataConnection.DBtype);
         }
         else
         {
             //Password could be plain text password from the Password field of the config file, the decrypted password from the MySQLPassHash field
             //of the config file, or password entered by the user and can be blank (empty string) in all cases
             dcon.SetDb(centralConnection.ServerName, centralConnection.DatabaseName, centralConnection.MySqlUser
                        , centralConnection.MySqlPassword, "", "", DataConnection.DBtype);
         }
         //a direct connection does not utilize lower privileges.
         RemotingClient.RemotingRole = RemotingRole.ClientDirect;
     }
     //Only gets this far if we have successfully connected, thus, saving connection settings is appropriate.
     TrySaveConnectionSettings(centralConnection, dbType, connectionString, noShowOnStartup: noShowOnStartup, listAdminCompNames,
                               isCommandLineArgs: isCommandLineArgs, useDynamicMode: useDynamicMode, allowAutoLogin: allowAutoLogin);
 }