本文整理匯總了C#中WebsitePanel.Providers.Web.WebServer.GetSite方法的典型用法代碼示例。如果您正苦於以下問題:C# WebServer.GetSite方法的具體用法?C# WebServer.GetSite怎麽用?C# WebServer.GetSite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebsitePanel.Providers.Web.WebServer
的用法示例。
在下文中一共展示了WebServer.GetSite方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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;
}
示例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;
}
示例3: 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();
}
}