예제 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Uninstall method uninstalls the components of the package
        /// </summary>
        /// <history>
        ///     [cnurse]	07/25/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void UnInstall()
        {
            //Iterate through all the Components
            for (int index = 0; index <= _componentInstallers.Count - 1; index++)
            {
                ComponentInstallerBase compInstaller = _componentInstallers.Values[index];
                var fileInstaller = compInstaller as FileInstaller;
                if (fileInstaller != null)
                {
                    fileInstaller.DeleteFiles = DeleteFiles;
                }
                Log.ResetFlags();
                Log.AddInfo(Util.UNINSTALL_StartComp + " - " + compInstaller.Type);
                compInstaller.UnInstall();
                Log.AddInfo(Util.COMPONENT_UnInstalled + " - " + compInstaller.Type);
                if (Log.Valid)
                {
                    Log.AddInfo(Util.UNINSTALL_SuccessComp + " - " + compInstaller.Type);
                }
                else
                {
                    Log.AddWarning(Util.UNINSTALL_WarningsComp + " - " + compInstaller.Type);
                }
            }

            //Remove the Package information from the Data Store
            PackageController.DeletePackage(Package);
        }
예제 #2
0
 public override void UnInstall()
 {
     for (int index = 0; index <= ComponentInstallers.Count - 1; index++)
     {
         ComponentInstallerBase compInstaller = ComponentInstallers.Values[index];
         FileInstaller          fileInstaller = compInstaller as FileInstaller;
         if (fileInstaller != null)
         {
             fileInstaller.DeleteFiles = DeleteFiles;
         }
         Log.ResetFlags();
         Log.AddInfo(Util.UNINSTALL_StartComp + " - " + compInstaller.Type);
         compInstaller.UnInstall();
         Log.AddInfo(Util.COMPONENT_UnInstalled + " - " + compInstaller.Type);
         if (Log.Valid)
         {
             Log.AddInfo(Util.UNINSTALL_SuccessComp + " - " + compInstaller.Type);
         }
         else
         {
             Log.AddWarning(Util.UNINSTALL_WarningsComp + " - " + compInstaller.Type);
         }
     }
     PackageController.DeletePackage(Package);
 }
예제 #3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Rollback method rolls back the package installation
        /// </summary>
        /// <history>
        ///     [cnurse]	07/31/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void Rollback()
        {
            for (int index = 0; index <= _componentInstallers.Count - 1; index++)
            {
                ComponentInstallerBase compInstaller = _componentInstallers.Values[index];
                if (compInstaller.Version > Package.InstalledVersion && compInstaller.Completed)
                {
                    Log.AddInfo(Util.COMPONENT_RollingBack + " - " + compInstaller.Type);
                    compInstaller.Rollback();
                    Log.AddInfo(Util.COMPONENT_RolledBack + " - " + compInstaller.Type);
                }
            }

            //If Previously Installed Package exists then we need to update the DataStore with this
            if (_installedPackage == null)
            {
                //No Previously Installed Package - Delete newly added Package
                PackageController.DeletePackage(Package);
            }
            else
            {
                //Previously Installed Package - Rollback to Previously Installed
                PackageController.SavePackage(_installedPackage);
            }
        }
예제 #4
0
        public void Rollback()
        {
            int packageId = Utils.ParseInt(ServiceSettings[PACKAGE_ID], -1);

            if (packageId > -1)
            {
                switch (previousStatus)
                {
                case PackageStatus.New:                         // delete package
                    int removeResult = PackageController.DeletePackage(packageId);
                    if (removeResult != 0)
                    {
                        throw new Exception("Unable to rollback(remove) package. Status code: " + removeResult);
                    }
                    break;

                case PackageStatus.Active:                         // return to active state
                case PackageStatus.Cancelled:
                case PackageStatus.Suspended:

                    PackageInfo package = PackageController.GetPackage(packageId);
                    package.StatusId = (int)previousStatus;

                    PackageResult result = PackageController.UpdatePackage(package);

                    if (result.Result != 0)
                    {
                        throw new Exception("Unable to rollback(update) package. Status code: " + result.Result);
                    }

                    break;
                }
            }
        }
예제 #5
0
        public static void DeleteDesktopModule(string moduleName)
        {
            DesktopModuleInfo desktopModule = GetDesktopModuleByModuleName(moduleName, Null.NullInteger);

            if (desktopModule != null)
            {
                DesktopModuleController controller = new DesktopModuleController();
                controller.DeleteDesktopModule(desktopModule.DesktopModuleID);
                PackageController.DeletePackage(desktopModule.PackageID);
            }
        }
예제 #6
0
 public override void Rollback()
 {
     for (int index = 0; index <= ComponentInstallers.Count - 1; index++)
     {
         ComponentInstallerBase compInstaller = ComponentInstallers.Values[index];
         if (compInstaller.Version > Package.InstalledVersion && compInstaller.Completed)
         {
             Log.AddInfo(Util.COMPONENT_RollingBack + " - " + compInstaller.Type);
             compInstaller.Rollback();
             Log.AddInfo(Util.COMPONENT_RolledBack + " - " + compInstaller.Type);
         }
     }
     if (InstalledPackage == null)
     {
         PackageController.DeletePackage(Package);
     }
     else
     {
         PackageController.SavePackage(InstalledPackage);
     }
 }
예제 #7
0
        public int DeletePackage(int packageId)
        {
            List <string> usersList   = new List <string>();
            List <string> domainsList = new List <string>();

            PackageInfo package = PackageController.GetPackage(packageId);

            // get package service items
            List <ServiceProviderItem> items = PackageController.GetServiceItemsForStatistics(
                0, package.PackageId, false, false, false, true); // disposable items

            // order items by service
            Dictionary <int, List <ServiceProviderItem> > orderedItems =
                PackageController.OrderServiceItemsByServices(items);

            int  maxItems          = 100000000;
            bool mailFilterEnabled = false;

            // delete service items by service sets
            foreach (int serviceId in orderedItems.Keys)
            {
                ServiceInfo service = ServerController.GetServiceInfo(serviceId);
                //Delete Exchange Organization
                if (service.ProviderId == 103 /*Organizations*/)
                {
                    int itemid = orderedItems[serviceId][0].Id;
                    OrganizationUsersPaged users    = OrganizationController.GetOrganizationUsersPaged(itemid, null, null, null, 0, maxItems);
                    StringDictionary       settings = ServerController.GetServiceSettings(serviceId);
                    if (settings != null && Convert.ToBoolean(settings["EnableMailFilter"]))
                    {
                        mailFilterEnabled = true;
                        foreach (OrganizationUser user in users.PageUsers)
                        {
                            SpamExpertsController.DeleteEmailFilter(packageId, user.PrimaryEmailAddress);
                        }
                    }
                }
            }
            if (mailFilterEnabled)
            {
                List <DomainInfo> domains = ServerController.GetDomains(packageId);
                foreach (DomainInfo domain in domains)
                {
                    SpamExpertsController.DeleteDomainFilter(domain);
                }
            }

            //Get VPS Package IPs
            PackageIPAddress[] ips = ServerController.GetPackageIPAddresses(packageId, 0,
                                                                            IPAddressPool.VpsExternalNetwork, "", "", "", 0, maxItems, true).Items;
            List <int> ipsIdList = new List <int>();

            foreach (PackageIPAddress ip in ips)
            {
                ipsIdList.Add(ip.AddressID);
            }

            //Delete Package
            int res = PackageController.DeletePackage(packageId);

            if (res >= 0)
            {
                // users
                //foreach (string user in usersList)
                //SEPlugin.SE.DeleteEmail(user);

                //domain
                //foreach (string domain in domainsList)
                //SEPlugin.SE.DeleteDomain(domain);

                //return IPs back to ParentPackage
                if (package.ParentPackageId != 1) // 1 is System (serveradmin), we don't want assign IP to the serveradmin.
                {
                    ServerController.AllocatePackageIPAddresses(package.ParentPackageId, ipsIdList.ToArray());
                }
            }

            return(res);
        }
예제 #8
0
 public int DeletePackage(int packageId)
 {
     return(PackageController.DeletePackage(packageId));
 }
예제 #9
0
        protected void RollbackOperation(int packageId)
        {
            // check input parameters first
            if (packageId < 1)
            {
                return;                 // exit
            }
            //
            try
            {
                TaskManager.Write("Trying rollback operation");
                // restore service
                HostingPackageSvc packageSvc = (HostingPackageSvc)RestoreObjectState("ServiceInfo");
                // restore consumer
                UserInfo consumer = (UserInfo)RestoreObjectState("ConsumerInfo");

                //
                int apiResult = 0;

                // rollback consumer changes first
                apiResult = UserController.UpdateUser(consumer);
                // check WebsitePanel API result
                if (apiResult < 0)
                {
                    //
                    TaskManager.WriteError("Could not rollback consumer changes");
                    //
                    TaskManager.WriteParameter("ResultCode", apiResult);
                }

                // during rollback package should be reverted to its original state
                // compensation logic - revert back package status
                switch (packageSvc.Status)
                {
                // Active State
                case ServiceStatus.Active:
                    apiResult = PackageController.ChangePackageStatus(packageId, PackageStatus.Active, false);
                    break;

                // Suspended State
                case ServiceStatus.Suspended:
                    apiResult = PackageController.ChangePackageStatus(packageId, PackageStatus.Suspended, false);
                    break;

                // Cancelled State
                case ServiceStatus.Cancelled:
                    apiResult = PackageController.ChangePackageStatus(packageId, PackageStatus.Cancelled, false);
                    break;

                // service has been just ordered & during rollback should be removed
                case ServiceStatus.Ordered:
                    // compensation logic - remove created package
                    apiResult = PackageController.DeletePackage(packageId);
                    break;
                }
                // check WebsitePanel API result
                if (apiResult < 0)
                {
                    //
                    if (packageSvc.Status == ServiceStatus.Ordered)
                    {
                        TaskManager.WriteError("Could not rollback operation and delete package");
                    }
                    else
                    {
                        TaskManager.WriteError("Could not rollback operation and revert package state");
                    }
                    //
                    TaskManager.WriteParameter("ResultCode", apiResult);
                }

                // rollback service changes in EC metabase
                apiResult = UpdateServiceInfo(packageSvc);
                // check API result
                if (apiResult < 0)
                {
                    //
                    TaskManager.WriteError("Could not rollback service changes");
                    //
                    TaskManager.WriteParameter("ResultCode", apiResult);
                }

                //
                TaskManager.Write("Rollback succeed");
            }
            catch (Exception ex)
            {
                TaskManager.WriteError(ex);
            }
        }