簡體   English   中英

使用 C# 為 Sharepoint 創建在線項目

[英]Creating a Project Online using C# for Sharepoint

是的,我有一些代碼可以讓我在線創建 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

我對“創建-更新-項目-示例”特別感興趣。 這將為您提供一個可以立即運行的程序,並有望證明我的問題是什么,所需要的只是添加上面的函數。

感謝這里的任何幫助,它通過上述函數傳遞了正確的 GUID,但沒有正確保存它。

在此處輸入圖片說明

我對你的問題也有很多困惑,我發現當你創建一個帶有任務列表的項目時,它會變成共享點任務項目。 希望這會有所幫助。

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

您如何創建TaskList對象,然后我可以嘗試此解決方案並報告其是否有效。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM