QuickFix/n - Custom fields inside Logon - c#

I'm trying to create an initiator based on QuickFix/n.
My counterpart (server) demand the logon message to carry two custom fields.I already added those to the Data Dictionary, in the Fields as well as in the Logon message.
In the code i can manipulate the message to add the username and password, but i can't find how to load custom fields.
Here are some excerpts from what i've done so far:
TradeClientApp.cs
...
public void ToAdmin(Message message, SessionID sessionID)
{
QuickFix.SessionSettings settings = new QuickFix.SessionSettings("./initiator.cfg");
List<SessionID> sids = settings.GetSessions().ToList();
Dictionary settingsDict = settings.Get(sids.First());
var appName = settingsDict.GetString("ApplicationName");
var userType = settingsDict.GetString("UserType");
if (message.GetType() == typeof(QuickFix.FIX44.Logon))
{
message.SetField(new Username("USERNAME"));
message.SetField(new Password("PASSWORD"));
message.SetField(new QuickFix.Fields.ResetSeqNumFlag(true));
//tag 9933
message.SetField(new RawData(string.Format($"9933={appName}")));
//tag 20110
message.SetField(new RawData(string.Format($"20110={userType}")));
}
}
The initiator.cfg file:
[DEFAULT]
UseDataDictionary=Y
DataDictionary=./spec/FIX44.xml
FileStorePath=store
FileLogPath=log
ConnectionType=initiator
ReconnectInterval=60
[SESSION]
BeginString=FIX.4.4
SenderCompID=USERNAME
ResetSeqNumFlag=Y
Username=USERNAME
Password=PASSWORD
TargetCompID=TARGETCOMPID
StartTime=12:30:00
EndTime=23:30:00
HeartBtInt=10
ApplicationName=app-name
UserType=V
SocketConnectPort=446
SocketConnectHost=SERVERHOST
Inside the FIX44.XML
<message name="Logon" msgtype="A" msgcat="admin">
<field name="EncryptMethod" required="Y" />
<field name="HeartBtInt" required="Y" />
<field name="RawDataLength" required="N" />
<field name="RawData" required="N" />
<field name="ResetSeqNumFlag" required="N" />
<field name="NextExpectedMsgSeqNum" required="N" />
<field name="MaxMessageSize" required="N" />
<group name="NoMsgTypes" required="N">
<field name="RefMsgType" required="N" />
<field name="MsgDirection" required="N" />
</group>
<field name="TestMessageIndicator" required="N" />
<field name="Username" required="N" />
<field name="Password" required="N" />
<field name="ApplicationName" required="N" />
<field name="UserType" required="N" />
</message>
<fields>
...
<field number="9933" name="ApplicationName" type="STRING"/>
<field number="20110" name="UserType" type="STRING" />
</fields>
</fix>
When i try to connect i get this log:
<outgoing> 8=FIX.4.49=12035=A34=149=USERNAME52=20191008-21:19:41.49856=TARGETCOMPID96=20110=V98=0108=10141=Y553=USERNAME554=PASSWORD10=097
Using the RawData as shown in my example, the message carries 20110=V as RawData, which is tag 96, which doesn't help me.
I already tried inside ToAdmin:
message.Header.SetField(new StringField(QuickFix.Fields.Tags.UserType, ""));
or
message.SetField(new QuickFix.Fields.UserType(true));
but neither work.
How on earth do you add custom fields to the logon message?

I think you are getting the RawData data type wrong. That is literally meant for raw data, not for Strings that follow the default encoding.
From the spec:
string field containing raw data with no format or content
restrictions. Data fields are always immediately preceded by a length
field. The length field should specify the number of bytes of the
value of the data field (up to but not including the terminating SOH).
I am not so familiar with the C# implementation of QuickFIX but you should simply be able to add these fields with the specific tag number, e.g.
message.SetField(new StringField(20110, "V"));
I hope there are no syntax errors, but you should get the idea.
Edit: I see you are manually setting the ResetSeqNum field on the Logon message. This is discouraged. quickFIX/n should deal with this when you set ResetSeqNum=Y in the settings (you already have that setting).

Related

Xamarin Android Mapping field Java.Lang.Enum to C# Enum

I have a problem with converting Java enum to C# enum when binding a Java native library. I have already tried:
https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata#enumfieldsxml-and-enummethodsxml
Xamarin Android Mapping Java.Lang.Enum to C# Enum
I have class Receipt and enum Status. Enum Status is nested inside Receipt class(Java code):
public class Receipt {
public enum Status {
created,
processing,
declined,
approved,
expired,
reversed;
}
public final Status status;
}
Class Receipt has a field with Status type. When I try to build it with enum mapping it doesn't generate properly. It generates class Status instead of enum(public sealed partial class Status : global::Java.Lang.Enum) and what is more important it doesn't generate field status for class Receipt at all(public final Status status).
EnumFields.xml
<enum-field-mappings>
<mapping jni-class="com/cloudipsp/android/Status" clr-enum-type="Com.Cloudipsp.Android.Status">
<field jni-name="created" clr-name="created" value="0" />
<field jni-name="processing" clr-name="processing" value="1" />
<field jni-name="declined" clr-name="declined" value="2" />
<field jni-name="approved" clr-name="approved" value="3" />
<field jni-name="expired" clr-name="expired" value="4" />
<field jni-name="reversed" clr-name="reversed" value="5" />
</mapping>
</enum-field-mappings>```
I would be grateful for any help.

SQL Server bulk insert XML format file with Maximum LENGTH

I want to set the length to MAX for one of my XML fields.
XML Code:
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharFixed" LENGTH="3" />
<FIELD ID="2" xsi:type="CharFixed" LENGTH="MAXLENGTH" />
<FIELD ID="3" xsi:type="CharFixed" LENGTH="10" />
<FIELD ID="4" xsi:type="CharFixed" LENGTH="8" />
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="Field1" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="2" NAME="Field2" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="3" NAME="Field3" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="4" NAME="Field4" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>
But 'MAXLENGTH' does not seem to work.
Error message:
bad value MAXLENGTH for attribute "LENGTH"
Any suggestions on how to put the LENGTH to maximum ?
The length of a string is limited to 4000 (nchar) or 8000 (char) type. There is no max length-constant - AFAIC
Refer to this, "Field Attributes"
If you look up the schema meta-data just as SQL Server does, you can follow this link
http://schemas.microsoft.com/sqlserver/2004/bulkload/format/bulkloadschema.xsd
to find this
<xsd:attribute name="LENGTH" type="xsd:positiveInteger" use="required"/>
[...]
<xsd:attribute name="MAX_LENGTH" type="xsd:positiveInteger" use="optional"/>
So the length is required while max_length seems to be optional, but if you specify it, it must be a positive integer.

How to create a new run in ALM

I am trying to call ALM REST api using postman , i am able to do the basic stuff like login , authentication, and other things also like using GET method for getting TEST-SET, TEST-INSTANCE, .
I am taking the return in XML format,
Similar way i am trying to update also using PUT method , tried updating test-set name , that too worked for me , now, my question is How to create a new run if i have all the required fields value with me in a XML format,
My main aim to have it integrated with C# Application.
Using Postman i am just testing the restAPI's.
Here is what i am trying to create a new run :
https://yourdomainName/qcbin/rest/domains/Default/projects/PROJECTNAME/runs
My XML is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Entity Type="run">
<Fields>
<Field Name="name">
<Value>Run_9-21_6-58-2</Value>
</Field>
<Field Name="test-instance">
<Value>1</Value>
</Field>
<Field Name="test-config-id">
<Value>189788</Value>
</Field>
<Field Name="testcycl-id">
<Value>1541011</Value>
</Field>
<Field Name="cycle-id">
<Value>77859</Value>
</Field>
<Field Name="test-id">
<Value>154070</Value>
</Field>
<Field Name="subtype-id">
<Value>hp.qc.run.MANUAL</Value>
</Field>
<Field Name="owner">
<Value>demouser</Value>
</Field>
<Field Name="status"><Value>Not Completed</Value>
</Field>
</Fields>
</Entity>
I am getting this error while calling PUT method :
Unexpected failure in getValuePostProcess
Exception Id: qccore.general-error
If any body has any idea please help , i am totally stuck.
Try these in sequence :
"<Entity Type=\"run\"><Fields>
<Field Name=\"name\"><Value> name</Value></Field>
<Field Name=\"test-id\"><Value>" + test_id + "</Value></Field>
<Field Name=\"testcycl-id\"><Value>" + testcycl_id + "</Value></Field>
<Field Name=\"owner\"><Value> OwnerName</Value></Field>
<Field Name=\"status\"><Value>Passed</Value></Field>
<Field Name=\"subtype-id\"><Value> SubtypeID</Value></Field>
<Field Name=\"execution-date\"><Value>ExecutionDate</Value></Field>
</Fields></Entity>
Instead of HTTPS use HTTP and use PUT call, e.g.
PUT
http://HOSTNAME:80/qcbin/rest/domains/WHOLESALE/projects/PROJECTNAME/runs/%ID%
In your case:
http://yourdomainName/qcbin/rest/domains/Default/projects/PROJECTNAME/runs/%ID%

Searching among documents with roles associated

I have a huge database (sql server) of text documents (~ 500GB so far). I do full text search on them.
I want to use solr/elastic search for this purpose.
However, text documents are associated with roles in organization, ie: manager documents, or bosses' documents. And roles of people change now and then.
I dont have a problem writing a sql query for this purpose.
I can't think of doing the same with Solr/elastic search.
How would you solve this problem?
There is a good blog post about this topic "Custom security filtering in Solr". It shows how to implement the PostFilter Interface where you can do anything Java offers to check if a document maybe accessed or not. This is intended for the case that you have some remote system that holds the access information, like a corporate LDAP.
But as the author notes
It’s important to note that PostFilter is a last resort for implementing document filtering. Don’t make the solution more complicated than it needs to be. More often than not, even access control filtering can be implemented using plain ol’ search techniques, by indexing allowed users and groups onto documents and using the lucene (or another) query parser to do the trick. Only when the rules are too complicated, or external information is needed, does a custom PostFilter make sense.
That means: Would it not be possible to add fields to the documents that hold the access information? Something like
<fields>
<!-- your other fields -->
<field name="owner"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="team"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="team-lead"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="roles"
type="String" indexed="true" stored="true" multiValued="true" />
</fields>
Then when searching you can add to the query
q=some+cool+query&fq=owner:username+OR+team:user's team name+OR+role:role1

Is it possible to Update Sharepoint List Without "ID"?

I want to Upload File on Sharepoint and while apploading only i want to add all properties of Uploaded Document.
We get ID field only when Document is uploaded on Sharepoint.
Is there any other way to Update List without passing ID Field.
Example:
<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="Update">
<Field Name="ID">4<Field>
<Field Name="Field_Name">Value</Field>
</Method>
<Method ID="2" Cmd="Update">
<Field Name="ID" >6</Field>
<Field Name="Field_Name">Value</Field>
</Method>
</Batch>
Refering Link
**** I am using Sharepoint Web Services.And Uploading Document in Chunks.****
This is not possible. First the file should complete uploading, then it will have properties that can be set! (otherwise properties may be set for non-existing files, in case that the file fails to upload.)

Categories

Resources