Esempio n. 1
0
static BOOL FillStructureFromControls (HWND hwnd)
{
   int  i;
   char buffer [MAXOBJECTNAME];
   LPOBJECTLIST
       list = NULL,
       obj;
   LPSTORAGEPARAMS  lpstorage = GetDlgProp (hwnd);
   HWND hwndContainer         = GetDlgItem (hwnd, IDC_RELOCATE_CONTAINER);


   // Mandatory in case current cell is a combo
   ContainerNewSel(hwndContainer);

   for (i=1; i<= nLine; i++)
   {
       ZEROINIT (buffer);
       ContainerGetComboCellSelection (hwndContainer, i, 1, buffer);
     
       obj = AddListObjectTail (&list, x_strlen (buffer) +1);
       if (obj)
       {
           x_strcpy ((UCHAR *)obj->lpObject, buffer);
           //list = obj;
       }
       else
       {
           FreeObjectList (list);
           list = NULL;
           return FALSE;
       }
   }
   FreeObjectList (lpstorage->lpNewLocations);
   lpstorage->lpNewLocations = NULL;
   lpstorage->lpNewLocations = list;

   return TRUE;
}
Esempio n. 2
0
LONG CuDlgDomPropTableColumns::OnUpdateData (WPARAM wParam, LPARAM lParam)
{
  // cast received parameters
  int nNodeHandle = (int)wParam;
  LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam;
  ASSERT (nNodeHandle != -1);
  ASSERT (pUps);

  // ignore selected actions on filters
  switch (pUps->nIpmHint)
  {
    case 0:
    //case FILTER_DOM_SYSTEMOBJECTS:
    //case FILTER_DOM_BASEOWNER:
    //case FILTER_DOM_OTHEROWNER:
      break;

    case FILTER_DOM_BKREFRESH_DETAIL:
      if (m_Data.m_refreshParams.MustRefresh(pUps->pSFilter->bOnLoad, pUps->pSFilter->refreshtime))
        break;    // need to update
      else
        return 0; // no need to update
      break;
    case FILTER_SETTING_CHANGE:
        VDBA_OnGeneralSettingChange(&m_cListColumns);
        return 0L;
    default:
      return 0L;    // nothing to change on the display
  }

  // Get info on the object
  TABLEPARAMS tableparams;
  memset (&tableparams, 0, sizeof (tableparams));

  LPTREERECORD  lpRecord = (LPTREERECORD)pUps->pStruct;
  ASSERT (lpRecord);
  ResetDisplay();
  x_strcpy ((char *)tableparams.DBName,     (const char *)lpRecord->extra);
  x_strcpy ((char *)tableparams.objectname, RemoveDisplayQuotesIfAny((LPCTSTR)StringWithoutOwner(lpRecord->objName)));
  x_strcpy ((char *)tableparams.szSchema,   (const char *)lpRecord->ownerName);
  tableparams.detailSubset = TABLE_SUBSET_COLUMNSONLY;  // minimize query duration

  int dummySesHndl;
  int iResult = GetDetailInfo ((LPUCHAR)GetVirtNodeName(nNodeHandle),
                               OT_TABLE,
                               &tableparams,
                               FALSE,
                               &dummySesHndl);
  if (iResult != RES_SUCCESS) {
    // Table may not exist if propagate too fast
    if (iResult != RES_ENDOFDATA)
      ASSERT (FALSE);

    // Reset m_Data
    CuDomPropDataTableColumns tempData;
    tempData.m_refreshParams = m_Data.m_refreshParams;
    m_Data = tempData;

    // Create error item and that's it!
    /* "<Data Unavailable>" */
    CuTblColumn tblColumn1(VDBA_MfcResourceString (IDS_DATA_UNAVAILABLE));
    m_Data.m_uaColumns.Add(tblColumn1);

    // Refresh display
    RefreshDisplay();

    return 0L;
  }

  // Update refresh info
  m_Data.m_refreshParams.UpdateRefreshParams();
  TCHAR *lpObjComment = NULL;
  int iret = RES_SUCCESS;
  LPOBJECTLIST ls ,lpColTemp,lpObjCol = NULL;
  LPCOMMENTCOLUMN lpCommentCol;
  ls = tableparams.lpColumns;
  while (ls)
  {
    lpColTemp = AddListObjectTail(&lpObjCol, sizeof(COMMENTCOLUMN));
    if (!lpColTemp)
    {
      // Need to free previously allocated objects.
      FreeObjectList(lpObjCol);
      lpObjCol = NULL;
      break;
    }
    LPCOLUMNPARAMS lstbl=(LPCOLUMNPARAMS)ls->lpObject;
    lpCommentCol = (LPCOMMENTCOLUMN)lpColTemp->lpObject;
    lstrcpy((LPTSTR)lpCommentCol->szColumnName,(LPCTSTR)(LPUCHAR)lstbl->szColumn);
    lpCommentCol->lpszComment = NULL;
    ls=(LPOBJECTLIST)ls->lpNext;
  }

  if (lpObjCol)
    iret = VDBAGetCommentInfo ( (LPTSTR)(LPUCHAR)GetVirtNodeName(nNodeHandle),
                                (LPTSTR)tableparams.DBName, (LPTSTR)tableparams.objectname,
                                (LPTSTR)tableparams.szSchema, &lpObjComment, lpObjCol);
  else
    ASSERT (FALSE);

  // update member variables, for display/load/save purpose

  // list of columns
  m_Data.m_uaColumns.RemoveAll();
  ls = tableparams.lpColumns;
  ASSERT (ls);    // No columns is unacceptable
  while (ls) {
    LPCOLUMNPARAMS lpCol = (LPCOLUMNPARAMS)ls->lpObject;
    ASSERT (lpCol);

    // Column name
    CString csName = lpCol->szColumn;

    // Format "column type"
    CString csType = "";
    if (lstrcmpi(lpCol->tchszInternalDataType, lpCol->tchszDataType) != 0)  {
      ASSERT (lpCol->tchszInternalDataType[0]);
      csType = lpCol->tchszInternalDataType;  // UDTs
      if (lstrcmpi(lpCol->tchszInternalDataType,VDBA_MfcResourceString(IDS_OBJECT_KEY)) == 0 ||
          lstrcmpi(lpCol->tchszInternalDataType,VDBA_MfcResourceString(IDS_TABLE_KEY) ) == 0) {
          if (lpCol->bSystemMaintained)
              csType += VDBA_MfcResourceString(IDS_SYSTEM_MAINTAINED);
          else
              csType += VDBA_MfcResourceString(IDS_NO_SYSTEM_MAINTAINED);
      }
    }
    else {
      LPUCHAR lpType;
      lpType = GetColTypeStr(lpCol);
      if (lpType) {
        csType = lpType;
        ESL_FreeMem(lpType);
      }
      else {
        // Unknown type: put type name "as is" - length will not be displayed
        csType = lpCol->tchszDataType;
	  }
    }

    // Format "default specification"
    CString csDefSpec = "";
    if (lpCol->lpszDefSpec)
      csDefSpec = lpCol->lpszDefSpec;

    // Format "Comment"
    CString csTblComment = "";
    LPOBJECTLIST LsObj = lpObjCol;
    LPCOMMENTCOLUMN lpCommentCol;

    while (LsObj)
    {
      lpCommentCol = (LPCOMMENTCOLUMN)LsObj->lpObject;
      if (strcmp((LPTSTR)lpCommentCol->szColumnName,(LPTSTR)lpCol->szColumn) == 0)
      {
        if (iret!=RES_SUCCESS && !lpCommentCol->lpszComment)
          csTblComment.LoadString(IDS_NOT_AVAILABLE);
        else
        {
            if (lpCommentCol->lpszComment)
              csTblComment = lpCommentCol->lpszComment;
        }
      }
      LsObj = (LPOBJECTLIST)LsObj->lpNext;
    }

    // item on the stack
    CuTblColumn tblColumn(csName,             // LPCTSTR name,
                          csType,             // LPCTSTR type, ??? Code complexe
                          lpCol->nKeySequence,// int primKeyRank,
                          lpCol->bNullable,   // BOOL bNullable,
                          lpCol->bDefault,    // BOOL bWithDefault,
                          csDefSpec,          // LPCTSTR defSpec
                          csTblComment );     // LPCTSTR comment on column
    CuMultFlag *pRefCol = m_Data.m_uaColumns.Find(&tblColumn);
    ASSERT (!pRefCol);
    m_Data.m_uaColumns.Add(tblColumn);

    // Loop on next column
    ls = (LPOBJECTLIST)ls->lpNext;
  }

  // liberate detail structure
  FreeAttachedPointers (&tableparams,  OT_TABLE);
  // liberate column comment
  ls = lpObjCol;
  while (ls)
  {
    lpCommentCol = (LPCOMMENTCOLUMN)ls->lpObject;
    if (lpCommentCol->lpszComment)
      ESL_FreeMem (lpCommentCol->lpszComment);
    ls = (LPOBJECTLIST)ls->lpNext;
  }
  FreeObjectList(lpObjCol);
  if (lpObjComment)
    ESL_FreeMem (lpObjComment);
  // Refresh display
  RefreshDisplay();

  return 0L;
}
Esempio n. 3
0
BOOL CxDlgObjectComment::InitializeObjectColumns()
{
	TCHAR tblNameWithOwner[MAXOBJECTNAME];
	int ires, nLevel = 2;
	LPUCHAR aparents [MAXPLEVEL];
	TCHAR   tchszBuf       [MAXOBJECTNAME];
	TCHAR   tchszOwner   [MAXOBJECTNAME];
	TCHAR   tchszBufComplim[MAXOBJECTNAME];
	LPTSTR  lpszOwner = NULL;
	BOOL    bSystem = FALSE;

	if (m_iCurObjType != OT_TABLE && m_iCurObjType != OT_VIEW)
		return FALSE;

	StringWithOwner((LPUCHAR)Quote4DisplayIfNeeded((LPTSTR)(LPCTSTR)m_csObjectName),
	                (LPUCHAR)(LPTSTR)(LPCTSTR) m_csObjectOwner, (LPUCHAR)tblNameWithOwner);

	aparents[0] = (LPUCHAR)(LPCTSTR)m_csDBName;
	aparents[1] = (LPUCHAR)tblNameWithOwner;
	aparents[2] = NULL;
	nLevel = 2;
	tchszBuf[0] = 0;
	tchszOwner[0] = 0;
	tchszBufComplim[0] = 0;
	LPOBJECTLIST lpColTemp;
	LPCOMMENTCOLUMN lpCommentCol;

	ires =  DOMGetFirstObject( m_nNodeHandle,
	                          (m_iCurObjType == OT_TABLE)? OT_COLUMN: OT_VIEWCOLUMN,
	                           nLevel,
	                           aparents,
	                           bSystem,
	                           NULL,
	                          (LPUCHAR)tchszBuf,
	                          (LPUCHAR)tchszOwner,
	                          (LPUCHAR)tchszBufComplim);
	if (ires != RES_SUCCESS && ires != RES_ENDOFDATA)
	{
		CString csMsg;
		csMsg.LoadString(IDS_E_COMMENTS_FAILED);
		MessageWithHistoryButton(m_hWnd,csMsg);
		return FALSE;
	}

	while (ires == RES_SUCCESS)
	{
		lpColTemp = AddListObjectTail(&m_ListColumn, sizeof(COMMENTCOLUMN));
		if (!lpColTemp)
		{
			// Need to free previously allocated objects.
			ErrorMessage ( (UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR);
			FreeObjectList(m_ListColumn);
			m_ListColumn = NULL;
			return FALSE;
		}
		lpCommentCol = (LPCOMMENTCOLUMN)lpColTemp->lpObject;
		lstrcpy((LPTSTR)lpCommentCol->szColumnName,tchszBuf);
		lpCommentCol->lpszComment = NULL;
		tchszBuf[0] = 0;
		tchszOwner[0] = 0;
		tchszBufComplim[0] = 0;
		ires = DOMGetNextObject ((LPUCHAR)tchszBuf, (LPUCHAR)tchszOwner, (LPUCHAR)tchszBufComplim);
	}
	return TRUE;
}