/// <summary>
        /// Uninstalls the server.
        /// </summary>
        public static void UnInstallServer(string applicationAssemblyPath)
        {
            CASApplicationInstance application = new CASApplicationInstance();

            string[] args = new string[2];
            args[0] = "/silent";
            args[1] = "/uninstall";
            application.ProcessCommandLine(true, applicationAssemblyPath, args);
        }
Esempio n. 2
0
 /// <summary>
 /// When overridden in a derived class, removes an installation.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after the installation was complete.</param>
 /// <exception cref="T:System.ArgumentException">
 /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted.
 /// </exception>
 /// <exception cref="T:System.Configuration.Install.InstallException">
 /// An exception occurred while uninstalling. This exception is ignored and the uninstall continues. However, the application might not be fully uninstalled after the uninstallation completes.
 /// </exception>
 public override void Uninstall(IDictionary savedState)
 {
     base.Uninstall(savedState);
     CASApplicationInstance.UnInstallServer(Context.Parameters["AssemblyPath"]);
 }
Esempio n. 3
0
        /// <summary>
        /// When overridden in a derived class, performs the installation.
        /// </summary>
        /// <param name="stateSaver">An <see cref="T:System.Collections.IDictionary"/> used to save information needed to perform a commit, rollback, or uninstall operation.</param>
        /// <exception cref="T:System.ArgumentException">
        /// The <paramref name="stateSaver"/> parameter is null.
        /// </exception>
        /// <exception cref="T:System.Exception">
        /// An exception occurred in the <see cref="E:System.Configuration.Install.Installer.BeforeInstall"/> event handler of one of the installers in the collection.
        /// -or-
        /// An exception occurred in the <see cref="E:System.Configuration.Install.Installer.AfterInstall"/> event handler of one of the installers in the collection.
        /// </exception>
        public override void Commit(IDictionary stateSaver)
        {
            base.Commit(stateSaver);

            CASApplicationInstance.InstallServer(Context.Parameters["AssemblyPath"]);
        }
Esempio n. 4
0
        static void Main()
        {
            string m_cmmdLine = Environment.CommandLine;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (m_cmmdLine.ToLower().Contains(str_debug_install_argument))
            {
                CASApplicationInstance.InstallServer(Assembly.GetExecutingAssembly().Location);
            }
            if (m_cmmdLine.ToLower().Contains(str_debug_uninstall_argument))
            {
                CASApplicationInstance.UnInstallServer(Assembly.GetExecutingAssembly().Location);
            }
            CASApplicationInstance  application = new CASApplicationInstance();
            ConfigurationEditorMain config      = new ConfigurationEditorMain();

            try
            {
                if (!Environment.UserInteractive)
                {
                    Directory.SetCurrentDirectory(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName);
                    if (application.ProcessCommandLine())
                    {
                        return;
                    }
                    application.StartAsService(new UAServer());
                    return;
                }
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error starting service.");
                return;
            }
#if DEBUG
            MessageBox.Show("Attach debug point");
#endif
            if (m_cmmdLine.ToLower().Contains(str_installic_argument))
            {
                try
                {
                    LibInstaller.InstallLicense(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("License installation has failed, reason: " + ex.Message);
                }
            }
            UAServer server = new UAServer();
            try
            {
                FileInfo configFI = RelativeFilePathsCalculator.GetAbsolutePathToFileInApplicationDataFolder(Settings.Default.ConfigurationFilePath);
                config.ReadConfiguration(configFI);
                if (config.Configuration == null)
                {
                    throw new ArgumentNullException("Cannot read configuration");
                }
                BaseDirectoryHelper.Instance.SetBaseDirectoryProvider(new BaseDirectoryProvider(configFI.DirectoryName));
                ApplicationCertificate.CheckApplicationInstanceCertificate(config.Configuration, 1024, (x, y) => true, true); //TODO add logging function or user interface.
                ApplicationCertificate.OverrideUaTcpImplementation(config.Configuration);
                server.Start(config.Configuration);
                Application.Run(new ServerForm(server, config.Configuration, application));
            }
            catch (Exception e)
            {
                HandleException("UA Server", e);
            }
            finally
            {
                server.Stop();
            }
        }