Esempio n. 1
0
        internal static AspInfo Load(XmlDocument serverConfigDocument)
        {
            AspInfo settings = null;

            XmlNode asp = serverConfigDocument.SelectSingleNode("/configuration/asp");
            if (asp != null)
            {
                settings = new AspInfo();

                settings.Scheme = XmlHelper.GetAttributeValue(asp, "scheme");
                settings.Host = XmlHelper.GetAttributeValue(asp, "host");
                settings.Port = XmlHelper.GetAttributeValue(asp, "port");
                settings.Database = XmlHelper.GetAttributeValue(asp, "database");
                settings.SiteId = long.Parse(XmlHelper.GetAttributeValue(asp, "siteId"), CultureInfo.InvariantCulture);
                settings.ApplicationPool = XmlHelper.GetAttributeValue(asp, "applicationPool");
                settings.IsApplicationPoolCreated = bool.Parse(XmlHelper.GetAttributeValue(asp, "applicationPoolCreated"));
            }

            return settings;
        }
Esempio n. 2
0
        internal static AspInfo Load(XmlDocument serverConfigDocument)
        {
            AspInfo settings = null;

            XmlNode asp = serverConfigDocument.SelectSingleNode("/configuration/asp");

            if (asp != null)
            {
                settings = new AspInfo();

                settings.Scheme                   = XmlHelper.GetAttributeValue(asp, "scheme");
                settings.Host                     = XmlHelper.GetAttributeValue(asp, "host");
                settings.Port                     = XmlHelper.GetAttributeValue(asp, "port");
                settings.Database                 = XmlHelper.GetAttributeValue(asp, "database");
                settings.SiteId                   = long.Parse(XmlHelper.GetAttributeValue(asp, "siteId"), CultureInfo.InvariantCulture);
                settings.ApplicationPool          = XmlHelper.GetAttributeValue(asp, "applicationPool");
                settings.IsApplicationPoolCreated = bool.Parse(XmlHelper.GetAttributeValue(asp, "applicationPoolCreated"));
            }

            return(settings);
        }
Esempio n. 3
0
        private void DeleteAspWeb(AspInfo aspSettings, string context)
        {
            if (aspSettings != null)
            {
                IIisManager iisManager = IisManager.Create(_aspPath);

                // Delete web site
                try
                {
                    iisManager.DeleteSite(aspSettings.SiteId);
                }
                catch (Exception ex)
                {
                    Log.WriteException(context, ex);
                }

                if (iisManager.IsApplicationPoolSupported)
                {
                    // Delete application pool
                    try
                    {
                        if (aspSettings.IsApplicationPoolCreated)
                            iisManager.DeleteApplicationPool(aspSettings.ApplicationPool);
                    }
                    catch (Exception ex)
                    {
                        Log.WriteException(context, ex);
                    }
                }

                // Enable custom SQL reports
                try
                {
                    RegistrySettings.WriteString(ConstDisableCustomSqlReport, null);
                }
                catch (Exception ex)
                {
                    Log.WriteException(context, ex);
                }
            }
        }
Esempio n. 4
0
        private AspInfo CreateAspSiteForDatabase(XmlDocument serverConfigDocument, XmlDocument schedulerConfigDocument, string database, string host, string iisIPAddress, int iisPort, string iisApplicationPool)
        {
            AspInfo aspSettings = new AspInfo();
            aspSettings.Database = database;
            aspSettings.Scheme = "http";
            aspSettings.Host = host;
            aspSettings.Port = (iisPort != 80 ? iisPort.ToString(CultureInfo.InvariantCulture) : string.Empty);

            // Update web.config
            string connectionString = SqlServerSettings.BuildConnectionString(AuthenticationType.SqlServer, _sqlServer, database, _sqlPortalUser, _sqlPortalPassword);
            UpdateWebConfig(_aspPath, connectionString, null, null);

            IIisManager iisManager = IisManager.Create(_aspPath);
            string prospectiveSiteName = ConstDefaultAspName;

            try
            {
                if (iisManager.IsApplicationPoolSupported)
                {
                    string[] pools = iisManager.ListApplicationPools();

                    if (string.IsNullOrEmpty(iisApplicationPool))
                    {
                        // Create application pool
                        aspSettings.ApplicationPool = BuildUniqueName(prospectiveSiteName, pools);
                        iisManager.CreateApplicationPool(aspSettings.ApplicationPool, true);
                        aspSettings.IsApplicationPoolCreated = true;
                    }
                    else
                        aspSettings.ApplicationPool = iisApplicationPool;
                }

                // Create web site
                string[] sites = iisManager.ListSites();
                string siteName = BuildUniqueName(prospectiveSiteName, sites);
                aspSettings.SiteId = iisManager.CreateSite(siteName, _aspPath, iisIPAddress, iisPort, host, aspSettings.ApplicationPool, false, true);

                // Start web site
                try
                {
                    iisManager.StartSite(aspSettings.SiteId);
                }
                catch (Exception ex)
                {
                    Log.WriteException("CreateAspSiteForDatabase", ex);
                }

                // Update ibn.config
                aspSettings.Save(serverConfigDocument);

                // Add record to ScheduleService.exe.config
                aspSettings.AddWebServiceUri(schedulerConfigDocument);
            }
            catch
            {
                if (iisManager.IsApplicationPoolSupported)
                {
                    // Delete application pool
                    try
                    {
                        if (aspSettings.IsApplicationPoolCreated)
                            iisManager.DeleteApplicationPool(aspSettings.ApplicationPool);
                    }
                    catch
                    {
                    }
                }

                throw;
            }

            return aspSettings;
        }