LEADTOOLS Medical (Leadtools.Ccow assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
InitializeBinding Method
See Also 
Leadtools.Ccow Namespace > ISecureBinding Interface : InitializeBinding Method



binderCoupon
The binder coupon.
propertyNames
The property names of the technology-specific secure binding-related properties for which the bindee wishes to establish agreement.
propertyValues
The property values.
binderPublicKey
The binder public key.
binderCoupon
The binder coupon.
propertyNames
The property names of the technology-specific secure binding-related properties for which the bindee wishes to establish agreement.
propertyValues
The property values.
binderPublicKey
The binder public key.
Enables a context management component ("bindee") to initiate the process of establishing a secure binding with another context management component ("binder").

Syntax

Visual Basic (Declaration) 
Function InitializeBinding( _
   ByVal binderCoupon As Integer, _
   ByVal propertyNames As Object, _
   ByVal propertyValues As Object, _
   ByRef binderPublicKey As String _
) As String
Visual Basic (Usage)Copy Code
Dim instance As ISecureBinding
Dim binderCoupon As Integer
Dim propertyNames As Object
Dim propertyValues As Object
Dim binderPublicKey As String
Dim value As String
 
value = instance.InitializeBinding(binderCoupon, propertyNames, propertyValues, binderPublicKey)
C# 
string InitializeBinding( 
   int binderCoupon,
   object propertyNames,
   object propertyValues,
   ref string binderPublicKey
)
C++/CLI 
String^ InitializeBinding( 
   int binderCoupon,
   Object^ propertyNames,
   Object^ propertyValues,
   % String^ binderPublicKey
) 

Parameters

binderCoupon
The binder coupon.
propertyNames
The property names of the technology-specific secure binding-related properties for which the bindee wishes to establish agreement.
propertyValues
The property values.
binderPublicKey
The binder public key.

Return Value

When a passcode-based secure binding is to be established, the value of the output mac is a message authentication code. This code shall be used by the bindee to prove the identity of the binder, and to ensure that the value of binderPublicKey has not been tampered with. When a PKI-based secure binding is to be established, the value of the output mac is a digital signature.

Example

Joins a common context and set patient information.

Visual BasicCopy Code
Private ApplicationName As String = "LEADTOOLS CCOW App"
      <Test> _
      Public Sub JoinCommonContext()
         Dim contextManager As IContextManager = Utils.COMCreateObject(Of IContextManager)(CcowProgId)
         Dim participant As ContextParticipant = New ContextParticipant()
         Dim coupon As Integer = 0

         Try
            coupon = contextManager.JoinCommonContext(participant, ApplicationName, True, False)

            '
            ' Set Patient Context
            '
            SetPatientContext(contextManager, coupon)

            '
            ' Get Patient Context
            '
            GetPatientContext(contextManager, coupon)

            contextManager.LeaveCommonContext(coupon)
         Catch e As Exception
            Debug.WriteLine(e.Message)
         End Try
      End Sub

      Public Sub SetPatientContext(ByVal contextManager As IContextManager, ByVal coupon As Integer)
         Dim patientSubject As Subject = New Subject("Patient")
         Dim contextData As IContextData = TryCast(contextManager, IContextData)
         Dim transactionCoupon As Integer = 0
         Dim noContinue As Boolean = True, disconnect As Boolean = False
         Dim reasons As Object
         Dim decision As String = "accept"

         patientSubject.Items.Add(New ContextItem("Patient.id.mrn", "123456789"))
         patientSubject.Items.Add(New ContextItem("Patient.co.Patientname", "Doe^John^^^"))

         Try
            transactionCoupon = contextManager.StartContextChanges(coupon)
            contextData.SetItemValues(coupon, patientSubject.ToItemNameArray(), patientSubject.ToItemValueArray(), transactionCoupon)
            reasons = contextManager.EndContextChanges(transactionCoupon, noContinue)

            '
            ' If any application responded that they cannot apply the change we need to display
            ' a dialog that displays the reasons for the problems.
            '
            If (Not reasons Is Nothing AndAlso (CType(reasons, String())).Length > 0) OrElse noContinue Then
               Dim pd As ProblemDialog = New ProblemDialog(CType(reasons, String()), noContinue)
               Dim result As DialogResult

               result = pd.ShowDialog()
               If noContinue Then
                  decision = "cancel"
               End If
               If result = System.Windows.Forms.DialogResult.OK Then
                  decision = "accept"
               ElseIf result = DialogResult.Cancel Then
                  decision = "cancel"
               Else
                  decision = "cancel"
                  disconnect = True
               End If
            End If

            contextManager.PublishChangesDecision(transactionCoupon, decision)

            '
            ' If user decided to break context we must leave
            '
            If disconnect Then
               contextManager.LeaveCommonContext(coupon)
            End If
         Catch e As Exception
            Debug.WriteLine(e.Message)
         End Try
      End Sub

      Public Sub GetPatientContext(ByVal contextManager As IContextManager, ByVal coupon As Integer)
         Dim contextData As IContextData = TryCast(contextManager, IContextData)
         Dim data As Object = Nothing

         Try
            data = contextData.GetItemNames(contextManager.MostRecentContextCoupon)
            If data.GetType() Is GetType(String() ) AndAlso (CType(data, String())).Length > 0 Then
               Dim names As String() = CType(data, String())

               For Each name As String In names
                  Debug.WriteLine(name)
               Next name
               data = contextData.GetItemValues(data, False, contextManager.MostRecentContextCoupon)
               If data.GetType() Is GetType(Object() ) Then
                  Dim values As Object() = CType(data, Object())

                  Dim i As Integer = 0
                  Do While i < values.Length
                     Debug.Write(values(i).ToString())
                     Debug.Write("     ")
                     Debug.WriteLine(values(i + 1).ToString())
                     i += 2
                  Loop
               End If
            End If
         Catch e As Exception
            Debug.WriteLine(e.Message)
         End Try
      End Sub

        <ComVisible(True)> _
        Public Class ContextParticipant
            Implements IContextParticipant
#Region "IContextParticipant Members"

            Public Sub CommonContextTerminated() Implements IContextParticipant.CommonContextTerminated
                Console.WriteLine("CommonContextTerminated")
            End Sub

            Public Sub ContextChangesAccepted(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesAccepted
                Console.WriteLine("ContextChangesAccepted")
            End Sub

            Public Sub ContextChangesCanceled(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesCanceled
                Console.WriteLine("ContextChangesCanceled")
            End Sub

            Public Function ContextChangesPending(ByVal contextCoupon As Integer, ByRef reason As String) As String Implements IContextParticipant.ContextChangesPending
                reason = String.Empty
                Console.WriteLine("ContextChangesPending")
                Return "accept"
            End Function

            Public Sub Ping() Implements IContextParticipant.Ping
            End Sub

#End Region
        End Class
C#Copy Code
private string ApplicationName = "LEADTOOLS CCOW App";

public void JoinCommonContext()
{
    IContextManager contextManager = Utils.COMCreateObject<IContextManager>(CcowProgId);
    ContextParticipant participant = new ContextParticipant();
    int coupon = 0;

    try
    {
        coupon = contextManager.JoinCommonContext(participant, ApplicationName, true, false);

        //
        // Set Patient Context
        //
        SetPatientContext(contextManager, coupon);

        //
        // Get Patient Context
        //
        GetPatientContext(contextManager, coupon);

        contextManager.LeaveCommonContext(coupon);
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

public void SetPatientContext(IContextManager contextManager, int coupon)
{
    Subject patientSubject = new Subject("Patient");
    IContextData contextData = contextManager as IContextData;
    int transactionCoupon = 0;
    bool noContinue = true, disconnect = false;
    object reasons;
    string decision = "accept";

    patientSubject.Items.Add(new ContextItem("Patient.id.mrn", "123456789"));
    patientSubject.Items.Add(new ContextItem("Patient.co.Patientname", "Doe^John^^^"));

    try
    {
        transactionCoupon = contextManager.StartContextChanges(coupon);
        contextData.SetItemValues(coupon, patientSubject.ToItemNameArray(), patientSubject.ToItemValueArray(), transactionCoupon);
        reasons = contextManager.EndContextChanges(transactionCoupon, ref noContinue);

        //
        // If any application responded that they cannot apply the change we need to display
        // a dialog that displays the reasons for the problems.
        //
        if ((reasons != null && ((string[])reasons).Length > 0) || noContinue)
        {
            ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);
            DialogResult result;

            result = pd.ShowDialog();
            if (noContinue)
                decision = "cancel";
            if (result == DialogResult.OK)
                decision = "accept";
            else if (result == DialogResult.Cancel)
                decision = "cancel";
            else
            {
                decision = "cancel";
                disconnect = true;
            }
        }

        contextManager.PublishChangesDecision(transactionCoupon, decision);

        //
        // If user decided to break context we must leave
        //
        if (disconnect)
        {
            contextManager.LeaveCommonContext(coupon);
        }
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

public void GetPatientContext(IContextManager contextManager, int coupon)
{
    IContextData contextData = contextManager as IContextData;
    object data = null;

    try
    {
        data = contextData.GetItemNames(contextManager.MostRecentContextCoupon);
        if (data.GetType() == typeof(string[]) && ((string[])data).Length > 0)
        {
            string[] names = (string[])data;

            foreach (string name in names)
            {
                Debug.WriteLine(name);
            }
            data = contextData.GetItemValues(data, false, contextManager.MostRecentContextCoupon);
            if (data.GetType() == typeof(object[]))
            {
                object[] values = (object[])data;

                for (int i = 0; i < values.Length; i += 2)
                {
                    Debug.Write(values[i].ToString());
                    Debug.Write("     ");
                    Debug.WriteLine(values[i + 1].ToString());
                }
            }
        }
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

[ComVisible(true)]
public class ContextParticipant : IContextParticipant
{
    #region IContextParticipant Members

    public void CommonContextTerminated()
    {
        Console.WriteLine("CommonContextTerminated");
    }

    public void ContextChangesAccepted(int contextCoupon)
    {
        Console.WriteLine("ContextChangesAccepted");
    }

    public void ContextChangesCanceled(int contextCoupon)
    {
        Console.WriteLine("ContextChangesCanceled");
    }

    public string ContextChangesPending(int contextCoupon, ref string reason)
    {
        reason = string.Empty;
        Console.WriteLine("ContextChangesPending");
        return "accept";
    }

    public void Ping()
    {
    }

    #endregion
}

Remarks

A secure binding shall be established by the bindee before it attempts to interact with the binder via methods that entail the use of either the bindee’s or the binder’s digital signature. For example, an application or user mapping agent shall establish a secure binding with the context manager before it attempts to access the context manager in order to set or get context item values that require the bindee’s digital signature.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Ccow requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features