Esempio n. 1
0
        RemoveApplication(IISHandler handler, string appName, string siteName)
        {
            if (appName.Equals("/"))
            {
                Console.WriteLine(appName + " cannot be removed safely. It is the site default. Removing would corrupt website.");
                return;
            }

            String[] paths = null;
            if (PathHelper.ContainsWildcard(appName))
            {
                Site site = handler.GetSiteByName(siteName);
                if (site == null)
                {
                    Console.WriteLine("Site " + siteName + " does not exist.");
                    return;
                }

                paths = PathHelper.ExpandWildcardDirectories(appName);
                List <Application> apps =
                    new List <Application>(site.Applications.Where(p => paths.Contains(p.VirtualDirectories["/"].PhysicalPath)));

                foreach (var app in apps)
                {
                    Console.WriteLine("Removing app " + app);
                    try
                    {
                        handler.RemoveApplicationNonCommit(site, app);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }

                handler.CommitChanges();
                return;
            }

            try
            {
                handler.RemoveApplication(siteName, appName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
        RemoveApplicationRecursively(IISHandler handler, string appPrefix, string siteName)
        {
            if (appPrefix.Equals("/"))
            {
                Console.WriteLine(appPrefix + " cannot be removed safely. It is the site default. Removing would corrupt website.");
                return;
            }

            try
            {
                Site site = handler.GetSiteByName(siteName);
                if (site == null)
                {
                    Console.WriteLine("Site " + siteName + " does not exist.");
                    return;
                }

                if (!appPrefix.StartsWith(site.Name))
                {
                    appPrefix = site.Name + appPrefix;
                }

                List <Application> apps =
                    new List <Application>(site.Applications
                                           .Where(p => p.ToString().StartsWith(appPrefix)));

                foreach (var app in apps)
                {
                    Console.WriteLine("Removing app: " + app);
                    try
                    {
                        handler.RemoveApplicationNonCommit(site, app);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                handler.CommitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 3
0
        AddApplication(IISHandler handler, string virPath, string physPath, string siteName)
        {
            string fullPath = Path.GetFullPath(physPath);

            Console.WriteLine("Adding app from dir: " + fullPath);
            Console.WriteLine("With virtual dir: " + virPath);
            Site site = handler.GetSiteByName(siteName);

            try
            {
                if (site != null)
                {
                    site.Applications.Add(virPath, fullPath);
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message); }

            handler.CommitChanges();
        }