• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Web.WebServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WebsitePanel.Providers.Web.WebServer的典型用法代码示例。如果您正苦于以下问题:C# WebServer类的具体用法?C# WebServer怎么用?C# WebServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebServer类属于WebsitePanel.Providers.Web命名空间,在下文中一共展示了WebServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddWebSite

        public static int AddWebSite(int packageId, int domainId, int packageAddressId,
            bool addInstantAlias)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // check package
            int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check quota
            QuotaValueInfo sitesQuota = PackageController.GetPackageQuota(packageId, Quotas.WEB_SITES);
            if (sitesQuota.QuotaExhausted)
                return BusinessErrorCodes.ERROR_WEB_SITES_QUOTA_LIMIT;

            // load domain name
            DomainInfo domain = ServerController.GetDomain(domainId);
            string domainName = domain.DomainName;

            // check if the web site already exists
            if (PackageController.GetPackageItemByName(packageId, domainName, typeof(WebSite)) != null)
                return BusinessErrorCodes.ERROR_WEB_SITE_ALREADY_EXISTS;

            // place log record
            TaskManager.StartTask("WEB_SITE", "ADD", domainName);

            try
            {

                // get service
                int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
                if (serviceId == 0)
                    return BusinessErrorCodes.ERROR_WEB_SITE_SERVICE_UNAVAILABLE;

				#region Fix for bug #587
				// Initialize IIS provider webservice proxy
				WebServer web = new WebServer();
				ServiceProviderProxy.Init(web, serviceId);

				// Ensure the web site is being created doesn't exist on the server
				if (web.SiteExists(domainName))
				{
					//
					PackageInfo packageInfo = PackageController.GetPackage(packageId);
					//
					ServerInfo serverInfo = ServerController.GetServerById(packageInfo.ServerId);
					// Give as much clues for the issue to an administrator as possible
					TaskManager.WriteError("Web site '{0}' could not be created because site with the name requested already " +
						"exists on '{1}' server.", domainName, serverInfo.ServerName);
					// Return generic operation failed error
					return BusinessErrorCodes.FAILED_EXECUTE_SERVICE_OPERATION;
				} 
				#endregion

                // load web settings
                StringDictionary webSettings = ServerController.GetServiceSettings(serviceId);
                int addressId = Utils.ParseInt(webSettings["SharedIP"], 0);

                bool dedicatedIp = false;
                if (packageAddressId != 0)
                {
                    // dedicated IP
                    PackageIPAddress packageIp = ServerController.GetPackageIPAddress(packageAddressId);
                    if (packageIp != null)
                    {
                        addressId = packageIp.AddressID;
                        dedicatedIp = true;
                    }
                }

                // load assigned IP address
                string ipAddr = "*";
                IPAddressInfo ip = ServerController.GetIPAddress(addressId);
                if (ip != null)
                    ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;

                // load domain instant alias
                string instantAlias = ServerController.GetDomainAlias(packageId, domainName);
                DomainInfo instantDomain = ServerController.GetDomain(instantAlias);
                if (instantDomain == null || instantDomain.WebSiteId > 0)
                    instantAlias = "";

                // load web DNS records
                List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(serviceId);

                // prepare site bindings
                List<ServerBinding> bindings = new List<ServerBinding>();

                if (!dedicatedIp)
                {
                    // SHARED IP
                    // fill main domain bindings
                    FillWebServerBindings(bindings, dnsRecords, ipAddr, domain.DomainName);

                    // fill alias bindings if required
                    if (addInstantAlias && !String.IsNullOrEmpty(instantAlias))
                    {
                        // fill bindings from DNS "A" records
                        FillWebServerBindings(bindings, dnsRecords, ipAddr, instantAlias);
//.........这里部分代码省略.........
开发者ID:jordan49,项目名称:websitepanel,代码行数:101,代码来源:WebServerController.cs


示例2: GetWebSite

        public static WebSite GetWebSite(int siteItemId)
        {
            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return null;

            // load live site from service
            WebServer web = new WebServer();
            ServiceProviderProxy.Init(web, siteItem.ServiceId);
            WebSite site = web.GetSite(siteItem.SiteId);
            
            // set other properties
            site.Id = siteItem.Id;
            site.Name = siteItem.Name;
            site.ServiceId = siteItem.ServiceId;
            site.PackageId = siteItem.PackageId;

            // load IP address
            site.SiteIPAddressId = siteItem.SiteIPAddressId;
            IPAddressInfo ip = ServerController.GetIPAddress(siteItem.SiteIPAddressId);
            if(ip != null)
                site.SiteIPAddress = ip.ExternalIP;

            // truncate home folder
            site.ContentPath = FilesController.GetVirtualPackagePath(siteItem.PackageId, site.ContentPath);

            //check if Coldfusion is available
            //site.ColdFusionAvailable = siteItem.ColdFusionAvailable;
            
            // set FrontPage account
            site.FrontPageAccount = siteItem.FrontPageAccount;
            if (String.IsNullOrEmpty(site.FrontPageAccount))
                site.FrontPageAccount = GetFrontPageUsername(site.Name);

			#region Restore Web Deploy publishing persistent properties
			// Set Web Deploy publishing account
			site.WebDeployPublishingAccount = siteItem.WebDeployPublishingAccount;
			// Set Web Deploy site publishing enabled
			site.WebDeploySitePublishingEnabled = siteItem.WebDeploySitePublishingEnabled;
			// Set Web Deploy site publishing profile
			site.WebDeploySitePublishingProfile = siteItem.WebDeploySitePublishingProfile;
			#endregion

            return site;
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:46,代码来源:WebServerController.cs


示例3: ChangeFrontPagePassword

        public static int ChangeFrontPagePassword(int siteItemId, string password)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "CHANGE_FP_PASSWORD", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("FrontPage username", siteItem.FrontPageAccount);

            try
            {
                if (String.IsNullOrEmpty(siteItem.FrontPageAccount))
                    siteItem.FrontPageAccount = GetFrontPageUsername(siteItem.Name);

                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                web.ChangeFrontPagePassword(siteItem.FrontPageAccount, password);

                // update site with FP account
                siteItem.FrontPagePassword = CryptoUtils.Encrypt(password);
                PackageController.UpdatePackageItem(siteItem);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:40,代码来源:WebServerController.cs


示例4: GetVirtualDirectory

        public static WebVirtualDirectory GetVirtualDirectory(int siteItemId, string vdirName)
        {
            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return null;

            // create directory
            WebServer web = new WebServer();
            ServiceProviderProxy.Init(web, siteItem.ServiceId);
            WebVirtualDirectory vdir = web.GetVirtualDirectory(siteItem.SiteId, vdirName);
            // truncate home folder
            vdir.ContentPath = FilesController.GetVirtualPackagePath(siteItem.PackageId, vdir.ContentPath);

            // set name
            vdir.ParentSiteName = siteItem.Name;
            vdir.PackageId = siteItem.PackageId;
            return vdir;
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:19,代码来源:WebServerController.cs


示例5: DeleteWebSitePointer

        public static int DeleteWebSitePointer(int siteItemId, int domainId, bool updateWebSite)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // load domain item
            DomainInfo domain = ServerController.GetDomain(domainId);
            if (domain == null)
                return BusinessErrorCodes.ERROR_DOMAIN_PACKAGE_ITEM_NOT_FOUND;

            // load appropriate zone
            DnsZone zone = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);
            //if (zone == null)
            //    return BusinessErrorCodes.ERROR_DNS_PACKAGE_ITEM_NOT_FOUND;

            // get zone records for the service
            List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(siteItem.ServiceId);

            // change DNS zone
            IPAddressInfo ip = ServerController.GetIPAddress(siteItem.SiteIPAddressId);
            if (ip == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_IP_ADDRESS_NOT_SPECIFIED;

            List<DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(
                dnsRecords, domain.DomainName, ip.ExternalIP);

            // place log record
            TaskManager.StartTask("WEB_SITE", "DELETE_POINTER", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("Domain pointer", domain.DomainName);

            try
            {
                if (zone != null)
                {
                    try
                    {
                        DNSServer dns = new DNSServer();
                        ServiceProviderProxy.Init(dns, zone.ServiceId);
                        dns.DeleteZoneRecords(zone.Name, resourceRecords.ToArray());
                    }
                    catch(Exception ex1)
                    {
                        TaskManager.WriteError(ex1, "Error deleting DNS records");
                    }
                }

                // load web settings
                StringDictionary webSettings = ServerController.GetServiceSettings(siteItem.ServiceId);
                int sharedIpId = Utils.ParseInt(webSettings["SharedIP"], 0);

                bool dedicatedIp = (siteItem.SiteIPAddressId != sharedIpId);

                if (updateWebSite && !dedicatedIp)
                {

                    // update host headers
                    WebServer web = new WebServer();
                    ServiceProviderProxy.Init(web, siteItem.ServiceId);

                    List<ServerBinding> bindings = new List<ServerBinding>();
                    bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));

                    // remove host headers
                    List<ServerBinding> domainBindings = new List<ServerBinding>();
                    FillWebServerBindings(domainBindings, dnsRecords, "", domain.DomainName);

                    // fill to remove list
                    List<string> headersToRemove = new List<string>();
                    foreach (ServerBinding domainBinding in domainBindings)
                    {
                        headersToRemove.Add(domainBinding.Host);
                    }

                    int pos = 0;
                    while (pos < bindings.Count)
                    {
                        if (headersToRemove.Contains(bindings[pos].Host))
                        {
                            bindings.RemoveAt(pos);
                            continue;
                        }
                        else
                        {
                            pos++;
                        }
                    }

                    web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray());
                }

                // update domain
                domain.WebSiteId = 0;
                ServerController.UpdateDomain(domain);
//.........这里部分代码省略.........
开发者ID:jordan49,项目名称:websitepanel,代码行数:101,代码来源:WebServerController.cs


示例6: DeleteWebSite

        public static int DeleteWebSite(int siteItemId)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load web site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "DELETE", siteItem.Name);
            TaskManager.ItemId = siteItemId;

            // delete web site
            try
            {
				// remove all web site pointers
				List<DomainInfo> pointers = GetWebSitePointers(siteItemId);
				foreach (DomainInfo pointer in pointers)
					DeleteWebSitePointer(siteItemId, pointer.DomainId, false);

				// remove web site main pointer
				DomainInfo domain = ServerController.GetDomain(siteItem.Name);
				if(domain != null)
					DeleteWebSitePointer(siteItemId, domain.DomainId, false);

				// delete web site
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);

				#region Fix for bug #710
				//
				if (web.IsFrontPageSystemInstalled() && web.IsFrontPageInstalled(siteItem.SiteId))
				{
					web.UninstallFrontPage(siteItem.SiteId, siteItem.FrontPageAccount);
				} 
				#endregion

				//
                web.DeleteSite(siteItem.SiteId);

                // delete service item
                PackageController.DeletePackageItem(siteItemId);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:57,代码来源:WebServerController.cs


示例7: DeleteWebSitePointer

        public static int DeleteWebSitePointer(int siteItemId, int domainId, bool updateWebSite)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // load domain item
            DomainInfo domain = ServerController.GetDomain(domainId);
            if (domain == null)
                return BusinessErrorCodes.ERROR_DOMAIN_PACKAGE_ITEM_NOT_FOUND;

            // load appropriate zone
            DnsZone zone = (DnsZone)PackageController.GetPackageItem(domain.ZoneItemId);

            // get zone records for the service
            List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(siteItem.ServiceId);

            // load web site IP address
            IPAddressInfo ip = ServerController.GetIPAddress(siteItem.SiteIPAddressId);

            // place log record
            TaskManager.StartTask("WEB_SITE", "DELETE_POINTER", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("Domain pointer", domain.DomainName);

            try
            {
                if (zone != null)
                {
                    // change DNS zone
                    string serviceIp = (ip != null) ? ip.ExternalIP : null;

                    List<DnsRecord> resourceRecords = DnsServerController.BuildDnsResourceRecords(
                        dnsRecords, domain.DomainName, serviceIp);

                    try
                    {
                        DNSServer dns = new DNSServer();
                        ServiceProviderProxy.Init(dns, zone.ServiceId);
                        dns.DeleteZoneRecords(zone.Name, resourceRecords.ToArray());
                    }
                    catch(Exception ex1)
                    {
                        TaskManager.WriteError(ex1, "Error deleting DNS records");
                    }
                }

                if (updateWebSite)
                {
                    // get existing web site bindings
                    WebServer web = new WebServer();
                    ServiceProviderProxy.Init(web, siteItem.ServiceId);

                    List<ServerBinding> bindings = new List<ServerBinding>();
                    bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));

                    // check if web site has dedicated IP assigned
                    bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });

                    // update binding only for "shared" ip addresses
                    if (!dedicatedIp)
                    {
                        // remove host headers
                        List<ServerBinding> domainBindings = new List<ServerBinding>();
                        FillWebServerBindings(domainBindings, dnsRecords, "", domain.DomainName);

                        // fill to remove list
                        List<string> headersToRemove = new List<string>();
                        foreach (ServerBinding domainBinding in domainBindings)
                            headersToRemove.Add(domainBinding.Host);

                        // remove bndings
                        bindings.RemoveAll(b => { return headersToRemove.Contains(b.Host) && b.Port == "80"; } );

                        // update bindings
                        web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray());
                    }
                }

                // update domain
                domain.WebSiteId = 0;
                ServerController.UpdateDomain(domain);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:99,代码来源:WebServerController.cs


示例8: GetAppPoolState

        public static AppPoolState GetAppPoolState(int siteItemId)
        {
            AppPoolState state = AppPoolState.Unknown;

            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return state;

            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return state;

            // check package
            int packageCheck = SecurityContext.CheckPackage(siteItem.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return state;

            // place log record
            TaskManager.StartTask("WEB_SITE", "GET_STATE", siteItem.Name);
            TaskManager.ItemId = siteItemId;

            try
            {
                // get state
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                state = web.GetAppPoolState(siteItem.SiteId);
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }

            return state;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:39,代码来源:WebServerController.cs


示例9: DeleteWebSite

        public static int DeleteWebSite(int siteItemId, bool deleteWebsiteDirectory)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load web site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "DELETE", siteItem.Name, siteItemId);

            // delete web site
            try
            {
				//cleanup certificates
                //cleanup certificates
                List<SSLCertificate> certificates = GetCertificatesForSite(siteItemId);
                foreach (SSLCertificate c in certificates)
                {
                    DeleteCertificate(siteItemId, c);
                }
                
                // remove all web site pointers
				List<DomainInfo> pointers = GetWebSitePointers(siteItemId);
				foreach (DomainInfo pointer in pointers)
					DeleteWebSitePointer(siteItemId, pointer.DomainId, false, true, true);

				// remove web site main pointer
				DomainInfo domain = ServerController.GetDomain(siteItem.Name);
				if(domain != null)
					DeleteWebSitePointer(siteItemId, domain.DomainId, false, true, true);

                List<WebSite> sites = WebServerController.GetWebSites(domain.PackageId, false);
                bool oneSiteOnly = (sites.Count == 1);

                if (oneSiteOnly)
                {
                    // load site item
                    IPAddressInfo ip = ServerController.GetIPAddress(sites[0].SiteIPAddressId);

                    string serviceIp = (ip != null) ? ip.ExternalIP : null;

                    if (string.IsNullOrEmpty(serviceIp))
                    {
                        StringDictionary settings = ServerController.GetServiceSettings(sites[0].ServiceId);
                        if (settings["PublicSharedIP"] != null)
                            serviceIp = settings["PublicSharedIP"].ToString();
                    }

                    ServerController.RemoveServiceDNSRecords(domain.PackageId, ResourceGroups.Web, domain, serviceIp, true);
                }




				// delete web site
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);

				//
				if (web.IsFrontPageSystemInstalled() && web.IsFrontPageInstalled(siteItem.SiteId))
				{
					web.UninstallFrontPage(siteItem.SiteId, siteItem.FrontPageAccount);
				} 

				//
                web.DeleteSite(siteItem.SiteId);

                // Delete WebManagementAccess Account
                WebServerController.RevokeWebManagementAccess(siteItemId);

                if (deleteWebsiteDirectory)
                {
                    // Delete website directory from file server
                    // This will remove the hard quota as well
                    FilesController.DeleteDirectoryRecursive(siteItem.PackageId, new DirectoryInfo(siteItem.DataPath).Parent.FullName);

                }
                // delete service item
                PackageController.DeletePackageItem(siteItemId);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:95,代码来源:WebServerController.cs


示例10: SetZooConsoleDisabled

        public static StringResultObject SetZooConsoleDisabled(int siteItemId, string appName)
        {
            StringResultObject result = new StringResultObject { IsSuccess = false };


            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return result;


            WebServer web = new WebServer();
            ServiceProviderProxy.Init(web, siteItem.ServiceId);
            return web.SetZooConsoleDisabled(siteItem.SiteId, appName);
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:15,代码来源:WebServerController.cs


示例11: ImporHostHeader

        public static int ImporHostHeader(int userId, int packageId, int siteId)
        {
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteId);
            if (siteItem == null)
                return -1;

            // load live site from service
            WebServer web = new WebServer();
            ServiceProviderProxy.Init(web, siteItem.ServiceId);

            // Verify if already exists
            List<DomainInfo> domains = ServerController.GetDomains(packageId);

            // Get hostheader
            foreach (ServerBinding b in web.GetSiteBindings(siteItem.SiteId))
            {
                if ((!DoesHeaderExistInDomains(b.Host.ToLower(), domains)) && (!string.IsNullOrEmpty(b.Host)))
                {
                    // If not get domain info and add to domains
                    int domainId = FindDomainForHeader(b.Host.ToLower(), domains);
                    if (domainId > 0)
                    {
                        DomainInfo domain = ServerController.GetDomain(domainId);
                        DomainInfo newDomain = new DomainInfo();
                        newDomain.DomainName = b.Host.ToLower();
                        newDomain.PackageId = domain.PackageId;
                        newDomain.IsDomainPointer = true;

                        int newDomainID = ServerController.AddDomain(newDomain, domain.IsInstantAlias, false);
                        if (newDomainID > 0)
                        {
                            newDomain = ServerController.GetDomain(newDomainID);
                            if (newDomain != null)
                            {
                                newDomain.WebSiteId = siteId;
                                newDomain.ZoneItemId = domain.ZoneItemId;
                                newDomain.DomainItemId = domain.DomainId;
                                ServerController.UpdateDomain(newDomain);
                            }
                        }
                    }
                }
            }

            return 0;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:46,代码来源:WebServerController.cs


示例12: AddWebSitePointer


//.........这里部分代码省略.........
                            }
                        }
                    }

                    try
                    {
                        DNSServer dns = new DNSServer();
                        ServiceProviderProxy.Init(dns, zone.ServiceId);

                        DnsRecord[] domainRecords = dns.GetZoneRecords(zone.Name);
                        var duplicateRecords = (from zoneRecord in domainRecords
                                                from resRecord in resourceRecords
                                                where zoneRecord.RecordName == resRecord.RecordName
                                                where zoneRecord.RecordType == resRecord.RecordType
                                                select zoneRecord).ToArray();
                        if (duplicateRecords != null && duplicateRecords.Count() > 0)
                        {
                            dns.DeleteZoneRecords(zone.Name, duplicateRecords);
                        }

                        // add new resource records
                        dns.AddZoneRecords(zone.Name, resourceRecords.ToArray());
                    }
                    catch (Exception ex1)
                    {
                        TaskManager.WriteError(ex1, "Error updating DNS records");
                    }
                }

                // update host headers
                List<ServerBinding> bindings = new List<ServerBinding>();

                // get existing web site bindings
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                    
                bindings.AddRange(web.GetSiteBindings(siteItem.SiteId));

                // check if web site has dedicated IP assigned
                bool dedicatedIp = bindings.Exists(binding => { return String.IsNullOrEmpty(binding.Host) && binding.IP != "*"; });

                // update binding only for "shared" ip addresses
                // add new host headers
                string ipAddr = "*";
                if (ip != null)
                    ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP;

                // fill bindings
                FillWebServerBindings(bindings, dnsRecords, ipAddr, hostName, domain.DomainName, ignoreGlobalDNSRecords);

                //for logging purposes
                foreach (ServerBinding b in bindings)
                {
                    string header = string.Format("{0} {1} {2}", b.Host, b.IP, b.Port);
                    TaskManager.WriteParameter("Add Binding", header);
                }

                // update bindings
                if (updateWebSite)
                    web.UpdateSiteBindings(siteItem.SiteId, bindings.ToArray(), false);

                // update domain
                if (!rebuild)
                {
                    domain.WebSiteId = siteItemId;
                    domain.IsDomainPointer = true;
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:67,代码来源:WebServerController.cs


示例13: GetWebSite

        public static WebSite GetWebSite(int siteItemId)
        {
            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return null;

            // load live site from service
            WebServer web = new WebServer();
            ServiceProviderProxy.Init(web, siteItem.ServiceId);
            WebSite site = web.GetSite(siteItem.SiteId);
            
            // set other properties
            site.Id = siteItem.Id;
            site.Name = siteItem.Name;
            site.ServiceId = siteItem.ServiceId;
            site.PackageId = siteItem.PackageId;

            // load IP address
            site.SiteIPAddressId = siteItem.SiteIPAddressId;
            IPAddressInfo ip = ServerController.GetIPAddress(siteItem.SiteIPAddressId);
            if(ip != null)
                site.SiteIPAddress = ip.ExternalIP;

            // check if site has dedicated IP assigned
            var siteIpAddresses = ServerController.GetItemIPAddresses(siteItemId, IPAddressPool.None);
            foreach (var siteIp in siteIpAddresses)
            {
                var packageIpAddress = ServerController.GetPackageIPAddress(siteIp.AddressID);
                if (packageIpAddress != null && packageIpAddress.ExternalIP == site.SiteIPAddress)
                {
                    site.IsDedicatedIP = true;
                    break;
                }
            }

            // truncate home folder
            site.ContentPath = FilesController.GetVirtualPackagePath(siteItem.PackageId, site.ContentPath);

            //check if Coldfusion is available
            //site.ColdFusionAvailable = siteItem.ColdFusionAvailable;
            
            // set FrontPage account
            site.FrontPageAccount = siteItem.FrontPageAccount;
            if (String.IsNullOrEmpty(site.FrontPageAccount))
                site.FrontPageAccount = GetFrontPageUsername(site.Name);

			// Set Web Deploy publishing account
			site.WebDeployPublishingAccount = siteItem.WebDeployPublishingAccount;
			// Set Web Deploy site publishing enabled
			site.WebDeploySitePublishingEnabled = siteItem.WebDeploySitePublishingEnabled;
			// Set Web Deploy site publishing profile
			site.WebDeploySitePublishingProfile = siteItem.WebDeploySitePublishingProfile;

            return site;
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:56,代码来源:WebServerController.cs


示例14: AddSite

        public static int AddSite(StatsSite item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // check package
            int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check quota
            QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.STATS_SITES);
            if (quota.QuotaExhausted)
                return BusinessErrorCodes.ERROR_STATS_RESOURCE_QUOTA_LIMIT;

            // check if stats resource is available
            int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Statistics);
            if (serviceId == 0)
                return BusinessErrorCodes.ERROR_STATS_RESOURCE_UNAVAILABLE;

            // check package items
            if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(StatsSite)) != null)
                return BusinessErrorCodes.ERROR_STATS_PACKAGE_ITEM_EXISTS;

            // place log record
            TaskManager.StartTask("STATS_SITE", "ADD", item.Name);

            try
            {
                // load web site
                WebSite siteItem = (WebSite)PackageController.GetPackageItemByName(item.PackageId,
                    item.Name, typeof(WebSite));

                if (siteItem == null)
                    return BusinessErrorCodes.ERROR_WEB_SITE_SERVICE_UNAVAILABLE;

                // get service web site
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                WebSite site = web.GetSite(siteItem.SiteId);

                List<DomainInfo> pointers = WebServerController.GetWebSitePointers(siteItem.Id);
                List<string> aliases = new List<string>();

                foreach(DomainInfo pointer in pointers)
                    aliases.Add(pointer.DomainName);

                StatisticsServer stats = new StatisticsServer();
                ServiceProviderProxy.Init(stats, serviceId);
                string siteNumber = (site.IIs7) ? site[WebSite.IIS7_SITE_ID] : siteItem.SiteId.Replace("/", "");
                string logsCommonFolder = site.LogsPath;
                string logsFolder = Path.Combine(logsCommonFolder, siteNumber);

				// get service settings
				StringDictionary settings = ServerController.GetServiceSettings(serviceId);
				if (Utils.ParseBool(settings["BuildUncLogsPath"], false))
				{
					logsFolder = FilesController.ConvertToUncPath(siteItem.ServiceId, logsFolder);
				}

                item.LogDirectory = logsFolder;
                item.DomainAliases = aliases.ToArray();

                // install statistics
                item.SiteId = stats.AddSite(item);

                // save statistics item
                item.ServiceId = serviceId;
                int itemId = PackageController.AddPackageItem(item);

                TaskManager.ItemId = itemId;

                return itemId;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:83,代码来源:StatisticsServerController.cs


示例15: UpdateWebSite

        public static int UpdateWebSite(WebSite site)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load web site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(site.Id);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "UPDATE", siteItem.Name);
            TaskManager.ItemId = site.Id;

            try
            {
                // update home folder
                string origPath = site.ContentPath;
                site.ContentPath = FilesController.GetFullPackagePath(site.PackageId, site.ContentPath);

                // build data folder path
                site.DataPath = siteItem.DataPath;

                // update site on the service
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                web.UpdateSite(site);
				// Restore settings back
				#region Web Deploy Settings
				site.WebDeployPublishingAccount = siteItem.WebDeployPublishingAccount;
				site.WebDeployPublishingPassword = siteItem.WebDeployPublishingPassword;
				site.WebDeploySitePublishingEnabled = siteItem.WebDeploySitePublishingEnabled;
				site.WebDeploySitePublishingProfile = siteItem.WebDeploySitePublishingProfile;
				#endregion

                // update service item
                PackageController.UpdatePackageItem(site);

                // set origpath
                site.ContentPath = origPath;

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
开发者ID:jordan49,项目名称:websitepanel,代码行数:53,代码来源:WebServerController.cs


示例16: SwitchWebSiteToDedicatedIP

        public static int SwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load web site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            
            int addressId = 0;
            PackageIPAddress packageIp = ServerController.GetPackageIPAddress(ipAddressId);
            if (packageIp != null)
            {
                addressId = packageIp.AddressID;
            }

            List<GlobalDnsRecord> dnsRecords = ServerController.GetDnsRecordsByService(siteItem.ServiceId);

            foreach (GlobalDnsRecord d in dnsRecords)
            {
                if (!string.IsNullOrEmpty(d.ExternalIP))
                {
                    if (!IsValidIPAdddress(d.ExternalIP)) return BusinessErrorCodes.ERROR_GLOBALDNS_FOR_DEDICATEDIP;
                }
            }

            // place log record
            TaskManager.StartTask("WEB_SITE", "SWITCH_TO_DEDICATED_IP", siteItem.Name, siteItemId);

            try
            {
                IPAddressInfo ip;

                // remove all web site pointers
                DomainInfo domain = ServerController.GetDomain(siteItem.Name);
                DomainInfo ZoneInfo = ServerController.GetDomain(domain.DomainItemId);

                if (ZoneInfo == null)
                    throw new Exception("Parent zone not found");

                //cleanup certificates
                List<SSLCertificate> certificates = GetCertificatesForSite(siteItemId);
                foreach (SSLCertificate c in certificates)
                {
                    DeleteCertificate(siteItemId, c);
                }

                certificates = GetPendingCertificates(siteItemId);
                foreach (SSLCertificate c in certificates)
                {
                    DeleteCertificateRequest(siteItemId, c.id);
                }
                
                List<DomainInfo> pointers = GetWebSitePointers(siteItemId);
                foreach (DomainInfo pointer in pointers)
                    DeleteWebSitePointer(siteItemId, pointer.DomainId, true, true, false);

                // remove web site main pointer
                if (domain != null)
                    DeleteWebSitePointer(siteItemId, domain.DomainId, true, true, false);

                // clear binding left overs
                List<ServerBinding> newBindings = new List<ServerBinding>();
                WebServer web = new WebServer();
                ServiceProviderProxy.Init(web, siteItem.ServiceId);
                try
                {
                    web.UpdateSiteBindings(siteItem.SiteId, newBindings.ToArray(), true);
                }
                catch (Exception)
                {

                }

                List<WebSite> sites = WebServerController.GetWebSites(domain.PackageId, false);
                bool oneSiteOnly = (sites.Count == 1);

                if (oneSiteOnly)
                {
                    // load site item
                    ip = ServerController.GetIPAddress(sites[0].SiteIPAddressId);

                    string serviceIp = (ip != null) ? ip.ExternalIP : null;

                    if (string.IsNullOrEmpty(serviceIp))
               

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web.WebSite类代码示例发布时间:2022-05-26
下一篇:
C# Web.SSLCertificate类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap