是的,我有一段代码可以让我在线创建一个Sharepoint项目,但是它是作为默认的“企业项目”创建的,是我想要创建的,它是作为"SharePoint任务列表“创建的,而不是。(以下是在线编辑项目时的两个选项)

我找到的唯一一段代码是为了改变它:
// 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,但是我仍然在创建一个企业项目,所以要么我遗漏了什么?
这里有一个示例项目列表可供下载,用于sharepoint:https://github.com/OfficeDev/Project-Samples
我对“创建-更新-项目-样本”特别感兴趣。这将给你一个程序,立即工作,并希望能演示我的问题是什么,所有的一切,所有的需要是增加上述功能。
感谢这里的任何帮助,它用上面的函数传递正确的GUID,但是它没有正确地保存它。

发布于 2017-10-05 13:31:28
我对您的问题也有很多困惑,我发现当您创建一个带有任务列表的项目时,它将成为sharepoint任务项目。希望这能帮上忙。
var pci = new ProjectCreationInformation
{
Name = "new1",
Description = "test",
EnterpriseProjectTypeId = new Guid(""),
//Id = Guid.NewGuid(),
Start = DateTime.UtcNow,
TaskList = taskList
};
var project = context.Projects.Add(pci);https://stackoverflow.com/questions/39953710
复制相似问题