Ejemplo n.º 1
0
// GS查询指定玩家的个人房屋副本GUID
void	CRsDupRgn::QuestPHGuidByPlayerID(const char* playerName, CGUID& retPHGUID)
{
	_RecordsetPtr rs, rs1;
	char sql[500] = "";
	try
	{
		TESTHR(CreateRs(rs));
		TESTHR(CreateRs(rs1));

		// 先查找Player GUID
		sprintf(sql, "SELECT * FROM baseproperty WHERE Name='%s'", playerName);
		TESTHR(OpenRs(sql, rs, GetGame()->GetDBEntityManager()->GetAccessThread()->GetConnPtr()));

		char* szGUID = NULL;
		if(!rs->GetadoEOF())
		{
			szGUID = (_bstr_t)rs->GetCollect("guid");
		}
		ReleaseRs(rs);
		sprintf(sql, "SELECT * FROM CSL_DUPRGN_PROPERTY WHERE OwnerGUID='%s'", szGUID);
		TESTHR(OpenRs(sql, rs, GetGame()->GetDBEntityManager()->GetAccessThread()->GetConnPtr()));

		while(!rs->GetadoEOF())
		{
			// GUID
			retPHGUID = CGUID((_bstr_t)rs->GetCollect("guid"));
		}
		ReleaseRs(rs1);
		PrintErr(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_QUESTRGNGUIDOK));
		return;
	}
	catch (_com_error &e)
	{
		ReleaseRs(rs);
		ReleaseRs(rs1);
		PrintErr(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_QUESTRGNGUIDFAIL), e);
		return;
	}

	return;
}
Ejemplo n.º 2
0
void CRsSetup::LoadPlayerID()
{
	char sql[512];
	_ConnectionPtr cn;
	_RecordsetPtr rs;

	CDBEntityManager::DBSetupMapItr itr = GetGame()->GetDBEntityManager()->GetDBSetupMap().begin();
	if(itr != GetGame()->GetDBEntityManager()->GetDBSetupMap().end())
	{
		try
		{
		//	TESTHR(CreateCn(cn));
			TESTHR(CreateRs(rs));

	//		TESTHR(OpenCn(cn));
			sprintf(sql, "SELECT TOP 1 playerID FROM csl_setup");
			TESTHR(OpenRs(sql, rs, GetGame()->GetDBEntityManager()->GetAccessThread()->GetConnPtr()/*m_Connection*/));


			if(rs->GetadoEOF())
			{
				itr->second->SetPlayerID(NULL_GUID);
			}
			else
			{
				itr->second->SetPlayerID( CGUID(((char*)(_bstr_t)rs->GetCollect("playerID"))) );
			}
			ReleaseRs(rs);
			//ReleaseCn(cn);
		}
		catch(_com_error &e)
		{
			ReleaseRs(rs);
			//ReleaseCn(cn);
			PrintErr("load playerid error", e);
			itr->second->SetPlayerID(NULL_GUID);
		}
	}
	else
	{
		CGUID guid;
		CGUID::CreateGUID(guid);
		CDBSetup* s = new CDBSetup(guid);
		GetGame()->GetDBEntityManager()->AddOneDBSetup(s);

		try
		{
		//	TESTHR(CreateCn(cn));
			TESTHR(CreateRs(rs));

		//	TESTHR(OpenCn(cn));
			sprintf(sql, "SELECT TOP 1 playerID FROM csl_setup");
			TESTHR(OpenRs(sql, rs, GetGame()->GetDBEntityManager()->GetAccessThread()->GetConnPtr()/*m_Connection*/));


			if(rs->GetadoEOF())
			{
				s->SetPlayerID(NULL_GUID);
			}
			else
			{
				s->SetPlayerID( CGUID(((char*)(_bstr_t)rs->GetCollect("playerID"))) );
			}
			ReleaseRs(rs);
			//ReleaseCn(cn);
		}
		catch(_com_error &e)
		{
			ReleaseRs(rs);
			//ReleaseCn(cn);
			PrintErr("load playerid error", e);
			s->SetPlayerID(NULL_GUID);
		}
	}
}
Ejemplo n.º 3
0
  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IStorage *pStg)
  { COMPtr<IPropertySetStorage> pPropSetStg;
    COMPtr<IEnumSTATSTG>        penum;
    HRESULT                     hr = S_OK;
    STATSTG                     statstg;
    int                         indent;

    LogStream<TCHAR>* logger = dynamic_cast< LogStream<TCHAR>* >(&os);
    
    if( NULL!=logger )
      indent = logger->GetIndent();

    ::memset( &statstg, 0, sizeof(statstg) );

    THROW_COMEXCEPTION( pStg->QueryInterface( IID_IPropertySetStorage,reinterpret_cast<void**>(&pPropSetStg) ) );

    os<<pPropSetStg;

    THROW_COMEXCEPTION( pStg->EnumElements( NULL, NULL, NULL, &penum ) );

    hr = penum->Next( 1, &statstg, 0 );
    THROW_COMEXCEPTION( hr );

    while( S_OK == hr )
    { 
      if( NULL!=logger )
        logger->SetIndent(indent);

      { if( STGTY_STORAGE==statstg.type )
          os<<_T("[");

        if( statstg.pwcsName[0]>_T('\x20') )
          os<<statstg.pwcsName;
        else
          os<<_T("'\\x")<<hex<<setw(2)<<setfill(_T('0'))<<(UINT)(statstg.pwcsName[0])<<_T("'")<<statstg.pwcsName+1;

        if( STGTY_STORAGE==statstg.type )
          os<<_T("]");

        if( _T('\005')==statstg.pwcsName[0] )
        { GUID fmtid;

          if( COM::COPropertySet::PropertySetNameToGuid(_tcslen(statstg.pwcsName),statstg.pwcsName,&fmtid) )
            os<<_T(" --> FMTID=")<<((const TString&)CGUID(fmtid)).c_str();
        } // of if

        os<<endl;
      } // of if

      if( STGTY_STORAGE==statstg.type && _T('\005')!=statstg.pwcsName[0] )
      { COMPtr<IStorage> pStgChild;

        THROW_COMEXCEPTION( pStg->OpenStorage( statstg.pwcsName,NULL,STGM_READ | STGM_SHARE_EXCLUSIVE,NULL, 0,&pStgChild ) );

        if( logger!=NULL )
          logger->SetIndent(indent+1);

        os<<pStgChild;
      } // of if

      ::CoTaskMemFree( statstg.pwcsName );
      statstg.pwcsName = NULL;

      hr = penum->Next( 1, &statstg, 0 );
      THROW_COMEXCEPTION( hr );
    } // of while
    
    return os;
  } // of basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, IStorage *pStg)
Ejemplo n.º 4
0
//! 读取个人房屋内的物品信息
bool    CRsDupRgn::LoadDupRgnObj(const CGUID& rgnGUID, CDBRgnGoodsGroup* goodsGroup, _ConnectionPtr& cn)
{
	bool ret = false;

	if(cn == NULL)
	{
		AddLogText(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_CNPTRNULL));
		return ret;
	}

	_RecordsetPtr rs;
	char sql[1024] = "";
	try
	{
		TESTHR(CreateRs(rs));

		char szGUID[128];
		rgnGUID.tostring(szGUID);

		// 先查找该个人房屋的成员
		sprintf(sql, "SELECT * FROM CSL_DUPRGN_GOODS WHERE DupRgnGUID='%s'", szGUID);
		TESTHR(OpenRs(sql, rs, cn));

		while(!rs->GetadoEOF())
		{
			// 基本属性部分
			_variant_t vGoodsID = rs->GetCollect("guid");
			CGUID guid = CGUID(((char*)(_bstr_t)vGoodsID));

			CDBRgnGoods* pGoods = new CDBRgnGoods(guid);
			CDataEntityManager::EntityPropertyMapItr epItr = pGoods->GetDataEntityManager().GetEntityPropertyMap().begin();
			for(; epItr != pGoods->GetDataEntityManager().GetEntityPropertyMap().end(); epItr++)
			{
				switch(epItr->second->GetDataType())
				{
				case DATA_OBJECT_TIME:
					{
						_variant_t var = rs->GetCollect(epItr->first.c_str());
						long timeBuf[6] = {0};
						if( var.vt != VT_NULL ) 
						{
							SYSTEMTIME st;
							VariantTimeToSystemTime(var.date, &st);

							timeBuf[0] = st.wYear;
							timeBuf[1] = st.wMonth;
							timeBuf[2] = st.wDay;
							timeBuf[3] = st.wHour;
							timeBuf[4] = st.wMinute;
							timeBuf[5] = st.wSecond;
							epItr->second->SetBufAttr(0, (void*)&timeBuf[0], sizeof(DWORD)*6);
						}		
					}
					break;
				case  DATA_OBJECT_STRING:
					{
						string strValue = (_bstr_t)rs->GetCollect(epItr->first.c_str());
						epItr->second->SetStringAttr(0, strValue.c_str());
					}
					break;
				case DATA_OBJECT_BUFFER:
					{
						LoadBufferField((CBaseDBEntity*)pGoods, epItr->first.c_str(), rs);
					}
					break;
				case DATA_OBJECT_GUID:
					{
						CGUID tGUID(_bstr_t(rs->GetCollect(epItr->first.c_str())));
						epItr->second->SetGuidAttr(0, tGUID);
					}
					break;
				case DATA_OBJECT_FLOAT:
				case DATA_OBJECT_LONG:
				case DATA_OBJECT_SHORT:
				case DATA_OBJECT_ULONG:
				case DATA_OBJECT_USHORT:
				case DATA_OBJECT_BOOL:
				case DATA_OBJECT_CHAR:
				case DATA_OBJECT_BYTE:
				case DATA_OBJECT_WORD:
				case DATA_OBJECT_DWORD:
					{
						long value = rs->GetCollect(epItr->first.c_str());
						epItr->second->SetLongAttr(0, value);
					}
					break;
				}
			}

			goodsGroup->GetGoodsGroupMap()[pGoods->GetExID()] = pGoods;
			// 下条记录
			rs->MoveNext();
		}

		ReleaseRs(rs);
		
		return true;
	}
	catch (_com_error &e)
	{
		ReleaseRs(rs);
		PrintErr(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_LOADRGNGOODSFAIL), e);
		return false;
	}

	return true;
}
Ejemplo n.º 5
0
  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& os, const PROPVARIANT& propvar)
  { switch( propvar.vt )
    {
    case VT_EMPTY:
      os<<_T("\"\"");
      break;
    case VT_NULL:
      os<<_T("NULL");
      break;
    case VT_I2:
      os<<propvar.iVal;
      break;
    case VT_I4:
    case VT_INT:
      os<<propvar.lVal;
      break;
    case VT_I8:
      os<<propvar.hVal.HighPart<<propvar.hVal.LowPart;
      break;
    case VT_UI2:
      os<<propvar.uiVal;
      break;
    case VT_UI4:
    case VT_UINT:
      os<<propvar.ulVal;
      break;
    case VT_UI8:
      os<<propvar.uhVal.HighPart<<propvar.uhVal.LowPart;
      break;
    case VT_R4:
      os<<propvar.fltVal;
      break;
    case VT_R8:
      os<<propvar.dblVal;
      break;
    case VT_BSTR:
      os<<propvar.bstrVal;
      break;
    case VT_ERROR:
      os<<hex<<_T("0x")<<setw(8)<<setfill(_T('0'))<<propvar.scode;
      break;
    case VT_BOOL:
      os<< (VARIANT_TRUE == propvar.boolVal ? _T("True") : _T("False") );
      break;
    case VT_I1:
      os<<propvar.cVal;
      break;
    case VT_UI1:
      os<<propvar.bVal;
      break;
    case VT_VOID:
      os<<_T("void");
      break;
    case VT_LPSTR:
      os<<propvar.pszVal;
      break;
    case VT_LPWSTR:
      os<<propvar.pwszVal;
      break;
    case VT_FILETIME:
      os<<propvar.filetime.dwHighDateTime<<_T(":")<<propvar.filetime.dwLowDateTime;
      break;
    case VT_CLSID:
      os<<((const TString&)CGUID(*propvar.puuid)).c_str();
      break;
    default:
      if( propvar.vt & VT_VECTOR )
      { ULONG count = 0;

        switch( propvar.vt & VT_TYPEMASK )
        {
        case VT_LPSTR:
          count = propvar.calpstr.cElems;
          for( ULONG i=0;i<count;i++ )
            os<<propvar.calpstr.pElems[i]<<_T(",");

          break;
        case VT_LPWSTR:
          count = propvar.calpwstr.cElems;
          for( ULONG i=0;i<count;i++ )
            os<<propvar.calpwstr.pElems[i]<<_T(",");

          break;
        default:
          os<<_T("VT_VECTOR");
          break;
        } // of switch
      } // of if
      else
        os<<_T("...");
      break;
    } // of switch
    
    return os;
  } // of basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& osconst STATPROPSTG& statpropstg)