Beispiel #1
0
        public DeployWebAppDeploymentTask(
            IProjectInfoRepository projectInfoRepository,
            IEnvironmentInfoRepository environmentInfoRepository,
            IMsDeploy msDeploy,
            IArtifactsRepository artifactsRepository,
            IIisManager iisManager,
            IFileAdapter fileAdapter,
            IZipFileAdapter zipFileAdapter,
            IApplicationConfiguration applicationConfiguration,
            IDirectoryAdapter directoryAdapter)
            : base(projectInfoRepository, environmentInfoRepository)
        {
            Guard.NotNull(msDeploy, "msDeploy");
            Guard.NotNull(artifactsRepository, "artifactsRepository");
            Guard.NotNull(iisManager, "iisManager");
            Guard.NotNull(fileAdapter, "fileAdapter");
            Guard.NotNull(zipFileAdapter, "zipFileAdapter");
            Guard.NotNull(directoryAdapter, "directoryAdapter");

            _msDeploy                 = msDeploy;
            _artifactsRepository      = artifactsRepository;
            _iisManager               = iisManager;
            _fileAdapter              = fileAdapter;
            _zipFileAdapter           = zipFileAdapter;
            _applicationConfiguration = applicationConfiguration;
            _directoryAdapter         = directoryAdapter;
        }
Beispiel #2
0
        static void Install()
        {
            LogFile.WriteMessage("*** Installing " + IbnConst.ProductName + " ***");
            try
            {
                IIisManager iisManager = IisManager.Create(Settings.InstallDirWeb);

                InstallMmc30();
                InstallServices();
                RegisterIMServer(true, Settings.InstallDirWeb, iisManager.Is64Bit());
                StartServices();
                UpdateRegistry();
                RegisterAspNet(iisManager);
                //throw new Exception();

                LogFile.WriteMessage("*** OK ***");
            }
            catch
            {
                LogFile.WriteMessage("*** Failed ***");
                if (_actions.Count > 0)
                {
                    LogFile.WriteMessage("");
                    LogFile.WriteMessage("Rollback started");
                    try
                    {
                        RollBack();
                    }
                    catch {}
                    LogFile.WriteMessage("Rollback finished");
                }
                throw;
            }
        }
        public SetAppPoolDeploymentStep(IIisManager iisManager, string machineName, string iisSiteName, string webAppName, IisAppPoolInfo appPoolInfo)
        {
            if (iisManager == null)
              {
            throw new ArgumentNullException("iisManager");
              }

              if (string.IsNullOrEmpty(machineName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "machineName");
              }

              if (string.IsNullOrEmpty(iisSiteName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "iisSiteName");
              }

              if (string.IsNullOrEmpty(webAppName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "webAppName");
              }

              if (appPoolInfo == null)
              {
            throw new ArgumentNullException("appPoolInfo");
              }

              _iisManager = iisManager;
              _machineName = machineName;
              _iisSiteName = iisSiteName;
              _webAppName = webAppName;
              _appPoolInfo = appPoolInfo;
        }
        public DeployWebAppDeploymentTask(
            IProjectInfoRepository projectInfoRepository,
            IEnvironmentInfoRepository environmentInfoRepository,
            IMsDeploy msDeploy,
            IArtifactsRepository artifactsRepository,
            IIisManager iisManager,
            IFileAdapter fileAdapter,
            IZipFileAdapter zipFileAdapter,
            IApplicationConfiguration applicationConfiguration,
            IDirectoryAdapter directoryAdapter)
            : base(projectInfoRepository, environmentInfoRepository)
        {
            Guard.NotNull(msDeploy, "msDeploy");
              Guard.NotNull(artifactsRepository, "artifactsRepository");
              Guard.NotNull(iisManager, "iisManager");
              Guard.NotNull(fileAdapter, "fileAdapter");
              Guard.NotNull(zipFileAdapter, "zipFileAdapter");
              Guard.NotNull(directoryAdapter, "directoryAdapter");

              _msDeploy = msDeploy;
              _artifactsRepository = artifactsRepository;
              _iisManager = iisManager;
              _fileAdapter = fileAdapter;
              _zipFileAdapter = zipFileAdapter;
              _applicationConfiguration = applicationConfiguration;
              _directoryAdapter = directoryAdapter;
        }
Beispiel #5
0
 public AcIisService(IOptionsSnapshot <AcumaticaSettings> acEnvironment, IIisManager iisManager
                     , IFileWrapper fileWrapper)
 {
     _environment = acEnvironment.Value;
     _iisManager  = iisManager;
     _fileWrapper = fileWrapper;
 }
        public CreateAppPoolDeploymentStep(IIisManager iisManager, string machineName, IisAppPoolInfo appPoolInfo)
        {
            Guard.NotNull(iisManager, "iisManager");
              Guard.NotNullNorEmpty(machineName, "machineName");
              Guard.NotNull(appPoolInfo, "appPoolInfo");

              _iisManager = iisManager;
              _machineName = machineName;
              _appPoolInfo = appPoolInfo;
        }
Beispiel #7
0
        public CreateAppPoolDeploymentStep(IIisManager iisManager, string machineName, IisAppPoolInfo appPoolInfo)
        {
            Guard.NotNull(iisManager, "iisManager");
            Guard.NotNullNorEmpty(machineName, "machineName");
            Guard.NotNull(appPoolInfo, "appPoolInfo");

            _iisManager  = iisManager;
            _machineName = machineName;
            _appPoolInfo = appPoolInfo;
        }
Beispiel #8
0
 static void RegisterAspNet(IIisManager iisManager)
 {
     if (iisManager.IisVersion < 7)
     {
         if (Settings.RegisterAspNet)
         {
             StartProcess(GetAspNetRegIis(iisManager.Is64Bit()), "-ir");
             //StartProcess(regiis, string.Format("-s w3svc/{0}/", Settings.SiteId));
         }
         //StartProcess(regiis, "-c");
     }
 }
        public SetAppPoolDeploymentStep(IIisManager iisManager, string machineName, string webSiteName, IisAppPoolInfo appPoolInfo, string webAppName = null)
        {
            Guard.NotNull(iisManager, "iisManager");
              Guard.NotNullNorEmpty(machineName, "machineName");
              Guard.NotNullNorEmpty(webSiteName, "webSiteName");
              Guard.NotNull(appPoolInfo, "appPoolInfo");

              _iisManager = iisManager;
              _machineName = machineName;
              _webSiteName = webSiteName;
              _appPoolInfo = appPoolInfo;
              _webAppName = webAppName;
        }
Beispiel #10
0
        public SetAppPoolDeploymentStep(IIisManager iisManager, string machineName, string webSiteName, IisAppPoolInfo appPoolInfo, string webAppName = null)
        {
            Guard.NotNull(iisManager, "iisManager");
            Guard.NotNullNorEmpty(machineName, "machineName");
            Guard.NotNullNorEmpty(webSiteName, "webSiteName");
            Guard.NotNull(appPoolInfo, "appPoolInfo");

            _iisManager  = iisManager;
            _machineName = machineName;
            _webSiteName = webSiteName;
            _appPoolInfo = appPoolInfo;
            _webAppName  = webAppName;
        }
        public DeployWebAppDeploymentTask(
      IMsDeploy msDeploy,
      IEnvironmentInfoRepository environmentInfoRepository,
      IArtifactsRepository artifactsRepository,
      IIisManager iisManager,
      WebAppProjectInfo projectInfo,
      string projectConfigurationName,
      string projectConfigurationBuildId,
      string targetEnvironmentName)
            : base(environmentInfoRepository, targetEnvironmentName)
        {
            if (msDeploy == null)
              {
            throw new ArgumentNullException("msDeploy");
              }

              if (artifactsRepository == null)
              {
            throw new ArgumentNullException("artifactsRepository");
              }

              if (iisManager == null)
              {
            throw new ArgumentNullException("iisManager");
              }

              if (projectInfo == null)
              {
            throw new ArgumentNullException("projectInfo");
              }

              if (string.IsNullOrEmpty(projectConfigurationName))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "projectConfigurationName");
              }

              if (string.IsNullOrEmpty(projectConfigurationBuildId))
              {
            throw new ArgumentException("Argument can't be null nor empty.", "projectConfigurationBuildId");
              }

              _msDeploy = msDeploy;
              _artifactsRepository = artifactsRepository;
              _iisManager = iisManager;
              _projectInfo = projectInfo;
              _projectConfigurationName = projectConfigurationName;
              _projectConfigurationBuildId = projectConfigurationBuildId;
        }
Beispiel #12
0
 static void StopWebSite(IIisManager iisManager, long siteId)
 {
     LogFile.WriteFormatted("Stopping web site '{0}", siteId);
     iisManager.StopSite(siteId);
     LogWriteOk();
 }
Beispiel #13
0
        private static string ChangeApplicationPool(IIisManager iisManager, long siteId, string oldPool, bool oldPoolCreated, string prospectivePoolName, string defaultPoolName)
        {
            string newPool = null;

            if (iisManager.IsApplicationPoolSupported)
            {
                bool newPoolCreated = false;
                bool poolChanged = false;

                try
                {
                    // Create new pool
                    if (string.IsNullOrEmpty(prospectivePoolName))
                    {
                        string[] pools = iisManager.ListApplicationPools();
                        newPool = BuildUniqueName(defaultPoolName, pools);
                        iisManager.CreateApplicationPool(newPool, true);
                        newPoolCreated = true;
                    }
                    else
                        newPool = prospectivePoolName;

                    // Change pool
                    iisManager.ChangeApplicationPool(siteId, newPool);
                    poolChanged = true;

                    // Delete old pool
                    if (oldPoolCreated)
                    {
                        try
                        {
                            iisManager.DeleteApplicationPool(oldPool);
                        }
                        catch (Exception ex)
                        {
                            Log.WriteException("ChangeApplicationPool", ex);
                        }
                    }
                }
                catch
                {
                    #region Undo changes

                    try
                    {
                        if (poolChanged)
                            iisManager.ChangeApplicationPool(siteId, oldPool);
                    }
                    catch
                    {
                    }

                    try
                    {
                        if (newPoolCreated)
                            iisManager.DeleteApplicationPool(newPool);
                    }
                    catch
                    {
                    }

                    #endregion

                    throw;
                }
            }

            return newPool;
        }
 public DeployWebServiceDeploymentTask(IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter)
     : base(projectInfoRepository, environmentInfoRepository, msDeploy, artifactsRepository, iisManager, fileAdapter, zipFileAdapter)
 {
 }
 public DeployWebServiceDeploymentTask(IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, IApplicationConfiguration applicationConfiguration, IDirectoryAdapter directoryAdapter)
     : base(projectInfoRepository, environmentInfoRepository, msDeploy, artifactsRepository, iisManager, fileAdapter, zipFileAdapter, applicationConfiguration, directoryAdapter)
 {
 }
Beispiel #16
0
        static void Update()
        {
            LogFile.WriteMessageFormat("*** Updating Mediachase {0} ***", IbnConst.ProductName);

            //GlobalContext.Current = new GlobalContext(Settings.InstallDirWeb + @"portal\Apps");
            DBHelper2.Init(new DBHelper(string.Format(CultureInfo.InvariantCulture, "Data source={0};Initial catalog=master;User Id={1};Password={2};Connection Timeout=36000", Settings.SqlServer, Settings.SqlUser, Settings.SqlPassword)));
            DBHelper2.DBHelper.CommandTimeout = CommandTimeout;

            IConfigurator configurator  = Configurator.Create();
            IIisManager   oldIisManager = IisManager.Create(Settings.InstallDirWeb);
            bool          x64           = oldIisManager.Is64Bit();

            // Get copmanies
            CompanyInfo[] oldCompanies = CompanyInfo.ListCompanies(DBHelper2.DBHelper);
            bool          isAsp        = (oldCompanies.Length > 1);

            List <string> newCompanies = ListNewCompanies(configurator);
            bool          firstLaunch  = (newCompanies == null);

            List <CompanyInfo> companies = new List <CompanyInfo>();

            if (firstLaunch)
            {
                companies.AddRange(oldCompanies);
            }
            else
            {
                foreach (CompanyInfo oldCompany in oldCompanies)
                {
                    if (!newCompanies.Contains(oldCompany.Host))
                    {
                        companies.Add(oldCompany);
                    }
                }
            }

            string newAspPath = Path.Combine(Settings.InstallDir, "Asp");
            string codePath   = Path.Combine(Settings.InstallDir, "Code");
            string sourcePath = Path.Combine(codePath, "_Source");
            string newWebPath = Path.Combine(sourcePath, "Web");

            try
            {
                // Stop old web site
                oldIisManager.StopSite(Settings.SiteId);

                // Stop old services
                if (firstLaunch)
                {
                    StopService("AlertService" + IbnConst.VersionMajorMinor, false);
                    StopService("McOleDBService" + IbnConst.VersionMajorMinor, false);
                    StopService("ScheduleService" + IbnConst.VersionMajorMinor, false);

                    // Unregister old components
                    RegisterComponents(false, GetOldComponents());

                    // Unregister old IM Server
                    RegisterIMServer(false, Settings.InstallDirWeb, x64);

                    // TODO: ? Delete ISAPI extension
                    // TODO: ? Delete portal application pool
                    // TODO: ? Delete IM application pool

                    // Copy old files to new location: InstallPath\Code\_Source
                    LogFile.WriteLine("Copying old files to new location...");

                    CopyDirectory(Path.Combine(Settings.InstallDir, @"Web\Asp"), newAspPath);
                    CopyDirectory(Settings.InstallDir, sourcePath, "Tools");
                    CopyDirectory(Settings.InstallDir, sourcePath, @"Web\Download");
                    CopyDirectory(Settings.InstallDir, sourcePath, @"Web\instmsg");
                    CopyDirectory(Settings.InstallDir, sourcePath, @"Web\instmsg64");
                    CopyDirectory(Settings.InstallDir, sourcePath, @"Web\Portal");

                    LogWriteOk();

                    // Delete error logs
                    Directory.Delete(Path.Combine(sourcePath, @"Web\Portal\Admin\Log\Error"), true);

                    // Update files
                    UpdateFiles();

                    // Register new components
                    RegisterComponents(true, GetNewComponents());

                    // Register new IM Server
                    RegisterIMServer(true, newWebPath, x64);

                    // Start new services
                    StartNewServices();
                }
                firstLaunch = false;

                Pause("Restore clean databases.");

                for (int i = 0; i < companies.Count; i++)
                {
                    CompanyInfo company = companies[i];

                    LogFile.WriteMessageFormat("* Converting company {0} of {1}: '{2}' *", i + 1, companies.Count, company.Host);

                    try
                    {
                        ConvertCompany(configurator, isAsp, company);

                        // Delete binding from old web site
                        try
                        {
                            if (isAsp)
                            {
                                oldIisManager.DeleteBinding(Settings.SiteId, company.Host);
                            }
                        }
                        catch
                        {
                        }

                        LogFile.WriteLine("* OK *");
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteLine("* Failed *");
                        LogFile.WriteLine("");

                        if (isAsp)
                        {
                            LogFile.WriteLine(ex.ToString());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                Settings.SaveVersion();

                Pause("Backup databases.");

                LogFile.WriteLine("*** OK ***");
            }
            catch (Exception ex)
            {
                LogFile.WriteLine("*** Failed ***");
                LogFile.WriteLine("");
                LogFile.WriteLine(ex.ToString());
                LogFile.WriteLine("");
                LogFile.WriteLine("Rollback started");

                #region Undo changes

                try
                {
                    if (!isAsp || firstLaunch)
                    {
                        // Unregister new components
                        try
                        {
                            RegisterComponents(false, GetNewComponents());
                        }
                        catch
                        {
                        }

                        // Unregister new IM server
                        try
                        {
                            RegisterIMServer(false, newWebPath, x64);
                        }
                        catch
                        {
                        }

                        // Recover files
                        try
                        {
                            RecoverFiles();
                        }
                        catch
                        {
                        }

                        // Delete [InstallDir]\Code
                        try
                        {
                            Directory.Delete(codePath, true);
                        }
                        catch
                        {
                        }

                        // Delete [InstallDir]\Asp
                        try
                        {
                            Directory.Delete(newAspPath, true);
                        }
                        catch
                        {
                        }

                        // Register old components
                        try
                        {
                            RegisterComponents(true, GetOldComponents());
                        }
                        catch
                        {
                        }

                        // Register old IM Server
                        try
                        {
                            RegisterIMServer(true, Settings.InstallDirWeb, x64);
                        }
                        catch
                        {
                        }

                        // Start old services
                        try
                        {
                            StartOldServices();
                        }
                        catch
                        {
                        }
                    }

                    // Start old web site
                    try
                    {
                        oldIisManager.StartSite(Settings.SiteId);
                    }
                    catch
                    {
                    }
                }
                catch
                {
                }

                #endregion

                LogFile.WriteLine("Rollback finished");
                throw;
            }
            finally
            {
                LogFile.WriteLine("");
                // Delete backup files
                DeleteBackupFiles();
            }
        }
 public DeployWebServiceDeploymentTask(IMsDeploy msDeploy,IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, IIisManager iisManager, WebAppProjectInfo projectInfo, string projectConfigurationName, string projectConfigurationBuildId, string targetEnvironmentName)
     : base(msDeploy, environmentInfoRepository, artifactsRepository, iisManager, projectInfo, projectConfigurationName, projectConfigurationBuildId, targetEnvironmentName)
 {
 }
Beispiel #18
0
 static void StopApplicationPool(IIisManager iisManager, string name)
 {
     LogFile.WriteFormatted("Stopping IIS application pool'{0}", name);
     iisManager.StopApplicationPool(name, true);
     LogWriteOk();
 }
Beispiel #19
0
 public DeployWebServiceDeploymentTask(IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, IApplicationConfiguration applicationConfiguration, IDirectoryAdapter directoryAdapter)
     : base(projectInfoRepository, environmentInfoRepository, msDeploy, artifactsRepository, iisManager, fileAdapter, zipFileAdapter, applicationConfiguration, directoryAdapter)
 {
 }