Enables an application to join a common context session.
public int JoinCommonContext(IContextParticipant contextParticipant,string applicationName,bool survey,bool wait)
Function JoinCommonContext( _ByVal contextParticipant As IContextParticipant, _ByVal applicationName As String, _ByVal survey As Boolean, _ByVal wait As Boolean _) As Integer
int JoinCommonContext(IContextParticipant^ contextParticipant,String^ applicationName,bool survey,bool wait)
contextParticipant
The context participant interface provided by the application.
applicationName
Name of the application. This string must be unique relative to the other applications that have already joined the common context session.
survey
If set to true participate in context change surveys. If false the application will only be informed when a context change has been accepted.
wait
If set to true wait for the current context change transaction to complete.
A participant coupon that the application uses to denote itself to the context manager.
Joins a common context and set patient information.
using Leadtools;using Leadtools.Ccow;using Leadtools.Ccow.UI;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 Memberspublic 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}
Imports LeadtoolsImports Leadtools.CcowImports Leadtools.Ccow.UIPrivate ApplicationName As String = "LEADTOOLS CCOW App"Public Sub JoinCommonContext()Dim contextManager As IContextManager = Utils.COMCreateObject(Of IContextManager)(CcowProgId)Dim participant As ContextParticipant = New ContextParticipant()Dim coupon As Integer = 0Trycoupon = contextManager.JoinCommonContext(participant, ApplicationName, True, False)'' Set Patient Context'SetPatientContext(contextManager, coupon)'' Get Patient Context'GetPatientContext(contextManager, coupon)contextManager.LeaveCommonContext(coupon)Catch e As ExceptionDebug.WriteLine(e.Message)End TryEnd SubPublic 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 = 0Dim noContinue As Boolean = True, disconnect As Boolean = FalseDim reasons As ObjectDim decision As String = "accept"patientSubject.Items.Add(New ContextItem("Patient.id.mrn", "123456789"))patientSubject.Items.Add(New ContextItem("Patient.co.Patientname", "Doe^John^^^"))TrytransactionCoupon = 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 ThenDim pd As ProblemDialog = New ProblemDialog(CType(reasons, String()), noContinue)Dim result As DialogResultresult = pd.ShowDialog()If noContinue Thendecision = "cancel"End IfIf result = System.Windows.Forms.DialogResult.OK Thendecision = "accept"ElseIf result = DialogResult.Cancel Thendecision = "cancel"Elsedecision = "cancel"disconnect = TrueEnd IfEnd IfcontextManager.PublishChangesDecision(transactionCoupon, decision)'' If user decided to break context we must leave'If disconnect ThencontextManager.LeaveCommonContext(coupon)End IfCatch e As ExceptionDebug.WriteLine(e.Message)End TryEnd SubPublic Sub GetPatientContext(ByVal contextManager As IContextManager, ByVal coupon As Integer)Dim contextData As IContextData = TryCast(contextManager, IContextData)Dim data As Object = NothingTrydata = contextData.GetItemNames(contextManager.MostRecentContextCoupon)If data.GetType() Is GetType(String()) AndAlso (CType(data, String())).Length > 0 ThenDim names As String() = CType(data, String())For Each name As String In namesDebug.WriteLine(name)Next namedata = contextData.GetItemValues(data, False, contextManager.MostRecentContextCoupon)If data.GetType() Is GetType(Object()) ThenDim values As Object() = CType(data, Object())Dim i As Integer = 0Do While i < values.LengthDebug.Write(values(i).ToString())Debug.Write(" ")Debug.WriteLine(values(i + 1).ToString())i += 2LoopEnd IfEnd IfCatch e As ExceptionDebug.WriteLine(e.Message)End TryEnd Sub<ComVisible(True)>Public Class ContextParticipantImplements IContextParticipantPublic Sub CommonContextTerminated() Implements IContextParticipant.CommonContextTerminatedConsole.WriteLine("CommonContextTerminated")End SubPublic Sub ContextChangesAccepted(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesAcceptedConsole.WriteLine("ContextChangesAccepted")End SubPublic Sub ContextChangesCanceled(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesCanceledConsole.WriteLine("ContextChangesCanceled")End SubPublic Function ContextChangesPending(ByVal contextCoupon As Integer, ByRef reason As String) As String Implements IContextParticipant.ContextChangesPendingreason = String.EmptyConsole.WriteLine("ContextChangesPending")Return "accept"End FunctionPublic Sub Ping() Implements IContextParticipant.PingEnd SubEnd Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
