private void InitAspAddressBlock() { IAspInfo aspInfo = this.Configurator.GetAspInfo(); if (aspInfo != null) { comboBoxSchema.SelectedIndex = aspInfo.Scheme == "https" ? 1 : 0; textHostName.Text = aspInfo.Host; textBoxIisPort.Text = aspInfo.Port; } }
private void InitIISPoolBlock() { IAspInfo aspInfo = this.Configurator.GetAspInfo(); if (aspInfo != null) { comboBoxIisPool.Items.Add(SnapInResources.CreateCompanyForm_Create_New_Pool); // Enum Available pools int selectedIndex = 0; foreach (string poolName in this.Configurator.ListApplicationPools()) { int index = comboBoxIisPool.Items.Add(poolName); if (poolName == aspInfo.ApplicationPool) { selectedIndex = index; } } comboBoxIisPool.SelectedIndex = selectedIndex; } }
private void InitAspBlock() { IConfigurator configurator = GetConfigurator(); groupBoxAsp.Visible = configurator.CanCreateAspSite() || configurator.CanDeleteAspSite(); if (configurator.CanCreateAspSite()) { buttonInstallAsp.Visible = true; buttonUninstallAsp.Visible = false; } else if (configurator.CanDeleteAspSite()) { buttonInstallAsp.Visible = false; buttonUninstallAsp.Visible = true; } IAspInfo aspInfo = configurator.GetAspInfo(); if (aspInfo != null) { // Fill Asp Information int port = (string.IsNullOrEmpty(aspInfo.Port) ? -1 : int.Parse(aspInfo.Port, CultureInfo.InvariantCulture)); linkLabelAspUrl.Text = new UriBuilder(aspInfo.Scheme, aspInfo.Host, port).ToString(); buttonAspConfigure.Enabled = true; textBoxAspSiteId.Text = aspInfo.SiteId.ToString(); textBoxAspDatabase.Text = aspInfo.Database; } else { linkLabelAspUrl.Text = string.Empty; buttonAspConfigure.Enabled = false; textBoxAspSiteId.Text = string.Empty; textBoxAspDatabase.Text = string.Empty; } }
static void UpdateCommon2(IAspInfo asp) { LogFile.WriteLine(); LogFile.WriteLine("* Updating common components *"); string commonRoot = Settings.InstallDir; try { int maxUpdateVersion = FindMaxUpdateVersion(); Version version = new Version(IbnConst.FullVersion); int newCommonVersion = Math.Max(version.Build, maxUpdateVersion); // Update files UpdateFiles(Settings.CommonVersion, commonRoot, false); // Update configs UpdateConfigs(Settings.CommonVersion, null); // Update ASP database if (asp != null) { string aspPath = Path.Combine(commonRoot, "Asp"); string connectionString = GetWebApplicationConnectionString(aspPath); using (DataContext dataContext = new DataContext(connectionString)) using (DataContextSwitcher switcher = new DataContextSwitcher(dataContext)) using (TransactionScope transaction = dataContext.BeginTransaction()) { UpdateDatabase(ScriptType.SqlAsp, asp.Database, null); // Update common version in registry Settings.UpdateCommonVersion(newCommonVersion); transaction.Commit(); } } if (asp == null) { // Update common version in registry Settings.UpdateCommonVersion(newCommonVersion); } } catch (Exception ex) { LogFile.WriteLine("* Failed *"); LogFile.WriteLine(); LogFile.WriteLine(ex.ToString()); LogFile.WriteLine(); LogFile.WriteLine("Rollback started"); #region Undo changes // Recover configs RecoverConfigs(); // Recover files RecoverFiles(commonRoot); #endregion LogFile.WriteLine("Rollback finished"); throw; } finally { // Delete backup files DeleteBackupFiles(); } LogFile.WriteLine("* OK *"); }
static void UpdateCommon(IAspInfo asp) { try { // Stop services StopServices(); // Stop IIS StopIis(); AddAction(UpdateAction.Iis); UpdateCommon2(asp); // Start IIS try { StartIis(); } catch { } // Start services StartServices(); } catch (Exception ex) { LogFile.WriteLine("* Failed *"); LogFile.WriteLine(); LogFile.WriteLine(ex.ToString()); LogFile.WriteLine(); #region Undo changes // Start IIS try { if (_actions.Contains(UpdateAction.Iis)) StartIis(); } catch { } // Start services StartServices(); #endregion throw; } finally { LogFile.WriteLine(); } }
static void RegisterUpdate(IConfigurator configurator, IAspInfo asp) { LogFile.WriteFormatted("Copying update to {0} installation directory...", IbnConst.ProductName); IUpdateInfo[] updates = configurator.GetUpdateInfo(Settings.UpdateDir); int maxVersion = 0; foreach (IUpdateInfo update in updates) { if (update.Version > maxVersion) maxVersion = update.Version; } string updatesDir = Path.Combine(Settings.InstallDir, "Updates"); string updateDir = Path.Combine(updatesDir, maxVersion.ToString(CultureInfo.InvariantCulture)); if (Directory.Exists(updateDir)) { LogWriteFailed(); string message = string.Format(CultureInfo.InvariantCulture, "Update {0} already exists.", maxVersion); LogFile.WriteLine(message); if (asp != null) throw new UpdateException(message); } else { CopyDirectory(Settings.UpdateDir, updateDir); LogWriteOk(); } }
static void UpdateServer(IConfigurator configurator, IAspInfo asp) { LogFile.WriteLine("* Updating common components and companies *"); try { // Stop services StopServices(); // Stop IIS StopIis(); AddAction(UpdateAction.Iis); // Update common components UpdateCommon2(asp); // Update companies ICompanyInfo[] companies = configurator.ListCompanies(false); for (int i = 0; i < companies.Length; i++) UpdateCompany2(configurator, companies[i].Id, i + 1, companies.Length, false); // Start IIS try { StartIis(); } catch { } // Start services StartServices(); } catch (Exception ex) { LogFile.WriteLine("* Failed *"); LogFile.WriteLine(); LogFile.WriteLine(ex.ToString()); LogFile.WriteLine(); #region Undo changes // Start IIS try { if (_actions.Contains(UpdateAction.Iis)) StartIis(); } catch { } // Start services StartServices(); #endregion throw; } finally { LogFile.WriteLine(); } LogFile.WriteLine("* OK *"); }