Public/Sync-DTXCal.ps1
Function Sync-DTXCal { [CmdletBinding()] param( # # Parameter help description # [Parameter()] # [int] # $ProjectCode, # # Parameter help description # [Parameter()] # [Int] # $Month = [DateTime]::now.Month, # Parameter help description [Parameter(Mandatory)] [PSCustomObject[]] $CalEntry ) $Payloads = @{} # $CalEntry | % { Write-Verbose "Found $($PSItem.Month)" } Foreach($Entry in $CalEntry){ # $Entry.Month if(-not $Payloads[$Entry.Month]){ $Payloads.($Entry.Month) = @{} } if(-not $Payloads.($Entry.Month).($Entry.ProjectCode)){ $Payloads.($Entry.Month).($Entry.ProjectCode) = @{} } if(-not $Payloads.($Entry.Month).($Entry.ProjectCode).($Entry.ProjectTask)){ $Payloads.($Entry.Month).($Entry.ProjectCode).($Entry.ProjectTask)= @() } $Payloads.($Entry.Month).($Entry.ProjectCode).($Entry.ProjectTask) += "day$($Entry.Day)=$($Entry.AllocatedTime)" } foreach($Payload in $Payloads){ #Month level foreach($month in $Payload.keys){ foreach($Project in $Payload.$month.keys){ foreach($Task in $Payload.$month.$Project.keys){ Write-Verbose "New Entry: $month/$Project/$($Task)" $null = New-DTXEntry -ProjectCode $Project -Month $month -DayEntry $Payload.$month.$Project.$Task -ProjectTask $Task } } } } } |