Esempio n. 1
0
 public static void RemoveSiteApplication(this ICakeContext context, string server, ApplicationSettings settings)
 {
     using (ServerManager manager = BaseManager.Connect(server))
     {
         WebsiteManager
             .Using(context.Environment, context.Log, manager)
             .RemoveApplication(settings);
     }
 }
Esempio n. 2
0
        public static void AddSiteApplication(this ICakeContext context, string server, ApplicationSettings settings)
        {
            using (ServerManager manager = BaseManager.Connect(server))
            {
                settings.ComputerName = server;

                WebsiteManager
                    .Using(context.Environment, context.Log, manager)
                    .AddApplication(settings);
            }
        }
Esempio n. 3
0
 public static void RemoveSiteApplication(this ICakeContext context, ApplicationSettings settings)
 {
     context.RemoveSiteApplication("", settings);
 }
Esempio n. 4
0
            public bool AddApplication(ApplicationSettings settings)
            {
                if (settings == null)
                {
                    throw new ArgumentNullException("settings");
                }

                if (string.IsNullOrWhiteSpace(settings.SiteName))
                {
                    throw new ArgumentException("Site name cannot be null!");
                }

                if (string.IsNullOrWhiteSpace(settings.ApplicationPath))
                {
                    throw new ArgumentException("Applicaiton path cannot be null!");
                }



                //Get Pool
                ApplicationPool appPool = _Server.ApplicationPools.SingleOrDefault(p => p.Name == settings.ApplicationPool);

                if (appPool == null)
                {
                    throw new Exception("Application Pool '" + settings.ApplicationPool + "' does not exist.");
                }



                //Get Site
                Site site = _Server.Sites.SingleOrDefault(p => p.Name == settings.SiteName);

                if (site != null)
                {
                    //Get Application
                    Application app = site.Applications.SingleOrDefault(p => p.Path == settings.ApplicationPath);

                    if (app != null)
                    {
                        throw new Exception("Application '" + settings.ApplicationPath + "' already exists.");
                    }
                    else
                    {
                        app = site.Applications.CreateElement();
                        app.Path = settings.ApplicationPath;
                        app.ApplicationPoolName = settings.ApplicationPool;



                        //Get Directory
                        VirtualDirectory vDir = app.VirtualDirectories.CreateElement();
                        vDir.Path = settings.VirtualDirectory;
                        vDir.PhysicalPath = this.GetPhysicalDirectory(settings);

                        if (!string.IsNullOrEmpty(settings.UserName))
                        {
                            if (string.IsNullOrEmpty(settings.Password))
                            {
                                throw new Exception("Invalid Virtual Directory User Account Password.");
                            }
                            else
                            {
                                vDir.UserName = settings.UserName;
                                vDir.Password = settings.Password;
                            }
                        }

                        app.VirtualDirectories.Add(vDir);
                    }

                    site.Applications.Add(app);
                    _Server.CommitChanges();

                    return true;
                }
                else
                {
                    throw new Exception("Site '" + settings.SiteName + "' does not exist.");
                }
            }
Esempio n. 5
0
            public bool RemoveApplication(ApplicationSettings settings)
            {
                if (settings == null)
                {
                    throw new ArgumentNullException("settings");
                }

                if (string.IsNullOrWhiteSpace(settings.SiteName))
                {
                    throw new ArgumentException("Site name cannot be null!");
                }

                if (string.IsNullOrWhiteSpace(settings.ApplicationPath))
                {
                    throw new ArgumentException("Applicaiton path cannot be null!");
                }



                //Get Pool
                ApplicationPool appPool = _Server.ApplicationPools.SingleOrDefault(p => p.Name == settings.ApplicationPool);

                if (appPool == null)
                {
                    throw new Exception("Application Pool '" + settings.ApplicationPool + "' does not exist.");
                }



                //Get Site
                Site site = _Server.Sites.SingleOrDefault(p => p.Name == settings.SiteName);

                if (site != null)
                {
                    //Get Application
                    Application app = site.Applications.SingleOrDefault(p => p.Path == settings.ApplicationPath);

                    if (app == null)
                    {
                        throw new Exception("Application '" + settings.ApplicationPath + "' does not exists.");
                    }
                    else
                    {
                        site.Applications.Remove(app);
                        _Server.CommitChanges();

                        return true;
                    }
                }
                else
                {
                    throw new Exception("Site '" + settings.SiteName + "' does not exist.");
                }
            }
Esempio n. 6
0
 public static bool SiteApplicationExists(this ICakeContext context, string server, ApplicationSettings settings)
 {
     using (ServerManager manager = BaseManager.Connect(server))
     {
         return(WebsiteManager
                .Using(context.Environment, context.Log, manager)
                .ApplicationExists(settings));
     }
 }
Esempio n. 7
0
 public static bool SiteApplicationExists(this ICakeContext context, ApplicationSettings settings)
 {
     return(context.SiteApplicationExists("", settings));
 }
Esempio n. 8
0
 public static void RemoveSiteApplication(this ICakeContext context, string server, ApplicationSettings settings)
 {
     using (ServerManager manager = BaseManager.Connect(server))
     {
         WebsiteManager
         .Using(context.Environment, context.Log, manager)
         .RemoveApplication(settings);
     }
 }
Esempio n. 9
0
 public static void RemoveSiteApplication(this ICakeContext context, ApplicationSettings settings)
 {
     context.RemoveSiteApplication("", settings);
 }
Esempio n. 10
0
        public static void AddSiteApplication(this ICakeContext context, string server, ApplicationSettings settings)
        {
            using (ServerManager manager = BaseManager.Connect(server))
            {
                settings.ComputerName = server;

                WebsiteManager
                .Using(context.Environment, context.Log, manager)
                .AddApplication(settings);
            }
        }