ここで提供される変換スクリプト例は、[変換エントリ]画面の[保留中エントリ]を処理する、かなり単純な場合です。
OnTranslationEvent ハンドラは、リソースの最初の文字に対する単純な確認を実行し、その値によってアクションを実行します。最初の文字が 'a' の場合、変換エントリは 'ignore' に設定されます。'b' の場合、削除されます。'c' の場合、変換されます。その他の場合は、変更されないまま手動で変換されます。 コード全体にわたるカウンタが、スクリプト実行中に何のアクションが実行されるかを記録します。 これは、実行されるごと、特にスクリプトが自動化されているときに、デバッグまたはスクリプトの実行の文書化に非常に役立ちます。 関数の最後の Tools.Commit コマンドを忘れないようにするのは非常に重要です。このコマンドがないと、スクリプトによる変更はデータベースに保存されません。
TranslateResource()関数が呼び出されると、(E2E プレフィックスと共に)保留中の変換エントリにより引き渡されたのと同じ名前のリソースがシステムに存在するかどうかを確認します。 存在しない場合は、スクリプトはこのリソースを追加してから変換を実行します。 すでに存在している場合は、そのリソース文字列から既存の CA Business Service Insight リソースに変換エントリを作成します。
スクリプトの最後の Result 関数は、単にスクリプトによって実行されたタスクの説明を出力します。 コードを以下に示します。
Option Explicit
dim translated
dim ignored
dim deleted
dim manually
dim ActionDate
Sub OnLoad()
'tools.log "Translation Script: In OnLoad procedure", "I"
End Sub
Sub OnTranslationEvent(entryDetails)
Dim dump
dump = entryDetails.Dump
tools.log dump
Dim resource, entryId
entryId = entryDetails.EntryId
resource = entryDetails.FieldValue(1)
ActionDate = entryDetails.LastActionDate
If mid(resource,1,1) = "a" Then
tools.IgnoreEntry entryId
ignored = ignored + 1
tools.log "ignored" & entryId & " " & resource
Else If mid(resource,1,1) = "b" Then
tools.DeleteEntry entryId
deleted = deleted + 1
tools.log "deleted" & entryId & " " & resource
Else If mid(resource,1,1) = "c" Then
TranslateResource resource, entryId
tools.log "translated" & entryId & " " & resource
Else
tools.SetManualTranslationEntry entryId, 1
manually = manually + 1
tools.log "manually" & entryId & " " & resource
End if
Tools.commit
End Sub
Sub TranslateResource(resource, entryId)
Dim newName
Dim vector
newName = "E2E-" & resource
if NOT tools.IsResourceExists(newName) Then
Dim resourceDetails
set resourceDetails = tools.GetResourceDetailsByDate(resource,ActionDate)
resourceDetails("ResourceName") = newName
resourceDetails("ResourceTypes") = "E2E Transactions"
tools.AddResourceByMap resourceDetails
end if
tools.TranslateEntry entryId, newName
End Sub
Sub Main()
end Sub
Function Result
Result = translated & "entries were translated, "& _
ignored & "entries were ignored," & _
deleted & "entries were deleted and "& _
manually & "entries were set to manually update!"
End Function
| Copyright © 2012 CA. All rights reserved. | このトピックについて CA Technologies に電子メールを送信する |