//***************************************************************************
void CBCGPDAOGridCtrl::OnItemChanged (CBCGPGridItem* pItem, int nRow, int nColumn)
{
	try
	{
		ASSERT_VALID (this);

		if (m_pRecordSet == NULL)
		{
			ASSERT (FALSE);
			return;
		}

		ASSERT_VALID (pItem);
		ASSERT_VALID (m_pRecordSet);

		CBCGPGridRow* pRow = pItem->GetParentRow ();
		if (pRow == NULL)
		{
			return;
		}

		ASSERT_VALID (pRow);

		m_pRecordSet->MoveFirst ();
		m_pRecordSet->Move (nRow);

		m_pRecordSet->Edit ();

		COleVariant varCurr;
		m_pRecordSet->GetFieldValue ((short) nColumn, varCurr);

		COleVariant varOut;
		_variant_t varItemData = pItem->GetValue ();

		if (varItemData.vt == VT_BSTR)
		{
			CString str = (LPCTSTR)(_bstr_t) varItemData;
			BuildURL (pItem, str);

			varOut = COleVariant (str, VT_BSTRT);
		}
		else
		{
			varOut = varItemData;
		}

		m_pRecordSet->SetFieldValue ((short) nColumn, varOut);
		m_pRecordSet->Update ();
	}
	catch (CDaoException* pEx)
	{
		OnDaoException (pEx);
		pEx->Delete ();

		OnItemUpdateFailed ();
	}
}
Example #2
0
void OGRPLScenesLayer::ResetReading()
{
    bEOF = FALSE;
    if( poGeoJSONLayer && bStillInFirstPage )
        poGeoJSONLayer->ResetReading();
    else
        poGeoJSONLayer = NULL;
    nNextFID = 1;
    bStillInFirstPage = TRUE;
    osRequestURL = BuildURL(nPageSize);
}
Example #3
0
void GDALWMSMiniDriver_WMS::GetTiledImageInfo(CPLString *url,
                                              const GDALWMSImageRequestInfo &iri,
                                              CPL_UNUSED const GDALWMSTiledImageRequestInfo &tiri,
                                              int nXInBlock,
                                              int nYInBlock)
{
    BuildURL(url, iri, "GetFeatureInfo");
    URLAppendF(url, "&query_layers=%s", m_layers.c_str());
    URLAppendF(url, "&x=%d", nXInBlock);
    URLAppendF(url, "&y=%d", nYInBlock);
    const char* pszInfoFormat = CPLGetConfigOption("WMS_INFO_FORMAT", "application/vnd.ogc.gml");
    URLAppendF(url, "&info_format=%s", pszInfoFormat);

    CPLDebug("WMS", "URL = %s", url->c_str());
}
Example #4
0
VSIOSSHandleHelper::VSIOSSHandleHelper( const CPLString& osSecretAccessKey,
                                      const CPLString& osAccessKeyId,
                                      const CPLString& osEndpoint,
                                      const CPLString& osBucket,
                                      const CPLString& osObjectKey,
                                      bool bUseHTTPS,
                                      bool bUseVirtualHosting ) :
    m_osURL(BuildURL(osEndpoint, osBucket, osObjectKey, bUseHTTPS,
                     bUseVirtualHosting)),
    m_osSecretAccessKey(osSecretAccessKey),
    m_osAccessKeyId(osAccessKeyId),
    m_osEndpoint(osEndpoint),
    m_osBucket(osBucket),
    m_osObjectKey(osObjectKey),
    m_bUseHTTPS(bUseHTTPS),
    m_bUseVirtualHosting(bUseVirtualHosting)
{}
Example #5
0
GIntBig OGRPLScenesLayer::GetFeatureCount(int bForce)
{
    if( nFeatureCount < 0 )
    {
        CPLString osURL(BuildURL(1));
        if( bFilterMustBeClientSideEvaluated )
        {
            nFeatureCount = OGRLayer::GetFeatureCount(bForce);
        }
        else if( osURL.find('?') == std::string::npos )
        {
            /* Case of a "id = XXXXX" filter: we get directly a Feature, */
            /* not a FeatureCollection */
            GetNextPage();
        }
        else
        {
            nFeatureCount = 0;
            json_object* poObj = poDS->RunRequest(osURL);
            if( poObj != NULL )
            {
                json_object* poCount = json_object_object_get(poObj, "count");
                if( poCount != NULL )
                    nFeatureCount = MAX(0, json_object_get_int64(poCount));

                // Small optimization, if the feature count is actually 1
                // then we can fetch it as the full layer
                if( nFeatureCount == 1 )
                {
                    delete poGeoJSONDS;
                    // Parse the Feature/FeatureCollection with the GeoJSON reader
                    poGeoJSONDS = new OGRGeoJSONDataSource();
                    OGRGeoJSONReader oReader;
                    oReader.SetFlattenNestedAttributes(true, '.');
                    oReader.ReadLayer( poGeoJSONDS, "layer", poObj);
                    poGeoJSONLayer = poGeoJSONDS->GetLayer(0);
                    osNextURL = "";
                }
                json_object_put(poObj);
            }
        }
    }

    return nFeatureCount;
}
Example #6
0
void CBCGPODBCGridCtrl::OnItemChanged (CBCGPGridItem* pItem, int nRow, int nColumn)
{
	ASSERT_VALID (this);

	if (m_pRecordSet == NULL)
	{
		ASSERT (FALSE);
		return;
	}

	try
	{
		ASSERT_VALID (pItem);
		ASSERT_VALID (m_pRecordSet);

		CBCGPGridRow* pRow = pItem->GetParentRow ();
		if (pRow == NULL)
		{
			return;
		}

		ASSERT_VALID (pRow);

		CString strTable = m_pRecordSet->GetTableName ();

		RETCODE nRetCode;
		SQLUSMALLINT   RowStatusArray[10];
		SQLHSTMT  hstmtU;

		AFX_SQL_SYNC (::SQLAllocStmt (m_pDataBase->m_hdbc, &hstmtU));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		AFX_SQL_SYNC (::SQLSetStmtAttr (hstmtU, SQL_ATTR_CONCURRENCY, (SQLPOINTER)SQL_CONCUR_LOCK, 0));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		AFX_SQL_SYNC (::SQLSetStmtAttr (hstmtU, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_KEYSET_DRIVEN, 0));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}
		AFX_SQL_SYNC (::SQLSetStmtAttr (hstmtU, SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN, 0));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}
		AFX_SQL_SYNC (::SQLSetStmtAttr (hstmtU, SQL_ATTR_ROW_STATUS_PTR, RowStatusArray, 0));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		_variant_t vtItemValue = pItem->GetValue ();

	    TCHAR				szFieldBuffer[5000];
		SQLSMALLINT			cbBoolVal;
		tagTIMESTAMP_STRUCT datetime;
		SQLSMALLINT			dataFormatShort;
		SQLINTEGER			dataFormatLong;
		TCHAR				dataFormatChar;
		SQLUSMALLINT		dataFormatUShort;
		SQLUINTEGER			dataFormatULong;
		SQLREAL				dataFormatFloat;
		SQLDOUBLE			dataFormatDouble;

#ifdef _WIN64
		SQLLEN				nFieldLenOrInd;
		SQLLEN				lenColDataTypeInd;
#else
		SQLINTEGER			nFieldLenOrInd;
		SQLINTEGER			lenColDataTypeInd;
#endif

		switch (vtItemValue.vt)
		{
		case VT_BSTR:
			  {
				CString strVal = (LPCTSTR) (_bstr_t) pItem->GetValue ();
				BuildURL (pItem, strVal);

				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1), 
					SQL_C_CHAR, szFieldBuffer, strVal.GetLength (), &nFieldLenOrInd)); 
			  }
			break;
		case VT_BOOL:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_BIT, &cbBoolVal, 0, 0));
			}
			break;

		case VT_DATE:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_TIMESTAMP, &datetime, sizeof (datetime), NULL));
			}
			break;
		case VT_I2:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1), 
					SQL_C_SSHORT, &dataFormatShort, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_I4:
		case VT_INT:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1), 
					SQL_C_SLONG, &dataFormatLong, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_UI1:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_BIT, &dataFormatChar, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_UI2:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1), 
					SQL_C_USHORT, &dataFormatUShort, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_UINT:
		case VT_UI4:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_ULONG, &dataFormatULong, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_R4:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_FLOAT, &dataFormatFloat, 0, &lenColDataTypeInd ));
			}
			break;
		case VT_R8:
			{
				AFX_SQL_SYNC (::SQLBindCol (hstmtU, (unsigned short)(nColumn+1),
					SQL_C_DOUBLE, &dataFormatDouble, 0, &lenColDataTypeInd ));
			}
			break;
		default:
			return;

		};

		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		CString strSQL = m_pRecordSet->GetSQL ();

#ifdef _UNICODE
		#if _MSC_VER >= 1300
			AFX_SQL_SYNC (::SQLExecDirect (hstmtU, (SQLWCHAR*)(LPCTSTR)strSQL, SQL_NTS));
		#else
			AFX_SQL_SYNC (::SQLExecDirect (hstmtU, (UCHAR*)(LPCTSTR)strSQL, SQL_NTS));
		#endif
#else
		AFX_SQL_SYNC (::SQLExecDirect (hstmtU, (SQLCHAR*)(LPCTSTR)strSQL, SQL_NTS));
#endif

		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		AFX_SQL_SYNC (::SQLFetchScroll (hstmtU, SQL_FETCH_ABSOLUTE, nRow+1));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}
		
		switch (vtItemValue.vt)
		{
		case VT_BSTR:
			{
				CString strVal = (LPCTSTR) (_bstr_t) pItem->GetValue ();
				BuildURL (pItem, strVal);

				nFieldLenOrInd = strVal.GetLength ();
				lstrcpy (szFieldBuffer, (LPCTSTR)strVal);;
			}
			break;
		case VT_DATE:
			{
				COleDateTime oleDate = (DATE) vtItemValue;
				datetime.day = (unsigned short)oleDate.GetDay ();
				datetime.month = (unsigned short)oleDate.GetMonth ();
				datetime.year = (unsigned short)oleDate.GetYear ();
				datetime.hour = (unsigned short)oleDate.GetHour ();
				datetime.minute = (unsigned short)oleDate.GetMinute ();
				datetime.second = (unsigned short)oleDate.GetSecond (); 
			}
			break;
		case VT_BOOL:
			cbBoolVal = (bool) vtItemValue;
			break;
		case VT_I2:
			dataFormatShort = (short) vtItemValue;
			break;
		case VT_I4:
		case VT_INT:
			dataFormatLong = (long) vtItemValue;
			break;
		case VT_UI1:
			dataFormatChar = (TCHAR)(BYTE)vtItemValue;
			break;
		case VT_UI2:
			dataFormatUShort = vtItemValue.uiVal;
			break;
		case VT_UINT:
		case VT_UI4:
			dataFormatULong = vtItemValue.ulVal;
			break;
		case VT_R4:
			dataFormatFloat = (float) vtItemValue;
			break;
		case VT_R8:
			dataFormatDouble = (double) vtItemValue;
			break;
		default:
			return;

		};

		AFX_SQL_SYNC (::SQLSetPos (hstmtU, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}

		AFX_SQL_SYNC(::SQLCloseCursor(hstmtU));
		if (!m_pDataBase->Check (nRetCode))
		{
			AfxThrowDBException (nRetCode, m_pDataBase, hstmtU);
		}
	}
	catch (CDBException* pEx)
	{
		OnODBCException (pEx);
		pEx->Delete ();

		OnItemUpdateFailed ();
	}
}
Example #7
0
void VSIOSSHandleHelper::RebuildURL()
{
    m_osURL = BuildURL(m_osEndpoint, m_osBucket, m_osObjectKey,
                       m_bUseHTTPS, m_bUseVirtualHosting);
    m_osURL += GetQueryString(false);
}
Example #8
0
void GDALWMSMiniDriver_WMS::ImageRequest(CPLString *url, const GDALWMSImageRequestInfo &iri) {
    BuildURL(url, iri, "GetMap");
    CPLDebug("WMS", "URL = %s", url->c_str());
}