首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C#为Sharepoint在线创建项目

使用C#为Sharepoint在线创建项目
EN

Stack Overflow用户
提问于 2016-10-10 07:59:44
回答 1查看 1K关注 0票数 1

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

我找到的唯一一段代码是为了改变它:

代码语言:javascript
复制
// 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,但是我仍然在创建一个企业项目,所以要么我遗漏了什么?

这里有一个示例项目列表可供下载,用于sharepoint:https://github.com/OfficeDev/Project-Samples

我对“创建-更新-项目-样本”特别感兴趣。这将给你一个程序,立即工作,并希望能演示我的问题是什么,所有的一切,所有的需要是增加上述功能。

感谢这里的任何帮助,它用上面的函数传递正确的GUID,但是它没有正确地保存它。

EN

回答 1

Stack Overflow用户

发布于 2017-10-05 13:31:28

我对您的问题也有很多困惑,我发现当您创建一个带有任务列表的项目时,它将成为sharepoint任务项目。希望这能帮上忙。

代码语言:javascript
复制
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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39953710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档