Example #1
0
        private void butChange_Click(object sender, EventArgs e)
        {
            FormRegistrationKey formR = new FormRegistrationKey();

            formR.ShowDialog();
            DataValid.SetInvalid(InvalidType.Prefs);
            string regkey = PrefC.GetString(PrefName.RegistrationKey);

            if (regkey.Length == 16)
            {
                textRegKey.Text = regkey.Substring(0, 4) + "-" + regkey.Substring(4, 4) + "-" + regkey.Substring(8, 4) + "-" + regkey.Substring(12, 4);
            }
            else
            {
                textRegKey.Text = regkey;
            }
        }
Example #2
0
 ///<summary>Returns false if it can't complete a conversion, find datapath, or validate registration key.</summary>
 private bool PrefsStartup()
 {
     Cache.Refresh(InvalidType.Prefs);
     if(!PrefL.CheckMySqlVersion()){
         return false;
     }
     if(DataConnection.DBtype==DatabaseType.MySql) {
         try {
             MiscData.SetSqlMode();
         }
         catch {
             MessageBox.Show("Unable to set global sql mode.  User probably does not have enough permission.");
             return false;
         }
         string updateComputerName=PrefC.GetStringSilent(PrefName.UpdateInProgressOnComputerName);
         if(updateComputerName != "" && Environment.MachineName != updateComputerName) {
             DialogResult result=MessageBox.Show("An update is in progress on "+updateComputerName+".  Not allowed to start up until that update is complete.\r\n\r\nIf you are the person who started the update and you wish to override this message because an update is not in progress, click Retry.\r\n\r\nDo not click Retry unless you started the update.",
                 "",MessageBoxButtons.RetryCancel);
             if(result==DialogResult.Retry) {
                 Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");
                 MsgBox.Show(this,"You will be allowed access when you restart.");
             }
             return false;
         }
     }
     //if RemotingRole.ClientWeb, version will have already been checked at login, so no danger here.
     //ClientWeb version can be older than this version, but that will be caught in a moment.
     if(!PrefL.ConvertDB()){
         return false;
     }
     PrefL.MySqlVersion55Remind();
     if(PrefC.UsingAtoZfolder) {
         string prefImagePath=ImageStore.GetPreferredAtoZpath();
         if(prefImagePath==null || !Directory.Exists(prefImagePath)) {//AtoZ folder not found
             Cache.Refresh(InvalidType.Security);
             FormPath FormP=new FormPath();
             FormP.IsStartingUp=true;
             FormP.ShowDialog();
             if(FormP.DialogResult!=DialogResult.OK) {
                 MsgBox.Show(this,"Invalid A to Z path.  Closing program.");
                 Application.Exit();
                 return false;
             }
             //bool usingAtoZ=FormPath.UsingImagePath();
             //ContrImages2.Enabled=usingAtoZ;
             //menuItemClaimForms.Visible=usingAtoZ;
             //CheckCustomReports();
             //this.RefreshCurrentModule();
             Cache.Refresh(InvalidType.Prefs);//because listening thread not started yet.
         }
     }
     if(!PrefL.CheckProgramVersion()){
         return false;
     }
     if(!FormRegistrationKey.ValidateKey(PrefC.GetString(PrefName.RegistrationKey))){
         //true){
         FormRegistrationKey FormR=new FormRegistrationKey();
         FormR.ShowDialog();
         if(FormR.DialogResult!=DialogResult.OK){
             Application.Exit();
             return false;
         }
         Cache.Refresh(InvalidType.Prefs);
     }
     Lans.RefreshCache();//automatically skips if current culture is en-US
     LanguageForeigns.Refresh(CultureInfo.CurrentCulture.Name,CultureInfo.CurrentCulture.TwoLetterISOLanguageName);//automatically skips if current culture is en-US
     //menuItemMergeDatabases.Visible=PrefC.GetBool(PrefName.RandomPrimaryKeys");
     return true;
 }
Example #3
0
		///<summary>Returns false if it can't complete a conversion, find datapath, or validate registration key.</summary>
		private bool PrefsStartup(bool isSilentUpdate){
			try {
				Cache.Refresh(InvalidType.Prefs);
			}
			catch(Exception ex) {
				if(isSilentUpdate) {
					ExitCode=100;//Database could not be accessed for cache refresh
					Application.Exit();
					return false;
				}
				MessageBox.Show(ex.Message);
				return false;//shuts program down.
			}
			if(!PrefL.CheckMySqlVersion(isSilentUpdate)){
				return false;
			}
			if(DataConnection.DBtype==DatabaseType.MySql) {
				try {
					MiscData.SetSqlMode();
				}
				catch {
					if(isSilentUpdate) {
						ExitCode=111;//Global SQL mode could not be set
						Application.Exit();
						return false;
					}
					MessageBox.Show("Unable to set global sql mode.  User probably does not have enough permission.");
					return false;
				}
				string updateComputerName=PrefC.GetStringSilent(PrefName.UpdateInProgressOnComputerName);
				if(updateComputerName != "" && Environment.MachineName != updateComputerName) {
					if(isSilentUpdate) {
						ExitCode=120;//Computer trying to access DB during update
						Application.Exit();
						return false;
					}
					DialogResult result=MessageBox.Show("An update is in progress on "+updateComputerName+".  Not allowed to start up until that update is complete.\r\n\r\nIf you are the person who started the update and you wish to override this message because an update is not in progress, click Retry.\r\n\r\nDo not click Retry unless you started the update.",
						"",MessageBoxButtons.RetryCancel);
					if(result==DialogResult.Retry) {
						Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");
						MsgBox.Show(this,"You will be allowed access when you restart.");
					}
					return false;
				}
			}
			//if RemotingRole.ClientWeb, version will have already been checked at login, so no danger here.
			//ClientWeb version can be older than this version, but that will be caught in a moment.
			if(isSilentUpdate) {
				if(!PrefL.ConvertDB(true,Application.ProductVersion)) {//refreshes Prefs if converted successfully.
					if(ExitCode==0) {//Unknown error occurred
						ExitCode=200;//Convert Database has failed during execution (Unknown Error)
					}
					Application.Exit();
					return false;
				}
			}
			else {
				if(!PrefL.ConvertDB()) {//refreshes Prefs if converted successfully.
					return false;
				}
			}
			if(!isSilentUpdate) {
				PrefL.MySqlVersion55Remind();
			}
			if(PrefC.AtoZfolderUsed) {
				string prefImagePath=ImageStore.GetPreferredAtoZpath();
				if(prefImagePath==null || !Directory.Exists(prefImagePath)) {//AtoZ folder not found
					if(isSilentUpdate) {
						ExitCode=300;//AtoZ folder not found (Warning)
						Application.Exit();
						return false;
					}
					Cache.Refresh(InvalidType.Security);
					FormPath FormP=new FormPath();
					FormP.IsStartingUp=true;
					FormP.ShowDialog();
					if(FormP.DialogResult!=DialogResult.OK) {
						MsgBox.Show(this,"Invalid A to Z path.  Closing program.");
						Application.Exit();
						return false;
					}
					Cache.Refresh(InvalidType.Prefs);//because listening thread not started yet.
				}
			}
			if(!PrefL.CheckProgramVersion(isSilentUpdate)){
				return false;
			}
			if(!FormRegistrationKey.ValidateKey(PrefC.GetString(PrefName.RegistrationKey))){
				if(isSilentUpdate) {
					ExitCode=311;//Registration Key could not be validated
					Application.Exit();
					return false;
				}
				FormRegistrationKey FormR=new FormRegistrationKey();
				FormR.ShowDialog();
				if(FormR.DialogResult!=DialogResult.OK){
					Application.Exit();
					return false;
				}
				Cache.Refresh(InvalidType.Prefs);
			}
			//This must be done at startup in case the user does not perform any action to save something to temp file.
			//This will cause slowdown, but only for the first week.
			if(DateTime.Today<PrefC.GetDate(PrefName.TempFolderDateFirstCleaned).AddDays(7)) {
				PrefL.GetTempFolderPath();//We don't care about the return value.  Just trying to trigger the one-time cleanup and create the temp/opendental directory.
			}
			Lans.RefreshCache();//automatically skips if current culture is en-US
			LanguageForeigns.Refresh(CultureInfo.CurrentCulture.Name,CultureInfo.CurrentCulture.TwoLetterISOLanguageName);//automatically skips if current culture is en-US
			//menuItemMergeDatabases.Visible=PrefC.GetBool(PrefName.RandomPrimaryKeys");
			return true;
		}
Example #4
0
		private void butChange_Click(object sender,EventArgs e) {
			FormRegistrationKey formR=new FormRegistrationKey();
			formR.ShowDialog();
			DataValid.SetInvalid(InvalidType.Prefs);
			string regkey=PrefC.GetString(PrefName.RegistrationKey);
			if(regkey.Length==16){
				textRegKey.Text=regkey.Substring(0,4)+"-"+regkey.Substring(4,4)+"-"+regkey.Substring(8,4)+"-"+regkey.Substring(12,4);
			}
			else{
				textRegKey.Text=regkey;
			}
		}