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

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.

Related

QuickFix/n - Custom fields inside Logon

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).

Avoid Aliases in result from FetchXml with linked entities

I have the following FetchXML:
<fetch>
<entity name="list" >
<attribute name="listname" />
<attribute name="listid" alias="List" />
<filter type="and" >
<condition attribute="listname" operator="eq" value="Test 1" />
</filter>
<link-entity name="listmember" from="listid" to="listid" intersect="true" alias="listmember" >
<attribute name="entitytype" />
<attribute name="listmemberid" />
<attribute name="entityid" />
<link-entity name="contact" from="contactid" to="entityid" alias="contact" >
<attribute name="contactid" />
<attribute name="owneridname" />
<attribute name="owneridtype" />
<attribute name="ownerid" />
</link-entity>
</link-entity>
</entity>
The result looks like this:
<resultset morerecords="0" paging-cookie="<cookie page="1"><listid lastnull="1" firstnull="1" /></cookie>">
<result>
<listname>Test 1</listname>
<listmember.entitytype formattedvalue="2">2</listmember.entitytype>
<listmember.listmemberid>{6739D9B9-xxxx-xxxx-xxxx-000D3A3852A3}</listmember.listmemberid>
<listmember.entityid type="2">{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</listmember.entityid>
<contact.contactid>{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</contact.contactid>
<contact.ownerid name="CRM Test" dsc="" type="8" yomi="CRM Test">{5ABA5CBA-xxxx-xxxx-xxxx-D472F64781F6}</contact.ownerid>
</result>
</resultset>
My issue now is that I have a generic way to retrieve the attributes returned by a FetchXml. But since this one has linked entites the aliases are added to the result, like:
<listmember.listmemberid>
So my retrieve will throw an error since I am looking for "listmemberid"
Is there a way to avoid having these aliases added to the result? Specially since the attribute names are unique?
Any ideas to get around this issue?
The only option to override the alias of the select column which is working - when you do aggregate function and I tested the below working example.
<fetch top="50" aggregate="true" >
<entity name="account" >
<attribute name="businesstypecode" alias="test" groupby="true" />
<link-entity name="contact" from="accountid" to="accountid" link-type="inner" alias="acc" >
<attribute name="accountrolecode" alias="testing" groupby="true" />
</link-entity>
</entity>
</fetch>
Result:
test testing
1 3
1
This didn't work. I don't know why, maybe limitation of fetchxml.
<fetch top="50" >
<entity name="contact" >
<attribute name="fullname" />
<link-entity name="account" from="accountid" to="accountid" alias="acct" >
<attribute name="name" alias="acctNAME" />
</link-entity>
</entity>
</fetch>
Result:
fullname acct.name
arun account arun account
Even with the Query Expression, you will get a special datatype called AliasedValue to handle this, so this is intended behavior. Read more
You get these aliases and then it’s value because you are retrieving data from linked entity. Whenever you do that I.e retrieving from linked entity you will have to use aliases, as far as I know you cannot circumvent it.
What I could suggest is if you need data only from ListMember entity and not from List and contact,
Create your fetch based on list member entity such as
select * from listmember where listname="Test 1"
But as soon as you need data from related entity, that related entity shall be aliased.

Retrieve "Applicable When" and "Success Criteria" from Dynamics CRM SLA programmatically

Currently developing a console application to check all the SLAs in the Dynamics 365 instance.
How to retrieve the "applicable when" and "success criteria" from Dynamics CRM SLA programmatically?
That information is stored in the applicablewhenxml and successconditionsxml fields of the slaitem entity. You can use the following FetchXML to retrieve them:
<fetch>
<entity name="slaitem" >
<attribute name="applicablewhenxml" />
<attribute name="successconditionsxml" />
</entity>
</fetch>
As you can imagine from the names, the information is stored as XML. For example, for a success condition of Status equals to Active:
<and>
<condition>
<column id="colEntity" value="incident" />
<column id="colAttribute" value="statecode" />
<column id="colOperator" value="eq" />
<column id="colStaticValue" value="0" dataslugs="" />
</condition>
</and>

How to correctly serialize class derived from collection using DataContracts

In C# and .NET 4.5 I'm in the process of implementing XML generation/parsing by means of DataContract serialization which appears extremely effective.
I have, however, run into a number of problems in a couple of situations I hope somebody can help me with.
The relevant classes are the following 5 (plus a number of embedded objects):
[DataContract]
public abstract class ItemList<T> : List<T>, IList
{
.....
}
[DataContract]
public class CashFlowList : ItemList<CashFlow>
{
.....
}
[DataContract]
public class CashFlow : ItemList<CashFlowPayment>
{
.....
}
[DataContract]
public class CashFlowPayment : ListItem, IDataImportExport
{
.....
}
[DataContract]
public abstract class ListItem : System.IComparable, IList
{
.....
}
When using the DataContractSerializer (on the CashFlowList type), the resulting XML looks like this:
<CashFlowList xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/FinancialData">
<_items>
<CashFlow>
<_items>
<CashFlowPayment>
<ID>-1</ID>
<ProbDist xmlns:d6p1="http://schemas.datacontract.org/2004/07/ProbabilityDistributions" i:nil="true" />
<UseProbabilityDistribution>true</UseProbabilityDistribution>
<ValidFrom>0001-01-01T00:00:00</ValidFrom>
<ValidThrough>9999-12-31T23:59:59.9999999</ValidThrough>
<Amount>4500</Amount>
<Ccy i:nil="true" />
<Date>2012-02-03T00:00:00</Date>
<DaysFromStartDate>-1</DaysFromStartDate>
</CashFlowPayment>
<CashFlowPayment>
<ID>-1</ID>
<ProbDist xmlns:d6p1="http://schemas.datacontract.org/2004/07/ProbabilityDistributions" i:nil="true" />
<UseProbabilityDistribution>true</UseProbabilityDistribution>
<ValidFrom>0001-01-01T00:00:00</ValidFrom>
<ValidThrough>9999-12-31T23:59:59.9999999</ValidThrough>
<Amount>-30000</Amount>
<Ccy i:nil="true" />
<Date>2013-04-10T00:00:00+02:00</Date>
<DaysFromStartDate>465</DaysFromStartDate>
<DaysUntilEndDate>-1</DaysUntilEndDate>
<IsPerpetual>false</IsPerpetual>
<PaymentType>Unknown</PaymentType>
<Schedule xmlns:d6p1="http://schemas.datacontract.org/2004/07/Schedules" i:nil="true" />
</CashFlowPayment>
<CashFlowPayment i:nil="true" />
<CashFlowPayment i:nil="true" />
</_items>
<_size>2</_size>
<_version>3</_version>
<ID>-1</ID>
<Name></Name>
<ProbDist xmlns:d4p1="http://schemas.datacontract.org/2004/07/ProbabilityDistributions" i:nil="true" />
<UseProbability>false</UseProbability>
<ValidFrom>0001-01-01T00:00:00</ValidFrom>
<ValidThrough>9999-12-31T23:59:59.9999999</ValidThrough>
<BaseCCY></BaseCCY>
..............................
<StartDate>2012-05-09T00:00:00</StartDate>
<SumOfNegativePayments>-30000</SumOfNegativePayments>
<SumOfPositivePayments>4500</SumOfPositivePayments>
<ValueDate>0001-01-01T00:00:00</ValueDate>
<XMLCashFlowElementName i:nil="true" />
<XMLPaymentElementName i:nil="true" />
<XMLPaymentsElementName i:nil="true" />
</CashFlow>
<CashFlow i:nil="true" />
<CashFlow i:nil="true" />
<CashFlow i:nil="true" />
</_items>
<_size>1</_size>
<_version>1</_version>
<ID>-1</ID>
<Name></Name>
<ProbDist xmlns:d2p1="http://schemas.datacontract.org/2004/07/ProbabilityDistributions" i:nil="true" />
<UseProbability>false</UseProbability>
<ValidFrom>0001-01-01T00:00:00</ValidFrom>
<ValidThrough>9999-12-31T23:59:59.9999999</ValidThrough>
</CashFlowList>
The generated XML is correct - but has a number of quirks: first of all the <_items> elements which I guess are required for the serializer to manage the output.
Secondly, you will notice that each collection - within the <_items> elements always has a minimum of 4 child elements - for example, adding another CashFlow to the
outer will result in only 2 elements - why, and is there a way of getting around that ?
Replacing one or more [DataContract] attributes with [CollectionDataContract] - regardless of what properties are set within the attributes - will produce
grammatically correct XML output as expected, but now - for each class having the [CollectionDataContract] attribute - only the collection items are output - and not the regular
properties within the class. I.e. an example would be:
<CashFlowList xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/FinancialData">
<CashFlow>
<CashFlowPayment>
....
</CashFlowPayment>
</CashFlow>
</CashFlowList>
In the example above the following elements (in the outer CashFlowList object) have been ignored:
<ID>-1</ID>
<Name></Name>
<ProbDist xmlns:d2p1="http://schemas.datacontract.org/2004/07/ProbabilityDistributions" i:nil="true" />
<UseProbability>false</UseProbability>
<ValidFrom>0001-01-01T00:00:00</ValidFrom>
<ValidThrough>9999-12-31T23:59:59.9999999</ValidThrough>
So my question is whether this is by design and is unavoidable - i.e. can you output a class derived from a collection and include additional properties in the output
when using the [CollectionDataContract] attribute ?
Interestingly, if [CollectionDataContract] attributes are used, you can generate/retrieve the corresponding XSD using the XsdDataContractExporter class without
problems (except that the XML is incomplete due to the missing properties). When using [DataContract] attributes, however, the XSD cannot be generated (fails in
the CanExport method), but the XML is correct and complete, but not particularly legible.
I would therefore really appreciate any insights and/or thoughts on this.
Best regards and thanks,
Michael

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