Beispiel #1
0
void ConvertUtil::CreateSQLiteFile(FdoIConnection *connection, FdoString *file)
{
    _wunlink(file);

    int    count = 0;
    wchar_t buffer[512];
    FdoString **names = NULL;
    
    swprintf(buffer, 512, L"File=%ls;UseFdoMetadata=TRUE", file);
    connection->SetConnectionString(buffer);

    FdoPtr<FdoICreateDataStore>    dataStore = static_cast<FdoICreateDataStore*>(connection->CreateCommand(FdoCommandType_CreateDataStore));
    FdoPtr<FdoIDataStorePropertyDictionary> dictionary = dataStore->GetDataStoreProperties();

    names = dictionary->GetPropertyNames(count);
    dictionary->SetProperty(names[0], file);

    dataStore->Execute();
}
void MgServerGetFeatureProviders::AddConnectionProperties(DOMElement* providerElem, FdoString* providerName)
{
    CHECKNULL(providerElem, L"MgServerGetFeatureProviders.AddConnectionProperties");

    // Get Properties
    FdoInt32 totalProperties = 0;

    // Add ConnnectionProperties element (mandatory element)
    DOMElement* connPropRootElem = m_xmlUtil->AddChildNode(providerElem, "ConnectionProperties" /* NOXLATE */ );
    CHECKNULL(connPropRootElem, L"MgServerGetFeatureProviders.AddConnectionProperties");

    // We ignore any exception thrown here so that even if client dll/so is missing, GetFeatureProviders
    // will continue to work.
    MG_FEATURE_SERVICE_TRY()

    // Get FdoIConnection instance
    // TODO: Should this connection be cached?
    FdoPtr<FdoIConnection> fdoConn = m_connManager->CreateConnection(providerName);
    CHECKNULL((FdoIConnection*)fdoConn, L"MgServerGetFeatureProviders.AddConnectionProperties");

    // Get FdoIConnectionInfo
    FdoPtr<FdoIConnectionInfo> fdoConnInfo = fdoConn->GetConnectionInfo();
    CHECKNULL((FdoIConnectionInfo*)fdoConnInfo, L"MgServerGetFeatureProviders.AddConnectionProperties");

    // Get FdoIConnectionPropertyDictionary
    FdoPtr<FdoIConnectionPropertyDictionary> fdoConnPropertyDict = fdoConnInfo->GetConnectionProperties();
    CHECKNULL((FdoIConnectionPropertyDictionary*)fdoConnPropertyDict, L"MgServerGetFeatureProviders.AddConnectionProperties");

    // Get list of all properties
    FdoString** properties = fdoConnPropertyDict->GetPropertyNames(totalProperties);
    CHECKNULL(properties, L"MgServerGetFeatureProviders.AddConnectionProperties");

    for ( FdoInt32 i=0; i < totalProperties; i++ )
    {
        AddConnectionProperty(connPropRootElem, properties[i], fdoConnPropertyDict);
    }

    MG_FEATURE_SERVICE_CATCH(L"MgServerGetFeatureProviders.GetFeatureProviders") // do not rethrow so that GetFeatureProviders works
}