示例#1
0
 public XMLAccess(bool p_IgnoreTest)
 {
     this.disposedValue = false;
     this.TL            = new TraceLogger("", "XMLAccess");
     this.TL.Enabled    = RegistryCommonCode.GetBool("Trace XMLAccess", false);
     VersionCode.RunningVersions(this.TL);
     this.sw           = new Stopwatch();
     this.swSupport    = new Stopwatch();
     this.FileStore    = (IFileStoreProvider) new AllUsersFileSystemProvider();
     this.ProfileMutex = new Mutex(false, "ASCOMProfileMutex");
     if (p_IgnoreTest)
     {
         return;
     }
     try
     {
         if (!this.FileStore.get_Exists("\\Profile.xml"))
         {
             throw new ProfileNotFoundException("Utilities Error Base key does not exist");
         }
         this.GetProfile("\\", "PlatformVersion");
     }
     catch (Exception ex)
     {
         //ProjectData.SetProjectError(ex);
         this.TL.LogMessageCrLf("XMLAccess.New Unexpected exception:", ex.ToString());
         throw;
     }
 }
示例#2
0
        public Timer()
        {
            this.Tick         += new Timer.TickEventHandler(this.Timer_Tick);
            this.disposedValue = false;
            this.TL            = new TraceLogger("", "Timer");
            this.TraceEnabled  = RegistryCommonCode.GetBool("Trace Timer", false);
            this.TL.Enabled    = this.TraceEnabled;
            this.TL.LogMessage("New", "Started on thread: " + Thread.CurrentThread.ManagedThreadId.ToString());
            this.FormTimer = new System.Windows.Forms.Timer();
            this.TL.LogMessage("New", "Created FormTimer");
            this.FormTimer.Enabled  = false;
            this.FormTimer.Interval = 1000;
            this.TL.LogMessage("New", "Set FormTimer interval");
            this.TimersTimer = new System.Timers.Timer();
            this.TL.LogMessage("New", "Created TimersTimer");
            this.TimersTimer.Enabled  = false;
            this.TimersTimer.Interval = 1000.0;
            this.TL.LogMessage("New", "Set TimersTimer interval");
            try
            {
                this.TL.LogMessage("New", "Process FileName \"" + Process.GetCurrentProcess().MainModule.FileName + "\"");
                PEReader peReader = new PEReader(Process.GetCurrentProcess().MainModule.FileName, this.TL);
                this.TL.LogMessage("New", "SubSystem " + peReader.SubSystem().ToString());
                switch (peReader.SubSystem())
                {
                case PEReader.SubSystemType.WINDOWS_GUI:
                    this.IsForm = true;
                    break;

                case PEReader.SubSystemType.WINDOWS_CUI:
                    this.IsForm = false;
                    break;

                default:
                    this.IsForm = false;
                    break;
                }
                this.IsForm = !this.ForceTimer(this.IsForm);
                this.TL.LogMessage("New", "IsForm: " + Conversions.ToString(this.IsForm));
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                Exception exception = ex;
                this.TL.LogMessageCrLf("New Exception", exception.ToString());
                EventLogCode.LogEvent("Timer:New", "Exception", EventLogEntryType.Error, GlobalConstants.EventLogErrors.TimerSetupException, exception.ToString());
                //ProjectData.ClearProjectError();
            }
        }
示例#3
0
 void IAccess.MigrateProfile(string CurrentPlatformVersion)
 {
     try
     {
         this.GetProfileMutex("MigrateProfile", "");
         this.sw.Reset();
         this.sw.Start();
         this.TL.LogMessage("MigrateProfile", "");
         bool enabled = this.TL.Enabled;
         this.TL.Enabled = true;
         VersionCode.RunningVersions(this.TL);
         this.TL.LogMessage("MigrateProfile", "Migrating keys");
         if (!this.FileStore.get_Exists("\\Profile.xml"))
         {
             this.FileStore.CreateDirectory("\\", this.TL);
             this.CreateKey("\\");
             this.TL.LogMessage("MigrateProfile", "Successfully created root directory and root key");
         }
         else
         {
             this.TL.LogMessage("MigrateProfile", "Root directory already exists");
         }
         this.TL.LogMessage("MigrateProfile", "Setting security ACLs on ASCOM root directory ");
         this.FileStore.SetSecurityACLs(this.TL);
         this.TL.LogMessage("MigrateProfile", "Copying Profile from Registry");
         RegistryKey p_FromKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\ASCOM");
         if (p_FromKey == null)
         {
             throw new ProfileNotFoundException("Cannot find ASCOM Profile in HKLM\\SOFTWARE\\ASCOM Is Platform 5 installed?");
         }
         this.TL.LogMessage("MigrateProfile", "FromKey Opened OK: " + p_FromKey.Name + ", SubKeyCount: " + p_FromKey.SubKeyCount.ToString() + ", ValueCount: " + p_FromKey.ValueCount.ToString());
         this.MigrateKey(p_FromKey, "");
         this.TL.LogMessage("MigrateProfile", "Successfully migrated keys");
         p_FromKey.Close();
         this.TL.Enabled = RegistryCommonCode.GetBool("Trace XMLAccess", false);
         this.sw.Stop();
         this.TL.LogMessage("  ElapsedTime", "  " + Conversions.ToString(this.sw.ElapsedMilliseconds) + " milliseconds");
         this.TL.Enabled = enabled;
     }
     catch (Exception ex)
     {
         //ProjectData.SetProjectError(ex);
         this.TL.LogMessageCrLf("MigrateProfile", "Exception: " + ex.ToString());
         throw;
     }
 }