【发布时间】:2016-10-10 07:59:44
【问题描述】:
是的,我有一段代码可以让我创建一个 Sharepoint 在线项目,但是它默认创建为“企业项目”,我想创建,它是一个“SharePoint 任务列表” " 而是。 (这些是在线编辑项目时的以下2个选项)
我设法找到的唯一代码是用于更改它:
// Get the GUID of the specified enterprise project type.
private static Guid GetEptUid(string eptName)
{
Guid eptUid = Guid.Empty;
try
{
// Get the list of EPTs that have the specified name.
// If the EPT name exists, the list will contain only one EPT.
var eptList = projContext.LoadQuery(
projContext.EnterpriseProjectTypes.Where(
ept => ept.Name == eptName));
projContext.ExecuteQuery();
eptUid = eptList.First().Id;
// Alternate routines to find the EPT GUID. Both (a) and (b) download the entire list of EPTs.
// (a) Using a foreach block:
//foreach (EnterpriseProjectType ept in projSvr.EnterpriseProjectTypes)
//{
// if (ept.Name == eptName)
// {
// eptUid = ept.Id;
// break;
// }
//}
// (b) Querying for the EPT list, and then using a lambda expression to select the EPT:
//var eptList = projContext.LoadQuery(projContext.EnterpriseProjectTypes);
//projContext.ExecuteQuery();
//eptUid = eptList.First(ept => ept.Name == eptName).Id;
}
catch (Exception ex)
{
string msg = string.Format("GetEptUid: eptName = \"{0}\"\n\n{1}",
eptName, ex.GetBaseException().ToString());
throw new ArgumentException(msg);
}
return eptUid;
}
从这个代码块中,我必须传入 basicEpt 名称,给出的示例是:private static string basicEpt = "SharePoint Tasks List";
我已尝试使用各种设置创建的多个 EPT,但我仍在创建企业项目,所以要么我遗漏了什么?
这里有一个示例项目列表可供共享点下载:https://github.com/OfficeDev/Project-Samples
我对“Create-Update-Project-Samples”特别感兴趣。这将为您提供一个可以立即运行的程序,并有望证明我的问题是什么,所需要的只是添加上面的函数。
感谢您在此提供的任何帮助,它使用上述函数传递了正确的 GUID,但没有正确保存。
【问题讨论】:
标签: c# visual-studio sharepoint