Esempio n. 1
0
        static void Main()
        {
#if !DEBUG // Exclude the unhandled exception handlers from the Debug version so that the application can be debugged in Visual Studio
            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

            // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ServerForm serverForm = new ServerForm();
            Application.Run(serverForm);

            if (serverForm.RestartApplication)
            {
                Application.Restart(); // Restart the application if the network permissions have been changed
            }
#if DEBUG                              // When debugging, include a log to show the time of close down
            TraceLogger TL = new TraceLogger("ASCOMRemoteEnded")
            {
                Enabled = true
            };
            TL.LogMessage("ASCOMRemoteEnded", "Application has exited");
            TL.Enabled = false;
            TL.Dispose();
            TL = null;
#endif
        }
Esempio n. 2
0
 public void Dispose()
 {
     // Clean up the tracelogger and util objects
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            try
            {
                TL         = new TraceLogger("", "SetFireWallRules");
                TL.Enabled = true;

                Version version = Assembly.GetEntryAssembly().GetName().Version;
                TL.LogMessage("SetFireWallRules", string.Format("Version {0}, Run on {1}", version.ToString(), DateTime.Now.ToString("dddd d MMMM yyyy HH:mm:ss")));
                TL.BlankLine();

                // Add the event handler for handling non-UI thread exceptions to the event.

                CommandLine.Parser.Default.ParseArguments <Options>(args)
                .WithParsed <Options>(opts => ProcessOptions(opts))
                .WithNotParsed <Options>((errs) => HandleParseError(errs));

                TL.Enabled = false;
                TL         = null;
            }
            catch (Exception ex)
            {
                TraceLogger TL = new TraceLogger("SetFireWallRulesMainException")
                {
                    Enabled = true
                };
                TL.LogMessageCrLf("Main", "Unhandled exception: " + ex.ToString());
                TL.Enabled = false;
                TL.Dispose();
                TL = null;
            }
        }
Esempio n. 4
0
 public void Dispose()
 {
     traceLogger.Enabled = false;
     traceLogger.Dispose();
     traceLogger = null;
     serialConnection.Dispose();
 }
Esempio n. 5
0
        /// <summary>
        /// Main program entry point
        /// </summary>
        /// <param name="args">Supplied parameters (not used in this program)</param>
        /// <returns>0 for success, 1 for error</returns>
        static int Main(string[] args)
        {
            try
            {
                Dictionary <string, string> vsTemplateDirectoryList; // Dictionary to hold the list of install directories holding templates
                string TemplateSourceDirectory = "";
                vsTemplateDirectoryList = new Dictionary <string, string>();

                TL         = new TraceLogger("", "InstallTemplates"); // Create a tracelogger so we can log what happens
                TL.Enabled = true;
                LogMessage("Main", "Install date: " + DateTime.Now.ToLongDateString());

                try
                {
                    LogMessage("Main", "Installing new templates...");

                    if (Environment.Is64BitOperatingSystem)
                    {
                        LogMessage("Main", "OS is 64bit");
                        TemplateSourceDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\ASCOM\Platform 6 Developer Components\Templates";
                    }
                    else
                    {
                        LogMessage("Main", "OS is 32bit");
                        TemplateSourceDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\ASCOM\Platform 6 Developer Components\Templates";
                    }

                    LogMessage("Main", "Template Source Directory: " + TemplateSourceDirectory);

                    // Search registry for template directories
                    vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInRegistry(Registry.CurrentUser, @"Software\Microsoft\VisualStudio"), vsTemplateDirectoryList);
                    vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInRegistry(Registry.CurrentUser, @"Software\Microsoft\WDExpress"), vsTemplateDirectoryList);

                    // Search My Documents file system for template directories
                    vsTemplateDirectoryList = AddTemplateDirectories(FindTemplateDirectoriesInFileSystem(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio*"), vsTemplateDirectoryList);

                    LogMessage("Main", " ");
                    foreach (KeyValuePair <string, string> templateDir in vsTemplateDirectoryList) // Install new templates in every template directory on this machine
                    {
                        LogMessage("Main", "Installing templates in directory: " + templateDir.Key.ToString());
                        InstallTemplates(templateDir.Key.ToString(), TemplateSourceDirectory);
                    }
                }
                catch (Exception ex)
                {
                    LogError("Main", ex.ToString());
                    ReturnCode = 1;
                }

                TL.Enabled = false; // Clean up tracelogger
                TL.Dispose();
                TL = null;
            }
            catch (Exception ex1)
            {
                Console.WriteLine("Exception creating TraceLogger: " + ex1.ToString());
                ReturnCode = 99;
            }
            return(ReturnCode);
        }
Esempio n. 6
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposedValue)
     {
         if (disposing)
         {
             // Free other state (managed objects).
             if ((TL != null))
             {
                 TL.Enabled = false;
                 TL.Dispose();
                 TL = null;
             }
         }
         // Free your own state (unmanaged objects) and set large fields to null.
         try
         {
             FreeLibrary(VideoDllHandle);
         }
         catch
         {
         }
     }
     this.disposedValue = true;
 }
Esempio n. 7
0
        /// <summary>
        /// Event handler for Profile button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetProfile_Click(System.Object sender, System.EventArgs e)
        {
            TL         = new TraceLogger("", TRACE_LOGGER_NAME);
            TL.Enabled = true;
            try
            {
                txtStatus.Clear();               // Clear the status screen

                Profile profile = new Profile(); // Create a Profile object
                profile.DeviceType = CurrentDeviceType;

                ASCOMProfile deviceProfile = profile.GetProfile(CurrentDevice); // Get the profile of the current device
                SortedList <string, SortedList <string, string> > results = deviceProfile.ProfileValues;

                // List each value of the root and all subkeys
                foreach (KeyValuePair <string, SortedList <string, string> > result in results)
                {
                    foreach (KeyValuePair <string, string> value in result.Value)
                    {
                        LogMsg(result.Key.ToString(), (value.Key.ToString() == "" ? "<Default>" : value.Key).PadRight(25) + " " + (value.Value == "" ? "<Empty>" : value.Value));
                    }
                }

                profile.Dispose();
            }
            catch (Exception ex)
            {
                LogMsg("Error", ex.ToString());
            }

            TL.Enabled = false;
            TL.Dispose();
        }
Esempio n. 8
0
        /// <summary>
        /// Standart dispose method
        /// </summary>
        public void Dispose()
        {
            tl.Dispose();
            tl = null;

            DeviceSemaphore.Dispose();
            DeviceSemaphore = null;
        }
Esempio n. 9
0
        /// <summary>
        /// Standart dispose method
        /// </summary>
        public void Dispose()
        {
            tl.Dispose();
            tl = null;

            VedrusSemaphore.Dispose();
            VedrusSemaphore = null;
        }
Esempio n. 10
0
 public void Dispose()
 {
     Stop();
     // Clean up the tracelogger and util objects
     traceLogger.Enabled = false;
     traceLogger.Dispose();
     traceLogger = null;
 }
Esempio n. 11
0
 public void Dispose()
 {
     // Clean up the trace logger and util objects
     TL.Enabled = false;
     TL.Dispose();
     TL = null;
     utilities.Dispose();
     utilities = null;
 }
Esempio n. 12
0
 protected virtual void Dispose(bool dispozing)
 {
     if (dispozing)
     {
         // Clean up the tracelogger and util objects
         tl.Enabled = false;
         tl.Dispose();
         tl = null;
     }
 }
Esempio n. 13
0
 public void Dispose()
 {
     // Clean up the tracelogger, settings form and util objects
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
     utilities.Dispose();
     utilities = null;
     settingsForm.Dispose();
 }
Esempio n. 14
0
        /// <summary>
        /// Exit button handler - just closes the application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnExit_Click(object sender, EventArgs e)
        {
            TL.LogMessage("Exit", "Closing the application");

            TL.Enabled = false;
            TL.Dispose();
            TL = null;

            Application.Exit();
        }
Esempio n. 15
0
 public void Dispose()
 {
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
     utilities.Dispose();
     utilities = null;
     astroUtilities.Dispose();
     astroUtilities = null;
 }
Esempio n. 16
0
 public void Dispose()
 {
     // Clean up the tracelogger and util objects
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
     utilities.Dispose();
     utilities = null;
     //astroUtilities.Dispose();
     //astroUtilities = null;
 }
Esempio n. 17
0
        private static IDisposable ActivateLogger()
        {
            var logger = new TraceLogger();

            Logger = logger;
            return(new ActionDisposable(() =>
            {
                logger.Dispose();
                Logger = NullLogger.Instance;
            }));
        }
Esempio n. 18
0
 protected override void OnDispose(bool disposing)
 {
     if (disposing)
     {
         if (_logger != null)
         {
             _logger.Dispose();
             _logger = null;
         }
     }
 }
Esempio n. 19
0
 public void Dispose()
 {
     // Clean up the tracelogger and util objects
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
     utilities.Dispose();
     utilities = null;
     astroUtilities.Dispose();
     astroUtilities = null;
     fMounter.Disconnect();
 }
Esempio n. 20
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   exception = (Exception)e.ExceptionObject;
            TraceLogger TL        = new TraceLogger("SetNetworkPemissionsException")
            {
                Enabled = true
            };

            TL.LogMessageCrLf("Main", "Unhandled exception: " + exception.ToString());
            TL.Enabled = false;
            TL.Dispose();
            Environment.Exit(0);
        }
Esempio n. 21
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         try { TL.LogMessage("Dispose", "Dispose called: " + disposing.ToString()); } catch { }
         //try { Handbox.Close(); } catch { }
         //try { Handbox.Dispose(); } catch { }
         try { _moveTimer.Stop(); } catch { }
         try { _moveTimer.Close(); } catch { }
         try { _moveTimer.Dispose(); } catch { }
         try { TL.Enabled = false; } catch { }
         try { TL.Dispose(); } catch { }
     }
 }
Esempio n. 22
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   exception = (Exception)e.ExceptionObject;
            TraceLogger TL        = new TraceLogger("RemoteAccessServerException")
            {
                Enabled = true
            };

            TL.LogMessageCrLf("Main", "Unhandled exception: " + exception.ToString());
            Process.Start(TL.LogFileName);
            TL.Enabled = false;
            TL.Dispose();
            Environment.Exit(0);
        }
Esempio n. 23
0
 public void Dispose()
 {
     // Clean up the trace logger and util objects
     Switches.Save();
     if (_serial != null)
     {
         _serial.Connected = false;
     }
     tl.Enabled = false;
     tl.Dispose();
     tl = null;
     utilities.Dispose();
     utilities = null;
     astroUtilities.Dispose();
     astroUtilities = null;
 }
Esempio n. 24
0
        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            TraceLogger TL = new TraceLogger("RemoteAccessServerException")
            {
                Enabled = true
            };

            TL.LogMessageCrLf("Main", "Thread exception: " + e.Exception.ToString());
            Process.Start(TL.LogFileName);

            TL.Enabled = false;
            TL.Dispose();

            //MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception, see RemoteAccessServerException log for details.");
            Environment.Exit(0);
        }
Esempio n. 25
0
        /// <summary>
        /// Event handler for Properties button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProperties_Click(System.Object sender, System.EventArgs e)
        {
            txtStatus.Clear();
            TL         = new TraceLogger("", TRACE_LOGGER_NAME);
            TL.Enabled = true;
            dynamic driver = null;

            try
            {
                LogMsg("Create", "Creating device");

                Type type = Type.GetTypeFromProgID(CurrentDevice);
                driver = Activator.CreateInstance(type);

                if (chkConnect.Checked)
                {
                    LogMsg("Connected", "Setting Connected = True");
                    driver.Connected = true;
                    LogMsg("Setup", "Opening setup dialogue");
                    driver.SetupDialog();
                    LogMsg("Connected", "Setting Connected = False");
                    driver.Connected = false;
                }
                else
                {
                    LogMsg("Connected", "Not setting Connected = True");
                    LogMsg("Setup", "Opening setup dialogue");
                    driver.SetupDialog();
                }
            }
            catch (Exception ex)
            {
                LogMsg("SetupError", ex.Message);
            }
            finally
            {
                LogMsg("Dispose", "Disposing of device");
                try { driver.Dispose(); }
                catch { }
                try { Marshal.ReleaseComObject(driver); }
                catch { }
                LogMsg("Dispose", "Completed disposal of device");
            }

            TL.Enabled = false;
            TL.Dispose();
        }
Esempio n. 26
0
        public void Dispose()
        {
            // Clean up the tracelogger and util objects
            tl.Enabled = false;
            tl.Dispose();
            tl = null;
            utilities.Dispose();
            utilities = null;
            serialConnection.Dispose();
            serialConnection = null;

            while (queryThreadTask != null && queryThreadTask.Status == TaskStatus.Canceled)
            {
                queryThreadTask.Dispose();
                queryThreadCts.Dispose();
            }
        }
Esempio n. 27
0
        protected override void Dispose(bool Disposing)
        {
            if (Disposing)
            {
                if (Form != null)
                {
                    Form.Dispose();
                    Form = null;
                }

                if (ASCOMTrace != null)
                {
                    ASCOMTrace.Dispose();
                    ASCOMTrace = null;
                }
            }
            base.Dispose(Disposing);
        }
Esempio n. 28
0
 public void Dispose()
 {
     if (MyDriverType == 0)
     {
         MySSFocuser.Dispose();
     }
     else
     {
         // Clean up the tracelogger and util objects
         tl.Enabled = false;
         tl.Dispose();
         tl = null;
         utilities.Dispose();
         utilities = null;
         astroUtilities.Dispose();
         astroUtilities = null;
     }
 }
Esempio n. 29
0
 /// <summary>
 /// Disposes of managed and unmanged resources
 /// </summary>
 /// <param name="disposing">True to dispose of managed resources, false to dispose of unmanged resources</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposedValue)
     {
         if (disposing)
         {
             if (memberFactory != null)
             {
                 memberFactory.Dispose();
                 memberFactory = null;
             }
             if (TL != null)
             {
                 TL.Dispose();
             }
         }
     }
     this.disposedValue = true;
 }
Esempio n. 30
0
        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

            // Create a trace logger and log the exception
            TraceLogger TL = new TraceLogger("DynamicClientThreadException")
            {
                Enabled = true
            };

            TL.LogMessage("Main", string.Format("ASCOM Dynamic Client Manager - Thread exception. Version: {0}", assemblyVersion.ToString()));
            TL.LogMessageCrLf("Main", e.Exception.ToString());

            // Display the exception in the default .txt editor and exit
            Process.Start(TL.LogFileName);

            TL.Enabled = false;
            TL.Dispose();

            Environment.Exit(0);
        }