This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region ServiceBase | |
protected override void OnStart(string[] args) | |
{ | |
base.OnStart(args); | |
_MicrosInterface = new MicrosInterface(MicrosMessageHandler, Properties.Settings.Default.ListenPort, Properties.Settings.Default.InterfaceMessageExpected); | |
_MicrosInterface.Start(); | |
} | |
protected override void OnStop() | |
{ | |
base.OnStop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import dw::core::Numbers | |
import dw::core::Strings | |
fun AND(lo: Number, ro: Number) = do { | |
var binary = getBinary(lo, ro) | |
--- | |
Numbers::fromBinary(binary.left map ($ as Number * binary.right[$$] as Number) reduce ($$++$)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import Bitwise | |
fun powerSet(set: Array) = do { | |
var iterable = (0 to pow(2,sizeOf(set))-1) as Array | |
--- | |
iterable map (item) -> set filter (Bitwise::AND(item,pow(2,$$)) != 0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
fun appendNamespace(data, nsSelector: (k: Key) -> Namespace | Null) = | |
data match { | |
case is Array -> data map appendNamespace($, nsSelector) | |
case is Object -> data mapObject do { | |
var ns0 = nsSelector($$) | |
--- | |
if (ns0 != null) ns0#"$($$)": appendNamespace($, nsSelector) | |
else ($$): appendNamespace($, nsSelector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<servers> | |
<server> | |
<id>anypoint-exchange-v2</id> | |
<username>USERNAME</username> | |
<password>PASSWORD</password> | |
</server> | |
<server> | |
<id>MuleRepository</id> | |
<username>USERNAME</username> | |
<password>PASSWORD</password> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
fun hlLoop(payload: Object) = | |
((payload.DeliveryItems distinctBy $.PurchaseOrder).PurchaseOrder reduce ((order, accum=hlLoopRoot(payload)) -> | |
payload.DeliveryItems distinctBy $.ProductId reduce ((item, accum=hlLoopPurchaseOrder(order, accum)) -> | |
(payload.DeliveryItems filter ($.ProductId == item.ProductId and $.ProductBatchNumber != null)) reduce ((package, accum=hlLoopItem(item, accum)) -> | |
hlLoopPackage(package, accum) | |
) | |
) | |
)).items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::edi::hlLoop | |
output application/json | |
--- | |
{ | |
"Delimiters": "|>U\n", | |
TransactionSets: { | |
v004010: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
fun getEdges(left: Array, right: Array, isEdgeFn: (l: Object, r: Object) -> Boolean) = | |
left reduce ((leftItem, mAccum = { li: 0, edges: [] }) -> | |
(right reduce ((rightItem, iAccum = { li: mAccum.li, ri: 0, edges: mAccum.edges }) -> | |
{ | |
li: iAccum.li, | |
ri: iAccum.ri + 1, | |
edges: iAccum.edges ++ [([iAccum.li, iAccum.ri]) if (isEdgeFn(leftItem, rightItem))] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
import * from dw::util::Values | |
var INF = pow(2, 28) //infinity constant | |
var ARR = (size, value) -> ((0 to size-1) as Array) map value //make it a bit easier to initialize an array | |
//function for while looping | |
var while = (conditionFn: (s: Any) -> Boolean, whileFn: (s: Any) -> Any, state = {}) -> | |
if (conditionFn(state)) while(conditionFn, whileFn, whileFn(state)) | |
else state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dw 2.0 | |
fun splice(arr: Array, index: Number) = | |
if (index == 0) arr[1 to -1] | |
else (arr[0 to index-1] default []) ++ (arr[index+1 to -1] default []) | |
fun shuffle(arr: Array) = | |
(((0 to sizeOf(arr)-1) as Array) reduce (i, s = {res:[], items: arr}) -> do { | |
var ri = floor(random() * sizeOf(s.items)) | |
--- |
OlderNewer