Ejemplo n.º 1
0
        //API-Helpers
        private void RollBack()
        {
            FolderUtilities.RenameFolder(m_AppConfig.BackupPath, m_AppConfig.InstallationPath);
            m_LogManager.WriteInfo("Performing RollBack : ");

            if (!m_ServiceManager.ServiceExists())
            {
                m_ServiceManager.InstallService();
                m_ServiceManager.StartService();
            }
            else
            {
                m_ServiceManager.StartService();
            }
        }
Ejemplo n.º 2
0
        private void DeleteInstalltion()
        {
            m_LogManager.WriteInfo("Deleteing Installtion : ");

            if (FolderUtilities.Exists(m_AppConfig.InstallationPath))
            {
                FolderUtilities.DeleteFolder(m_AppConfig.InstallationPath);
            }
            if (m_ServiceManager.ServiceRunning())
            {
                m_ServiceManager.StopService();
            }
            if (m_ServiceManager.ServiceExists())
            {
                m_ServiceManager.DeleteService();
            }
        }
Ejemplo n.º 3
0
        public void Deploy()
        {
            eDeployment deployType = eDeployment.NewInstall;

            try
            {
                string currentVer = FileUtilities.GetVersion(m_AppConfig.ExecutablePath);
                string upgradeVer = FileUtilities.GetVersion(FolderUtilities.GetExecutablePath(m_AppConfig.RemotePath));
                if (currentVer == upgradeVer && !string.IsNullOrEmpty(currentVer))
                {
                    deployType = eDeployment.VersionAlreadyExists;
                    throw new Exception("current version is :" + currentVer + ", trying to deploy : " + upgradeVer + " [Same Version]");
                }

                m_LogManager.WriteInfo("Deploy Started");
                m_LogManager.WriteInfo("Current Version : " + currentVer + " , Deploying Version : " + upgradeVer);
                if (m_ServiceManager.service())
                {
                    m_LogManager.WriteInfo("Service Already Exists.");
                    if (m_ServiceManager.ServiceRunning())
                    {
                        m_ServiceManager.StopService();
                        m_ServiceManager.DeleteService();
                    }
                    else
                    {
                        m_ServiceManager.DeleteService();
                    }
                }
                //new install
                if (FolderUtilities.Exists(m_AppConfig.InstallationPath))
                {
                    m_LogManager.WriteInfo("Folder Already Exists.");

                    deployType = eDeployment.Upgrade;
                    if (FolderUtilities.Exists(m_AppConfig.BackupPath))
                    {
                        throw new Exception("You are trying to install older version(Backup already exists)");
                    }
                    FolderUtilities.RenameFolder(m_AppConfig.InstallationPath, m_AppConfig.BackupPath);
                }
                m_LogManager.WriteInfo("Copying remote folder.");

                FolderUtilities.CopyFolder(m_AppConfig.RemotePath, m_AppConfig.InstallationPath);
                refreshAppConfig();
                m_ServiceManager.InstallService();
                m_ServiceManager.StartService();
            }
            catch (Exception ex)
            {
                string exception = ex.Message;
                switch (deployType)
                {
                case eDeployment.NewInstall:
                    DeleteInstalltion();

                    exception += "[Installtion aborted]";

                    break;

                case eDeployment.Upgrade:
                    RollBack();
                    exception += "[RollBack Preformed]";
                    break;

                case eDeployment.VersionAlreadyExists:
                    exception += "[Idle]";

                    break;
                }
                throw new Exception(exception);
            }
        }