【问题标题】:Creating a Project Online using C# for Sharepoint使用 C# for Sharepoint 创建在线项目
【发布时间】: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;
        }

从这里引用:https://msdn.microsoft.com/en-us/library/microsoft.projectserver.client.projectcontext.waitforqueue.aspx

从这个代码块中,我必须传入 basicEpt 名称,给出的示例是:private static string basicEpt = "SharePoint Tasks List";

我已尝试使用各种设置创建的多个 EPT,但我仍在创建企业项目,所以要么我遗漏了什么?

这里有一个示例项目列表可供共享点下载:https://github.com/OfficeDev/Project-Samples

我对“Create-Update-Project-Samples”特别感兴趣。这将为您提供一个可以立即运行的程序,并有望证明我的问题是什么,所需要的只是添加上面的函数。

感谢您在此提供的任何帮助,它使用上述函数传递了正确的 GUID,但没有正确保存。

【问题讨论】:

    标签: c# visual-studio sharepoint


    【解决方案1】:

    我对你的问题也有很多困惑,我发现当你创建一个带有任务列表的项目时,它会变成共享点任务项目。 希望这会有所帮助。

    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);
    

    【讨论】:

    • 感谢您的帮助,我将在下周初尝试并回复您
    猜你喜欢
    • 1970-01-01
    • 2020-02-18
    • 2011-03-30
    • 2018-11-12
    • 2020-12-14
    • 1970-01-01
    • 2011-08-28
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多