// ViewAss.cpp : implementation file // #include "stdafx.h" #include "dclient.h" #include "ViewAss.h" const WCHAR BASED_CODE _szLicString[] = LEAD_LICENSE_STRING; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CViewAssociate dialog CViewAssociate::CViewAssociate(CWnd* pParent /*=NULL*/) : CDialog(CViewAssociate::IDD, pParent) { //{{AFX_DATA_INIT(CViewAssociate) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_hPDU=0; } void CViewAssociate::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CViewAssociate) DDX_Control(pDX, IDC_PRESENTATION, m_Presentation); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CViewAssociate, CDialog) //{{AFX_MSG_MAP(CViewAssociate) ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CViewAssociate message handlers BOOL CViewAssociate::OnInitDialog() { CDialog::OnInitDialog(); short nID; long lCount; long x; CString szOut; CString szAbstract; CString szTransfer; short nRet; long lBytes; long n; int nIndex; VARIANT Data; VariantInit(&Data); //******************************* BSTR lpLic = SysAllocString(_szLicString); ILEADDicomFactory *pFactory=NULL; CoCreateInstance(CLSID_LEADDicomFactory, NULL, CLSCTX_ALL, IID_ILEADDicomFactory, (void**)&pFactory); #if _MSC_VER < 1200 m_pLEADDicomNet = (ILEADDicomDS*)pFactory->CreateObject("LEADDicomNet.LEADDicomNet", lpLic); #else ILEADDicomNetPtr spLEADDicomNet=NULL; spLEADDicomNet = pFactory->CreateObject("LEADDicomNet.LEADDicomNet", lpLic); m_pLEADDicomNet = spLEADDicomNet; // m_pLEADDicomNet->AddRef();//because when spLEADDicomNet goes out of scope, it will auto Release()! #endif #if _MSC_VER < 1200 m_pLEADDicomDS = (ILEADDicomDS*)pFactory->CreateObject("LEADDicomDS.LEADDicomDS", lpLic); #else ILEADDicomDSPtr spLEADDicomDS=NULL; spLEADDicomDS = pFactory->CreateObject("LEADDicomDS.LEADDicomDS", lpLic); m_pLEADDicomDS = spLEADDicomDS; // m_pLEADDicomDS->AddRef();//because when spLEADDicomDS goes out of scope, it will auto Release()! #endif //************************** m_pLEADDicomNet->EnableMethodErrors = FALSE; m_Presentation.InsertColumn(0, "ID", LVCFMT_LEFT, 30, 1); m_Presentation.InsertColumn(1, "Abstract", LVCFMT_LEFT, 310, 2); m_Presentation.InsertColumn(2, "Result", LVCFMT_LEFT, 170, 3); m_Presentation.InsertColumn(3, "Transfer", LVCFMT_LEFT, 150, 4); m_Presentation.InsertColumn(4, "User", LVCFMT_LEFT, 40, 5); m_Presentation.InsertColumn(5, "Provider", LVCFMT_LEFT, 60, 6); m_Presentation.InsertColumn(6, "Extended", LVCFMT_LEFT, 70, 7); if(!m_hPDU) EndDialog(IDCANCEL); else { SetDlgItemText(IDC_CALLED, m_pLEADDicomNet->GetCalled(m_hPDU)); SetDlgItemText(IDC_CALLING, m_pLEADDicomNet->GetCalling(m_hPDU)); szOut.Format("%d", m_pLEADDicomNet->GetVersion(m_hPDU)); SetDlgItemText(IDC_VERSION, szOut); SetDlgItemText(IDC_APPLICATION, m_pLEADDicomNet->GetApplication(m_hPDU)); szOut.Format("%ld", m_pLEADDicomNet->GetMaxLength(m_hPDU)); SetDlgItemText(IDC_MAX_LENGTH, szOut); if(m_pLEADDicomNet->IsMaxLengthEnabled(m_hPDU)) CheckDlgButton(IDC_B_MAX_LENGTH, 1); else CheckDlgButton(IDC_B_MAX_LENGTH, 0); BSTR bstr = m_pLEADDicomNet->GetImplementClass(m_hPDU); szOut = bstr; SysFreeString(bstr); SetDlgItemText(IDC_IMPLEMENT_CLASS, szOut); if(m_pLEADDicomNet->IsImplementClass(m_hPDU)) CheckDlgButton(IDC_B_IMPLEMENT_CLASS, 1); else CheckDlgButton(IDC_B_IMPLEMENT_CLASS, 0); bstr = m_pLEADDicomNet->GetImplementVersion(m_hPDU); szOut = bstr; SysFreeString(bstr); SetDlgItemText(IDC_IMPLEMENT_VERSION, szOut); if(m_pLEADDicomNet->IsImplementVersion(m_hPDU)) CheckDlgButton(IDC_B_IMPLEMENT_VERSION, 1); else CheckDlgButton(IDC_B_IMPLEMENT_VERSION, 0); if(m_pLEADDicomNet->IsAsyncOperations(m_hPDU)) CheckDlgButton(IDC_B_ASYNC_OPERATIONS, 1); else CheckDlgButton(IDC_B_ASYNC_OPERATIONS, 0); szOut.Format("%ld", m_pLEADDicomNet->GetInvokedOperationsCount(m_hPDU)); SetDlgItemText(IDC_INVOKED, szOut); szOut.Format("%ld", m_pLEADDicomNet->GetPerformedOperationsCount(m_hPDU)); SetDlgItemText(IDC_PERFORMED, szOut); //fill in presentation context information m_pLEADDicomDS->EnableMethodErrors = FALSE; //get each Presentation Context lCount = m_pLEADDicomNet->GetPresentationCount(m_hPDU); for(x=0; xGetPresentationID(m_hPDU, x); nIndex = m_Presentation.InsertItem(m_Presentation.GetItemCount(), "Z"); szOut.Format("%u", nID); m_Presentation.SetItem(nIndex, 0, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); //each Presentation Context can have one Abstract Syntax BSTR bstr = m_pLEADDicomNet->GetPresentationAbstract(m_hPDU, nID); szAbstract = bstr; SysFreeString(bstr); if(szAbstract.GetLength() > 0) { BSTR bstr = szAbstract.AllocSysString(); nRet = m_pLEADDicomDS->FindUID(bstr); SysFreeString(bstr); if(nRet == 0) { IDicomUIDItemPtr pCurrentUID = m_pLEADDicomDS->GetCurrentUID(); BSTR bstr = pCurrentUID->GetName(); szOut = bstr; SysFreeString(bstr); } else szOut = szAbstract; } m_Presentation.SetItem(nIndex, 1, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); //get the result switch(m_pLEADDicomNet->GetPresentationResult(m_hPDU, nID)) { case PDU_ACCEPT_RESULT_SUCCESS: szOut = "Acceptance"; break; case PDU_ACCEPT_RESULT_USER_REJECT: szOut = "User Rejection"; break; case PDU_ACCEPT_RESULT_PROVIDER_REJECT: szOut = "Provider Rejection"; break; case PDU_ACCEPT_RESULT_ABSTRACT_SYNTAX: szOut = "Abstract Syntax Not Supported"; break; case PDU_ACCEPT_RESULT_TRANSFER_SYNTAX: szOut = "Transfer Syntax(es) Not Supported"; break; default: szOut.Format("Unknown Reason - %d", m_pLEADDicomNet->GetPresentationResult(m_hPDU, nID)); break; } m_Presentation.SetItem(nIndex, 2, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); //get the Transfer Syntax bstr = m_pLEADDicomNet->GetTransferSyntax(m_hPDU, nID, 0); szTransfer = bstr; SysFreeString(bstr); if(szTransfer.GetLength() > 0) { BSTR bstr = szTransfer.AllocSysString(); nRet = m_pLEADDicomDS->FindUID(bstr); SysFreeString(bstr); if(nRet == 0) { IDicomUIDItemPtr pCurrentUID = m_pLEADDicomDS->GetCurrentUID(); BSTR bstr = pCurrentUID->GetName(); szOut = bstr; SysFreeString(bstr); } else szOut = szTransfer; m_Presentation.SetItem(nIndex, 3, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); } //Role Selection szOut.Format("%d", m_pLEADDicomNet->GetUserRole(m_hPDU, nID)); m_Presentation.SetItem(nIndex, 4, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); szOut.Format("%d", m_pLEADDicomNet->GetProviderRole(m_hPDU, nID)); m_Presentation.SetItem(nIndex, 5, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); //extended association lBytes = m_pLEADDicomNet->GetExtendedDataLength(m_hPDU, nID); if(lBytes > 0) { Data = m_pLEADDicomNet->GetExtendedData(m_hPDU, nID); szOut = ""; BYTE byte; CString szTemp; for(n=0; n 0) m_Presentation.SetItem(nIndex, 6, LVIF_TEXT|LVIF_STATE, szOut, 0, LVIS_SELECTED, LVIS_SELECTED, 0); } } VariantClear(&Data); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CViewAssociate::OnClose() { if(m_pLEADDicomNet) m_pLEADDicomNet->Release(); if(m_pLEADDicomDS) m_pLEADDicomDS->Release(); m_pLEADDicomNet=NULL; m_pLEADDicomDS=NULL; CDialog::OnClose(); }