public ArrayList AddSiteBinding(string siteName, PropertyBag bindingBag) { if (string.IsNullOrEmpty(siteName)) { throw new ArgumentNullException("siteName"); } if (bindingBag == null) { throw new ArgumentNullException("bindingBag"); } // Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistCannotAddBindingExceptionError"); } string bindingProtocol = (string)bindingBag[0]; string bindingInformation = (string)bindingBag[1]; site.Bindings.Add(bindingInformation, bindingProtocol); ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings); ServerManager.CommitChanges(); return(allBindings); }
public void AddSite(PropertyBag bag) { // ensure bag not empty if (bag == null) { throw new ArgumentNullException("bag"); } // ensure site not exists string name = (string)bag[FtpSiteGlobals.Site_Name]; if (ServerManager.Sites[name] != null) { throw new Exception("SiteAlreadyExistsExceptionError"); } // ensure site path string directory = (string)bag[FtpSiteGlobals.AppVirtualDirectory_PhysicalPath]; if (!Directory.Exists(FileUtils.EvaluateSystemVariables(directory))) { throw new Exception("SiteDirectoryDoesNotExistExceptionError"); } // ensure site binding PropertyBag bag2 = (PropertyBag)bag[FtpSiteGlobals.Site_SingleBinding]; if (bag2 == null) { throw new ArgumentNullException("bindingBag"); } string bindingInformation = (string)bag2[FtpSiteGlobals.BindingInformation]; SitesHelper.DeserializeSiteProperties(ServerManager.Sites.Add(name, "ftp", bindingInformation, directory), bag); // authorization PropertyBag authBag = (PropertyBag)bag[FtpSiteGlobals.Authorization_Rule]; if (authBag != null) { AddAuthorizationRules(name, authBag); } ServerManager.CommitChanges(); Site site = ServerManager.Sites[name]; try { FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site); // if (ftpSiteElement.ServerAutoStart) { ftpSiteElement.Start(); } } catch { } }
public void EditSiteDefaults(PropertyBag bag) { if (bag == null) { throw new ArgumentNullException("bag"); } SitesHelper.DeserializeFtpSiteProperties(FtpHelper.GetFtpSiteDefaultElement(ServerManager.SiteDefaults), bag); ServerManager.CommitChanges(); }
public PropertyBag GetSite(string siteName) { if (string.IsNullOrEmpty(siteName)) { throw new ArgumentNullException(siteName); } Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistExceptionError"); } return(SitesHelper.SerializeSite(site)); }
public ArrayList EditSiteBinding(string siteName, PropertyBag originalBindingBag, PropertyBag newBindingBag) { if (string.IsNullOrEmpty(siteName)) { throw new ArgumentNullException("siteName"); } if (originalBindingBag == null) { throw new ArgumentNullException("originalBindingBag"); } if (newBindingBag == null) { throw new ArgumentNullException("newBindingBag"); } // Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistCannotEditBindingExceptionError"); } string b = (string)originalBindingBag[1]; int num = (int)originalBindingBag[2]; string str2 = (string)newBindingBag[1]; int num2 = 0; bool flag = false; foreach (Binding binding in site.Bindings) { if (((num == num2) && string.Equals(binding.Protocol, "ftp", StringComparison.OrdinalIgnoreCase)) && string.Equals(binding.BindingInformation, b, StringComparison.OrdinalIgnoreCase)) { binding.BindingInformation = str2; flag = true; } num2++; } if (!flag) { throw new Exception("SitesBindingDoesNotExistCannotEditBindingExceptionError"); } ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings); ServerManager.CommitChanges(); return(allBindings); }
public PropertyBag GetSiteProperties(string siteName) { if (string.IsNullOrEmpty(siteName)) { throw new ArgumentNullException(siteName); } Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistExceptionError"); } PropertyBag bag = SitesHelper.SerializeSite(site); SitesHelper.SerializeFtpSiteProperties(FtpHelper.GetFtpSiteElement(site), bag); return(bag); }
public ArrayList RemoveSiteBinding(string siteName, PropertyBag bindingBag) { if (string.IsNullOrEmpty(siteName)) { throw new ArgumentNullException("siteName"); } if (bindingBag == null) { throw new ArgumentNullException("bindingBag"); } Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistCannotRemoveBindingExceptionError"); } string b = (string)bindingBag[1]; int num = (int)bindingBag[2]; int num2 = 0; Binding element = null; foreach (Binding binding2 in site.Bindings) { if (((num == num2) && string.Equals(binding2.Protocol, "ftp", StringComparison.OrdinalIgnoreCase)) && string.Equals(binding2.BindingInformation, b, StringComparison.OrdinalIgnoreCase)) { binding2.BindingInformation = b; element = binding2; } num2++; } if (element == null) { throw new Exception("SitesBindingDoesNotExistCannotRemoveBindingExceptionError"); } site.Bindings.Remove(element); ArrayList allBindings = SitesHelper.GetAllBindings(site.Bindings); // ServerManager.CommitChanges(); return(allBindings); }
public PropertyBag EditSiteProperties(PropertyBag bag) { if (bag == null) { throw new ArgumentNullException("bag"); } string siteName = (string)bag[100]; PropertyBag bindingBag = (PropertyBag)bag[0x68]; if (bindingBag != null) { this.AddSiteBinding(siteName, bindingBag); } Site site = ServerManager.Sites[siteName]; if (site == null) { throw new Exception("SiteDoesNotExistCannotEditExceptionError"); } SitesHelper.DeserializeSiteProperties(site, bag); PropertyBag authBag = (PropertyBag)bag[0x1a6]; if (authBag != null) { this.AddAuthorizationRules(siteName, authBag); } // ServerManager.CommitChanges(); // site = ServerManager.Sites[siteName]; try { FtpSite ftpSiteElement = FtpHelper.GetFtpSiteElement(site); if (ftpSiteElement.ServerAutoStart) { ftpSiteElement.Start(); } } catch { } return(SitesHelper.SerializeSite(site)); }
public PropertyBag GetSiteDefaults() { return(SitesHelper.SerializeSiteDefaults(ManagementUnit.ReadOnlyServerManager)); }