Exemplo n.º 1
0
void CVoxSQLite::InsertStreetAddress( int nId, StreetAddress& addr )
{
	std::string	strSql = "INSERT INTO StreetAddress "
		"( [profile_id], [type], [street], [locality], [region], [postcode], [country], [visibility] ) "
						 "VALUES( ?, ?, ?, ?, ?, ?, ?, ? ); ";

	try
	{
		//TODO: compile as a member var?
		CppSQLite3Statement stmt = m_db.compileStatement( strSql.c_str() );

		stmt.bind( 1, nId	);
		stmt.bind( 2, addr.getType().c_str()		);
		stmt.bind( 3, addr.getStreet1().c_str() 	);
		stmt.bind( 4, addr.getCity().c_str()		);
		stmt.bind( 5, addr.getStateProvince().c_str());
		stmt.bind( 6, addr.getPostalCode().c_str()	);
		stmt.bind( 7, addr.getCountry().c_str()		);
		stmt.bind( 8, (int) addr.getVisibility()	);

		stmt.execDML();		//We expect a return value == 1 (Number of rows changed);
		stmt.reset();
	}

	catch (CppSQLite3Exception& e)
	{
		e.errorCode();
	}
}
Exemplo n.º 2
0
void ConfigImporter::addContactDetails(Contact & contact, void * structVcard) {
	vcard_t * mVcard = (vcard_t *) structVcard;

	contact.setFirstName(mVcard->fname);
	contact.setLastName(mVcard->lname);
	contact.setCompany(mVcard->company);
	contact.setBirthdate(Date(mVcard->birthday.day, mVcard->birthday.month, mVcard->birthday.year));
	contact.setNotes(mVcard->note);
	contact.setWebsite(mVcard->website);
	if (!mVcard->address.city.empty()) {
		StreetAddress adress;
		adress.setStreet1(mVcard->address.street);
		adress.setCity(mVcard->address.city);
		adress.setPostalCode(mVcard->address.post_code);
		adress.setStateProvince(mVcard->address.state);
		adress.setCountry(mVcard->address.country);
		contact.setStreetAddress(adress);
	}

	if (mVcard->gender != UNKNOWN) {
		contact.setSex(mVcard->gender == MALE ? EnumSex::SexMale : EnumSex::SexFemale);
	}

	telNumberIt it;
	for (it = mVcard->numbers.begin(); it != mVcard->numbers.end(); it++) {
		if (!(*it)->key.compare(HOME_NUMBER_KEY) && !((*it)->value.empty())) {
			contact.setHomePhone((*it)->value);
		}
		else if (!(*it)->key.compare(WORK_NUMBER_KEY) && !((*it)->value.empty())) {
			contact.setWorkPhone((*it)->value);
		}
		else if (!(*it)->key.compare(CELL_NUMBER_KEY) && !((*it)->value.empty())) {
			contact.setMobilePhone((*it)->value);
		}
		else if (!(*it)->key.compare(FAX_NUMBER_KEY) && !((*it)->value.empty())) {
			contact.setFax((*it)->value);
		}
		else if (!(*it)->key.compare(OTHER_NUMBER_KEY) && !((*it)->value.empty())) {
			contact.setOtherPhone((*it)->value);
		}
	}

	if (mVcard->emails.size() >= 1 && !mVcard->emails[0].empty()) {
		contact.setPersonalEmail(mVcard->emails[0]);
	}
	if (mVcard->emails.size() >= 2 && !mVcard->emails[1].empty()) {
		contact.setWorkPhone(mVcard->emails[1]);
	}
	if (mVcard->emails.size() >= 3 && !mVcard->emails[2].empty()) {
		contact.setOtherPhone(mVcard->emails[2]);
	}
}
Exemplo n.º 3
0
void CVoxSQLite::GetStreetAddresses( int nProfileId, StreetAddresses& rAddrs )
{
	CppSQLite3Buffer buf;
	buf.format( "SELECT * from StreetAddress WHERE profile_id = %d;", nProfileId );

	try
	{
		CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf );

		int				nId		= 0;
		CppSQLite3Query q		= stmt.execQuery();

		StreetAddress	addr;

		//Process record set.
        while (!q.eof())
        {
//			"( [profile_id], [type], [street], [locality], [region], [postcode], [country], [visibility] ) "
			nId  = q.getIntField(0);			//Not part of Profile.

			addr.setType		 ( q.getStringField(1) );
			addr.setStreet1		 ( q.getStringField(2) );
			addr.setCity		 ( q.getStringField(3) );
			addr.setStateProvince( q.getStringField(4) );
			addr.setPostalCode	 ( q.getStringField(5) );
			addr.setCountry		 ( q.getStringField(6) );
			addr.setVisibility   ( (EnumVisibility::Visibility)q.getIntField(7) );

			rAddrs.Add( &addr );

			q.nextRow();
        }

		stmt.reset();
	}

	catch (CppSQLite3Exception& e)
	{
		e.errorCode();
	}
}
Exemplo n.º 4
0
// geoCountryCanada          39   Canada
// geoCountryUnitedStates   244   United States
zOPER_EXPORT zSHORT OPERATION
MapPointValidateAddress( zPCHAR pchStreet, zPCHAR pchCity, zPCHAR pchOtherCity,
                         zPCHAR pchRegion, zPCHAR pchPostalCode,
                         zCPCHAR cpcStreetAddress, zLONG lFlag )
{
   AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
   SHORT nRC = 0;
   ZMapPointApp *pApp = (ZMapPointApp *) ::AfxGetApp( );

   *pchStreet = 0;
   *pchCity = 0;
   *pchOtherCity = 0;
   *pchRegion = 0;
   *pchPostalCode = 0;
   if ( pApp )
   {
      TRY
      {
         if ( pApp->GetMapPointState( ) == 0 )  // not active
            return( zCALL_ERROR );

         _Application *pMP = pApp->GetMapPointApplication( );
         if ( pMP == 0 )
         {
            nRC = zCALL_ERROR;
         }
         else
         {
            _Map Map = pMP->GetActiveMap( );
         // if ( pMap == 0 )
         //    nRC = zCALL_ERROR;
         // else
            {
            // Item    item;
               zLONG   lCnt;
               VARIANT a;
               a.vt = VT_I4;
               a.lVal = 244; // geoMapNorthAmerica!
            // a.lVal = 1; // geoMapNorthAmerica!
            // a.lVal = 2; // geoMapEurope!

               StreetAddress SA = Map.ParseStreetAddress( cpcStreetAddress );
               zstrcpy( pchStreet, SA.GetStreet( ) );
               zstrcpy( pchCity, SA.GetCity( ) );
               zstrcpy( pchOtherCity, SA.GetOtherCity( ) );
               zstrcpy( pchRegion, SA.GetRegion( ) );
               zstrcpy( pchPostalCode, SA.GetPostalCode( ) );
               FindResults FR = Map.FindAddressResults( pchStreet, pchCity,
                                                        pchOtherCity,
                                                        pchRegion,
                                                        pchPostalCode, a );
               TraceLineI( "FindAddressResults Quality: ", FR.GetResultsQuality( ) );
               lCnt = FR.GetCount( );
               TraceLineI( "FindAddressResults Count: ", lCnt );
#if 0
               for ( int k = 1; k <= lCnt; k++ )
               {
                  a.lVal = k;
                  Location L = FR.GetItem( &a );
                  long lType = L.GetType( );
                  long lX = Map.LocationToX( L );
                  long lY = Map.LocationToY( L );
                  TraceLine( "Location Name: %s  Type: %d  X: %d  Y: %d",
                             L.GetName( ), lType, lX, lY );

                  Map.AddPushpin( L, L.GetName( ) );
                  PlaceCategory PC = L.GetPlaceCategory( );
                  TraceLineS( "The Place Category is: ", PC.GetName( ) );
               }
#endif
            }
         }
      }
      CATCH_ALL( e )
      {
         nRC = zCALL_ERROR;
      }
      END_CATCH_ALL
   }

   return( nRC );
}