概要
このオブジェクトは、ルールをローカルでチェックする目的では Web Verification Station では利用できません。
メソッド
定義 | 説明 |
|---|---|
Move(item : IBatchItem, position : int) | 要素をコレクション内の指定した位置に移動します。 注: このメソッドは、要素を移動する先のコレクションに対して呼び出します。 注: |
プロパティ
| 名前 | 型 | アクセス | 説明 |
|---|---|---|---|
| Count | int | 読み取り専用 | コレクション内の要素の数 |
Move メソッドの例
- セットを分解する
- 指定した順序で、ドキュメントを型ごとにグループ化する
- 指定したキーフィールドごとにドキュメントをグループ化する
- 同じキーフィールドを持つドキュメントをセットにアセンブルする
using System.Collections.Generic;
IBatchItems batch = Batch.AsBatchItem.ChildItems;
List<string> docDefs = new List<string> {"DocSet","Doc1","Doc2"}; // ドキュメントのアセンブリ順序
// キーフィールド名
// (すべてのドキュメントでインデックス化され、同じ名前である必要があります)
string keyFieldName = "SSN";
List<string> keyFields = new List<string>();
// セットの分解
bool foundChildren = false;
do
{
foreach (IBatchItem itm in batch)
{
if (itm.ChildItems.Count > 1)
{
int shift = 0;
foreach (IBatchItem subItm in itm.ChildItems)
{
shift++;
batch.Move(subItm, itm.Index + shift);
}
}
}
foreach (IBatchItem itm in batch)
if (itm.ChildItems.Count > 1)
foundChildren = true;
} while (foundChildren);
// セット内の正しい順序にドキュメントを並べ替える
// (セット自体の後にすべてのサブドキュメントが続く順序)
foreach (string docDefName in docDefs)
{
List<int> indexList = new List<int>();
foreach (IBatchItem itm in batch)
if (itm.Type == TBatchItemType.BIT_Document)
if (itm.AsDocument.DefinitionName == docDefName) indexList.Add(itm.Index);
for (int i = 0; i < indexList.Count; i++)
batch.Move(batch[indexList[i]-i], batch.Count);
}
// バッチ内のキーフィールドの値をすべて検索する
foreach (IBatchItem itm in batch)
{
if (itm.Type == TBatchItemType.BIT_Document)
{
string keyFieldValue = (string)itm.AsDocument.IndexedItemValue(keyFieldName);
if (!keyFields.Contains(keyFieldValue))
keyFields.Add(keyFieldValue);
}
}
// 同じキーフィールドを持つドキュメントをアセンブルする
foreach (string keyFieldValue in keyFields)
{
List<int> indexList = new List<int>();
foreach (IBatchItem itm in batch)
if (itm.Type == TBatchItemType.BIT_Document)
if ((string)itm.AsDocument.IndexedItemValue(keyFieldName) == keyFieldValue) indexList.Add(itm.Index);
for (int i = 0; i < indexList.Count; i++)
batch.Move(batch[indexList[i]-i], batch.Count);
}
// キーフィールドが一致する場合にのみサブドキュメントをセットに移動する
// (セットのセクションを先に、子ドキュメントを後に)
int ind = 0;
while (ind < batch.Count)
{
if (batch[ind].Type == TBatchItemType.BIT_Document)
// セットの先頭を検索する
if (batch[ind].AsDocument.DefinitionName == docDefs[0])
// セットの後のドキュメントがセットでなく、キーフィールドが一致する場合、
// そのドキュメントをこのセットに追加する
while (ind+1 < batch.Count &&
batch[ind+1].AsDocument.DefinitionName != docDefs[0] &&
(string)batch[ind+1].AsDocument.IndexedItemValue(keyFieldName) == (string)batch[ind].AsDocument.IndexedItemValue(keyFieldName))
batch[ind].ChildItems.Move(batch[ind+1], batch[ind].ChildItems.Count);
ind++;
}
