Exemplo n.º 1
0
        ///<summary>Updates the database with computerPrefNew.  Returns true if changes were needed or if computerPrefOld is null.
        ///Automatically clears out class-wide variables if any changes were needed.</summary>
        public static bool Update(ComputerPref computerPrefNew, ComputerPref computerPrefOld)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                bool wasUpdateNeeded = Meth.GetBool(MethodBase.GetCurrentMethod(), computerPrefNew, computerPrefOld);
                if (wasUpdateNeeded)
                {
                    //If we are running Middle Tier, we need to make sure these variables are reset on the client.
                    _localComputer    = null;
                    _localComputerOld = null;
                }
                return(wasUpdateNeeded);
            }
            bool hadChanges = false;

            if (computerPrefOld == null)
            {
                Crud.ComputerPrefCrud.Update(computerPrefNew);
                hadChanges = true;              //Assume that there were database changes.
            }
            else
            {
                hadChanges = Crud.ComputerPrefCrud.Update(computerPrefNew, computerPrefOld);
            }
            if (hadChanges)
            {
                //DB was updated, may also contain other changes from other WS.
                //Set to null so that we can go to DB again when needed, ensures _localComputer is never stale.
                _localComputer    = null;
                _localComputerOld = null;
            }
            return(hadChanges);
        }
Exemplo n.º 2
0
 ///<summary>Any time this is called, ComputerPrefs.LocalComputer will be passed in.  It will have already been changed for local use, and this saves it for next time.</summary>
 public static void Update(ComputerPref computerPref)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),computerPref);
         return;
     }
     Crud.ComputerPrefCrud.Update(computerPref);
 }
Exemplo n.º 3
0
 ///<summary>Should not be called by external classes.</summary>
 public static long Insert(ComputerPref computerPref)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         computerPref.ComputerPrefNum=Meth.GetLong(MethodBase.GetCurrentMethod(),computerPref);
         return computerPref.ComputerPrefNum;
     }
     return Crud.ComputerPrefCrud.Insert(computerPref);
 }
Exemplo n.º 4
0
 ///<summary>Any time this is called, ComputerPrefs.LocalComputer will be passed in.  It will have already been changed for local use, and this saves it for next time.</summary>
 public static void Update(ComputerPref computerPref)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), computerPref);
         return;
     }
     Crud.ComputerPrefCrud.Update(computerPref);
 }
Exemplo n.º 5
0
 ///<summary>Should not be called by external classes.</summary>
 public static long Insert(ComputerPref computerPref)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         computerPref.ComputerPrefNum = Meth.GetLong(MethodBase.GetCurrentMethod(), computerPref);
         return(computerPref.ComputerPrefNum);
     }
     return(Crud.ComputerPrefCrud.Insert(computerPref));
 }
Exemplo n.º 6
0
        ///<summary>Returns the computer preferences for the computer with the passed in computer name.</summary>
        public static ComputerPref GetForComputer(string computerName)
        {
            //No need to check RemotingRole; no call to db.
            ComputerPref computerPref = new ComputerPref();

            //OpenGL tooth chart not supported on Unix systems.
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                computerPref.GraphicsSimple = DrawingMode.Simple2D;
            }
            //Default sensor values to start
            computerPref.SensorType     = "D";
            computerPref.SensorPort     = 0;
            computerPref.SensorExposure = 1;
            computerPref.SensorBinned   = false;
            //Default values to start
            computerPref.AtoZpath           = "";
            computerPref.TaskKeepListHidden = false; //show docked task list on this computer
            computerPref.TaskDock           = 0;     //bottom
            computerPref.TaskX               = 900;
            computerPref.TaskY               = 625;
            computerPref.ComputerName        = computerName;
            computerPref.DirectXFormat       = "";
            computerPref.ScanDocSelectSource = false;
            computerPref.ScanDocShowOptions  = false;
            computerPref.ScanDocDuplex       = false;
            computerPref.ScanDocGrayscale    = false;
            computerPref.ScanDocResolution   = 150;    //default suggested in FormImagingSetup
            computerPref.ScanDocQuality      = 40;     //default suggested in FormImagingSetup
            computerPref.GraphicsSimple      = DrawingMode.DirectX;
            computerPref.NoShowLanguage      = false;
            DataTable table = GetPrefsForComputer(computerName);

            if (table == null)
            {
                //In case of database error, just use default graphics settings so that it is possible for the program to start.
                return(computerPref);
            }
            if (table.Rows.Count == 0)          //Computer pref row does not yet exist for this computer.
            {
                Insert(computerPref);           //Create default prefs for the specified computer. Also sets primary key in our computerPref object.
                return(computerPref);
            }
            if (table.Rows.Count > 1)
            {
                //Should never happen (would only happen if the primary key showed up more than once).
                Logger.openlog.LogMB("Corrupt computerpref table in database. The computer name '"
                                     + POut.String(computerName) + "' is a primary key in multiple records. Please run the "
                                     + "database maintenance tool, then call us for help if you still get this message.",
                                     Logger.Severity.WARNING);
            }
            computerPref = Crud.ComputerPrefCrud.TableToList(table)[0];
            return(computerPref);
        }
Exemplo n.º 7
0
        ///<summary>Updates the local computerpref's ComputerOS if it is different than what is stored.</summary>
        public static void UpdateLocalComputerOS()
        {
            //No need to check RemotingRole; no call to db.
            string platformIdAsString = POut.String(Environment.OSVersion.Platform.ToString());

            if (LocalComputer.ComputerOS.ToString() == platformIdAsString)           //We only want to update this column if there is indeed a difference between values.
            {
                return;
            }
            UpdateComputerOS(platformIdAsString, ComputerPrefs.LocalComputer.ComputerPrefNum);
            _localComputer = null;          //Setting to null will trigger LocalComputer to update from DB next time it is accessed.
        }
Exemplo n.º 8
0
        public ComputerPref Copy()
        {
            ComputerPref cp = new ComputerPref();

            cp.ComputerPrefNum         = ComputerPrefNum;
            cp.ComputerName            = ComputerName;
            cp.GraphicsUseHardware     = GraphicsUseHardware;
            cp.GraphicsSimple          = GraphicsSimple;
            cp.SensorType              = SensorType;
            cp.SensorBinned            = SensorBinned;
            cp.SensorPort              = SensorPort;
            cp.SensorExposure          = SensorExposure;
            cp.GraphicsDoubleBuffering = GraphicsDoubleBuffering;
            cp.PreferredPixelFormatNum = PreferredPixelFormatNum;
            return(cp);
        }
Exemplo n.º 9
0
		///<summary>Returns the computer preferences for the computer which this instance of Open Dental is running on.</summary>
		private static ComputerPref GetForLocalComputer(){
			//No need to check RemotingRole; no call to db.
			string computerName=Dns.GetHostName();//local computer name
			ComputerPref computerPref=new ComputerPref();
			//OpenGL tooth chart not supported on Unix systems.
			if(Environment.OSVersion.Platform==PlatformID.Unix) {
				computerPref.GraphicsSimple=DrawingMode.Simple2D;
			}
			//Default sensor values to start
			computerPref.SensorType="D";
			computerPref.SensorPort=0;
			computerPref.SensorExposure=1;
			computerPref.SensorBinned=false;
			//Default values to start
			computerPref.AtoZpath="";
			computerPref.TaskKeepListHidden=false; //show docked task list on this computer 
			computerPref.TaskDock=0; //bottom
			computerPref.TaskX=900;
			computerPref.TaskY=625;
			computerPref.ComputerName=computerName;
			computerPref.DirectXFormat="";
			computerPref.ScanDocSelectSource=false;
			computerPref.ScanDocShowOptions=false;
			computerPref.ScanDocDuplex=false;
			computerPref.ScanDocGrayscale=false;
			computerPref.ScanDocResolution=150;//default suggested in FormImagingSetup
			computerPref.ScanDocQuality=40;//default suggested in FormImagingSetup
			computerPref.GraphicsSimple=DrawingMode.DirectX;
			DataTable table=GetPrefsForComputer(computerName);
			if(table==null){
				//In case of database error, just use default graphics settings so that it is possible for the program to start.
				return computerPref;
			}
			if(table.Rows.Count==0){//Computer pref row does not yet exist for this computer.
				Insert(computerPref);//Create default prefs for the specified computer. Also sets primary key in our computerPref object.
				return computerPref;
			}
			if(table.Rows.Count>1){
				//Should never happen (would only happen if the primary key showed up more than once).
				Logger.openlog.LogMB("Corrupt computerpref table in database. The computer name '"
					+POut.String(computerName)+"' is a primary key in multiple records. Please run the "
					+"database maintenance tool, then call us for help if you still get this message.",
					Logger.Severity.WARNING);
			}
			computerPref=Crud.ComputerPrefCrud.TableToList(table)[0];
			return computerPref;
		}
Exemplo n.º 10
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":
                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;
        }
Exemplo n.º 11
0
 ///<summary>Any time this is called, ComputerPrefs.LocalComputer MUST be passed in.
 ///It will have already been changed for local use, and this saves it for next time.</summary>
 public static void Update(ComputerPref computerPref)
 {
     //No need to check RemotingRole; no call to db.
     Update(computerPref, _localComputerOld);
 }