CustomFields.UpdateCustomFields2 メソッド
作成、変更、または数式は、言語に依存する形式で、エンタープライズ ユーザー設定フィールドを削除します。
名前空間: WebSvcCustomFields
アセンブリ: ProjectServerServices (ProjectServerServices.dll 内)
構文
'宣言
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/UpdateCustomFields2", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub UpdateCustomFields2 ( _
cfds As CustomFieldDataSet, _
validateOnly As Boolean, _
autoCheckIn As Boolean _
)
'使用
Dim instance As CustomFields
Dim cfds As CustomFieldDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean
instance.UpdateCustomFields2(cfds, validateOnly, _
autoCheckIn)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/UpdateCustomFields2", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateCustomFields2(
CustomFieldDataSet cfds,
bool validateOnly,
bool autoCheckIn
)
パラメーター
cfds
型: WebSvcCustomFields.CustomFieldDataSetCustomFieldDataSetには、更新されたユーザー設定フィールドの定義が含まれています。
validateOnly
型: System.Boolean場合はtrue、 CustomFieldDataSetのみを検証します。
autoCheckIn
型: System.Boolean場合はtrue、それらが更新された後、ユーザー設定フィールドをチェックインします。
注釈
Project Server 2010の新しい方法です。UpdateCustomFields2はCustomFieldDataSetの新しいユーザー設定フィールドが含まれています、既存のユーザー設定フィールドを変更して、 CustomFieldDataSetに含まれていないカスタム フィールドを削除する場合、ユーザー設定フィールドを作成します。
Project Server を実行しているコンピューターの [地域と言語のオプション コントロール パネルで指定されているロケールの形式で、 CustomFieldDataSetでマークやカスタム フィールドを計算するために使用されている数式を記述できます。UpdateCustomFields2メソッドは、言語に依存しない形式で数式を保存します。一方、 UpdateCustomFieldsメソッドは、ロケールの形式に関係なく、数式を保存します。
注意
UpdateCustomFieldsメソッドとUpdateCustomFields2メソッドだけでなく、 Project Web App、すべてのタイプのフラグは、エンタープライズ プロジェクト ユーザー設定フィールドを作成することを許可し、ワークフローを制御するユーザー設定フィールドを設定します。ただし、フラグ ユーザー設定フィールド Project Server ワークフローは制御できません。ワークフロー コントロールのフラグの種類のプロジェクトのユーザー設定フィールドを設定しないでください。
プロジェクト サーバーのアクセス許可
権限 |
説明 |
---|---|
エンタープライズ ユーザー設定フィールドと参照テーブル値の定義を変更することができます。グローバル アクセス権。 |
場合は、ユーザーのチェック アウトを行わず、ユーザー設定フィールド、 UpdateCustomFields2に管理者のアクセス許可を強制的にチェックインする必要があります。
例
次の使用例は、 ReadCustomFieldsByMdPropUidsとReadCustomFieldsByMdPropUids2を使用して、カスタム フィールドを読み取るし、内容を書き込みますcustomFieldDSCustomFieldDataSet.xmlおよびCustomFieldDataSet2.xml、それぞれ.MD_PROP_FORMULAを除く 2 つの方法は、同じデータを返します。
詳細については、同じ式でProject Web AppとProject Professional 2010を使用する方法を示す手順も含めて、 Using Formulas and Graphical Indicators with Custom Fieldsを参照してください。
ReadCustomFieldsByMdPropUidsによって返される式のフィールドで、 MD_PROP_FORMULA (サーバおよびプロジェクトのインストールの言語) のロケールによって異なります表示、次のコードに示します。
<MD_PROP_FORMULA>Switch(Not ([MSPJ188743724] >= #01/01/1984# And [MSPJ188743724] < #01/01/2050#),
"No Baseline", ([MSPJ188743685] + 1) / ([MSPJ188743686] + 1) > 1.2, "Overbudget by 20% or more",
([MSPJ188743685] + 1) / ([MSPJ188743686] + 1) > 1, "Overbudget", True, "Under budget")</MD_PROP_FORMULA>
(に示すように、次のコード) は、 ReadCustomFieldsByMdPropUids2によって返される式のフィールドMD_PROP_FORMULAは、ロケールに依存しません。同様に、異なる言語のインストールで動作します。このため、 ReadCustomFieldsByMdPropUids2メソッドは、 ReadCustomFieldsByMdPropUidsメソッドを優先です。
<MD_PROP_FORMULA><MD_PROP_FORMULA>Switch(Not ([Baseline Estimated Finish] >= #1/1/1984# And [Baseline Estimated Finish] < #1/1/2050#),
"No Baseline", ([Cost] + 1) / ([Baseline Cost] + 1) > 1.2, "Overbudget by 20% or more",
([Cost] + 1) / ([Baseline Cost] + 1) > 1, "Overbudget", True, "Under budget")</MD_PROP_FORMULA>
さらに、例では、数式を変更して、ユーザー設定のフィールドを更新するには、 UpdateCustomFields2メソッドを呼び出すし、 UpdatedCustomFieldData.xmlにし、更新されたデータセットを書き込みます
編集後に、ユーザー設定フィールドをチェックインするには、 CheckInCustomFieldsを呼び出すし、それらを変更する前に、ユーザー設定のフィールドを確認するには、 CheckOutCustomFieldsを呼び出します。
例では、ProjectServerServices.dll プロキシ アセンブリ内のSvcCustomFieldsの名前空間を使用します。ConfigClientEndpointsメソッドとSetClientEndpointsメソッドは、WCF のバインディング、動作、およびエンドポイントの設定を app.config ファイルを使用します。PSI プロキシ アセンブリと app.config ファイルを作成する方法の詳細については、 Project 2013 での WCF ベースのコード サンプルの前提条件を参照してください。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
namespace Microsoft.SDK.Project.Samples.TestCustomFields
{
class CustomFields
{
private static SvcCustomFields.CustomFieldsClient customFieldClient;
private static SvcResource.ResourceClient resourceClient;
private const string RES_ENDPOINT = "basicHttp_Resource";
private const string CUST_ENDPOINT = "basicHttp_CustomFields";
private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
private static string outFilePathCustomFields;
private static string outFilePathCustomFields2;
private static string outFilePathCustomFields3;
static void Main(string[] args)
{
try
{
Guid[] customFieldID = new Guid[1];
customFieldID[0] = new Guid("4bfa524a-ce48-4a31-a2d6-5e8baa6c9d29");
ConfigClientEndpoints(CUST_ENDPOINT);
SetClientEndpoints(RES_ENDPOINT);
// If 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.
outFilePathCustomFields = OUTPUT_FILES + "CustomFieldData.xml";
outFilePathCustomFields2 = OUTPUT_FILES + "CustomFieldData2.xml";
outFilePathCustomFields3 = OUTPUT_FILES + "UpdatedCustomFieldData.xml";
// Create a custom fields dataset.
SvcCustomFields.CustomFieldDataSet customFieldDS =
new SvcCustomFields.CustomFieldDataSet();
// Read the custom fields data by using ReadCustomFieldsByMdPropUids.
customFieldDS = customFieldClient.ReadCustomFieldsByMdPropUids(
new Guid[] { customFieldID[0] }, false);
// Write the dataset to an XML file.
customFieldDS.WriteXml(outFilePathCustomFields);
Console.WriteLine("\nSee XML output of the CustomFieldDataSet at {0}",
outFilePathCustomFields);
// Read the custom fields data by using ReadCustomFieldsByMdPropUids2.
customFieldDS = customFieldClient.ReadCustomFieldsByMdPropUids2(
new Guid[] { customFieldID[0] }, false);
// Write the dataset to an XML file.
customFieldDS.WriteXml(outFilePathCustomFields2);
bool checkedOut = false;
// Get the ID of the user.
Guid me = resourceClient.GetCurrentUserUid();
// Check whether the custom field to be updated is checked out.
foreach (SvcCustomFields.CustomFieldDataSet.CustomFieldsRow custRow in customFieldDS.CustomFields)
{
if (custRow.MD_PROP_UID.ToString() == customFieldID[0].ToString())
{
if (custRow.IsNull("MD_PROP_CHECKOUTBY")) // If the custom field is not checked out.
{
// Check out the custom field.
customFieldClient.CheckOutCustomFields(new Guid[] { custRow.MD_PROP_UID });
checkedOut = true;
Console.WriteLine("Custom field checked out.....");
break;
}
else
{
// Check whether the custom field is checked out by you.
if (custRow.MD_PROP_CHECKOUTBY == me)
{
checkedOut = true;
Console.WriteLine("The custom field is already checked out by you");
break;
}
else
{
// The custom field is checked out by some other user.
checkedOut = false;
Console.WriteLine("This custom field has already been checked out");
Console.ReadLine();
break;
}
}
}
}
if (checkedOut)
{
// Modify the formula field of the custom field.
// Type the following statement in a single line.
customFieldDS.CustomFields[0].MD_PROP_FORMULA =
"Switch(Not ([Baseline Estimated Finish] >= #1/1/1984# And [Baseline Estimated Finish] < #1/1/2050#),
\"No Baseline\", ([Cost] + 1) / ([Baseline Cost] + 1) > 1.5, \"Overbudget by 50% or more\",
([Cost] + 1) / ([Baseline Cost] + 1) > 1, \"Overbudget\", True, \"Under budget\")";
// Update the dataset.
customFieldClient.UpdateCustomFields2(customFieldDS, false, false);
customFieldDS.WriteXml(outFilePathCustomFields3);
// Write the custom field data to an XML file.
Console.WriteLine("\nSee XML output of the CustomFieldDataSet at {0}",
outFilePathCustomFields3);
// Check in the custom field.
customFieldClient.CheckInCustomFields(new Guid[] { customFieldID[0] }, false);
}
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
finally
{
Console.Write("\r\n\r\nPress any key....");
Console.ReadKey();
}
}
// Configure the custom field client endpoints.
public static void ConfigClientEndpoints(string endpt)
{
customFieldClient = new SvcCustomFields.CustomFieldsClient(endpt);
}
// Configure the resource client endpoints.
public static void SetClientEndpoints(string ept)
{
resourceClient = new SvcResource.ResourceClient(ept);
}
}
}
式のフィールドが変更されたMD_PROP_FORMULAで、更新されたデータセットUpdatedCustomFieldData.xmlが書き込まれ、次のコードに示します。
<?xml version="1.0" standalone="yes"?>
<CustomFieldDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/CustomFieldDataSet/">
<CustomFields>
<MD_PROP_UID>4bfa524a-ce48-4a31-a2d6-5e8baa6c9d29</MD_PROP_UID>
<MD_PROP_ID>188776464</MD_PROP_ID>
<MD_PROP_UID_SECONDARY>64546b89-9a2a-49d8-b3ce-190119a3c562</MD_PROP_UID_SECONDARY> <MD_PROP_ID_SECONDARY>255885317</MD_PROP_ID_SECONDARY>
<MD_ENT_TYPE_UID>ebad93e7-2149-410d-9a39-a8680738329d</MD_ENT_TYPE_UID>
<MD_PROP_NAME>Budget Indicator</MD_PROP_NAME>
<MD_PROP_IS_WORKFLOW_CONTROLLED>false</MD_PROP_IS_WORKFLOW_CONTROLLED>
<MD_PROP_IS_REQUIRED>false</MD_PROP_IS_REQUIRED>
<MD_AGGREGATION_TYPE_ENUM>9</MD_AGGREGATION_TYPE_ENUM>
<MD_PROP_TYPE_ENUM>21</MD_PROP_TYPE_ENUM>
<MD_PROP_IS_MULTILINE_TEXT>false</MD_PROP_IS_MULTILINE_TEXT>
<MD_PROP_DESCRIPTION>Test for graphical indicator example in SDK</MD_PROP_DESCRIPTION>
<MD_PROP_MAX_VALUES>1</MD_PROP_MAX_VALUES>
<MD_PROP_FORMULA>Switch(Not ([Baseline Estimated Finish] >= #1/1/1984# And [Baseline Estimated Finish] < #1/1/2050#),
"No Baseline", ([Cost] + 1) / ([Baseline Cost] + 1) > 1.5, "Overbudget by 50% or more",
([Cost] + 1) / ([Baseline Cost] + 1) > 1, "Overbudget", True, "Under budget")</MD_PROP_FORMULA>
<MD_PROP_GRAPHICAL_INDICATOR>[[==No baseline][5]][[==Overbudget by 50% or more][3]]
[[==Overbudget][2]][[==Under budget][1]]</MD_PROP_GRAPHICAL_INDICATOR>
<MD_PROP_SUMM_GRAPHICAL_INDICATOR>[[==No baseline][5]][[==Overbudget by 50% or more][3]]
[[==Overbudget][2]][[==Under budget][1]]</MD_PROP_SUMM_GRAPHICAL_INDICATOR>
<MD_PROP_PROJ_SUMM_GRAPHICAL_INDICATOR>[[==No baseline][5]][[==Overbudget by 50% or more][3]]
[[==Overbudget][2]][[==Under budget][1]]</MD_PROP_PROJ_SUMM_GRAPHICAL_INDICATOR>
<MD_PROP_GRAPHICAL_INDICATOR_TOOLTIP>false</MD_PROP_GRAPHICAL_INDICATOR_TOOLTIP>
<MD_PROP_ROLLDOWN_TO_ASSN>false</MD_PROP_ROLLDOWN_TO_ASSN>
<MD_PROP_COPY_ON_REASSIGNMENT>false</MD_PROP_COPY_ON_REASSIGNMENT>
<MD_PROP_CHECKOUTDATE>2010-02-08T10:57:21.21-08:00</MD_PROP_CHECKOUTDATE>
<MOD_DATE>2010-02-08T11:12:40.78-08:00</MOD_DATE>
</CustomFields>
</CustomFieldDataSet>