本文整理汇总了C#中Web类的典型用法代码示例。如果您正苦于以下问题:C# Web类的具体用法?C# Web怎么用?C# Web使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Web类属于命名空间,在下文中一共展示了Web类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
public Web Connect(string url)
{
using (var site = CreateSite(url))
{
using (var web = site.OpenWeb())
{
Web = new Web(this)
{
Id = web.ID,
Url = url,
Title = web.Title
};
Web.Lists = web.Lists.Cast<SPList>().Select(l => new SList
{
Web = Web,
Title = l.Title,
Id = l.ID,
IsHidden = l.Hidden
}).ToList();
return Web;
}
}
}
示例2: PersistFile
internal void PersistFile(Web web, ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope, string folderPath, string fileName, Boolean decodeFileName = false)
{
if (creationInfo.FileConnector != null)
{
SharePointConnector connector = new SharePointConnector(web.Context, web.Url, "dummy");
Uri u = new Uri(web.Url);
if (folderPath.IndexOf(u.PathAndQuery, StringComparison.InvariantCultureIgnoreCase) > -1)
{
folderPath = folderPath.Replace(u.PathAndQuery, "");
}
using (Stream s = connector.GetFileStream(fileName, folderPath))
{
if (s != null)
{
creationInfo.FileConnector.SaveFileStream(decodeFileName ? HttpUtility.UrlDecode(fileName) : fileName, s);
}
}
}
else
{
WriteWarning("No connector present to persist homepage.", ProvisioningMessageType.Error);
scope.LogError("No connector present to persist homepage");
}
}
示例3: SetDocumentAsTemplate
private static void SetDocumentAsTemplate(ClientContext cc, Web web)
{
ContentType ct = web.ContentTypes.GetById("0x0101009189AB5D3D2647B580F011DA2F356FB3");
cc.Load(ct);
cc.ExecuteQuery();
// Get instance to the _cts folder created for the each of the content types
string ctFolderServerRelativeURL = "_cts/" + ct.Name;
Folder ctFolder = web.GetFolderByServerRelativeUrl(ctFolderServerRelativeURL);
cc.Load(ctFolder);
cc.ExecuteQuery();
// Load the local template document
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template.docx");
string fileName = System.IO.Path.GetFileName(path);
byte[] filecontent = System.IO.File.ReadAllBytes(path);
// Uplaod file to the Office365
using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open))
{
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = filecontent;
newFile.Url = ctFolderServerRelativeURL + "/" + fileName;
Microsoft.SharePoint.Client.File uploadedFile = ctFolder.Files.Add(newFile);
cc.Load(uploadedFile);
cc.ExecuteQuery();
}
ct.DocumentTemplate = fileName;
ct.Update(true);
cc.ExecuteQuery();
Console.WriteLine("Document template uploaded and set to the content type.");
}
示例4: Edit
public ActionResult Edit(int id, Web.Models.SlotModel model)
{
_wrapper.UpdateSlot(
Mapper.Map<Model.SlotModel>(Mapper.Map<Model.SlotModel>(model))
);
return RedirectToAction("Index", new { taskId = model.TaskId });
}
示例5: DeployRegionalSettings
private void DeployRegionalSettings(object modelHost, Web web, RegionalSettingsDefinition definition)
{
var settings = GetCurrentRegionalSettings(web);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = settings,
ObjectType = typeof(RegionalSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
MapRegionalSettings(settings, definition);
//web.RegionalSettings = settings;
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = settings,
ObjectType = typeof(RegionalSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
}
示例6: Validate
public static bool Validate(CustomActions sourceCustomActions, CustomActions targetCustomActions, TokenParser tokenParser, Web web)
{
if (web.IsNoScriptSite())
{
Console.WriteLine("Skipping validation of custom actions due to noscript site.");
return true;
}
Console.WriteLine("Custom Action validation started...");
bool isSiteCustomActionsMatch = false;
bool isWebCustomActionsMatch = false;
if (sourceCustomActions.SiteCustomActions.Count > 0)
{
isSiteCustomActionsMatch = ValidateCustomActions(sourceCustomActions.SiteCustomActions, targetCustomActions.SiteCustomActions, tokenParser, web);
Console.WriteLine("Site Custom Actions validation " + isSiteCustomActionsMatch);
}
if (sourceCustomActions.WebCustomActions.Count > 0)
{
isWebCustomActionsMatch = ValidateCustomActions(sourceCustomActions.WebCustomActions, targetCustomActions.WebCustomActions, tokenParser, web);
Console.WriteLine("Web Custom Actions validation " + isWebCustomActionsMatch);
}
if (!isSiteCustomActionsMatch || !isWebCustomActionsMatch)
{
return false;
}
else
{
return true;
}
}
示例7: ProvisionObjects
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
var context = web.Context as ClientContext;
foreach (var handler in template.ExtensibilityHandlers
.Union(template.Providers)
.Union(applyingInformation.ExtensibilityHandlers))
{
if (handler.Enabled)
{
try
{
if (!string.IsNullOrEmpty(handler.Configuration))
{
//replace tokens in configuration data
handler.Configuration = parser.ParseString(handler.Configuration);
}
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_extensibility_callout__0_, handler.Assembly);
_extManager.ExecuteExtensibilityProvisionCallOut(context, handler, template, applyingInformation, parser, scope);
}
catch (Exception ex)
{
scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_callout_failed___0_____1_, ex.Message, ex.StackTrace);
throw;
}
}
}
}
return parser;
}
示例8: Edit
public ActionResult Edit(int id, Web.Models.TaskModel model)
{
_wrapper.UpdateTask(
Mapper.Map<Model.TaskModel>(Mapper.Map<Model.TaskModel>(model))
);
return RedirectToAction("Index", new { projectId = model.ProjectId });
}
示例9: AddPublishingPage
public static void AddPublishingPage(PublishingPage page, ClientContext ctx, Web web)
{
SPPublishing.PublishingPage publishingPage = web.GetPublishingPage(page.FileName + ".aspx");
RemovePublishingPage(publishingPage, page, ctx, web);
web.AddPublishingPage(page.FileName, page.Layout, page.Title, false); //DO NOT Publish here or it will fail if library doesn't enable Minor versions (PnP bug)
publishingPage = web.GetPublishingPage(page.FileName + ".aspx");
Microsoft.SharePoint.Client.File pageFile = publishingPage.ListItem.File;
pageFile.CheckOut();
if (page.Properties != null && page.Properties.Count > 0)
{
ctx.Load(pageFile, p => p.Name, p => p.CheckOutType); //need these values in SetFileProperties
ctx.ExecuteQuery();
pageFile.SetFileProperties(page.Properties, false);
}
if (page.WebParts != null && page.WebParts.Count > 0)
{
Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager mgr = pageFile.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);
ctx.Load(mgr);
ctx.ExecuteQuery();
AddWebpartsToPublishingPage(page, ctx, mgr);
}
List pagesLibrary = publishingPage.ListItem.ParentList;
ctx.Load(pagesLibrary);
ctx.ExecuteQueryRetry();
ListItem pageItem = publishingPage.ListItem;
web.Context.Load(pageItem, p => p.File.CheckOutType);
web.Context.ExecuteQueryRetry();
if (pageItem.File.CheckOutType != CheckOutType.None)
{
pageItem.File.CheckIn(String.Empty, CheckinType.MajorCheckIn);
}
if (page.Publish && pagesLibrary.EnableMinorVersions)
{
pageItem.File.Publish(String.Empty);
if (pagesLibrary.EnableModeration)
{
pageItem.File.Approve(String.Empty);
}
}
if (page.WelcomePage)
{
SetWelcomePage(web, pageFile);
}
ctx.ExecuteQuery();
}
示例10: SPOWebPipeBind
public SPOWebPipeBind()
{
_id = Guid.Empty;
_url = string.Empty;
_spOnlineWeb = null;
_web = null;
}
示例11: RemovePublishingPage
private static void RemovePublishingPage(SPPublishing.PublishingPage publishingPage, PublishingPage page, ClientContext ctx, Web web)
{
if (publishingPage != null && publishingPage.ServerObjectIsNull.Value == false)
{
if (!web.IsPropertyAvailable("RootFolder"))
{
web.Context.Load(web.RootFolder);
web.Context.ExecuteQueryRetry();
}
if (page.Overwrite)
{
if (page.WelcomePage && web.RootFolder.WelcomePage.Contains(page.FileName + ".aspx"))
{
//set the welcome page to a Temp page to allow remove the page
web.RootFolder.WelcomePage = "home.aspx";
web.RootFolder.Update();
web.Update();
ctx.Load(publishingPage);
ctx.ExecuteQuery();
}
publishingPage.ListItem.DeleteObject();
ctx.ExecuteQuery();
}
else
{
return;
}
}
}
示例12: AddExtendedTokens
public TokenParser AddExtendedTokens(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
var context = web.Context as ClientContext;
foreach (var provider in template.Providers)
{
if (provider.Enabled)
{
try
{
if (!string.IsNullOrEmpty(provider.Configuration))
{
provider.Configuration = parser.ParseString(provider.Configuration);
}
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_tokenprovider_extensibility_callout__0_, provider.Assembly);
var _providedTokens = _extManager.ExecuteTokenProviderCallOut(context, provider, template);
if (_providedTokens != null)
{
foreach (var token in _providedTokens)
{
parser.AddToken(token);
}
}
}
catch (Exception ex)
{
scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_tokenprovider_callout_failed___0_____1_, ex.Message, ex.StackTrace);
throw;
}
}
}
return parser;
}
}
示例13: SPOWeb
public SPOWeb(Web web)
{
_web = web;
//if (web.IsObjectPropertyInstantiated("AvailableFields"))
// AvailableFields = web.AvailableFields;
//if (web.IsPropertyAvailable("EffectiveBasePermissions"))
// EffectiveBasePermissions = web.EffectiveBasePermissions;
//if (web.IsObjectPropertyInstantiated("Features"))
// Features = web.Features;
//if (web.IsObjectPropertyInstantiated("Fields"))
// Fields = web.Fields;
//if (web.IsObjectPropertyInstantiated("ListTemplates"))
// ListTemplates = web.ListTemplates;
//if (web.IsObjectPropertyInstantiated("Navigation"))
// Navigation = web.Navigation;
//if (web.IsObjectPropertyInstantiated("RootFolder"))
// RootFolder = web.RootFolder;
//if (web.IsObjectPropertyInstantiated("SiteGroups"))
// SiteGroups = web.SiteGroups;
//if (web.IsObjectPropertyInstantiated("SiteUserInfoList"))
// SiteUserInfoList = web.SiteUserInfoList;
//if (web.IsObjectPropertyInstantiated("SiteUsers"))
// SiteUsers = web.SiteUsers;
}
示例14: Main
static void Main() {
Console.WriteLine("Adding Team Site Content");
Console.WriteLine();
clientContext = new ClientContext(siteUrl);
site = clientContext.Web;
clientContext.Load(site);
clientContext.ExecuteQuery();
WingtipContentGenerator.CreateProductCategoriesTermset();
WingtipContentGenerator.CreateProductsLists();
Console.WriteLine();
Console.WriteLine("The program has finsihed. Press ENTER to close this window");
Console.WriteLine();
Console.ReadLine();
clientContext.ExecuteQuery();
}
示例15: Delete
private void Delete(Web web)
{
if (!base.ShouldProcess(Identity.ToString()))
return;
var ctx = base.Context;
if (!web.IsObjectPropertyInstantiated("Webs"))
{
ctx.Load(web.Webs);
ctx.ExecuteQuery();
}
if (web.Webs.Count > 0)
{
foreach (Web childWeb in web.Webs)
{
Delete(childWeb);
}
if (web.Webs.Count == 0)
{
web.DeleteObject();
web.Context.ExecuteQuery();
}
}
else
{
web.DeleteObject();
web.Context.ExecuteQuery();
}
}