次の方法で共有


Project.UpdateProjectSyncSettings メソッド

Project Server と SharePoint タスク リスト プロジェクトを同期するためのマッピングを指定するには、データを更新します。

名前空間:  WebSvcProject
アセンブリ:  ProjectServerServices (ProjectServerServices.dll 内)

構文

'宣言
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/UpdateProjectSyncSettings", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub UpdateProjectSyncSettings ( _
    syncDataSet As SyncDataSet _
)
'使用
Dim instance As Project
Dim syncDataSet As SyncDataSet

instance.UpdateProjectSyncSettings(syncDataSet)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/UpdateProjectSyncSettings", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateProjectSyncSettings(
    SyncDataSet syncDataSet
)

パラメーター

  • syncDataSet
    型: WebSvcProject.SyncDataSet

    SharePoint タスク リストで、プロジェクトを同期するために、更新されたデータが含まれています。

注釈

これは、 Project Server 2013の新しいメソッドです。UpdateProjectSyncSettingsメソッドは既に、同期するが、同期データは、 CreateWssListSyncedProjectメソッドによって作成されたプロジェクトでは動作します。

プロジェクト サーバーのアクセス許可

権限

説明

PublishProject

プロジェクト サーバーの公開データベースにプロジェクトを発行することができます。

例では、ProjectServerServices.dll プロキシ アセンブリ内のSvcProjectの名前空間を使用します。ConfigClientEndpointsメソッドとSetClientEndPointsメソッドは、WCF のバインディング、動作、およびエンドポイントの設定を app.config ファイルを使用します。PSI プロキシ アセンブリと app.config ファイルを作成する方法の詳細については、 Project 2013 での WCF ベースのコード サンプルの前提条件を参照してください。

注意

次の使用例は、 UpdateProjectSyncSettings、 SyncProjectWithWss、およびCreateWssListSyncedProjectメソッドの使用を示すために設計されています。完全なソリューションではありません。Guid は、必要なフィールドをハードコードします。この例を使用するには、まず、SharePoint リストを作成します。可能であれば、 Project Server 2013のテスト インストールに一致するように、コードで、 LIST_TITLE、 SHAREPOINT_LIST_SITEの、およびその他の URL の値変更します。

Lists.GetListCollection web メソッドは、SharePoint サイトで、名前と Guid がすべてのリストを含む XML ドキュメントを返します。サンプルは、 XElement.Parseメソッドを使用してrootをという名前のXElementオブジェクトに、XML ドキュメントを変更します。GetListGuidメソッドは、 rootオブジェクトのクエリに、LINQ to XML しリストのタイトルに対応するリストの GUID を返します。

SyncDataSet.xmlSyncDataSetの内容が書き込まれます。次に、 priority high project settings値が 900 に変更します。UpdateProjectSyncSettingsメソッドは、新しい値で、 SyncDataSetを更新します。

注意

プロジェクトの同期の設定を更新するときに、 SyncTaskItemsMappingテーブルを空にする必要があります。

更新する前にSyncDataSetの内容を次に示します。

<?xml version="1.0" standalone="yes"?>
<SyncDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/SyncDataSet">
  <SyncProjectSettings>
    <SYNC_WSS_LIST_UID>9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <PROJ_UID>58a75120-fcb3-43a0-a811-1c11fc0dfed1</PROJ_UID>
    <SYNC_WSS_SERVER_URL>http://jc2vm1</SYNC_WSS_SERVER_URL>
    <SYNC_LAST_SYNC_DATE>2010-06-02T08:01:45.653-07:00</SYNC_LAST_SYNC_DATE>
  </SyncProjectSettings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    cda3b2ee-9af8-4d59-9581-1b682fd5fd6d</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Priority
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    cd21b4c2-6841-4f9e-a23a-738a65f99889</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Due Date
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    0328d1c7-fc8b-4c41-bd58-66c1a4ff390a</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>FinishDate
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    53101f38-dd2e-458c-b245-0c236cc13d1a</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Assigned To
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    914829a1-3151-48c4-8f40-6d9e8d5bfd0f</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Assigned To</SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    64cd368d-2f95-4bfc-a1f9-8d4324ecb007</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Start Date
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    870004dc-a44c-4f5d-9cc9-72ce3025481b</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>StartDate
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    d2311440-1ed6-46ea-b46d-daa643dc3886</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>% Complete
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    041965eb-bb89-4be9-8843-7a40f78f8ee4</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>PercentComplete
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    7662cd2c-f069-4dba-9e35-082cf976e170</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Body
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    9eb68d1f-caa3-41a8-8f6f-e97ae9fd0717</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Notes
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    fa564e0f-0c70-4ab9-b863-0177e6ddd247</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Title
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    9594ab82-f7fd-4336-a387-f5d842e53ea5</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Title
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncItemTaskMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_LIST_ITEM_ID>1
    </SYNC_WSS_LIST_ITEM_ID>
    <SYNC_TASK_UID>
    36e2e450-3a57-4a80-b94e-fcb1cb56e3e7</SYNC_TASK_UID>
  </SyncItemTaskMappings>
  <SyncItemTaskMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_LIST_ITEM_ID>2
    </SYNC_WSS_LIST_ITEM_ID>
    <SYNC_TASK_UID>
    822adcfd-d358-44fe-9ed0-c6d557cb6458</SYNC_TASK_UID>
  </SyncItemTaskMappings>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(1) High
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>600
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(2) Normal
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>500
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(3) Low
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>400
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
</SyncDataSet>

最新のSyncDataSetの内容を次に示します。

<?xml version="1.0" standalone="yes"?>
<SyncDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/SyncDataSet">
  <SyncProjectSettings>
    <SYNC_WSS_LIST_UID>9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <PROJ_UID>58a75120-fcb3-43a0-a811-1c11fc0dfed1</PROJ_UID>
    <SYNC_WSS_SERVER_URL>http://jc2vm1</SYNC_WSS_SERVER_URL>
    <SYNC_LAST_SYNC_DATE>2010-06-02T08:01:45.653-07:00</SYNC_LAST_SYNC_DATE>
  </SyncProjectSettings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    cda3b2ee-9af8-4d59-9581-1b682fd5fd6d</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Priority
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    cd21b4c2-6841-4f9e-a23a-738a65f99889</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Due Date
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    0328d1c7-fc8b-4c41-bd58-66c1a4ff390a</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>FinishDate
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    53101f38-dd2e-458c-b245-0c236cc13d1a</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Assigned To
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    914829a1-3151-48c4-8f40-6d9e8d5bfd0f</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Assigned To</SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    64cd368d-2f95-4bfc-a1f9-8d4324ecb007</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Start Date
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    870004dc-a44c-4f5d-9cc9-72ce3025481b</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>StartDate
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    d2311440-1ed6-46ea-b46d-daa643dc3886</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>% Complete
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    041965eb-bb89-4be9-8843-7a40f78f8ee4</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>PercentComplete
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    7662cd2c-f069-4dba-9e35-082cf976e170</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Body
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    9eb68d1f-caa3-41a8-8f6f-e97ae9fd0717</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Notes
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncFieldMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    fa564e0f-0c70-4ab9-b863-0177e6ddd247</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Title
    </SYNC_WSS_FIELD_NAME>
    <SYNC_PROJECT_FIELD_UID>
    9594ab82-f7fd-4336-a387-f5d842e53ea5</SYNC_PROJECT_FIELD_UID>
    <SYNC_PROJECT_FIELD_NAME>Title
    </SYNC_PROJECT_FIELD_NAME>
    <SYNC_IS_PROJECT_CUSTOM_FIELD>false
    </SYNC_IS_PROJECT_CUSTOM_FIELD>
  </SyncFieldMappings>
  <SyncItemTaskMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_LIST_ITEM_ID>1
    </SYNC_WSS_LIST_ITEM_ID>
    <SYNC_TASK_UID>
    36e2e450-3a57-4a80-b94e-fcb1cb56e3e7</SYNC_TASK_UID>
  </SyncItemTaskMappings>
  <SyncItemTaskMappings>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_LIST_ITEM_ID>2
    </SYNC_WSS_LIST_ITEM_ID>
    <SYNC_TASK_UID>
    822adcfd-d358-44fe-9ed0-c6d557cb6458</SYNC_TASK_UID>
  </SyncItemTaskMappings>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(1) High
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>900
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(2) Normal
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>500
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
  <SyncValueTranslations>
    <SYNC_WSS_LIST_UID>
    9419bc3c-8084-4d58-a0bf-c8c0df016254</SYNC_WSS_LIST_UID>
    <SYNC_WSS_FIELD_UID>
    a8eb573e-9e11-481a-a8c9-1104a54b2fbd</SYNC_WSS_FIELD_UID>
    <SYNC_WSS_FIELD_NAME>Priority
    </SYNC_WSS_FIELD_NAME>
    <SYNC_WSS_VALUE>(3) Low
    </SYNC_WSS_VALUE>
    <SYNC_PROJECT_VALUE>400
    </SYNC_PROJECT_VALUE>
  </SyncValueTranslations>
</SyncDataSet>

完全なサンプル コードは次のとおりです。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.IO;
using System.ServiceModel;
using System.Xml;
using System.Xml.Linq;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using System.Data;
using System.Web.Services;
using WebSvcLists = Microsoft.SDK.Project.Samples.ReadArchivedProjectsList.WebSvcLists;

namespace Microsoft.SDK.Project.Samples.SyncProject
{
    class Program
    {
        // Change the URL of the SharePoint list site and the name of the task list.
        private const string SHAREPOINT_LIST_SITE = "http://jc2vm1";
        private const string LIST_TITLE = "Task List 102";

        private const string ENDPOINT_PROJECT = "basicHttp_Project";
        private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
        private static string outFilePathSyncDataSet;
        private static string outFilePathUpdatedSyncDS;

        private static SvcProject.ProjectClient projectClient;
        private static WebSvcLists.Lists lists;
        
        // The GUIDs of the default fields are the same in all 
        // SharePoint 2010 default task lists.
        private const string PRIORITY_LIST_FIELD_GUID =
            "a8eb573e-9e11-481a-a8c9-1104a54b2fbd";
        private const string DUEDATE_LIST_FIELD_GUID =
            "cd21b4c2-6841-4f9e-a23a-738a65f99889";
        private const string STARTDATE_LIST_FIELD_GUID =
            "64cd368d-2f95-4bfc-a1f9-8d4324ecb007";
        private const string BODY_LIST_FIELD_GUID =
            "7662cd2c-f069-4dba-9e35-082cf976e170";
        private const string ASSIGNEDTO_LIST_FIELD_GUID =
            "53101f38-dd2e-458c-b245-0c236cc13d1a";
        private const string PERCENTCOMPLETE_LIST_FIELD_GUID =
            "d2311440-1ed6-46ea-b46d-daa643dc3886";
        private const string TITLE_LIST_FIELD_GUID =
            "fa564e0f-0c70-4ab9-b863-0177e6ddd247";
        private const string PRIORITY_FIELD_GUID = 
            "a8eb573e-9e11-481a-a8c9-1104a54b2fbd";

        private static XElement root;  // The root of the list XML data.

        static void Main(string[] args)
        {
            lists = new WebSvcLists.Lists();
            lists.Url = "http://jc2vm1/_vti_bin/lists.asmx";
            lists.Credentials = CredentialCache.DefaultCredentials;

            // Get the XML data for the lists in the specified 
            // SharePoint lists collection.
            XmlNode listData = lists.GetListCollection();

            root = XElement.Parse(listData.OuterXml);

            string projectName = string.Empty;
            Guid listUid = GetListGuid(root, LIST_TITLE, out projectName);
            
            // If the output directory does not exist, create it.
            if(!Directory.Exists(OUTPUT_FILES))
            {
                Directory.CreateDirectory(OUTPUT_FILES);
            }

            // Assign the path where the output XML file will be saved.
            outFilePathSyncDataSet = OUTPUT_FILES + "SyncDataSet.xml";
            outFilePathUpdatedSyncDS = OUTPUT_FILES + "UpdatedSyncDataSet.xml";

            // Configure the endpoints.
            ConfigClientEndpoints(ENDPOINT_PROJECT);

            try
            {
                // Create Sync Dataset.
                SvcProject.SyncDataSet syncDS = CreateSyncDataSet(listUid);

                // Create the project.
                Guid CreatedProject_Guid = projectClient.CreateWssListSyncedProject(
                    syncDS, projectName);
                Guid[] syncEntityGuids = new Guid[1];
                syncEntityGuids[0] = listUid;

                // Read back the SyncDataSet, and write it to a file.
                SvcProject.SyncEntityUidType syncEntityUidType =
                    SvcProject.SyncEntityUidType.WssListUid;
                syncDS = projectClient.ReadProjectSyncSettings
                        (syncEntityGuids, syncEntityUidType, true);
                syncDS.WriteXml(outFilePathSyncDataSet);

                // Update project synchronization settings.
                syncDS.SyncValueTranslations.Rows[0]["SYNC_PROJECT_VALUE"] = "900";

                // No values are allowed in the SyncItemTaskMappings table, 
                // when updating the project synchronization settings.
                syncDS.SyncItemTaskMappings.Clear();
                syncDS.AcceptChanges();

                projectClient.UpdateProjectSyncSettings(syncDS);
                syncDS.WriteXml(outFilePathUpdatedSyncDS);

                // Synchronize the updated project.
                projectClient.SyncProjectWithWss(listUid, syncEntityUidType);
            }
            catch (CommunicationException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(
                    "\n***System.ServiceModel.CommunicationException:");
                Console.WriteLine(e.ToString());
                Console.ResetColor();
            }
            Console.WriteLine("\n\nPress any key to exit.");
            Console.ReadKey(false);
        }

        static Guid GetListGuid(XElement listCollection, string listTitle, 
            out string projectName)
        {
            string listId = string.Empty;
            XNamespace xmlns = "https://schemas.microsoft.com/sharepoint/soap/";

            var query = from el in root.Elements(xmlns + "List")
                        where el.Attribute("Title").Value.Equals(listTitle)
                        select el;

            int numElem = query.Count<XElement>();
            Console.WriteLine("Number of elements in query: " + numElem.ToString());

            projectName = query.First<XElement>().Attribute("Title").Value;
            Console.WriteLine(projectName);

            listId = query.First<XElement>().Attribute("ID").Value;
            Guid listUid = new Guid(listId);
            Console.WriteLine("List ID = " + listUid.ToString());
            return listUid;
        }

        // Create the initial SyncDataSet, to use for synchronizing
        // a project the first time.
        static SvcProject.SyncDataSet CreateSyncDataSet(Guid listUid)
        {
            SvcProject.SyncDataSet syncDS = new SvcProject.SyncDataSet();

            string priority = PSLibrary.WSSSync.PriorityFieldName;
            string wssDuedate = "Due Date";
            string projectDueDate = PSLibrary.WSSSync.FinishDateFieldName;
            string wssAssignedTo = "Assigned To";
            string projectAssignedTo = PSLibrary.WSSSync.AssignedToFieldName;
            string wssStartDate = "Start Date";
            string projectStartDate = PSLibrary.WSSSync.StartDateFieldName;
            string wssPercentComplete = "% Complete";
            string projectPercentComplete = PSLibrary.WSSSync.PercentCompleteFieldName;
            string wssBody = "Body";
            string projectNotes = PSLibrary.WSSSync.PercentCompleteFieldName;
            string title = "Title";
            string priorityHigh = "(1) High";
            string priorityNormal = "(2) Normal";
            string priorityLow = "(3) Low";
            string priorityHighValue = "600";
            string priorityNormalValue = "500";
            string priorityLowValue = "400";

            // Project field GUIDs are the same for all projects.
            Guid PRIORITY_PROJECT_FIELD_GUID = PSLibrary.WSSSync.PriorityFieldUid;
            Guid FINISHDATE_PROJECT_FIELD_GUID = PSLibrary.WSSSync.FinishDateFieldUid;
            Guid ASSIGNEDTO_PROJECT_FIELD_GUID = PSLibrary.WSSSync.AssignedToFieldUid;
            Guid STARTDATE_PROJECT_FIELD_GUID = PSLibrary.WSSSync.StartDateFieldUid;
            Guid PERCENTCOMPLETE_PROJECT_FIELD_GUID = PSLibrary.WSSSync.PercentCompleteFieldUid;
            Guid NOTES_PROJECT_FIELD_GUID = PSLibrary.WSSSync.DescriptionFieldUid;
            Guid TITLE_PROJECT_FIELD_GUID = PSLibrary.WSSSync.TitleFieldUid;

            // Create a SyncProjectSettings row.
            SvcProject.SyncDataSet.SyncProjectSettingsRow synProjectSettingRow = 
                syncDS.SyncProjectSettings.NewSyncProjectSettingsRow();
            synProjectSettingRow.SYNC_WSS_LIST_UID = listUid;
            synProjectSettingRow.PROJ_UID = Guid.NewGuid();
            synProjectSettingRow.SYNC_WSS_SERVER_URL = SHAREPOINT_LIST_SITE;
            syncDS.SyncProjectSettings.AddSyncProjectSettingsRow(
                synProjectSettingRow);

            // Add SyncFieldMappingsRows.
            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow.SYNC_WSS_FIELD_UID = 
                new Guid(PRIORITY_LIST_FIELD_GUID);
            syncFieldMappingsRow.SYNC_WSS_FIELD_NAME = priority;
            syncFieldMappingsRow.SYNC_PROJECT_FIELD_UID = 
                PRIORITY_PROJECT_FIELD_GUID;
            syncFieldMappingsRow.SYNC_PROJECT_FIELD_NAME = priority;
            syncFieldMappingsRow.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow1 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow1.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow1.SYNC_WSS_FIELD_UID = 
                new Guid(DUEDATE_LIST_FIELD_GUID);
            syncFieldMappingsRow1.SYNC_WSS_FIELD_NAME = wssDuedate;
            syncFieldMappingsRow1.SYNC_PROJECT_FIELD_UID = 
                FINISHDATE_PROJECT_FIELD_GUID;
            syncFieldMappingsRow1.SYNC_PROJECT_FIELD_NAME = projectDueDate;
            syncFieldMappingsRow1.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow1);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow2 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow2.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow2.SYNC_WSS_FIELD_UID = 
                new Guid(ASSIGNEDTO_LIST_FIELD_GUID);
            syncFieldMappingsRow2.SYNC_WSS_FIELD_NAME = wssAssignedTo;
            syncFieldMappingsRow2.SYNC_PROJECT_FIELD_UID = 
                ASSIGNEDTO_PROJECT_FIELD_GUID;
            syncFieldMappingsRow2.SYNC_PROJECT_FIELD_NAME = projectAssignedTo;
            syncFieldMappingsRow2.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow2);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow3 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow3.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow3.SYNC_WSS_FIELD_UID = 
                new Guid(STARTDATE_LIST_FIELD_GUID);
            syncFieldMappingsRow3.SYNC_WSS_FIELD_NAME = wssStartDate;
            syncFieldMappingsRow3.SYNC_PROJECT_FIELD_UID = 
                STARTDATE_PROJECT_FIELD_GUID;
            syncFieldMappingsRow3.SYNC_PROJECT_FIELD_NAME = projectStartDate;
            syncFieldMappingsRow3.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow3);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow4 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow4.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow4.SYNC_WSS_FIELD_UID = 
               new Guid(PERCENTCOMPLETE_LIST_FIELD_GUID);
            syncFieldMappingsRow4.SYNC_WSS_FIELD_NAME = wssPercentComplete;
            syncFieldMappingsRow4.SYNC_PROJECT_FIELD_UID = 
                PERCENTCOMPLETE_PROJECT_FIELD_GUID;
            syncFieldMappingsRow4.SYNC_PROJECT_FIELD_NAME = 
                projectPercentComplete;
            syncFieldMappingsRow4.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow4);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow5 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow5.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow5.SYNC_WSS_FIELD_UID = 
                new Guid(BODY_LIST_FIELD_GUID);
            syncFieldMappingsRow5.SYNC_WSS_FIELD_NAME = wssBody;
            syncFieldMappingsRow5.SYNC_PROJECT_FIELD_UID = 
                NOTES_PROJECT_FIELD_GUID;
            syncFieldMappingsRow5.SYNC_PROJECT_FIELD_NAME = projectNotes;
            syncFieldMappingsRow5.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow5);

            SvcProject.SyncDataSet.SyncFieldMappingsRow syncFieldMappingsRow6 =
                syncDS.SyncFieldMappings.NewSyncFieldMappingsRow();
            syncFieldMappingsRow6.SYNC_WSS_LIST_UID = listUid;
            syncFieldMappingsRow6.SYNC_WSS_FIELD_UID = 
                new Guid(TITLE_LIST_FIELD_GUID);
            syncFieldMappingsRow6.SYNC_WSS_FIELD_NAME = title;
            syncFieldMappingsRow6.SYNC_PROJECT_FIELD_UID = 
                TITLE_PROJECT_FIELD_GUID;
            syncFieldMappingsRow6.SYNC_PROJECT_FIELD_NAME = title;
            syncFieldMappingsRow6.SYNC_IS_PROJECT_CUSTOM_FIELD = false;
            syncDS.SyncFieldMappings.AddSyncFieldMappingsRow(
                syncFieldMappingsRow6);

            // Add SyncValueTranslationsRow.        
            //SvcProject.SyncDataSet.SyncValueTranslationsRow
            //    syncValueTranslationsRow = 
            //    syncDS.SyncValueTranslations.NewSyncValueTranslationsRow();

            SvcProject.SyncDataSet.SyncValueTranslationsRow
                syncValueTranslationsRow1 = 
                syncDS.SyncValueTranslations.NewSyncValueTranslationsRow();
            syncValueTranslationsRow1.SYNC_WSS_LIST_UID = listUid;
            syncValueTranslationsRow1.SYNC_WSS_FIELD_UID = new Guid(PRIORITY_FIELD_GUID);
            syncValueTranslationsRow1.SYNC_WSS_FIELD_NAME = priority;
            syncValueTranslationsRow1.SYNC_WSS_VALUE = priorityHigh;
            syncValueTranslationsRow1.SYNC_PROJECT_VALUE = priorityHighValue;
            syncDS.SyncValueTranslations.AddSyncValueTranslationsRow(syncValueTranslationsRow1);

            SvcProject.SyncDataSet.SyncValueTranslationsRow
                syncValueTranslationsRow2 = syncDS.SyncValueTranslations.NewSyncValueTranslationsRow();
            syncValueTranslationsRow2.SYNC_WSS_LIST_UID = listUid;
            syncValueTranslationsRow2.SYNC_WSS_FIELD_UID = new Guid(PRIORITY_FIELD_GUID);
            syncValueTranslationsRow2.SYNC_WSS_FIELD_NAME = priority;
            syncValueTranslationsRow2.SYNC_WSS_VALUE = priorityNormal;
            syncValueTranslationsRow2.SYNC_PROJECT_VALUE = priorityNormalValue;
            syncDS.SyncValueTranslations.AddSyncValueTranslationsRow(syncValueTranslationsRow2);

            SvcProject.SyncDataSet.SyncValueTranslationsRow
                syncValueTranslationsRow3 = syncDS.SyncValueTranslations.NewSyncValueTranslationsRow();
            syncValueTranslationsRow3.SYNC_WSS_LIST_UID = listUid;
            syncValueTranslationsRow3.SYNC_WSS_FIELD_UID = new Guid(PRIORITY_FIELD_GUID);
            syncValueTranslationsRow3.SYNC_WSS_FIELD_NAME = priority;
            syncValueTranslationsRow3.SYNC_WSS_VALUE = priorityLow;
            syncValueTranslationsRow3.SYNC_PROJECT_VALUE = priorityLowValue;
            syncDS.SyncValueTranslations.AddSyncValueTranslationsRow(syncValueTranslationsRow3);
 
            return syncDS;
        }

        // Configure the client endpoints.
        public static void ConfigClientEndpoints(string endpt)
        {
            projectClient = new SvcProject.ProjectClient(endpt);
        }
    }
}

関連項目

参照先

Project クラス

Project メンバー

WebSvcProject 名前空間