Skip to content
Permalink
Browse files

various fixes, countrycode generator included

  • Loading branch information...
DXSdata committed Sep 9, 2019
1 parent 68b45c5 commit 090f8f58d83132de04e3b6c8cbc3b5c184965274
@@ -1,4 +1,6 @@

using ISO3166;
using System.Linq;
using System.Xml.Serialization;

namespace openTRANS
@@ -102,5 +104,12 @@ public class TypedItem
[XmlAttribute("type")]
public string Type;
}

public static string GetCountryCode(string countryName)
{
var country = Country.List.FirstOrDefault(c => c.Name == countryName);

return country?.ThreeLetterCode;
}
}
}
@@ -67,9 +67,12 @@ public class OrderInfo
[XmlArrayItem("PARTY")]
public List<Party> Parties = new List<Party>();


[XmlElement("ORDER_PARTIES_REFERENCE")]
public OrderPartiesReference OrderPartiesReference = new OrderPartiesReference();

[XmlElement("CUSTOMER_ORDER_REFERENCE")]
public CustomerOrderReference CustomerOrderReference = new CustomerOrderReference();

}


@@ -130,6 +133,9 @@ public class Address
[XmlElement("COUNTRY", Namespace = Common.Namespace.bmecat)]
public string Country;

[XmlElement("COUNTRY_CODED", Namespace = Common.Namespace.bmecat)]
public string CountryCoded;

[XmlElement("PHONE", Namespace = Common.Namespace.bmecat)]
public TypedItem Phone = new TypedItem();

@@ -161,7 +167,13 @@ public class OrderPartiesReference

}



public class CustomerOrderReference
{
[XmlElement("ORDER_DESCR")]
public string OrderDescr;
}


public class ShipmentPartiesReference
{
@@ -13,22 +13,10 @@ public class XmlCreator
private Encoding encoding = new UpperCaseUTF8Encoding(); //Previously Encoding.Utf8; in case of changing also change StringWriter below; would otherwise produce wrong xml encoding attribute
private bool standalone = true;

//private XNamespace xmlns = "http://www.opentrans.org/XMLSchema/2.1";
private XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
private string schemaLocation = "http://www.opentrans.org/XMLSchema/2.1%20opentrans_2_1.xsd";
private string bmecat = "http://www.bmecat.org/bmecat/2005";
private string xmime = "http://www.w3.org/2005/05/xmlmime";
private string xsig = "http://www.w3.org/2000/09/xmldsig#";

private string version = "2.1";
private string type = "standard";


private Order order;

private const string OrderHeader = "ORDER_HEADER";
private const string ControlInfo = "CONTROL_INFO";
private const string ControlInfoGenerationDate = "GENERATION_DATE";

public XmlCreator(Order order)
{
this.order = order;
@@ -6,7 +6,11 @@
<Authors>DXSdata</Authors>
<Company>DXSdata GmbH</Company>
<Description>.NET Core / Standard implementation of the openTRANS v2.1 definitions by Fraunhofer IAO</Description>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ISO3166" Version="1.0.2" />
</ItemGroup>

</Project>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ISO3166" version="1.0.2" targetFramework="net471" />
</packages>
@@ -36,6 +36,7 @@ private void testform_Load(object sender, EventArgs e)

o.OrderHeader.OrderInfo.OrderId = "123";
o.OrderHeader.OrderInfo.OrderDate = DateTime.Now.Date;
o.OrderHeader.OrderInfo.CustomerOrderReference.OrderDescr = "MyOrderNr";

var p1 = new Party();
p1.PartyId.Value = "TestSupplier";
@@ -53,6 +54,7 @@ private void testform_Load(object sender, EventArgs e)
p2.Address.Zip = "MyZipCode";
p2.Address.City = "MyCity";
p2.Address.Country = "Austria";
p2.Address.CountryCoded = Common.GetCountryCode(p2.Address.Country);
p2.Address.Phone.Value = "+1234";
p2.Address.Phone.Value = PhoneType.Office;
p2.Address.Fax.Value = "+5678";
@@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ISO3166, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ISO3166.1.0.2\lib\net20\ISO3166.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -67,6 +70,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

0 comments on commit 090f8f5

Please sign in to comment.
You can’t perform that action at this time.