modules/FeedProcessor/AuditLog/Outcome.psm1
using module '..\..\Enums.psm1' using module '..\..\Helper\ObjectHelper.psm1' using module '..\..\Helper\DateTimeHelper.psm1' class Outcome { [string] $id [string] $externalId [string] $name [string] $action [string] $status [string] $price [string] $resulted [string] $settlement [hashtable] $specifiers [hashtable] $other Outcome() { $this.other = @{} } Outcome([string] $id, [string] $externalId, [string] $name, [string] $action, [string] $status, ` [string] $type, [hashtable] $specifiers, [string] $price, [string] $resulted, [string] $settlement) { $this.Outcome() $this.id = $id $this.externalId = $externalId $this.name = $name $this.action = $action $this.status = $status $this.type = $type $this.specifiers = $specifiers $this.price = $price $this.resulted = $resulted $this.settlement = $settlement } [void] Aggregate([OUtcome] $o){ if ($null -ne $o) { if (-not $this.action) { $this.action = $o.action } if (-not $this.status) { $this.status = $o.status } if (-not $this.price) { $this.price = $o.price } if (-not $this.resulted) { $this.resulted = $o.resulted } if (-not $this.settlement) { $this.settlement = $o.settlement } $this.other = [ObjectHelper]::MergeHashtables($this.other, $o.other) } } [bool] Equal([Outcome] $outcome){ if (-not $outcome) { return $false } $retValue = ($this.id -eq $outcome.id -and $this.status -eq $outcome.status -and ` $this.price -eq $outcome.price -and -$this.resulted -eq $outcome.resulted -and ` $this.settlement -eq $outcome.settlement) return $retValue } [string] ToString(){ [string] $retValue = '' $_status = $this.status $_settlement = $this.settlement if ($_status) { $_status = $this.status.Substring(0,1) } if ($_settlement) { $_settlement = $this.settlement.Substring(0,1) } if ($this.resulted -or $this.settlement){ $retValue = ('{0} ({1}/{2})' -f @($this.price, $_status, $_settlement)) } else { $retValue = ('{0} ({1})' -f @($this.price, $_status)) } return $retValue } [Outcome] Copy(){ $outcome = [Outcome]::new() $outcome.id = $this.id $outcome.externalId = $this.externalId $outcome.name = $this.name $outcome.action = $this.action $outcome.status = $this.status $outcome.price = $this.price $outcome.resulted = $this.resulted $outcome.settlement = $this.settlement $outcome.specifiers = $this.specifiers $outcome.other = $this.other return $outcome } [PSCustomObject] displayInfo(){ $info = @{} if ($this.externalId) { $info.Add('external', $this.externalId) } if ($this.resulted) { $info.Add('resulted', $this.resulted) } if ($this.settlement) { $info.Add('settlement', $this.settlement) } return [ObjectHelper]::ConvertToObject($info) } [PSCustomObject] displayOrigin([PSCustomObject] $messageOther){ return ([ObjectHelper]::ConvertToObject($this.other)) } } |