|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- namespace TM.EDIBroker.TransSmart.Transforms {
-
-
- [Microsoft.XLANGs.BaseTypes.SchemaReference(@"TM.EDIBroker.TransSmart.Schemas.Shipment", typeof(global::TM.EDIBroker.TransSmart.Schemas.Shipment))]
- [Microsoft.XLANGs.BaseTypes.SchemaReference(@"TM.Shared.Schemas.Order", typeof(global::TM.Shared.Schemas.Order))]
- public sealed class TM_EDIBroker_TransSmart_Shipment_to_TM_Shared_Order : global::Microsoft.XLANGs.BaseTypes.TransformBase {
-
- private const string _strMap = @"<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""1.0""
- xmlns:ScriptNS0=""http://schemas.microsoft.com/BizTalk/2003/ScriptNS0""
- xmlns:ScriptNS1=""http://schemas.microsoft.com/BizTalk/2003/ScriptNS1""
-
- xmlns:DateTime=""TM.Shared.Components.DateTime""
- xmlns:SSO=""TM.Shared.Components.SSO""
- xmlns:String=""TM.Shared.Components.String""
-
- xmlns:s0=""http://TM.EDIBroker.TransSmart.Shipment""
- xmlns:ns0=""http://TM.KLG.com/KLG/Order""
-
- exclude-result-prefixes=""s0 ns0 ScriptNS0 ScriptNS1 DateTime SSO String"">
-
- <xsl:output omit-xml-declaration=""yes"" method=""xml"" version=""1.0"" indent=""yes"" />
-
- <!-- region global variable initialization -->
-
- <xsl:key name=""groepje"" match=""s0:shipmentLine"" use=""concat(generate-id(..), '|', s0:lineNo)"" />
-
-
- <xsl:variable name=""connectionString"" select=""SSO:GetValue('TM.EDIBroker.TransSmart', 'ESBLookupConnectionString')""/>
- <xsl:variable name=""sender"" select=""'TUUCIOISTE01'""/>
- <xsl:variable name=""receiver"" select=""'KLGEUVENLO01'""/>
- <xsl:variable name=""currentDate"" select=""DateTime:GetCurrentDate()"" />
-
- <!-- end region -->
-
- <!-- region templates -->
-
- <xsl:template match=""/"">
- <xsl:apply-templates select=""/s0:carrierBooking"" />
- </xsl:template>
-
- <xsl:template match=""/s0:carrierBooking"">
- <ns0:Order>
- <Sender>
- <xsl:value-of select=""$sender""/>
- </Sender>
- <Receiver>
- <xsl:value-of select=""$receiver""/>
- </Receiver>
- <GroupName>
- <xsl:text>N/A</xsl:text>
- </GroupName>
- <Consolidation>
- <xsl:text>N/A</xsl:text>
- </Consolidation>
- <Reference>
- <xsl:value-of select=""s0:shipments[1]/s0:shipmentInfo[1]/s0:reference""/>
- </Reference>
- <TimeStamp>
- <xsl:value-of select=""DateTime:GetCurrentDateTime()"" />
- </TimeStamp>
- <Status>NEW</Status>
- <Date>
- <xsl:value-of select=""$currentDate"" />
- </Date>
- <FullTruckLoad>false</FullTruckLoad>
- <xsl:for-each select=""s0:shipments/s0:shipmentInfo"">
- <Shipment>
- <xsl:call-template name=""Shipment""/>
- </Shipment>
- </xsl:for-each>
- </ns0:Order>
- </xsl:template>
-
- <xsl:template name=""Shipment"">
-
- <Consignor>
- <xsl:value-of select=""$sender""/>
- </Consignor>
- <ConsignorReference>
- <xsl:value-of select=""s0:reference/text()""/>
- </ConsignorReference>
-
- <Debtor>
- <xsl:value-of select=""$sender""/>
- </Debtor>
-
- <DebtorReference>
- <xsl:value-of select=""s0:reference/text()""/>
- </DebtorReference>
-
- <Incoterm>
- <xsl:choose>
- <xsl:when test=""s0:incoterms/text() = 'DDU'"">
- <xsl:value-of select=""'DAP'""/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""s0:incoterms/text()""/>
- </xsl:otherwise>
- </xsl:choose>
- </Incoterm>
- <IncotermCity/>
- <IncotermCountryCode/>
-
- <COD>0</COD>
- <CODCurrency>EUR</CODCurrency>
-
- <xsl:call-template name=""Address_SF"">
- </xsl:call-template>
-
- <xsl:call-template name=""Address_ST"">
- </xsl:call-template>
-
- <xsl:for-each select=""s0:shipmentLines/s0:shipmentLine[generate-id() = generate-id(key('groepje', concat(generate-id(..), '|', s0:lineNo))[1])]"">
- <Good>
- <xsl:call-template name=""Good"">
- <xsl:with-param name=""reference"" select = ""REPLACE"" />
- </xsl:call-template>
- </Good>
- </xsl:for-each>
-
- <Parametergroup>
- <Qualifier>
- <xsl:text>Scenario</xsl:text>
- </Qualifier>
-
- <Parameter>
- <Qualifier>
- <xsl:text>Scenario</xsl:text>
- </Qualifier>
- <Value>
- <xsl:text>21</xsl:text>
- </Value>
- </Parameter>
- </Parametergroup>
- </xsl:template>
-
- <xsl:template name=""Address_SF"">
-
- <xsl:variable name=""collectionDate"" select=""concat(substring(s0:pickupDate/text(), 1, 4), '-', substring(s0:pickupDate/text(), 5, 2), '-', substring(s0:pickupDate/text(), 7, 2))""/>
- <xsl:variable name=""collectionTimeFrom"" select=""concat(substring(s0:pickupTime/text(), 1, 2), ':', substring(s0:pickupTime/text(), 3, 2), ':00')""/>
- <xsl:variable name=""collectionTimeUntill"" select=""concat(substring(s0:pickupTimeTo/text(), 1, 2), ':', substring(s0:pickupTimeTo/text(), 3, 2), ':00')""/>
-
- <xsl:variable name=""loadingDateTimeFrom"">
- <xsl:choose>
- <xsl:when test=""not($collectionDate = '00000000') and not(normalize-space($collectionDate)='') and string-length($collectionDate) = 10"">
- <xsl:choose>
- <xsl:when test=""not(normalize-space($collectionTimeFrom)='') and string-length($collectionTimeFrom) = 8"">
- <xsl:value-of select=""concat($collectionDate, 'T', $collectionTimeFrom)"" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($collectionDate, 'T07:00:00')"" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($currentDate, 'T07:00:00')""/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name=""loadingDateTimeTo"">
- <xsl:choose>
- <xsl:when test=""not($collectionDate = '00000000') and not(normalize-space($collectionDate)='') and string-length($collectionDate) = 10"">
- <xsl:choose>
- <xsl:when test=""not(normalize-space($collectionTimeUntill)='') and string-length($collectionTimeUntill) = 8"">
- <xsl:value-of select=""concat($collectionDate, 'T', $collectionTimeUntill)"" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($collectionDate, 'T16:00:00')"" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($currentDate, 'T16:00:00')""/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <Address>
- <xsl:call-template name=""Address"">
- <xsl:with-param name=""addressType"" select = ""'SF'"" />
- <xsl:with-param name=""name1"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:name"" />
- <xsl:with-param name=""name2"" select = ""''"" />
- <xsl:with-param name=""address1"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:street1"" />
- <xsl:with-param name=""address2"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:street2"" />
- <xsl:with-param name=""postalCode"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:zipCode"" />
- <xsl:with-param name=""city"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:city"" />
- <xsl:with-param name=""region"" select = ""s0:addresses/s0:address[s0:type = 'SEND' and s0:countryCode = 'IE']/s0:state"" />
- <xsl:with-param name=""countryCode"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:countryCode"" />
- <xsl:with-param name=""start"" select = ""$loadingDateTimeFrom"" />
- <xsl:with-param name=""end"" select = ""$loadingDateTimeTo"" />
- <xsl:with-param name=""reference"" select = ""s0:reference"" />
- <xsl:with-param name=""externalRemark1"" select = ""''"" />
- <xsl:with-param name=""externalRemark2"" select = ""''"" />
- <xsl:with-param name=""internalRemark1"" select = ""''"" />
- <xsl:with-param name=""internalRemark2"" select = ""''"" />
- </xsl:call-template>
- <xsl:call-template name=""ContactPerson"">
- <xsl:with-param name=""name"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:contact"" />
- <xsl:with-param name=""phone"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:telNo"" />
- <xsl:with-param name=""fax"" select = ""''"" />
- <xsl:with-param name=""email"" select = ""s0:addresses/s0:address[s0:type = 'SEND']/s0:email"" />
- </xsl:call-template>
- </Address>
- </xsl:template>
-
- <xsl:template name=""Address_ST"">
- <xsl:param name=""reference"" />
-
- <xsl:variable name=""deliveryDate"" select=""concat(substring(s0:requestedDeliveryDate/text(), 1, 4), '-', substring(s0:requestedDeliveryDate/text(), 5, 2), '-', substring(s0:requestedDeliveryDate/text(), 7, 2))""/>
- <xsl:variable name=""deliveryTimeFrom"" select=""concat(substring(s0:requestedDeliveryTime/text(), 1, 2), ':', substring(s0:requestedDeliveryTime/text(), 3, 2), ':00')""/>
- <xsl:variable name=""deliveryTimeUntill"" select=""concat(substring(s0:requestedDeliveryTimeTo/text(), 1, 2), ':', substring(s0:requestedDeliveryTimeTo/text(), 3, 2), ':00')""/>
-
- <xsl:variable name=""deliveryDateTimeFrom"">
- <xsl:choose>
- <xsl:when test=""not($deliveryDate = '00000000') and not(normalize-space($deliveryDate)='') and string-length($deliveryDate) = 10"">
- <xsl:choose>
- <xsl:when test=""not(normalize-space($deliveryTimeFrom)='') and string-length($deliveryTimeFrom) = 8"">
- <xsl:value-of select=""concat($deliveryDate, 'T', $deliveryTimeFrom)"" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($deliveryDate, 'T07:00:00')"" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($currentDate, 'T07:00:00')""/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name=""deliveryDateTimeTo"">
- <xsl:choose>
- <xsl:when test=""not($deliveryDate = '00000000') and not(normalize-space($deliveryDate)='') and string-length($deliveryDate) = 10"">
- <xsl:choose>
- <xsl:when test=""not(normalize-space($deliveryTimeUntill)='') and string-length($deliveryTimeUntill) = 8"">
- <xsl:value-of select=""concat($deliveryDate, 'T', $deliveryTimeUntill)"" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($deliveryDate, 'T16:00:00')"" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select=""concat($currentDate, 'T16:00:00')""/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <Address>
- <xsl:call-template name=""Address"">
- <xsl:with-param name=""addressType"" select = ""'ST'"" />
- <xsl:with-param name=""name1"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:name"" />
- <xsl:with-param name=""name2"" select = ""''"" />
- <xsl:with-param name=""address1"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:street1"" />
- <xsl:with-param name=""address2"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:street2"" />
- <xsl:with-param name=""postalCode"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:zipCode"" />
- <xsl:with-param name=""city"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:city"" />
- <xsl:with-param name=""region"" select = ""s0:addresses/s0:address[s0:type = 'RECV' and s0:countryCode = 'IE']/s0:state"" />
- <xsl:with-param name=""countryCode"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:countryCode"" />
- <xsl:with-param name=""start"" select = ""$deliveryDateTimeFrom"" />
- <xsl:with-param name=""end"" select = ""$deliveryDateTimeTo"" />
- <xsl:with-param name=""reference"" select = ""s0:reference"" />
- <xsl:with-param name=""externalRemark1"" select = ""''"" />
- <xsl:with-param name=""externalRemark2"" select = ""s0:instruction"" />
- <xsl:with-param name=""internalRemark1"" select = ""''"" />
- <xsl:with-param name=""internalRemark2"" select = ""''"" />
- </xsl:call-template>
- <xsl:call-template name=""ContactPerson"">
- <xsl:with-param name=""name"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:contact"" />
- <xsl:with-param name=""phone"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:telNo"" />
- <xsl:with-param name=""fax"" select = ""''"" />
- <xsl:with-param name=""email"" select = ""s0:addresses/s0:address[s0:type = 'RECV']/s0:email"" />
- </xsl:call-template>
- </Address>
- </xsl:template>
-
- <xsl:template name=""Address"">
- <xsl:param name=""addressType"" />
- <xsl:param name=""name1"" />
- <xsl:param name=""name2"" />
- <xsl:param name=""address1"" />
- <xsl:param name=""address2"" />
- <xsl:param name=""postalCode"" />
- <xsl:param name=""city"" />
- <xsl:param name=""region"" />
- <xsl:param name=""countryCode"" />
- <xsl:param name=""start"" />
- <xsl:param name=""end"" />
- <xsl:param name=""reference"" />
- <xsl:param name=""externalRemark1"" />
- <xsl:param name=""externalRemark2"" />
- <xsl:param name=""internalRemark1"" />
- <xsl:param name=""internalRemark2"" />
- <AddressType>
- <xsl:value-of select=""$addressType"" />
- </AddressType>
- <Name1>
- <xsl:value-of select=""$name1"" />
- </Name1>
- <Name2>
- <xsl:value-of select=""$name2"" />
- </Name2>
- <Address1>
- <xsl:value-of select=""$address1"" />
- </Address1>
- <Address2>
- <xsl:value-of select=""$address2"" />
- </Address2>
- <PostalCode>
- <xsl:value-of select=""$postalCode"" />
- </PostalCode>
- <City>
- <xsl:value-of select=""$city"" />
- </City>
- <Region>
- <xsl:value-of select=""$region"" />
- </Region>
- <CountryCode>
- <xsl:value-of select=""$countryCode"" />
- </CountryCode>
- <Start>
- <xsl:value-of select=""$start"" />
- </Start>
- <End>
- <xsl:value-of select=""$end"" />
- </End>
- <Reference>
- <xsl:value-of select=""$reference"" />
- </Reference>
- <ExternalRemark1>
- <xsl:value-of select=""$externalRemark1"" />
- </ExternalRemark1>
- <ExternalRemark2>
- <xsl:value-of select=""$externalRemark2"" />
- </ExternalRemark2>
- <InternalRemark1>
- <xsl:value-of select=""$internalRemark1"" />
- </InternalRemark1>
- <InternalRemark2>
- <xsl:value-of select=""$internalRemark2"" />
- </InternalRemark2>
- </xsl:template>
-
- <xsl:template name=""ContactPerson"">
- <xsl:param name=""name"" />
- <xsl:param name=""phone"" />
- <xsl:param name=""fax"" />
- <xsl:param name=""email"" />
- <ContactPerson>
- <Name>
- <xsl:value-of select=""$name"" />
- </Name>
- <Phone>
- <xsl:value-of select=""$phone"" />
- </Phone>
- <Fax>
- <xsl:value-of select=""$fax"" />
- </Fax>
- <Email>
- <xsl:value-of select=""$email"" />
- </Email>
- </ContactPerson>
- </xsl:template>
-
- <xsl:template name=""Good"">
- <xsl:param name=""reference"" />
-
- <xsl:variable name=""currentLineNo"" select=""s0:lineNo"" />
- <xsl:variable name=""quantity"" select=""sum(../s0:shipmentLine[s0:lineNo = $currentLineNo]/s0:quantity)""/>
-
- <PackingQty>
- <xsl:value-of select=""$quantity""/>
- </PackingQty>
- <PackingType>
- <xsl:value-of select=""s0:packageType""/>
- </PackingType>
-
- <PackageQty>0</PackageQty>
- <xsl:variable name=""DbLookupPackageCode"" select=""ScriptNS0:DBLookup(2 ,s0:packageType , connectionString , 'TM_TransSmart_Package' , 'TransSmart')"" />
- <xsl:variable name=""PackageType"" select=""ScriptNS0:DBValueExtract($DbLookupPackageCode , 'KLG')"" />
- <PackageType>
- <xsl:value-of select=""$PackageType""/>
- </PackageType>
-
- <ProductDescription>
- <xsl:value-of select=""s0:description/text()""/>
- </ProductDescription>
-
- <Brand>
- </Brand>
-
- <BrutoWeight>
- <xsl:value-of select=""round(sum(s0:measurements/s0:weight/text()))""/>
- </BrutoWeight>
- <NettoWeight>
- <xsl:value-of select=""round(sum(s0:measurements/s0:weight/text()))""/>
- </NettoWeight>
-
- <LoadingMeter>
- <xsl:value-of select=""format-number(((((round(sum(s0:measurements/s0:length/text())) * round(sum(s0:measurements/s0:width/text()))) div 24000) * $quantity) * 100) div 100,'##0.00' )""/>
- </LoadingMeter>
-
- <Volume>
- <xsl:value-of select=""((round(sum(s0:measurements/s0:length/text())) * round(sum(s0:measurements/s0:width/text())) * round(sum(s0:measurements/s0:height/text()))) * $quantity) div 1000000""/>
- </Volume>
- <PalletPlaces>
- <xsl:text>0</xsl:text>
- </PalletPlaces>
-
- <PackingLength>
- <xsl:value-of select=""round(sum(s0:measurements/s0:length/text()))""/>
- </PackingLength>
- <PackingWidth>
- <xsl:value-of select=""round(sum(s0:measurements/s0:width/text()))""/>
- </PackingWidth>
- <PackingHeight>
- <xsl:value-of select=""round(sum(s0:measurements/s0:height/text()))""/>
- </PackingHeight>
-
- <GoodsValue>
- <xsl:text>0</xsl:text>
- </GoodsValue>
- <GoodsValueCurrency>
- <xsl:text>EUR</xsl:text>
- </GoodsValueCurrency>
- </xsl:template>
-
- <!-- end region -->
-
- <xsl:variable name=""dbClose"" select=""ScriptNS0:DBLookupShutdown()""/>
-
- </xsl:stylesheet>
- ";
-
- private const string _strArgList = @"<ExtensionObjects>
- <ExtensionObject Namespace=""http://schemas.microsoft.com/BizTalk/2003/ScriptNS0""
- AssemblyName=""Microsoft.BizTalk.BaseFunctoids, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35""
- ClassName=""Microsoft.BizTalk.BaseFunctoids.FunctoidScripts"" />
- <ExtensionObject Namespace=""http://schemas.microsoft.com/BizTalk/2003/ScriptNS1""
- AssemblyName=""Microsoft.BizTalk.CrossReferencing, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35""
- ClassName=""Microsoft.BizTalk.CrossReferencing.CrossReferencing"" />
- <ExtensionObject Namespace=""TM.Shared.Components.DateTime""
- AssemblyName=""TM.Shared.Components, Version=1.0.7.0, Culture=neutral, PublicKeyToken=9cbf569b151cb1d4""
- ClassName=""TM.Shared.Components.DateTimeFunctions"" />
- <ExtensionObject Namespace=""TM.Shared.Components.KeyList""
- AssemblyName=""TM.Shared.Components, Version=1.0.7.0, Culture=neutral, PublicKeyToken=9cbf569b151cb1d4""
- ClassName=""TM.Shared.Components.KeyListFunctions"" />
- <ExtensionObject Namespace=""TM.Shared.Components.SSO""
- AssemblyName=""TM.Shared.Components, Version=1.0.7.0, Culture=neutral, PublicKeyToken=9cbf569b151cb1d4""
- ClassName=""TM.Shared.Components.SSOFunctions"" />
- <ExtensionObject Namespace=""TM.Shared.Components.String""
- AssemblyName=""TM.Shared.Components, Version=1.0.7.0, Culture=neutral, PublicKeyToken=9cbf569b151cb1d4""
- ClassName=""TM.Shared.Components.StringFunctions"" />
- </ExtensionObjects>";
-
- private const string _strSrcSchemasList0 = @"TM.EDIBroker.TransSmart.Schemas.Shipment";
-
- private const global::TM.EDIBroker.TransSmart.Schemas.Shipment _srcSchemaTypeReference0 = null;
-
- private const string _strTrgSchemasList0 = @"TM.Shared.Schemas.Order";
-
- private const global::TM.Shared.Schemas.Order _trgSchemaTypeReference0 = null;
-
- public override string XmlContent {
- get {
- return _strMap;
- }
- }
-
- public override string XsltArgumentListContent {
- get {
- return _strArgList;
- }
- }
-
- public override string[] SourceSchemas {
- get {
- string[] _SrcSchemas = new string [1];
- _SrcSchemas[0] = @"TM.EDIBroker.TransSmart.Schemas.Shipment";
- return _SrcSchemas;
- }
- }
-
- public override string[] TargetSchemas {
- get {
- string[] _TrgSchemas = new string [1];
- _TrgSchemas[0] = @"TM.Shared.Schemas.Order";
- return _TrgSchemas;
- }
- }
- }
- }
|