本文整理汇总了C#中ListCreationInformation类的典型用法代码示例。如果您正苦于以下问题:C# ListCreationInformation类的具体用法?C# ListCreationInformation怎么用?C# ListCreationInformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListCreationInformation类属于命名空间,在下文中一共展示了ListCreationInformation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateSharePointRepositoryList
public static List CreateSharePointRepositoryList(Web web, string title, string description, string url)
{
List _requestList = web.GetListByTitle(title);
if(_requestList == null) //List Doesnt Existing
{
var _listCreation = new ListCreationInformation()
{
Title = title,
TemplateType = (int)ListTemplateType.GenericList,
Description = description,
Url = url
};
_requestList = web.Lists.Add(_listCreation);
web.Context.Load(_requestList);
web.Context.ExecuteQuery();
}
var _fields = CreateListFields(web);
var _contentID = CreateContentType(web, SiteRequestList.CONTENTTYPE_NAME,
SiteRequestList.CONTENTTYPE_DESCRIPTION,
SiteRequestList.DEFAULT_CTYPE_GROUP,
SiteRequestList.CONTENTTYPE_ID);
//add fields to CT
BindFieldsToContentType(web, SiteRequestList.CONTENTTYPE_ID, _fields);
AddContentTypeToList(web, SiteRequestList.CONTENTTYPE_ID, SiteRequestList.TITLE, _fields);
return _requestList;
}
开发者ID:Calisto1980,项目名称:PnP,代码行数:30,代码来源:SiteRequestList.cs
示例2: Initialize
public void Initialize()
{
Console.WriteLine("TaxonomyExtensionsTests.Initialise");
// Create some taxonomy groups and terms
using (var clientContext = TestCommon.CreateClientContext())
{
_termGroupName = "Test_Group_" + DateTime.Now.ToFileTime();
_termSetName = "Test_Termset_" + DateTime.Now.ToFileTime();
_termName = "Test_Term_" + DateTime.Now.ToFileTime();
// Termgroup
var taxSession = TaxonomySession.GetTaxonomySession(clientContext);
var termStore = taxSession.GetDefaultSiteCollectionTermStore();
var termGroup = termStore.CreateGroup(_termGroupName, _termGroupId);
clientContext.Load(termGroup);
clientContext.ExecuteQuery();
// Termset
var termSet = termGroup.CreateTermSet(_termSetName, _termSetId, 1033);
clientContext.Load(termSet);
clientContext.ExecuteQuery();
// Term
termSet.CreateTerm(_termName, 1033, _termId);
clientContext.ExecuteQuery();
// List
ListCreationInformation listCI = new ListCreationInformation();
listCI.TemplateType = (int)ListTemplateType.GenericList;
listCI.Title = "Test_List_" + DateTime.Now.ToFileTime();
var list = clientContext.Web.Lists.Add(listCI);
clientContext.Load(list);
clientContext.ExecuteQuery();
_listId = list.Id;
}
}
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:35,代码来源:TaxonomyExtensionsTests.cs
示例3: CreateDefaultList
public void CreateDefaultList(ClientContext context, Web web)
{
// Create a list
var listInfo = new ListCreationInformation
{
Title = "Default List",
TemplateType = (int)ListTemplateType.GenericList
};
var list = web.Lists.Add(listInfo);
list.Description = "A default list that is provisioned.";
list.EnableVersioning = true;
list.Update();
context.ExecuteQuery();
// Add a field
var field = list.Fields.AddFieldAsXml("<Field DisplayName='My Number1' Type='Number' />", true, AddFieldOptions.DefaultValue);
var numberField = context.CastTo<FieldNumber>(field);
numberField.MaximumValue = 1000;
numberField.MinimumValue = 10;
numberField.Update();
// Add a second field
var field2 = list.Fields.AddFieldAsXml("<Field DisplayName='My Number2' Type='Number' />", true, AddFieldOptions.DefaultValue);
context.ExecuteQuery();
}
开发者ID:mehrosu,项目名称:SPOEmulators,代码行数:26,代码来源:ProvisioningEngine.cs
示例4: AddList
/// <summary>
/// Adds a list to a site
/// </summary>
/// <param name="properties">Site to operate on</param>
/// <param name="listType">Type of the list</param>
/// <param name="featureID">Feature guid that brings this list type</param>
/// <param name="listName">Name of the list</param>
/// <param name="enableVersioning">Enable versioning on the list</param>
public bool AddList(ClientContext ctx, Web web, int listType, Guid featureID, string listName, bool enableVersioning)
{
bool created = false;
ListCollection listCollection = web.Lists;
ctx.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == listName));
ctx.ExecuteQuery();
if (listCollection.Count == 0)
{
ListCreationInformation lci = new ListCreationInformation();
lci.Title = listName;
lci.TemplateFeatureId = featureID;
lci.TemplateType = listType;
List newList = web.Lists.Add(lci);
if (enableVersioning)
{
newList.EnableVersioning = true;
newList.EnableMinorVersions = true;
}
newList.Update();
ctx.ExecuteQuery();
created = true;
}
return created;
}
开发者ID:NicolajLarsen,项目名称:PnP,代码行数:35,代码来源:LabHelper.cs
示例5: CreateListInternal
private static void CreateListInternal(this Web web, ListTemplateType listType, string listName, bool enableVersioning, bool updateAndExecuteQuery = true, string urlPath = "")
{
ListCollection listCol = web.Lists;
ListCreationInformation lci = new ListCreationInformation();
lci.Title = listName;
lci.TemplateType = (int)listType;
if (!string.IsNullOrEmpty(urlPath))
lci.Url = urlPath;
List newList = listCol.Add(lci);
if (enableVersioning)
{
newList.EnableVersioning = true;
newList.EnableMinorVersions = true;
}
if (updateAndExecuteQuery)
{
newList.Update();
web.Context.Load(listCol);
web.Context.ExecuteQuery();
}
}
开发者ID:CherifSy,项目名称:PnP,代码行数:26,代码来源:ListExtensions.cs
示例6: AddList
/// <summary>
/// Adds a list to a site
/// </summary>
/// <param name="properties">Site to operate on</param>
/// <param name="listType">Type of the list</param>
/// <param name="featureID">Feature guid that brings this list type</param>
/// <param name="listName">Name of the list</param>
/// <param name="enableVersioning">Enable versioning on the list</param>
public static List AddList(ClientContext ctx, Web web, ListTemplateType listType, string listName)
{
ListCollection listCollection = web.Lists;
ctx.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == listName));
ctx.ExecuteQuery();
if (listCollection.Count == 0)
{
ListCollection listCol = web.Lists;
ListCreationInformation lci = new ListCreationInformation();
lci.Title = listName;
lci.TemplateType = (int)listType;
List newList = listCol.Add(lci);
newList.Description = "Demo list for remote event receiver lab";
newList.Fields.AddFieldAsXml("<Field DisplayName='Description' Type='Text' />",true,AddFieldOptions.DefaultValue);
newList.Fields.AddFieldAsXml("<Field DisplayName='AssignedTo' Type='Text' />",true,AddFieldOptions.DefaultValue);
newList.Update();
return newList;
//ctx.Load(listCol);
//ctx.ExecuteQuery();
}
else
{
return listCollection[0];
}
}
开发者ID:modulexcite,项目名称:TrainingContent,代码行数:34,代码来源:LabHelper.cs
示例7: AddCalendarList
/// <summary>
/// Add Calendar Web Part to client site
/// </summary>
/// <param name="clientContext">SharePoint Client Context</param>
/// <param name="matter">Matter object containing Matter data</param>
internal static void AddCalendarList(ClientContext clientContext, Matter matter)
{
string calendarName = string.Concat(matter.MatterName, ConfigurationManager.AppSettings["CalendarNameSuffix"]);
try
{
Web web = clientContext.Web;
clientContext.Load(web, item => item.ListTemplates);
clientContext.ExecuteQuery();
ListTemplate listTemplate = null;
foreach (var calendar in web.ListTemplates)
{
if (calendar.Name == Constants.CalendarName)
{
listTemplate = calendar;
}
}
ListCreationInformation listCreationInformation = new ListCreationInformation();
listCreationInformation.TemplateType = listTemplate.ListTemplateTypeKind;
listCreationInformation.Title = calendarName;
// Added URL property for URL consolidation changes
listCreationInformation.Url = Constants.TitleListPath + matter.MatterGuid + ConfigurationManager.AppSettings["CalendarNameSuffix"];
web.Lists.Add(listCreationInformation);
web.Update();
clientContext.ExecuteQuery();
MatterProvisionHelperUtility.BreakPermission(clientContext, matter.MatterName, matter.CopyPermissionsFromParent, calendarName);
}
catch (Exception exception)
{
//// Generic Exception
MatterProvisionHelper.DeleteMatter(clientContext, matter);
DisplayAndLogError(errorFilePath, "Message: " + exception.Message + "\nStacktrace: " + exception.StackTrace);
}
}
开发者ID:Microsoft,项目名称:mattercenter,代码行数:39,代码来源:Utility.cs
示例8: cmdCreateCustomersList_Click
protected void cmdCreateCustomersList_Click(object sender, EventArgs e)
{
SharePointContext spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (ClientContext clientContext = spContext.CreateUserClientContextForSPHost()) {
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
string listTitle = "Customers";
// delete list if it exists
ExceptionHandlingScope scope = new ExceptionHandlingScope(clientContext);
using (scope.StartScope()) {
using (scope.StartTry()) {
clientContext.Web.Lists.GetByTitle(listTitle).DeleteObject();
}
using (scope.StartCatch()) { }
}
// create and initialize ListCreationInformation object
ListCreationInformation listInformation = new ListCreationInformation();
listInformation.Title = listTitle;
listInformation.Url = "Lists/Customers";
listInformation.QuickLaunchOption = QuickLaunchOptions.On;
listInformation.TemplateType = (int)ListTemplateType.Contacts;
// Add ListCreationInformation to lists collection and return list object
List list = clientContext.Web.Lists.Add(listInformation);
// modify additional list properties and update
list.OnQuickLaunch = true;
list.EnableAttachments = false;
list.Update();
// send command to server to create list
clientContext.ExecuteQuery();
// add an item to the list
ListItemCreationInformation lici1 = new ListItemCreationInformation();
var item1 = list.AddItem(lici1);
item1["Title"] = "Lennon";
item1["FirstName"] = "John";
item1.Update();
// add a second item
ListItemCreationInformation lici2 = new ListItemCreationInformation();
var item2 = list.AddItem(lici2);
item2["Title"] = "McCartney";
item2["FirstName"] = "Paul";
item2.Update();
// send add commands to server
clientContext.ExecuteQuery();
// add message to app’s start page
placeholderMainContent.Text = "New list created";
}
}
开发者ID:kimberpjub,项目名称:GSA2013,代码行数:59,代码来源:Default.aspx.cs
示例9: AddList
/// <summary>
/// Adds a list to a site
/// </summary>
/// <param name="web">Site to be processed - can be root web or sub site</param>
/// <param name="listType">Type of the list</param>
/// <param name="listName">Name of the list</param>
/// <param name="enableVersioning">Enable versioning on the list</param>
/// <param name="updateAndExecuteQuery">Perform list update and executequery, defaults to true</param>
public static void AddList(Web web, ListTemplateType listType, string listName)
{
ListCollection listCol = web.Lists;
ListCreationInformation lci = new ListCreationInformation();
lci.Title = listName;
lci.TemplateType = (int)listType;
List newList = listCol.Add(lci);
}
开发者ID:chrissimusokwe,项目名称:TrainingContent,代码行数:16,代码来源:Program.cs
示例10: CreateSiteClassificationList
private void CreateSiteClassificationList(ClientContext ctx)
{
var _newList = new ListCreationInformation()
{
Title = SiteClassificationList.SiteClassificationListTitle,
Description = SiteClassificationList.SiteClassificationDesc,
TemplateType = (int)ListTemplateType.GenericList,
Url = SiteClassificationList.SiteClassificationUrl,
QuickLaunchOption = QuickLaunchOptions.Off
};
if(!ctx.Web.ContentTypeExistsById(SiteClassificationContentType.SITEINFORMATION_CT_ID))
{
//ct
ContentType _contentType = ctx.Web.CreateContentType(SiteClassificationContentType.SITEINFORMATION_CT_NAME,
SiteClassificationContentType.SITEINFORMATION_CT_DESC,
SiteClassificationContentType.SITEINFORMATION_CT_ID,
SiteClassificationContentType.SITEINFORMATION_CT_GROUP);
FieldLink _titleFieldLink = _contentType.FieldLinks.GetById(new Guid("fa564e0f-0c70-4ab9-b863-0177e6ddd247"));
_titleFieldLink.Required = false;
_contentType.Update(false);
//Key Field
ctx.Web.CreateField(SiteClassificationFields.FLD_KEY_ID,
SiteClassificationFields.FLD_KEY_INTERNAL_NAME,
FieldType.Text,
SiteClassificationFields.FLD_KEY_DISPLAY_NAME,
SiteClassificationFields.FIELDS_GROUPNAME);
//value field
ctx.Web.CreateField(SiteClassificationFields.FLD_VALUE_ID,
SiteClassificationFields.FLD_VALUE_INTERNAL_NAME,
FieldType.Text,
SiteClassificationFields.FLD_VALUE_DISPLAY_NAME,
SiteClassificationFields.FIELDS_GROUPNAME);
//Add Key Field to content type
ctx.Web.AddFieldToContentTypeById(SiteClassificationContentType.SITEINFORMATION_CT_ID,
SiteClassificationFields.FLD_KEY_ID.ToString(),
true);
//Add Value Field to content type
ctx.Web.AddFieldToContentTypeById(SiteClassificationContentType.SITEINFORMATION_CT_ID,
SiteClassificationFields.FLD_VALUE_ID.ToString(),
true);
}
var _list = ctx.Web.Lists.Add(_newList);
_list.Hidden = true;
_list.ContentTypesEnabled = true;
_list.Update();
ctx.Web.AddContentTypeToListById(SiteClassificationList.SiteClassificationListTitle, SiteClassificationContentType.SITEINFORMATION_CT_ID, true);
this.CreateCustomPropertiesInList(_list);
ctx.ExecuteQuery();
this.RemoveFromQuickLaunch(ctx, SiteClassificationList.SiteClassificationListTitle);
}
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:57,代码来源:SiteManagerImpl.cs
示例11: Create
/// <summary>
/// Function to create document library for Matter and OneNote
/// </summary>
/// <param name="clientContext">Client Context</param>
/// <param name="listInfo">List information</param>
/// <returns>Success flag</returns>
public static bool Create(ClientContext clientContext, ListInformation listInfo)
{
bool result = true;
if (null != clientContext && null != listInfo && !string.IsNullOrWhiteSpace(listInfo.name))
{
Web web = clientContext.Web;
ListTemplateCollection listTemplates = web.ListTemplates;
ListCreationInformation creationInfo = new ListCreationInformation();
creationInfo.Title = listInfo.name;
creationInfo.Description = listInfo.description;
// To determine changes in URL we specified below condition as this function is common
if (!string.IsNullOrWhiteSpace(listInfo.Path))
{
creationInfo.Url = listInfo.Path;
}
if (!string.IsNullOrWhiteSpace(listInfo.templateType))
{
string templateType = listInfo.templateType;
clientContext.Load(listTemplates, item => item.Include(currentTemplate => currentTemplate.Name, currentTemplate => currentTemplate.ListTemplateTypeKind).Where(selectedTemplate => selectedTemplate.Name == templateType));
clientContext.ExecuteQuery();
if (null != listTemplates && 0 < listTemplates.Count)
{
creationInfo.TemplateType = listTemplates.FirstOrDefault().ListTemplateTypeKind;
}
else
{
result = false;
}
}
else
{
creationInfo.TemplateType = (int)ListTemplateType.DocumentLibrary;
}
if (result)
{
List list = web.Lists.Add(creationInfo);
list.ContentTypesEnabled = listInfo.isContentTypeEnable;
if (null != listInfo.folderNames && listInfo.folderNames.Count > 0)
{
list = Lists.AddFolders(clientContext, list, listInfo.folderNames);
}
if (null != listInfo.versioning)
{
list.EnableVersioning = listInfo.versioning.EnableVersioning;
list.EnableMinorVersions = listInfo.versioning.EnableMinorVersions;
list.ForceCheckout = listInfo.versioning.ForceCheckout;
}
list.Update();
clientContext.Load(list, l => l.DefaultViewUrl);
clientContext.ExecuteQuery();
result = true;
}
}
return result;
}
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:62,代码来源:Lists.cs
示例12: CreateList
private static void CreateList(ClientContext clientContext, string listName)
{
Web currentWeb = clientContext.Web;
ListCreationInformation creationInfo = new ListCreationInformation();
creationInfo.Title = listName;
creationInfo.TemplateType = (int)ListTemplateType.GenericList;
List list = currentWeb.Lists.Add(creationInfo);
list.Description = "My custom list";
list.Update();
clientContext.ExecuteQuery();
}
开发者ID:bayzid026,项目名称:mvc,代码行数:11,代码来源:Program.cs
示例13: CreateDocumentLibrary
public List CreateDocumentLibrary(string DocLibName, string DocDesc)
{
Web web = Ctx.Web;
ListCreationInformation creationInfo = new ListCreationInformation();
creationInfo.Title = DocLibName;
creationInfo.TemplateType = (int)ListTemplateType.DocumentLibrary;
List list = web.Lists.Add(creationInfo);
list.Description = DocDesc;
list.Update();
Ctx.ExecuteQuery();
return list;
}
开发者ID:uneidel,项目名称:Create-SPLoad,代码行数:12,代码来源:SharePointHelper.cs
示例14: CreateDocLibrary
public void CreateDocLibrary(ClientContext ctx, string libraryName, string description)
{
// Create new list to the host web
ListCreationInformation list = new ListCreationInformation();
list.Title = libraryName;
list.TemplateType = (int)ListTemplateType.DocumentLibrary;
list.Description = description;
list.Url = libraryName;
ctx.Web.Lists.Add(list);
ctx.ExecuteQuery();
}
开发者ID:ivanvagunin,项目名称:PnP,代码行数:12,代码来源:SiteManager.cs
示例15: CreateOrderList
internal static void CreateOrderList(ClientContext ctx) {
ListCreationInformation lci = new ListCreationInformation();
lci.Title = "Order";
lci.TemplateType = 100;
if (!ctx.Web.ListExists("Order")) {
var OrderList = ctx.Web.Lists.Add(lci);
OrderList.AddContentTypeToList(ctx.Web.GetContentTypeById(Constants.GUID.OrderCT.OrderCTGUID), true);
OrderList.Update();
ctx.ExecuteQuery();
}
}
开发者ID:Luviz,项目名称:OfficeDev1.MAssinment,代码行数:13,代码来源:Order.cs
示例16: ProcessEvent
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties) {
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false)) {
if (clientContext != null) {
clientContext.Load(clientContext.Web);
string listTitle = "Customers";
// delete list if it exists
ExceptionHandlingScope scope = new ExceptionHandlingScope(clientContext);
using (scope.StartScope()) {
using (scope.StartTry()) {
clientContext.Web.Lists.GetByTitle(listTitle).DeleteObject();
}
using (scope.StartCatch()) { }
}
// create and initialize ListCreationInformation object
ListCreationInformation listInformation = new ListCreationInformation();
listInformation.Title = listTitle;
listInformation.Url = "Lists/Customers";
listInformation.QuickLaunchOption = QuickLaunchOptions.On;
listInformation.TemplateType = (int)ListTemplateType.Contacts;
// Add ListCreationInformation to lists collection and return list object
List list = clientContext.Web.Lists.Add(listInformation);
// modify additional list properties and update
list.OnQuickLaunch = true;
list.EnableAttachments = false;
list.Update();
// send command to server to create list
clientContext.ExecuteQuery();
// create a sample item in the list
var customer1 = list.AddItem(new ListItemCreationInformation());
customer1["FirstName"] = "Mike";
customer1["Title"] = "Fitzmaurice";
customer1["Company"] = "Wingtip Toys";
customer1["WorkPhone"] = "(111)111-1111";
customer1["HomePhone"] = "(222)222-2222";
customer1["Email"] = "[email protected]";
customer1.Update();
// send command to server to create item
clientContext.ExecuteQuery();
}
}
return result;
}
开发者ID:chrissimusokwe,项目名称:TrainingContent,代码行数:51,代码来源:AppEventReceiver.svc.cs
示例17: CreateList
public static List CreateList(ClientContext ctx, int templateType,
string title, string url, QuickLaunchOptions quickLaunchOptions)
{
ListCreationInformation listCreationInfo = new ListCreationInformation
{
TemplateType = templateType,
Title = title,
Url = url,
QuickLaunchOption = quickLaunchOptions
};
List spList = ctx.Web.Lists.Add(listCreationInfo);
ctx.Load(spList);
ctx.ExecuteQuery();
return spList;
}
开发者ID:BNATENSTEDT,项目名称:PnP,代码行数:16,代码来源:Util.cs
示例18: CreateDocLibrary
public void CreateDocLibrary(ClientContext ctx, string libraryName, string requestor)
{
// Create new list to the host web
ListCreationInformation newList = new ListCreationInformation();
newList.Title = libraryName;
newList.TemplateType = (int)ListTemplateType.GenericList;
newList.Description = requestor;
newList.Url = libraryName;
List list = ctx.Web.Lists.Add(newList);
ListItemCreationInformation newItem = new ListItemCreationInformation();
ListItem item = list.AddItem(newItem);
item["Title"] = requestor;
item.Update();
ctx.ExecuteQuery();
}
开发者ID:tandis,项目名称:PnP,代码行数:17,代码来源:SiteManager.cs
示例19: Add
public ActionResult Add(string name = null)
{
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
ViewBag.SPHostUrl = spContext.SPHostUrl;
if (!string.IsNullOrEmpty(name))
{
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
ListCreationInformation creationInfo = new ListCreationInformation();
creationInfo.Title = name;
creationInfo.TemplateType = (int)ListTemplateType.Announcements;
List list = clientContext.Web.Lists.Add(creationInfo);
list.Description = "Description";
list.Update();
clientContext.ExecuteQuery();
return RedirectToAction("Index", "Lists", new { SPHostUrl = spContext.SPHostUrl });
}
}
return RedirectToAction("Index", "Lists", new { SPHostUrl = spContext.SPHostUrl });
}
开发者ID:Vethro,项目名称:Learning,代码行数:20,代码来源:ListsController.cs
示例20: CreateProductImagesLibrary
static void CreateProductImagesLibrary()
{
Console.WriteLine();
Console.WriteLine("Creating Product Images library...");
ListCreationInformation listInformationProductImages = new ListCreationInformation();
listInformationProductImages.Title = "Product Images";
listInformationProductImages.Url = "ProductImages";
listInformationProductImages.QuickLaunchOption = QuickLaunchOptions.On;
listInformationProductImages.TemplateType = (int)ListTemplateType.PictureLibrary;
listProductImages = site.Lists.Add(listInformationProductImages);
listProductImages.OnQuickLaunch = true;
listProductImages.Update();
clientContext.Load(listProductImages);
clientContext.Load(listProductImages.RootFolder);
clientContext.ExecuteQuery();
listProductImagesUrl = listProductImages.RootFolder.ServerRelativeUrl;
}
开发者ID:CriticalPathTraining,项目名称:BBS2013,代码行数:20,代码来源:Program.cs
注:本文中的ListCreationInformation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论