メインコンテンツへスキップ

概要

IBatchItem のコレクションです。 注: このオブジェクトは、ルールをローカルでチェックする目的では Web Verification Station では利用できません。

メソッド

定義

説明

Move(item : IBatchItem, position : int)

要素をコレクション内の指定した位置に移動します。

注: このメソッドは、要素を移動する先のコレクションに対して呼び出します。

注: position パラメーターには、0 からコレクションのサイズまでの値を指定できます。

プロパティ

名前アクセス名前
Countint読み取り専用コレクション内の要素の数

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);
}
// batch 内で主要項目のすべての値を検索
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++;
}
サンプルはここからダウンロードできます: Sample_IBatchItems_Move.zip