本文整理汇总了C#中SPWeb.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.Update方法的具体用法?C# SPWeb.Update怎么用?C# SPWeb.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWeb
的用法示例。
在下文中一共展示了SPWeb.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: create_group
protected SPGroup create_group(string group_name, SPWeb web)
{
SPUser user = web.EnsureUser("Administrator");
web.SiteGroups.Add(group_name, user, null, group_name);
SPGroup group = web.SiteGroups[group_name];
web.Update();
SPRoleAssignment assignment = new SPRoleAssignment(group);
SPRoleDefinition role = web.RoleDefinitions["读取"];
assignment.RoleDefinitionBindings.Add(role);
web.RoleAssignments.Add(assignment);
return group;
}
示例2: WriteToLog
internal static void WriteToLog(SPWeb web, string message)
{
ASCIIEncoding enc = new ASCIIEncoding();
UnicodeEncoding uniEncoding = new UnicodeEncoding();
string errors = message;
SPFile files = web.GetFile("/" + DocumentLibraryName + "/" + LogFileName);
if (files.Exists)
{
byte[] fileContents = files.OpenBinary();
string newContents = enc.GetString(fileContents) + Environment.NewLine + errors;
files.SaveBinary(enc.GetBytes(newContents));
}
else
{
using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(ms, uniEncoding))
{
sw.Write(errors);
}
SPFolder LogLibraryFolder = web.Folders[DocumentLibraryName];
LogLibraryFolder.Files.Add(LogFileName, ms.ToArray(), false);
}
}
web.Update();
}
示例3: DeployRegionalSettings
private void DeployRegionalSettings(object modelHost, SPWeb web, RegionalSettingsDefinition definition)
{
var settings = GetCurrentRegionalSettings(web);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = settings,
ObjectType = typeof(SPRegionalSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
MapRegionalSettings(settings, definition);
web.RegionalSettings = settings;
web.Update();
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = settings,
ObjectType = typeof(SPRegionalSettings),
ObjectDefinition = definition,
ModelHost = modelHost
});
}
示例4: DeployDefinition
private void DeployDefinition(object modelHost, SPWeb web, SearchSettingsDefinition definition)
{
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = web,
ObjectType = typeof(SPWeb),
ObjectDefinition = definition,
ModelHost = modelHost
});
ProcessObject(web, definition);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = web,
ObjectType = typeof(SPWeb),
ObjectDefinition = definition,
ModelHost = modelHost
});
web.Update();
}
示例5: InitializeWebDefaultRegionalSettings
public void InitializeWebDefaultRegionalSettings(SPWeb web)
{
// Web regional settings should en-CA or fr-CA, depending on web default language
var settings = web.Language == (uint)Language.English.Culture.LCID ? this.EnglishCanadianSettings(web, false) : this.FrenchCanadianSettings(web, false);
web.RegionalSettings = settings;
web.Update();
}
示例6: UpdateTask
/// <summary>
/// This method update task ref in the root site.
/// </summary>
/// <param name="TaskId">string</param>
/// <param name="IsComplete">bool</param>
public void UpdateTask(int TaskId, string Status, SPWeb Web)
{
SPList ObjTaskList = Web.Lists["Document Approval Tasks"];
SPListItem _task = ObjTaskList.Items.GetItemById(TaskId);
_task["Status"] = Status;
_task.SystemUpdate();
Web.Update();
}
示例7: CreateNewList
internal static void CreateNewList(SPWeb web, string name, string desc, SPListTemplateType type)
{
if (web.Lists.TryGetList(name) == null)
{
web.Lists.Add(name, desc, type);
web.Update();
}
}
示例8: AddTemplateList
public static void AddTemplateList(SPWeb spWeb, String templateName, String templateFilePath, String listName, String listDescription)
{
// Adding Configuration List Template
SPList templateList = spWeb.Site.RootWeb.Lists["List Template Gallery"];
// Uploading Configuration List Template to the Root web
bool f = (from SPFile file in templateList.RootFolder.Files let fileName = Path.GetFileName(templateFilePath) where fileName != null && (file.Name.ToLower() == templateName.ToLower() || fileName.ToLower() == file.Name.ToLower()) select file).Any();
if (f == false)
{
if (File.Exists(templateFilePath))
{
byte[] b = File.ReadAllBytes(templateFilePath);
templateList.RootFolder.Files.Add(Path.GetFileName(templateFilePath), b);
templateList.Update();
spWeb.Update();
}
}
// Creating Configuration List to Web
SPListTemplate listTemplate = spWeb.Site.GetCustomListTemplates(spWeb.Site.RootWeb)[templateName];
SPList slist;
try
{
slist = spWeb.Lists[listName];
}
catch (Exception)
{
slist = null;
}
if (slist == null)
{
spWeb.Lists.Add(listName, listDescription, listTemplate);
spWeb.Update();
}
int index = 0;
foreach (SPListItem item in templateList.Items)
{
if (listName != null)
if (item.DisplayName.ToLower() == listName.ToLower())
{
templateList.Items.Delete(index);
templateList.Update();
break;
}
index += 1;
}
}
示例9: AddEventReceivers
private static void AddEventReceivers(SPWeb web)
{
var documentContentType = web.ContentTypes[new SPContentTypeId("0x01")];
AddEventReceiver(documentContentType, SPEventReceiverType.ItemAdded, typeof(FileChangedEventReceiver), 1000);
AddEventReceiver(documentContentType, SPEventReceiverType.ItemUpdated, typeof(FileChangedEventReceiver), 1001);
AddEventReceiver(documentContentType, SPEventReceiverType.ItemAttachmentAdded, typeof(FileChangedEventReceiver), 1002);
web.Update();
ULSLog.LogMessage("Successfully installed global event receivers on base item content type.");
}
示例10: TeamSiteWebFeatureActivatedHandler
internal static void TeamSiteWebFeatureActivatedHandler(SPWeb web, SPFeaturePropertyCollection properties)
{
// Create three additional libraries
CreateNewList(web, "Meeting Notes", "Meeting notes", SPListTemplateType.DocumentLibrary);
CreateNewList(web, "Presentations", "Presentations", SPListTemplateType.DocumentLibrary);
CreateNewList(web, "Issues", "Issues", SPListTemplateType.IssueTracking);
// Set master page
web.MasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, "/_catalogs/masterpage/contoso.master");
web.Update();
}
示例11: AddEventReceiverToWeb
private void AddEventReceiverToWeb(SPWeb currentWeb, SPEventReceiverType type)
{
SPEventReceiverDefinition def = currentWeb.EventReceivers.Add();
def.Name = "Web Event Receiver - " + type.ToString();
def.Type = type;
def.Assembly = Assembly.GetExecutingAssembly().FullName;
def.Class = eventRcvClass;
def.Update();
currentWeb.Update();
}
示例12: EnsureLanguageSupport
public void EnsureLanguageSupport(SPWeb web, CultureInfo language)
{
if (!web.SupportedUICultures.Contains(language))
{
if (!web.IsMultilingual)
{
web.IsMultilingual = true;
}
web.AddSupportedUICulture(language);
web.Update();
}
}
示例13: UpdateMasterPageofWebs
private void UpdateMasterPageofWebs(SPWeb childWeb)
{
childWeb.MasterUrl = MasterUrl;
childWeb.CustomMasterUrl = CustomMasterUrl;
childWeb.Update();
foreach (SPWeb childSubWeb in childWeb.Webs)
{
UpdateMasterPageofWebs(childSubWeb);
}
}
示例14: DeleteCustomAction
/// <summary>
/// Removes a custom action from a web
/// </summary>
/// <param name="web">The SharePoint web</param>
/// <param name="actionName">The ID for the custom action</param>
public void DeleteCustomAction(SPWeb web, string actionName)
{
var customActionId = this.GetCustomActionIdForName(web, actionName);
if (!string.IsNullOrEmpty(customActionId))
{
var customAction = web.UserCustomActions[new Guid(customActionId)];
customAction.Delete();
}
if (!string.IsNullOrEmpty(customActionId))
{
web.Update();
}
}
示例15: ClearWikiPage
public void ClearWikiPage(SPFile wikiFile, SPWeb web)
{
wikiFile.RequireNotNull("wikiFile");
web.RequireNotNull("web");
ChangeWikiContent(wikiFile, string.Empty);
using (SPLimitedWebPartManager limitedWebPartManager = wikiFile.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
List<Microsoft.SharePoint.WebPartPages.WebPart> webParts =
new List<Microsoft.SharePoint.WebPartPages.WebPart>(
from Microsoft.SharePoint.WebPartPages.WebPart w in limitedWebPartManager.WebParts
select w);
webParts.ForEach(w => limitedWebPartManager.DeleteWebPart(w));
}
web.Update();
}