Esempio n. 1
0
void CmdHelper::PostJsonDatasToRpc()
{
	TCHAR strFileName[MAX_PATH];
	if(acedGetString(0, _T("请指定数据文件名称:"), strFileName) != RTNORM) return;

	std::ifstream infile(W2C(strFileName));
	if(!infile) return;

	//有些请求可能需要传递给cad一些参数
	std::string input_datas = "{}";
	infile >> input_datas;

	//服务器生成的密钥
	std::string secret_key = "#";
	infile >> secret_key;
	infile.close();

	acutPrintf(_T("\n1:%s\n2:%s"), C2W(input_datas), C2W(secret_key));
	if(secret_key == "#") return;

	// 收集数据(根据input_datas的内容进行判断:input_datas是一个json数据)

	//发送rpc服务器进行缓存
	std::string out_datas = "{'name':'dlj'}";
	CbmClientHelper::PostJsonDatasFromCAD(secret_key, input_datas, out_datas);
}
Esempio n. 2
0
void UnicodeToAnsi(std::string & strDest, const WCHAR* src)
{
	char* str = NULL;
	W2C(&str, src);
	strDest = str;
	SAFE_ARRYDELETE(str);
}
Esempio n. 3
0
 void Utf8ToAnsi(char** dest, const char* src)
 {
	 ASSERT(dest!= NULL || src != NULL);
	 WCHAR* str = NULL;
	 Utf8ToUnicode(&str, src);
	 W2C(dest, str);
	 SAFE_ARRYDELETE(str);
 }
Esempio n. 4
0
void T2C(char** dest, const TCHAR* src)
{
#ifdef _UNICODE
	W2C(dest, src);
#else
	int len = _tcslen(src) + 1;
	*dest = new TCHAR[len];
	strcpy(*dest, src);
#endif
}
/*
 *    This is the AddEvent() for ParseProcedure().  ParseProcedure() events always get called
 *  with a DispID of 0, therefore, these events are always treated as an individual container.
 */
STDMETHODIMP OrxEvent::AddEvent(OLECHAR *pName, LPCOLESTR Code, DISPID SinkDispID,DWORD Flags, IDispatch **pbIDispatch)
{
    ESource  *Current;
    ListItem *Next;
    HRESULT  RetCode=S_OK;
    char     Name[MAX_PATH];

    FPRINTF2(logfile,"OrxEvent::AddEvent() SinkDispID %d. \n",(int)SinkDispID);

    *pbIDispatch = (IDispatch *)NULL;
    Current = new ESource;
    if (Current == NULL)
    {
        RetCode = E_OUTOFMEMORY;
    }
    else
    {
        RetCode = Current->InitEvent(pName,Code,SinkDispID,Engine,logfile);
        if (SUCCEEDED(RetCode))
        {
            W2C(&Name[0], pName, (int)wcslen(pName)+1);
            Next = EventSourceChain->AddItem(Name,LinkedList::End,(void *)Current);
            //  Make sure the Event can tell people if it goes away prematurely.
            Current->SetDestructor(EventSourceChain, (void *)Current);
        }
        else
        {
            Next = NULL;
        }
        if (Next)
        {
            *pbIDispatch = (IDispatch *)Current;
        }
        else
        {
            delete Current;
            RetCode = SUCCEEDED(RetCode) ? E_OUTOFMEMORY : RetCode;
        }
    }
    FPRINTF2(logfile,"OrxEvent::AddEvent() HRESULT %08x. \n",RetCode);
    return RetCode;
}
/******************************************************************************
*                 GetDispID
******************************************************************************/
  STDMETHODIMP OrxScript::GetDispID(
    /* [in] */ BSTR pName,
    /* [in] */ DWORD pFlags,               // Derived from fdexName... defines.
    /* [out] */ DISPID __RPC_FAR *pbDispID)
{
    HRESULT   RetCode= S_OK;
    void     *Property;
    DISPID    PropertyDispID;
    char      lName[MAX_PATH];
    PDID          DispIDData;


    //    N.B. (Nota Bene - Latin for read this, your life may depend on it.)
    //  The flags are ignored, and all comparisons are case sensative.
    FPRINTF(logfile,"OrxScript::GetDispID\n");
    FPRINTF2(logfile,"Name \"%S\" Flags 0x%08x\n",pName,pFlags);
    FPRINTF2(logfile,"In english the pFlags signifies:\n");
    FPRINTF2(logfile,"%s\n",FlagMeaning('H',pFlags,DispExGetDispID));

    do
    {
        if (pFlags & fdexNameEnsure)
        {      // We are not supporting the Dynamic ability to add
            RetCode = E_NOTIMPL;             // properties or methods.
            break;
        }
        if (pbDispID == NULL)
        {
            RetCode = E_POINTER;
            break;
        }

        *pbDispID = -1;
        //    Generalities are OK, it is the special cases that kill you.
        if (EventState == Searching && EventSourceName != NULL)
        {
            FPRINTF2(logfile,"Searching for an event name?  \n");
            if (wcsicmp(EventSourceName,pName) == 0)
            {
                //  Yes, we are being queried for an Event that we are looking for!
                //  We must deny knowing this, or we will be forced to provided information
                //  that we really don't have.
                RetCode = DISP_E_UNKNOWNNAME;
                break;
            }
            // For now, if it looks like we had an event call, but didn't
            // then do normal processing.  Later it may be decided that this
            // is an error.
        }
        //    This is to help enforce Rexx scoping rules.  This is set during a NoValue check.
        //  During this, Mr. Phelps, we deny all knowledge of ourserves.
        if (EventState == IMF)
        {
            RetCode = DISP_E_UNKNOWNNAME;
            break;
        }



        // Do we already have this name?
        FPRINTF2(logfile,"Searching through the list.  \n");
        RetCode = DispID.FindDispID(pName,pbDispID);
        if (EventState != NoProperties)
        {
            //  No, then see if it could be a Property.
            if (FAILED(RetCode))
            {
                //  Using W2C() instead of sprintf() since the max length specification is easier.
                W2C(lName,pName,sizeof(lName));
                Property = PropertyList.FindContent(lName);
                if (Property)
                {
                    RetCode = DispID.AddDispID(pName,0,DID::Property,Property,&PropertyDispID);
                }
                if (SUCCEEDED(RetCode))
                {
                    *pbDispID = PropertyDispID;
                }
            }
        }
        else
        {
            //  Yes, then ensure it is not a Property.
            if (SUCCEEDED(RetCode))
            {
                RetCode = DispID.FindDID(*pbDispID,&DispIDData);
                if (DispIDData->Type == DID::Property)
                {
                    RetCode = DISP_E_UNKNOWNNAME;
                    *pbDispID = -1;
                }
            }
        }

    } while (0==1);

    if (SUCCEEDED(RetCode))
    {
        FPRINTF2(logfile,"%03d - *%S*\n",(int)*pbDispID,pName);
    }
    if (FAILED(RetCode))
    {
        FPRINTF2(logfile,"A DispID for \"%S\" was not found, or created.  HRESULT = %08x\n",pName,RetCode);
    }

    return RetCode;

}
Esempio n. 7
0
 void UnicodeToAnsi(char** dest,  const WCHAR* src)
 {
 	ASSERT(dest!= NULL || src != NULL);
	W2C(dest, src);
 }