本文整理汇总了C#中SPWeb.GetList方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.GetList方法的具体用法?C# SPWeb.GetList怎么用?C# SPWeb.GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWeb
的用法示例。
在下文中一共展示了SPWeb.GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewsRepository
public NewsRepository(string listNewsUrl)
{
_listNewsUrl = listNewsUrl;
_spSite = new SPSite(NewsString.RootSiteUrl);
_spWeb = _spSite.RootWeb;
_spList = _spWeb.GetList(_listNewsUrl);
_spPicture = _spWeb.GetList(NewsString.PiclibaryUrl);
}
示例2: ImportSecurity
public static void ImportSecurity(XmlDocument xmlDoc, bool includeItemSecurity, SPWeb web)
{
Logger.Write("Start Time: {0}.", DateTime.Now.ToString());
foreach (XmlElement listElement in xmlDoc.SelectNodes("//List"))
{
SPList list = null;
try
{
list = web.GetList(web.ServerRelativeUrl.TrimEnd('/') + "/" + listElement.GetAttribute("Url"));
}
catch (ArgumentException) { }
catch (FileNotFoundException) { }
if (list == null)
{
Console.WriteLine("WARNING: List was not found - skipping.");
continue;
}
ImportSecurity(list, web, includeItemSecurity, listElement);
}
Logger.Write("Finish Time: {0}.\r\n", DateTime.Now.ToString());
}
示例3: GenerateRequestCode
public static string GenerateRequestCode(SPWeb web, string Code, int Month, int Year)
{
SPQuery query;
string result = string.Empty;
string WhereClause = "<Where>" +
"<And>" +
"<Eq>" +
"<FieldRef Name='Title' />" +
"<Value Type='Text'>{0}</Value>" +
"</Eq>" +
"<And>" +
"<Eq>" +
"<FieldRef Name='Month' />" +
"<Value Type='Number'>{1}</Value>" +
"</Eq>" +
"<Eq>" +
"<FieldRef Name='Year' />" +
"<Value Type='Number'>{2}</Value>" +
"</Eq>" +
"</And>" +
"</And>" +
"</Where>";
query = new SPQuery();
query.Query = string.Format(WhereClause, Code, Month.ToString(), Year.ToString());
SPList list = web.GetList(MyUtil.CreateSharePointListStrUrl(web.Url, "RequestCode"));
web.AllowUnsafeUpdates = true;
SPListItemCollection coll = list.GetItems(query);
if (coll.Count == 0)
{
SPListItem itemAdd = list.Items.Add();
itemAdd["Title"] = Code;
itemAdd["Month"] = Month.ToString();
itemAdd["Year"] = Year.ToString();
itemAdd["Counter"] = 1;
itemAdd.Update();
result = string.Format("{0}{1}{2}{3}", Code, Year.ToString(), Month.ToString("0#"), Convert.ToInt32(1).ToString("00000#"));
}
else
{
int Counter = 0;
SPListItem item = coll[0];
Counter = Convert.ToInt32(item["Counter"].ToString()) + 1;
item["Counter"] = Counter;
item.Update();
result = string.Format("{0}{1}{2}{3}", Code, Year.ToString(), Month.ToString("0#"), Convert.ToInt32(Counter).ToString("00000#"));
}
web.AllowUnsafeUpdates = false;
return result;
}
示例4: Create
/// <summary>
/// Creates a new wall post
/// </summary>
/// <param name="web">The current web</param>
/// <param name="newEntity">The new wall post entity</param>
public void Create(SPWeb web, WallPost newEntity)
{
// Use SPWebContext so that the repo can be used by code called from outside a web request context (e.g. Powershell or OWSTimer)
var list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, ListUrls.WallPosts));
var newListItem = list.AddItem();
this._binder.FromEntity(newEntity, newListItem);
newListItem.Update();
}
示例5: DocumentLibraryManager
public DocumentLibraryManager(SPWeb web, string folderUrl, string pastedItemsJson )
{
this.Web = web;
//this.TargetFolderUrl = folderUrl.Replace(web.ServerRelativeUrl, string.Empty).TrimStart('/');
this.TargetFolderUrl = folderUrl.TrimStart('/');
this.PastedItems = JsonConvert.DeserializeObject<List<PastedItemJson>>(pastedItemsJson);
var doclibUrl = string.Format("{0}/DocLib1", web.Url);
this.ArchiveDocLib = web.GetList(doclibUrl);
}
示例6: getListByUrl
public static SPList getListByUrl(SPWeb web, string listUrl)
{
try {
return web.GetList(web.ServerRelativeUrl + "/lists/" + listUrl);
}
catch (Exception ex) {
logger.Error("List " + listUrl + " was not found", ex.Message.ToString());
throw ex;
}
}
示例7: UpdateResources
private static void UpdateResources(SPWeb web)
{
SPList sitePages = null;
try
{
string listUrl = web.Url + "/" + ListsName.English.CQQNResources;
sitePages = web.GetList(listUrl);
}
catch (Exception ex)
{
//Utilities.LogToUls(ex);
}
if (sitePages == null)
{
Guid listId = web.Lists.Add(ListsName.English.CQQNResources, string.Empty, SPListTemplateType.DocumentLibrary);
sitePages = web.Lists[listId];
sitePages.Title = ListsName.VietNamese.CQQNResources;
sitePages.Update();
}
if (!sitePages.Fields.ContainsField(FieldsName.CQQNResources.Japanese.ResourceType))
{
sitePages.Fields.Add(FieldsName.CQQNResources.English.ResourceType, SPFieldType.Choice, true);
var field = (SPFieldChoice)sitePages.Fields.GetFieldByInternalName(FieldsName.CQQNResources.English.ResourceType);
StringCollection Choices = new StringCollection
{
FieldsName.CQQNResources.FieldValuesDefault.Type.JS,
FieldsName.CQQNResources.FieldValuesDefault.Type.CSS,
FieldsName.CQQNResources.FieldValuesDefault.Type.IMAGE,
FieldsName.CQQNResources.FieldValuesDefault.Type.TEMPLATE,
FieldsName.CQQNResources.FieldValuesDefault.Type.XML
};
foreach (var choice in Choices)
{
field.Choices.Add(choice);
}
field.Title = FieldsName.CQQNResources.Japanese.ResourceType;
field.Update();
}
// Upload files
string resourcesPathCss = SPUtility.GetGenericSetupPath("TEMPLATE\\FEATURES\\CQ.SharePoint.QN\\Resources\\Css");
string resourcesPathJavascript = SPUtility.GetGenericSetupPath("TEMPLATE\\FEATURES\\CQ.SharePoint.QN\\Resources\\Javascript");
string resourcesPathImage = SPUtility.GetGenericSetupPath("TEMPLATE\\FEATURES\\CQ.SharePoint.QN\\Resources\\Images");
UploadFileToDocumentLibrary(resourcesPathCss, web, FieldsName.CQQNResources.FieldValuesDefault.Type.CSS);
UploadFileToDocumentLibrary(resourcesPathJavascript, web, FieldsName.CQQNResources.FieldValuesDefault.Type.JS);
UploadFileToDocumentLibrary(resourcesPathImage, web, FieldsName.CQQNResources.FieldValuesDefault.Type.IMAGE);
}
示例8: GetListInfoByListRelativeUrl
public static SPList GetListInfoByListRelativeUrl(SPWeb web, string listPath)
{
SPList list = null;
try
{
list = web.GetList(listPath);
}
catch (Exception ex)
{
UlsLogging.LogError("List. GetListInfoByListRelativeUrl(SPWeb web, string ListName). Message: {0}, StackTrace: {1}", ex.Message, ex.StackTrace);
}
return list;
}
示例9: GetWallRepliesByPostId
/// <summary>
/// Retrieves all wall replies by their wall post id
/// </summary>
/// <param name="web">The current web</param>
/// <param name="parentPostId">Id of parent wall post</param>
/// <returns>The replies of the post</returns>
public IEnumerable<WallReply> GetWallRepliesByPostId(SPWeb web, int parentPostId)
{
// Use SPWebContext so that the repo can be used by code called from outside a web request context (e.g. Powershell or OWSTimer)
var list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, ListUrls.WallReplies));
var query = new SPQuery();
// CAML.NET doesn't support the LookupId attrbute for FieldRefs
query.Query = CAML.Where(CAML.Eq(CAML.FieldRef(WallFields.PostLookupName).Replace("/>", " LookupId=\"TRUE\"/>"), CAML.Value("Integer", parentPostId.ToString(CultureInfo.InvariantCulture))));
var items = list.GetItems(query);
return items.Cast<SPListItem>().Select(x => this._binder.Get<WallReply>(x)).ToList();
}
示例10: UpdateMasterpageGallery
private static void UpdateMasterpageGallery(SPFeatureReceiverProperties properties, SPWeb web)
{
ArrayList arrlstMasterpageFilesToOverwrite = new ArrayList();
foreach (SPFeatureProperty p in properties.Feature.Properties)
{
if (p.Name.StartsWith("overwritemasterpagefile"))
{
arrlstMasterpageFilesToOverwrite.Add(p.Value);
}
}
using (web)
{
for (int i = 0; i < arrlstMasterpageFilesToOverwrite.Count; i++)
{
//SPFile fileMasterpage = web.Lists["Master Page Gallery"].RootFolder.Files["woodgroup_site.master"];
string strFileName = arrlstMasterpageFilesToOverwrite[i].ToString();
string strFileNameWithoutExt = Path.GetFileNameWithoutExtension(strFileName);
string strFileExt = Path.GetExtension(strFileName);
try
{
SPFile fileMasterpage = web.GetFile("_catalogs/masterpage/" + strFileName);
if (fileMasterpage != null)
{
if (fileMasterpage.CheckOutType != SPFile.SPCheckOutType.None)
{
fileMasterpage.CheckIn("checked in by feature");
}
fileMasterpage.CheckOut();
//backup file will show up in Master Page/Page Layout dropdowns so either Hide them or dont make a backup
//fileMasterpage.CopyTo(web.Url + "/_catalogs/masterpage/" + strFileNameWithoutExt + "_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + strFileExt);
string strPathNewMasterPage = properties.Definition.RootDirectory + "/MOMasterpages/" + strFileName;
if (File.Exists(strPathNewMasterPage))
{
byte[] fcontents = File.ReadAllBytes(strPathNewMasterPage);
web.GetList("/_catalogs/masterpage/").RootFolder.Files.Add(strFileName, fcontents, true);
// web.Lists["Raccolta pagine master"].RootFolder.Files.Add(strFileName, fcontents, true);
fileMasterpage.Update();
fileMasterpage.CheckIn("checked in by feature");
fileMasterpage.Publish("successfully published by feature");
fileMasterpage.Approve("approved by site feature");
}
}
}
catch
{
}
}
}
}
示例11: GetByUrl
public SPList GetByUrl(SPWeb web, string listUrl)
{
SPList list = null;
try
{
list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, listUrl));
}
catch (ArgumentException)
{
this._logger.Warn("Failed to find list " + listUrl + " in web " + web.ServerRelativeUrl);
}
return list;
}
示例12: GetTargetList
public static SPList GetTargetList(SPWeb targetWeb, string listTitle, string listUrl, Guid? listId)
{
SPList result = null;
if (listId.HasValue && listId != default(Guid))
result = targetWeb.Lists[listId.Value];
else if (!string.IsNullOrEmpty(listUrl))
result = targetWeb.GetList(SPUrlUtility.CombineUrl(targetWeb.ServerRelativeUrl, listUrl));
else if (!string.IsNullOrEmpty(listTitle))
result = targetWeb.Lists.TryGetList(listTitle);
else
{
throw new SPMeta2Exception("ListUrl, ListTitle or ListId should be defined.");
}
return result;
}
示例13: IndexItems
/// <summary>
/// Submit all selected items to the SharePoint Content Organizer
/// Note that user must have EditListItems and DeleteListItem to reindex a document.
/// </summary>
private void IndexItems(SPWeb web)
{
// Get Query String Parameters
var listUrlDir = web.Url + "/" + this.Request.QueryString["ListUrlDir"];
var siteUrl = this.Request.QueryString["SiteUrl"];
var items = this.Request["Items"] != null ? this.Request["Items"].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries) : new string[] { };
// Allow unsafe updates to edit the curretn list items
web.AllowUnsafeUpdates = true;
// Ge the target list
var list = web.GetList(listUrlDir);
var host = new SPOfficialFileHost
{
OfficialFileUrl = new Uri(web.Url + "/_vti_bin/OfficialFile.asmx"),
OfficialFileName = "Content Organizer Automatic Indexation",
Action = SPOfficialFileAction.Move
};
string result;
var processedItems = new Collection<string>();
foreach (string id in items)
{
// If the item has not already been processed
if (!processedItems.Contains(id))
{
// Fetch list item
var listItem = list.GetItemById(int.Parse(id, CultureInfo.InvariantCulture));
// Check if the document exist before send (Maybe already routed to the Drop Off Libray through an other selected item)
if (listItem != null)
{
string fileType = listItem.ContentType.Name;
// Send the document to the Content Organizer
listItem.File.SendToOfficialFile(fileType, host, null, SPOfficialFileSubmissionMode.None, out result);
}
}
}
web.AllowUnsafeUpdates = false;
}
开发者ID:GSoft-SharePoint,项目名称:Dynamite-2010-Example-ContentOrganizer,代码行数:49,代码来源:ContentOrganizerProcessing.aspx.cs
示例14: AllWallPosts
/// <summary>
/// Retrieves all wall posts from SharePoint list
/// </summary>
/// <param name="web">The current web</param>
/// <returns>All wall post entities</returns>
public IEnumerable<WallPost> AllWallPosts(SPWeb web)
{
// Use SPWebContext so that the repo can be used by code called from outside a web request context (e.g. Powershell or OWSTimer)
var list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, ListUrls.WallPosts));
var items = list.Items;
var mappedPosts = items.Cast<SPListItem>().Select(x => this._binder.Get<WallPost>(x)).ToList();
// Join with wall replies to populate each post's replies collection
mappedPosts.ForEach(post =>
{
post.Replies = this._wallRepliesRepository.GetWallRepliesByPostId(web, post.Id).ToList();
this._log.Info(string.Format(CultureInfo.InvariantCulture, "Found {0} replies for post {1}", post.Replies.Count(), post.Id));
});
return mappedPosts;
}
示例15: GetByUrl
/// <summary>
/// Find a list by its web-relative url
/// </summary>
/// <param name="web">The context's web</param>
/// <param name="listUrl">The web-relative path to the list</param>
/// <returns>The list</returns>
public SPList GetByUrl(SPWeb web, Uri listUrl)
{
SPList list = null;
if (listUrl.IsAbsoluteUri)
{
throw new ArgumentException("Provided listUrl should be relative (only the sub-path after the SPWeb URL).");
}
try
{
list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, listUrl.ToString()));
}
catch (ArgumentException)
{
this.logger.Warn("Failed to find list " + listUrl + " in web " + web.ServerRelativeUrl);
}
return list;
}