2016-10-10 9 views
0

私はSharepoint Project Onlineを作成するためのコードを用意していますが、デフォルトでは "Enterprise Project"として作成しています。作成します代わりに "SharePointタスクリスト"として。 (これらは、オンラインプロジェクトを編集する際に、以下の2つのオプションがある)Sharepoint用のC#を使用してオンラインでプロジェクトを作成

enter image description here

私が見つけるために管理しているコードのビットのみが、これはそれを変更することです:

// 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";

私はvarius設定で作成した複数のEPTを試しましたが、まだエンタープライズプロジェクトを作成しているので、何か不足していますか?

for SharePointは、ここでダウンロードできるサンプルプロジェクトのリストがあります:https://github.com/OfficeDev/Project-Samples

私は特に「作成・更新・プロジェクト・サンプル」に興味があります。これはすぐに動作するプログラムを提供し、うまくいけば私の問題が何であるかを実証します。必要なのは上の関数を追加することだけです。

ここで助けていただきありがとうございます、上記の関数で正しいGUIDを渡していますが、正しく保存されていません。

enter image description here

答えて

0

私はまた、あなたの問題について多くのことを混同しており、私はあなたがタスクリストでプロジェクトを作成するとき、それが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); 
+0

助けてくれてありがとう、私は来週早くこれを試してみよう – Crezzer7

関連する問題