5

IEdmEnumeratorVariable5::SetVarWindowsフォームへのユーザー入力に基づいて、いくつかのファイルカード変数を更新するために使用しようとしています。私のコードが実行され、エラー メッセージは表示されず、ファイルがチェックアウトされ、再度チェックインされ、適切なコメントが履歴に追加されます。ただし、カードの変数は更新されません。

実行時にコードをステップ実行することで、すべての変数に正しい (予想どおりの) データが入力されていることを確認しました。手順はSetVarすべて問題なく終了しますが、データ カードの変数の値は変わりません。フォルダ ビューを手動で更新しても効果はありません。


以下は私のコードです。

これは、ターゲット フレームワーク .NET 4.0 を使用して、VS Community 2015 を使用して VB でクラス ライブラリ プロジェクトとして作成されたアドイン アプリケーションです。

この質問をより簡潔にするために; すぐ下に、変数の設定を行うコードのスニペットだけを含めました。次に、必要に応じて全体像を把握できるように、さらに多くのコードも含めました。


ヒントだけ:

これは、変数の設定を行うコードです。

Dim UserManager As IEdmUserMgr5 = .SourceVault
Dim User As IEdmUser5 = UserManager.GetLoggedInUser

CardComment = UserComment & CardComment
CardDate = Today().ToString("yyMMdd", Globalization.CultureInfo.InvariantCulture)
CardBy = User.Name
CardDisposition = UserDisposition

CardVariables.SetVar(DispositionVariable, "@", CardDisposition)
CardVariables.SetVar(CommentVariable, "@", CardComment)
CardVariables.SetVar(ByVariable, "@", CardBy)
CardVariables.SetVar(DateVariable, "@", CardDate)
CardVariables.Flush()


より広いストローク:

クラス モジュール レベルの変数:

Private Structure CommandInfo
    Dim SourceVault As IEdmVault11
    Dim SourceCommand As EdmCmd
    Dim SourceSelection As System.Array
    Dim TargetTemplate As System.String
    Dim VerifiedPaths As List(Of String)
End Structure

Private ReceivedCommand As CommandInfo

OnCmd プロシージャ (呼び出し元):

Public Sub OnCmd(ByRef poCmd As EdmCmd,
                 ByRef ppoData As System.Array) Implements IEdmAddIn5.OnCmd

    Dim CommandToRun As MenuCommand

    Try

        With ReceivedCommand
            .SourceVault = poCmd.mpoVault
            .SourceCommand = poCmd
            .SourceSelection = ppoData

            'Get the command structure for the command ID
            Select Case poCmd.meCmdType

                Case EdmCmdType.EdmCmd_Menu
                    CommandToRun = AvailableCommands(.SourceCommand.mlCmdID)

                Case EdmCmdType.EdmCmd_CardButton
                    Select Case True
                        Case poCmd.mbsComment.ToString.ToUpper.Contains("DISPOSITION")
                            DispositionRequest()
                        Case Else : Exit Sub
                    End Select

                Case Else : Exit Sub
            End Select
    '...... (End Try, End Sub, Etc.)

DispositionRequest プロシージャ (呼び出し先):

Private Sub DispositionRequest()

    Dim UserDisposition As String

    Using Disposition As New DispositionForm
        With Disposition
            If Not .ShowDialog() = System.Windows.Forms.DialogResult.OK Then Exit Sub
            Select Case True

                Case .Approve.Checked
                    UserDisposition = "Approved"

                Case .Reject.Checked
                    UserDisposition = "Rejected"

                Case Else : Exit Sub

            End Select
        End With
    End Using



    Dim UserComment As String

    Using Explanation As New DispositionExplanation
        With Explanation

            If Not .ShowDialog() = System.Windows.Forms.DialogResult.OK Then Exit Sub

            If .ListView1.Items.Count > 0 Then
                 'do some stuff not relevant to this question...
            End If

            UserComment = .Comments.Text

        End With
    End Using

    'This next procedure just gets a list of paths from ReceivedCommand.SourceSelection  - which is just the ppoData argument from the OnCmd procedure - see code block above!
    Dim RequestPaths As List(Of String) = GetSelectedFilePaths()

    For Each Path As String In RequestPaths
        With ReceivedCommand
            Dim RequestFile As IEdmFile5 = .SourceVault.GetFileFromPath(Path)
            Dim ParentFolder As IEdmFolder6 = .SourceVault.GetFolderFromPath(System.IO.Path.GetDirectoryName(Path))
            Dim UnlockLater As Boolean = False

            If Not RequestFile.IsLocked Then
                UnlockLater = True
                RequestFile.LockFile(ParentFolder.ID, .SourceCommand.mlParentWnd, CInt(EdmLockFlag.EdmLock_Simple))
            End If

            Dim CardVariables As IEdmEnumeratorVariable5 = RequestFile.GetEnumeratorVariable

            'We allow users to re-disposition a request so we want to keep any previous disposition information so it is not lost
            Dim CardComment As String = String.Empty
            Dim CardBy As String = String.Empty
            Dim CardDate As String = String.Empty
            Dim CardDisposition As String = String.Empty
            Dim Success As Boolean

            Const CommentVariable As String = "DispComm"
            Const ByVariable As String = "DisposedBy"
            Const DateVariable As String = "DisposedDate"
            Const DispositionVariable As String = "Disposition"

            Success = CardVariables.GetVar(DispositionVariable, "@", CardDisposition)

            If Success Then
                Success = CardVariables.GetVar(CommentVariable, "@", CardComment)
                If Success Then Success = CardVariables.GetVar(ByVariable, "@", CardBy)
                If Success Then Success = CardVariables.GetVar(DateVariable, "@", CardDate)
                If Success Then CardComment = "Previously dispositioned as: """ & CardDisposition & """ by: " & CardBy & " on: " & CardDate & vbNewLine &
                                                 "---------Previous disposition explanation---------" & vbNewLine & CardComment
            End If

            Dim UserManager As IEdmUserMgr5 = .SourceVault
            Dim User As IEdmUser5 = UserManager.GetLoggedInUser

            CardComment = UserComment & CardComment
            CardDate = Today().ToString("yyMMdd", Globalization.CultureInfo.InvariantCulture)
            CardBy = User.Name
            CardDisposition = UserDisposition

            CardVariables.SetVar(DispositionVariable, "@", CardDisposition)
            CardVariables.SetVar(CommentVariable, "@", CardComment)
            CardVariables.SetVar(ByVariable, "@", CardBy)
            CardVariables.SetVar(DateVariable, "@", CardDate)
            CardVariables.Flush()

            If UnlockLater Then RequestFile.UnlockFile(lParentWnd:= .SourceCommand.mlParentWnd,
                                                        bsComment:="Dispositioned as " & CardDisposition,
                                                        lEdmUnlockFlags:=0)
            .SourceVault.RefreshFolder(ParentFolder.LocalPath)
        End With
    Next


End Sub
4

1 に答える 1

3

ドキュメントから:

bsCfgName : 変数値を格納する構成またはレイアウトの名前。構成をサポートしないフォルダーとファイルの種類の空の文字列

構成をサポートしていない仮想ファイルで作業していました。仮想ファイルで動作する C の例を見て、null 参照を渡していたので、ドキュメントを読み直して上記の抜粋を見たので、mboconfiguration 引数のコードを から に変更したところ、動作するようになりました "@"!String.Empty

CardVariables.SetVar(DispositionVariable, String.Empty, CardDisposition)
CardVariables.SetVar(CommentVariable, String.Empty, CardComment)
CardVariables.SetVar(ByVariable, String.Empty, CardBy)
CardVariables.SetVar(DateVariable, String.Empty, CardDate)
CardVariables.Flush()
于 2015-08-31T21:11:25.623 に答える