Hi,
Little changes when creating an event to notify the clients of the SEC server that an instrument was updated - for instance, directly into the database by an update or insert-: a new tag should be added: wdID. I don't know the signification of this tag, but adding this tag and setting it to a "0" value works fine. If this tag is not added, an error 'tag not found' will be returned by the CSREvent::SendEvent method.
Thus, finally, for those who want all the code, this one works fine on the 5.3.2:
CSREvent _event;
const CSRInstrument* _instrument = NULL;
try
{
// first: release the instrument if already loaded, because the internal definition
// could be different on the web service: if we try to notify, it's that there's a problem
// of coherency between the database and the memory somewhere....
CSRInstrument::Free(*ident);
// then load it again
_instrument = CSRInstrument::GetInstance(*ident);
}
catch(...)
{
exception->set(__ITQ_E_INSTRUMENT_GETTING__,"Unknown error");
}
if(exception->m_error==0)
{
if(_instrument!=NULL)
{
char _buffer[41];
// Internal code
_event.Add('SICO',*ident);
// Reference
_instrument->GetReference(_buffer);
_event.Add('refc',_buffer);
// Name
_instrument->GetName(_buffer);
_event.Add('name',_buffer);
// Currency
long _ccy = _instrument->GetCurrency();
_event.Add('curr',_ccy);
// Type
_buffer[0] = _instrument->GetType();
_buffer[1] = '\0';
_event.Add('type',_buffer);
// + Beta (needed)
const CSREquity* _equity = dynamic_cast<const CSREquity*>(_instrument);
double _beta = _equity==NULL ? 0. : _equity->GetBeta();
_event.Add('beta',_beta);
// Owner/modifier
_event.Add('ownr',(short)0);
// wdID ???
_event.Add('wdID',(long)0);
long _eventType = ieCHANGE; // ajti
try
{
sophis::misc::eEventErrorCode _error = _event.SendEvent(classAPIPacket,_eventType); // PAPI + ajti
if(_error!=eecNoError)
{
char _msg[256];
snprintf(_msg,sizeof(_msg),"Error while sending instrument event, error=%i",_error);
exception->set(__ITQ_E_EVENT_SEND__,_msg);
}
}
catch(...)
{
exception->set(__ITQ_E_EVENT_SEND__,"Unknown error while sending instrument event");
}
}
else
exception->set(__ITQ_E_UNDEFINED_INSTRUMENT__,"Undefined instrument");
}
Rgds,
Philippe