示例#1
0
        private void DeleteVirtualDirectory(string siteId, string name)
        {
            try
            {
                Log.WriteStart("Deleting virtual directory");
                Log.WriteInfo(string.Format("Deleting virtual directory \"{0}\" for the site \"{1}\"", name, siteId));
                if (WebUtils.VirtualDirectoryExists(siteId, name))
                {
                    WebUtils.DeleteVirtualDirectory(siteId, name);
                    Log.WriteEnd("Deleted  virtual directory");
                    InstallLog.AppendLine(string.Format("- Deleted \"{0}\" virtual directory ", name));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Virtual directory delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" virtual directory ", name));
                throw;
            }
        }
示例#2
0
        private void DeleteIIS7ApplicationPool(string name)
        {
            try
            {
                Log.WriteStart("Deleting application pool");
                Log.WriteInfo(string.Format("Deleting \"{0}\" application pool", name));
                if (WebUtils.IIS7ApplicationPoolExists(name))
                {
                    int count = WebUtils.GetIIS7ApplicationPoolSitesCount(name);
                    if (count > 0)
                    {
                        Log.WriteEnd("Application pool is not empty");
                    }
                    else
                    {
                        WebUtils.DeleteIIS7ApplicationPool(name);
                        Log.WriteEnd("Deleted  application pool");
                        InstallLog.AppendLine(string.Format("- Deleted \"{0}\" application pool ", name));
                    }
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Application pool delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" application pool ", name));
                throw;
            }
        }
示例#3
0
        private void DeleteIIS7WebSite(string siteId)
        {
            try
            {
                Log.WriteStart("Deleting web site");
                Log.WriteInfo(string.Format("Deleting \"{0}\" web site", siteId));
                if (WebUtils.IIS7SiteExists(siteId))
                {
                    WebUtils.DeleteIIS7Site(siteId);
                    Log.WriteEnd("Deleted web site");
                    InstallLog.AppendLine(string.Format("- Deleted \"{0}\" web site ", siteId));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Web site delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" web site ", siteId));

                throw;
            }
        }
示例#4
0
        private void DeleteDatabaseLogin(string connectionString, string loginName)
        {
            try
            {
                Log.WriteStart("Deleting SQL server login");
                Log.WriteInfo(string.Format("Deleting \"{0}\" SQL server login", loginName));
                if (SqlUtils.LoginExists(connectionString, loginName))
                {
                    SqlUtils.DeleteLogin(connectionString, loginName);
                    Log.WriteEnd("Deleted SQL server login");
                    InstallLog.AppendLine(string.Format("- Deleted \"{0}\" SQL server login ", loginName));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Database login delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" SQL server login ", loginName));
                throw;
            }
        }
示例#5
0
        private void DeleteUserAccount(string domain, string username)
        {
            try
            {
                Log.WriteStart("Deleting user account");
                Log.WriteInfo(string.Format("Deleting \"{0}\" user account", username));
                if (SecurityUtils.UserExists(domain, username))
                {
                    SecurityUtils.DeleteUser(domain, username);
                    Log.WriteEnd("Deleted user account");
                    InstallLog.AppendLine(string.Format("- Deleted \"{0}\" user account ", username));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("User account delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" user account ", username));
                throw;
            }
        }
示例#6
0
        private void DeleteRegistryKey(string subkey, bool deleteEmptyOnly)
        {
            try
            {
                Log.WriteStart("Deleting registry key");
                if (RegistryUtils.RegistryKeyExist(subkey))
                {
                    if (deleteEmptyOnly && RegistryUtils.GetSubKeyCount(subkey) != 0)
                    {
                        Log.WriteEnd(string.Format("Registry key \"{0}\" is not empty", subkey));
                        return;
                    }
                    Log.WriteInfo(string.Format("Deleting registry key \"{0}\"", subkey));
                    RegistryUtils.DeleteRegistryKey(subkey);
                    Log.WriteEnd("Deleted registry key");
                    InstallLog.AppendLine(string.Format("- Deleted registry key \"{0}\"", subkey));
                }
                else
                {
                    Log.WriteEnd(string.Format("Registry key \"{0}\" not found", subkey));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Registry key delete error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete registry key \"{0}\"", subkey));
                throw;
            }
        }
示例#7
0
        private void UpdateSystemConfiguration(string componentId)
        {
            try
            {
                Log.WriteStart("Updating system configuration");
                string componentName = AppConfig.GetComponentSettingStringValue(componentId, "ComponentName");
                Log.WriteInfo(string.Format("Deleting \"{0}\" component settings ", componentName));
                XmlUtils.RemoveXmlNode(AppConfig.GetComponentConfig(componentId));
                Log.WriteInfo("Saving system configuration");
                AppConfig.SaveConfiguration();
                Log.WriteEnd("Updated system configuration");
                InstallLog.AppendLine("- Updated system configuration");
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Config error", ex);
                InstallLog.AppendLine("- Failed to update system configuration");
                throw;
            }
        }
示例#8
0
        private void DeleteDirectory(string path)
        {
            try
            {
                Log.WriteStart("Deleting folder");
                Log.WriteInfo(string.Format("Deleting \"{0}\" folder", path));
                if (FileUtils.DirectoryExists(path))
                {
                    FileUtils.DeleteDirectory(path);
                    Log.WriteEnd("Deleted folder");
                }
                InstallLog.AppendLine(string.Format("- Deleted \"{0}\" folder", path));
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("I/O error", ex);
                InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" folder", path));
                //throw;
            }
        }
示例#9
0
        public static void OpenFirewallPort(string name, string port, Version iisVersion)
        {
            bool iis7 = (iisVersion.Major >= 7);

            if (iis7)
            {
                if (Utils.IsWindowsFirewallEnabled() && Utils.IsWindowsFirewallExceptionsAllowed())
                {
                    Log.WriteStart(String.Format("Opening port {0} in windows firewall", port));
                    Utils.OpenWindowsFirewallPortAdv(name, port);
                    Log.WriteEnd("Opened port in windows firewall");
                    InstallLog.AppendLine(String.Format("- Opened port {0} in Windows Firewall", port));
                }
            }
            else
            {
                if (Utils.IsWindowsFirewallEnabled() &&
                    Utils.IsWindowsFirewallExceptionsAllowed())
                {
                    //SetProgressText("Opening port in windows firewall...");

                    Log.WriteStart(String.Format("Opening port {0} in windows firewall", port));

                    Utils.OpenWindowsFirewallPort(name, port);

                    //update log
                    Log.WriteEnd("Opened port in windows firewall");
                    InstallLog.AppendLine(String.Format("- Opened port {0} in Windows Firewall", port));
                }
            }
        }
示例#10
0
        private void UnregisterWindowsService(string path, string serviceName)
        {
            try
            {
                Log.WriteStart(string.Format("Removing \"{0}\" Windows service", serviceName));
                Log.WriteStart(string.Format("Stopping \"{0}\" Windows service", serviceName));
                try
                {
                    Utils.StopService(serviceName);
                    Log.WriteEnd("Stopped Windows service");
                }
                catch (Exception ex)
                {
                    if (!Utils.IsThreadAbortException(ex))
                    {
                        Log.WriteError("Windows service stop error", ex);
                    }
                }

                try
                {
                    ManagedInstallerClass.InstallHelper(new[] { "/u", path });
                }
                catch (Exception)
                {
                    Log.WriteError(string.Format("Unable to remove \"{0}\" Windows service.", serviceName), null);
                    InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName));
                    throw;
                }

                Log.WriteEnd("Removed Windows service");
                InstallLog.AppendLine(string.Format("- Removed \"{0}\" Windows service", serviceName));
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Windows service error", ex);
                InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName));
                throw;
            }
        }
示例#11
0
        private void UnregisterWindowsService(string path, string serviceName)
        {
            try
            {
                Log.WriteStart(string.Format("Removing \"{0}\" Windows service", serviceName));
                Log.WriteStart(string.Format("Stopping \"{0}\" Windows service", serviceName));
                try
                {
                    Utils.StopService(serviceName);
                    Log.WriteEnd("Stopped Windows service");
                }
                catch (Exception ex)
                {
                    if (!Utils.IsThreadAbortException(ex))
                    {
                        Log.WriteError("Windows service stop error", ex);
                    }
                }

                int exitCode = Utils.RunProcess(path, "/u");
                if (exitCode == 0)
                {
                    Log.WriteEnd("Removed Windows service");
                    InstallLog.AppendLine(string.Format("- Removed \"{0}\" Windows service", serviceName));
                }
                else
                {
                    Log.WriteError(string.Format("Unable to remove \"{0}\" Windows service. Error code: {1}", serviceName, exitCode), null);
                    InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName));
                }
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Windows service error", ex);
                InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName));
                throw;
            }
        }
示例#12
0
        private void DeleteShortcuts(string fileName)
        {
            try
            {
                Log.WriteStart("Deleting menu shortcut");
                string programs = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
                string path     = Path.Combine(programs, "WebsitePanel Software");
                path = Path.Combine(path, fileName);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                Log.WriteEnd("Deleted menu shortcut");

                Log.WriteStart("Deleting desktop shortcut");
                string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                path = Path.Combine(desktop, fileName);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                Log.WriteEnd("Deleted desktop shortcut");
                InstallLog.AppendLine("- Deleted application shortcuts");
            }
            catch (Exception ex)
            {
                if (Utils.IsThreadAbortException(ex))
                {
                    return;
                }

                Log.WriteError("Delete shortcut error", ex);
                InstallLog.AppendLine("- Failed to delete application shortcuts");
                throw;
            }
        }