I have referd to here :
QuickFix Login Failed due to password missing
and here :
How to make the login part in QuickFIX
to add username and password in toAdmin like following :
void Application::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX44::Logon& logon_message = dynamic_cast<FIX44::Logon&>(message);
FIX::Username username = std::string("my_username") ;
logon_message.setField( username );
}
}
This cause compiler error in gcc 4.8.2 :
error: cannot dynamic_cast ??message?? (of type ??class FIX::Message??) to type ??class FIX44::Logon&?? (target is not pointer or reference to complete type)
then I change my code to
FIX44::Logon* logon_message = (FIX44::Logon*)(&message);
FIX::Username username = std::string("my_username") ;
logon_message->setField( username );
this time , compiler error again :
error: invalid use of incomplete type ??class FIX44::Logon??
logon_message->setField( username );
^
What should I modify so that I can correctly set username and password in
function toAdmin ? what is wrong with logon_message->setField( username ); ?
Edit :
according to this webpage :
https://sourceforge.net/p/quickfix/mailman/message/26233433/
The following works fine to me :
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
message.getHeader().setField(553, "XXXXXXXXX");
message.getHeader().setField(554, "yyyyyyyyy");
}
Have you tried
FIX44::Logon* logon_message = dynamic_cast<FIX44::Logon*>(message);
or
FIX44::Logon* logon_message = dynamic_cast<FIX44::Logon*>( *(message) );
or
FIX44::Logon* logon_message = dynamic_cast<FIX44::Logon*>(&message);
I think this may be an issue of dereferencing message correctly.
The error message suggests that you did not #include "quickfix/fix44/Logon.h".
That is why it thinks that you are using an incomplete type. Your compiler now probably just sees a forward declared: class FIX44::Logon; and it does not know what methods this class contains.
The other answers correctly state that you don't even need to downcast
message.setField(FIX::Username(username));
message.setField(FIX::Password(password));
You don't need to cast your message. Ultimately you end up calling setField which is a function available to the base class FIX::Message.
void FIXSession::toAdmin(FIX::Message& msg, const FIX::SessionID& sid)
{
const std::string& field = msg.getHeader().getField(FIX::FIELD::MsgType);
if (FIX::MsgType_Logon == field)
{
FIX::Dictionary dd(m_sessionSettings.get(sid));
if (dd.has(FixSettingUsername))
{
FIX::Username username = dd.getString(FixSettingUsername);
msg.setField(username);
}
if (dd.has(FixSettingPassword))
{
FIX::Password password = dd.getString(FixSettingPassword);
msg.setField(password);
}
if (dd.has(FIX::SEND_RESETSEQNUMFLAG))
{
FIX::ResetSeqNumFlag rsn(dd.getBool(FIX::SEND_RESETSEQNUMFLAG));
msg.setField(rsn);
}
}
}
Related
I have literally tried everything but still in vain. This here is InvoiceJournalExpParticipantProvider class that is supposed to provide me partici[ant names inside the workflow (all of this is custom code). Now what i want is to pass the LedgerJounalTrans table instead of the VendInvoiceInfoTable or VendInvoiceInfoLine table. I cannot seem to find a way to do this. I tried using the following code
else if (_context.parmTableId() == tableNum(LedgerJournalTrans))
{
ledgerJournalTrans = LedgerJournalTrans::findRecId(_context.parmRecId(),false);
}
But it constantly gives me an error either telling me that the operand types are of not the same types or the number of arguments passed are invalid although when i go and check the findRecId() method of ledgerJournalTrans table there are only two params being passed.
public WorkflowUserList resolve(WorkflowContext _Context, WorkflowParticipantToken _participantTokenName)
{
WorkflowUserList userList = WorkflowUserList::construct();
VendInvoiceInfoTable vendInvoiceInfoTable;
VendInvoiceInfoLine vendInvoiceInfoLine;
VendInvoiceInfoLine_Project vendInvoiceInfoLine_Project;
WorkflowParticipantExpenToken workflowParticipantExpenToken;
WorkflowParticipantExpenTokenLine workflowParticipantExpenTokenLine;
RefRecId dimensionAttributeSetRecId;
MarkupTrans markupTrans;
CompanyInfo legalEntity;
ProjTable projTable;
HcmWorker worker;
DirPersonUser personUser;
HcmPositionDetail hcmPositionDetail;
HcmPosition hcmPosition;
HcmPositionWorkerAssignment hcmPositionWorkerAssignment;
LedgerJournalTrans ledgerJournalTrans;
// check participant token name is given otherwise throw error
if(!_participantTokenName)
{
throw error('Participant name');
}
userList.add('Admin');
if (!_participantTokenName)
{
throw error("#SYS105453");
}
workflowParticipantExpenToken = WorkflowParticipantExpenToken::findName(
this.documentType(),
_participantTokenName);
if (!workflowParticipantExpenToken)
{
throw error(strFmt("#SYS313865", _participantTokenName));
}
if (_context.parmTableId() == tableNum(VendInvoiceInfoTable))
{
vendInvoiceInfoTable = VendInvoiceInfoTable::findRecId(_context.parmRecId());
}
else if (_context.parmTableId() == tableNum(VendInvoiceInfoLine))
{
vendInvoiceInfoTable = VendInvoiceInfoLine::findRecId(_context.parmRecId()).vendInvoiceInfoTable();
}
I would to send user data, so i added a field in the message file :
class MpeiMacHeader extends MacHeaderBase
{
MPEIMacType type;
uint32_t data;
}
This is what the received message looks like :
msg fields
I didn't success to get the field data in my code. I tried several expressions, i could only get : msg fields
But when I try to compile with msg->content in my code :
no member named 'content' in 'omnetpp::cMessage'
How to get this field in my code ? There is a getData() in generated files, but i didn't find how to use it.
I tried to get the data in handleSelfMessage(), I found a solution using handleLowerPacket() :
void MpeiMac::handleLowerPacket(Packet *packet)
{
if (packet->hasBitError())
{
...
}
else
{
const auto& hdr = packet->peekAtFront<MpeiMacHeader>();
packet->setKind(hdr->getType());
if( hostID == 0 )
data = hdr->getData();
// simply pass the massage as self message, to be processed by the FSM.
handleSelfMessage(packet);
}
}
Maybe this section can explain : inet_developers-guide :
I am trying to use a library for showing Flash Messages https://github.com/elpete/flashmessage But I am having trouble getting it working correctly. The documentation isn't that great and I am new to ColdFusion. I want to have the ability to have persistent error messages across pages. Specifically during checkout so when the user needs to go back or a validation error occurs the message will appear. According to the documentation:
The FlashMessage.cfc needs three parameters to work:
A reference to your flash storage object. This object will need
get(key) and put(key, value) methods. A config object with the
following properties: A unique flashKey name to avoid naming
conflicts. A reference to your containerTemplatePath. This is the view
that surrounds each of the individual messages. It will have
references to a flashMessages array and your messageTemplatePath. A
reference to your messageTemplatePath. This is the view that
represents a single message in FlashMessage. It will have a reference
to a single flash message. The name is chosen by you in your container
template. Create your object with your two parameters and then use it
as normal.
I am getting the error
the function getMessages has an invalid return value , can't cast null value to value of type [array]
I had this script somewhat working at one point but it seems very finicky. I believe it is my implementation of it. I am hoping someone here can help me figure out where I went wrong. Or give me some pointers because I am not sure I am even implementing it correctly.
This is What I have in my testing script:
<cfscript>
alertStorage = createObject("component", 'alert');
config = {
flashKey = "myCustomFlashKey",
containerTemplatePath = "/flashmessage/views/_templates/FlashMessageContainer.cfm",
messageTemplatePath = "/flashmessage/views/_templates/FlashMessage.cfm"
};
flash = new flashmessage.models.FlashMessage(alertStorage, config);
flash.message('blah');
flash.danger('boom');
</cfscript>
And inside of alert.cfc I have:
component {
public any function get(key) {
for(var i = 1; i < ArrayLen(session[key]); i++) {
return session[key][i];
}
}
public any function put(key, value) {
ArrayAppend(session.myCustomFlashKey, value);
return true;
}
public any function exists() {
if(structKeyExists(session,"myCustomFlashKey")) {
return true;
} else {
session.myCustomFlashKey = ArrayNew();
return false;
}
}
}
The Flash Message Component looks like this:
component name="FlashMessage" singleton {
/**
* #flashStorage.inject coldbox:flash
* #config.inject coldbox:setting:flashmessage
*/
public FlashMessage function init(any flashStorage, any config) {
instance.flashKey = arguments.config.flashKey;
singleton.flashStorage = arguments.flashStorage;
instance.containerTemplatePath = arguments.config.containerTemplatePath;
instance.messageTemplatePath = arguments.config.messageTemplatePath;
// Initialize our flash messages to an empty array if it hasn't ever been created
if (! singleton.flashStorage.exists(instance.flashKey)) {
setMessages([]);
}
return this;
}
public void function message(required string text, string type = "default") {
appendMessage({ message: arguments.text, type = arguments.type });
}
public any function onMissingMethod(required string methodName, required struct methodArgs) {
message(methodArgs[1], methodName);
}
public any function render() {
var flashMessages = getMessages();
var flashMessageTemplatePath = instance.messageTemplatePath;
savecontent variable="messagesHTML" {
include "#instance.containerTemplatePath#";
}
setMessages([]);
return messagesHTML;
}
public array function getMessages() {
return singleton.flashStorage.get(instance.flashKey, []);
}
private void function setMessages(required array messages) {
singleton.flashStorage.put(
name = instance.flashKey,
value = arguments.messages
);
}
private void function appendMessage(required struct message) {
var currentMessages = getMessages();
ArrayAppend(currentMessages, arguments.message);
setMessages(currentMessages);
}
}
I am using quickfix C++ implementation to connect to the FIX Server, everything is ok except when i tries to connect it says the field missing username. To correct this i added the following code to the toAdmin Method
void Application::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX44::Logon & logon_message = dynamic_cast<FIX44::Logon&>(message);
logon_message.setField(FIX::Username("username"));
logon_message.setField(FIX::Password("password"));
}
std::cout<<message.toString();
}
}
but is causes an exception. To check whether it is working or not also tried to print the message using std::cout<<message.ToString();
but nothing worked.
I think you were almost there. Here is my solution for initiating a FIX session with FXCM in C# (should be easy for you to port a C++ implementation).
1- Use the QuickFix Examples.TradeClient project.
2- Ensure your fix.cfg file is present in TradeClient/bin/Debug directory.
3- Ensure your dictionary (FIXFXCM10.XML) is present in TradeClient/bin/Debug directory.
4- Your main Program.cs should look something like this;
var settings = new QuickFix.SessionSettings("fix.cfg");
var client = new QuickFixClient();
var storeFactory = new QuickFix.FileStoreFactory(settings);
var logFactory = new QuickFix.ScreenLogFactory(settings);
var initiator = new QuickFix.Transport.SocketInitiator(client, storeFactory, settings, logFactory);
initiator.Start();
client.Run();
initiator.Stop();
and replace
public void ToAdmin(Message message, SessionID sessionID) {}
with this
public void ToAdmin(Message message, SessionID sessionID)
{
if (message.GetType() == typeof(QuickFix.FIX44.Logon))
{
message.SetField(new Username("YOUR_USERNAME"));
message.SetField(new Password("YOUR_PASSWORD"));
}
message.SetField(new QuickFix.Fields.Account("YOUR_ACCOUNT_NUMBER"));
}
FXCM require the account number (tag 1=) to be sent with every message to be valid. That could also prevent a successful logon if its not present.
Hope this helps!
This is how I added password:
void toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
{
// put password in the logon message
if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
{
FIX::Password fixpasswd = ConfigSingleton::getInstance().CurrenexConfig.FIXPassword; //use your std::string password here.
message.getHeader().setField(FIX::Password(fixpasswd)); //also add username here.
}
}
If you can see your username and password, then it means ok already.
Regarding the exception, I also encountered before. For me, it comes from toApp function and I changed it as below and it works fine:
void toApp( FIX::Message& message, const FIX::SessionID& sessionID )
throw( FIX::DoNotSend )
{
try
{
FIX::PossDupFlag possDupFlag;
message.getHeader().getField( possDupFlag );
if ( possDupFlag ) throw FIX::DoNotSend();
}
catch ( FIX::FieldNotFound& e)
{
//std::cout << e.what() << " " << message.toString() << ENDLINE;
}
}
Actually, no exception.
BTW, if you didn't define your own function for some message types, the messages will be rejected.
Hope this will help.
I have a working method which will successfully open Outlook (and other mail clients), open a new message window, and set the body and subject fields with provided strings, and attach one or more files indicated by a vector of our internal filepath object. I'm trying to extend this to add a recipient in the To: field. The code below omits all of the subject/body/path stuff for brevity and just shows what I've done with recipients.
void createMailMessage( const char *recipientAddr, const char *subject, const char *body, const std::vector<FSPath> &attachments) {
// first get all of the const char* into std::wstring
// ommitted here for brevity
MapiMessageW message = { 0 };
MapiRecipDescW *recipients = NULL;
if (recipientAddr != NULL) {
recipients = new MapiRecipDescW[1];
memset(recipients, 0x00, sizeof(MapiRecipDescW) ) // only one recipient
recipients[0].lpszAddress = (PWSTR) recipStrW.c_str(); // recipStrW is from omitted code above
recipients[0].ulRecipClass = MAPI_TO;
message.nRecipCount = (ULONG) 1;
message.lpRecips = recipients;
}
// fill in the rest of the message info here
// this stuff is already working and i left it unchanged
MAPISendMailHelper(NULL, NULL, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0);
}
In the debugger I can see that the message struct is still well-formed, simply with the addition of a pointer to the recipients struct and the nRecipCount field filled correctly. That struct is also well-formed, with the expected address string and class value. When the code executes, it reaches the same call that produces the new message dialog ( pfnMapiSendMailA() in MapiUnicodeHelp.h ), but does not seem to execute it.
Help! What am I missing?!
Thanks in advance!