Exemplo n.º 1
0
        public static string DeletePortal( PortalInfo portal, string serverPath )
        {
            string strPortalName = null;
            string strMessage = string.Empty;

            // check if this is the last portal
            int portalCount = DataProvider.Instance().GetPortalCount();

            if( portalCount > 1 )
            {
                if( portal != null )
                {
                    // delete custom resource files
                    Globals.DeleteFilesRecursive( serverPath, ".Portal-" + portal.PortalID.ToString() + ".resx" );

                    //If child portal delete child folder
                    PortalAliasController objPortalAliasController = new PortalAliasController();
                    ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID( portal.PortalID );
                    PortalAliasInfo objPortalAliasInfo = (PortalAliasInfo)( arr[0] );
                    strPortalName = Globals.GetPortalDomainName( objPortalAliasInfo.HTTPAlias, null, true );
                    if( Convert.ToBoolean( ( objPortalAliasInfo.HTTPAlias.IndexOf( "/", 0 ) + 1 ) ) )
                    {
                        strPortalName = objPortalAliasInfo.HTTPAlias.Substring( ( objPortalAliasInfo.HTTPAlias.LastIndexOf( "/" ) + 1 ) );
                    }
                    if( strPortalName != "" && Directory.Exists( serverPath + strPortalName ) )
                    {
                        Globals.DeleteFolderRecursive( serverPath + strPortalName );
                    }

                    // delete upload directory
                    Globals.DeleteFolderRecursive( serverPath + "Portals\\" + portal.PortalID.ToString() );
                    string HomeDirectory = portal.HomeDirectoryMapPath;
                    if( Directory.Exists( HomeDirectory ) )
                    {
                        Globals.DeleteFolderRecursive( HomeDirectory );
                    }

                    // remove database references
                    PortalController objPortalController = new PortalController();
                    objPortalController.DeletePortalInfo( portal.PortalID );
                }
            }
            else
            {
                strMessage = Localization.GetString( "LastPortal" );
            }

            return strMessage;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the portal.
        /// </summary>
        /// <param name="portal">The portal.</param>
        /// <param name="serverPath">The server path.</param>
        /// <returns>If the method executed successful, it will return NullString, otherwise return error message.</returns>
        public static string DeletePortal(PortalInfo portal, string serverPath)
        {
            var portalController = new PortalController();
            string message = string.Empty;

            //check if this is the last portal
            int portalCount = portalController.GetPortals().Count;
            if (portalCount > 1)
            {
                if (portal != null)
                {
                    //delete custom resource files
                    Globals.DeleteFilesRecursive(serverPath, ".Portal-" + portal.PortalID + ".resx");

                    //If child portal delete child folder
                    var arr = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(portal.PortalID).ToList();
                    if (arr.Count > 0)
                    {
                        var portalAliasInfo = (PortalAliasInfo)arr[0];
                        string portalName = Globals.GetPortalDomainName(portalAliasInfo.HTTPAlias, null, true);
                        if (portalAliasInfo.HTTPAlias.IndexOf("/", StringComparison.Ordinal) > -1)
                        {
                            portalName = GetPortalFolder(portalAliasInfo.HTTPAlias);
                        }
                        if (!String.IsNullOrEmpty(portalName) && Directory.Exists(serverPath + portalName))
                        {
                            DeletePortalFolder(serverPath, portalName);
                        }
                    }
                    //delete upload directory
                    Globals.DeleteFolderRecursive(serverPath + "Portals\\" + portal.PortalID);
                    if (!string.IsNullOrEmpty(portal.HomeDirectory))
                    {
                        string HomeDirectory = portal.HomeDirectoryMapPath;
                        if (Directory.Exists(HomeDirectory))
                        {
                            Globals.DeleteFolderRecursive(HomeDirectory);
                        }
                    }
                    //remove database references
                    portalController.DeletePortalInfo(portal.PortalID);
                }
            }
            else
            {
                message = Localization.GetString("LastPortal");
            }
            return message;
        }