Exemple #1
0
void CAdhocLinkerDlg::UpdateList(void)
{
	ADHOC_STATUS status;

	if(!m_Client.GetAdhocStatus(status))
	{
		m_ClientList.DeleteAllItems();
		m_DeviceList.DeleteAllItems();
		return;
	}

	if(!memcmp(&m_AdhocStatus, &status, sizeof(m_AdhocStatus)))
		return;

	if(m_AdhocStatus.ClientInfoCount != status.ClientInfoCount ||
		m_AdhocStatus.DeviceInfoCount != status.DeviceInfoCount)
	{
		ResetListItems(status);
	}
	else
	{
		UpdateListItems(status);
	}

	m_AdhocStatus = status;
}
void CDlgReadInfo::OnSelectChanged(HTREEITEM hItem)
{
	// Quit previous field editing.
	m_wndList.EndEdit(FALSE);

	// 清空属性列表
	ResetListItems();

	CString strCadLayerName, strSdeLayerName,strRowId;

	m_strCurObjectId = m_wndTree.GetItemText(hItem);

	ITEM_DATA xxItemData = mapItemData[m_strCurObjectId];
	m_strCadlayerName = strCadLayerName = xxItemData.strCadLayerName;
	strSdeLayerName = xxItemData.strSdelayerName;
	strRowId = xxItemData.strRowId;

	STB_CONTENT_TREE xxContentTree = Glb_mapTree[strCadLayerName];

	IDistConnection* pConnection = Glb_pConnection;

	if (Glb_bMultiConnection)
	{
		pConnection = xxContentTree.bIsLocalLayer ? Glb_pLocalConnection : Glb_pConnection;
	}

	if(NULL == pConnection)
	{
		acutPrintf("\n空间数据库没有连接!"); return;
	}

	IDistParameter* pParam = NULL;
	int nParamNum = 0;
	IDistCommand* pCommand = CreateSDECommandObjcet();
	pCommand->SetConnectObj(pConnection);

	long nRet = pCommand->GetTableInfo(&pParam,&nParamNum,strSdeLayerName.GetBuffer(),"SDE");
	strSdeLayerName.ReleaseBuffer();
	if(1 != nRet)
	{
		pCommand->Release(); 
		return;
	}

	CString strRowIdColumn = "OBJECTID";
	CString strName; 
	for(int i=0; i<nParamNum; i++)
	{
		if(pParam[i].fld_nType == kShape) 
			continue;

		if(pParam[i].fld_nRowIdType == kRowIdColumnSde)
		{
			strRowIdColumn = pParam[i].fld_strName;
			continue;
		}

		strName = strName + pParam[i].fld_strName + ",";
	}

	if(strName.IsEmpty())
	{
		pCommand->Release(); 

		return;
	}

	char strSQL[1024]={0};
	sprintf(strSQL,"F:%sT:%s,W:%s=%s",strName, strSdeLayerName, strRowIdColumn, strRowId);

	IDistRecordSet* pRcdSet = NULL;
	if(1 != pCommand->SelectData(strSQL,&pRcdSet,NULL))
	{
		if(pRcdSet != NULL)
		{
			pRcdSet->Release();
		}

		pCommand->Release(); 

		return;
	}

	if(pRcdSet->BatchRead()==1)
	{
		for(int i=0; i<nParamNum; i++)
		{
			if(pParam[i].fld_nType == kShape) 
				continue;

			if(pParam[i].fld_nRowIdType == kRowIdColumnSde)
				continue;

			COLUMN_VALUE xxParam;
			xxParam.strName = pParam[i].fld_strName;
			xxParam.strAlias = pParam[i].fld_strAliasName;

			pRcdSet->GetValueAsString(xxParam.strValue.GetBuffer(128), xxParam.strName);
			xxParam.strValue.ReleaseBuffer();

			long nType = 0;
			switch(pParam[i].fld_nType)
			{
			case kInt16:
			case kInt32:
				nType = 1;
				break;
			case kFloat32:
			case kFloat64:
				nType = 2;
				break;
			case kDate:
				nType = 3;
				break;
			case kString:
			case kNString:
			case kBLOB:
			case kShape:
				break;
			default:
				break;
			}

			paramList.Add(xxParam);
			m_wndList.AddItem(nType, xxParam.strAlias, xxParam.strValue);

			/*			if (IsFieldEditable())
			{
			m_wndList.FreezeColumn(i);
			m_wndList.SetItemTextColor(i, 1, GetSysColor(COLOR_GRAYTEXT));
			}
			else
			{
			m_wndList.UnfreezeColumn(i);
			}
			*/		}
	}

	pRcdSet->Release();
	pCommand->Release();
}
void CDlgReadInfo::OnBnClickedBtnSelect()
{
	//交互选择实体
	BeginEditorCommand();

	CString strCadName;
	CComboBox* pCmb = (CComboBox*)GetDlgItem(IDC_COMBO_CADLY);
	pCmb->GetLBText(pCmb->GetCurSel(),strCadName);

	
	ads_name ssName;
	struct resbuf *filter=NULL;
	if(strCadName.CompareNoCase("所有图层") != 0)
	{
		filter=acutNewRb(AcDb::kDxfLayerName);
		filter->restype=AcDb::kDxfLayerName;
		filter->resval.rstring = (char*) malloc((strCadName.GetLength()+1)*sizeof(char));
		strcpy(filter->resval.rstring,strCadName.GetBuffer(0));
		filter->rbnext=NULL;
	}
	
	if (acedSSGet(":S", NULL, NULL, filter, ssName) != RTNORM)
	{
		acutPrintf("\n选择实体有误!");
		acedSSFree(ssName); acutRelRb(filter);
		CompleteEditorCommand();
		return;
	}
	if(filter != NULL) acutRelRb(filter);

	AcDbObjectId tempObjId;
	ads_name ssTemp;
	long nNum = 0;
	int nPos = 0;
	acedSSLength(ssName,&nNum);
	CString strSdeName,strId,strRowId;

	m_wndTree.DeleteAllItems();

	// 清空属性列表
	ResetListItems();

	for(int i=0; i<nNum; i++)
	{
		acedSSName(ssName, i, ssTemp);
		if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue;
		strId.Format("%d",tempObjId.asOldId());
		CDistXData tempXData(tempObjId,"ROWID_OBJS");
		if(tempXData.Select("SDELYNAME",strSdeName)==FALSE) continue;
		if(tempXData.Select("OBJECTID",strRowId)==FALSE) continue;
		tempXData.Close();

		HTREEITEM hItem = m_wndTree.InsertItem(strId);

		AcDbEntity *pEnt = NULL;
		if (Acad::eOk != acdbOpenObject(pEnt, tempObjId, AcDb::kForRead))
		{
			return;
		}
		pEnt->close();

		ITEM_DATA xxItemData;
		xxItemData.strID = strId;
		xxItemData.strSdelayerName = strSdeName;
		xxItemData.strCadLayerName = pEnt->layer();
		xxItemData.strRowId = strRowId;

		mapItemData[strId] = xxItemData;

		nPos++;
	}
	
	acedSSFree(ssName);

	CompleteEditorCommand();

	if (m_wndTree.GetCount() <= 0)
	{
		return;
	}

	HTREEITEM hItem = m_wndTree.GetFirstVisibleItem();

	// 显示属性
	OnSelectChanged(hItem);
}