Skip to content

Commit e50fec6

Browse files
authored
Merge pull request timabell#24 from jlrodriguesPrimeIt/master
changes for version 2017
2 parents 34a5e77 + 22e80ed commit e50fec6

5 files changed

Lines changed: 66 additions & 41 deletions

File tree

.vs/ProjectSettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"CurrentProjectSetting": null
3+
}

.vs/slnx.sqlite

84 KB
Binary file not shown.

ssrs-powershell-deploy/SSRS/Get-SSRSProjectConfiguration.ps1

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,42 @@
2121

2222
[xml]$Project = Get-Content -Path $Path
2323

24-
$Config = $Project.SelectNodes('Project/Configurations/Configuration') |
25-
Where-Object { $_.Name -eq $Configuration } |
26-
Select-Object -First 1
24+
$propertyGroupCount = $Project.Project.PropertyGroup.Count
25+
26+
for($i = 0; $i -lt $propertyGroupCount; $i++)
27+
{
28+
if($Project.Project.PropertyGroup[$i].FullPath -eq $Configuration)
29+
{
30+
$Config = $Project.Project.PropertyGroup[$i]
31+
break
32+
}
33+
}
34+
35+
#$Config = $Project.SelectNodes('Project/PropertyGroup') |
36+
# Where-Object { $_.FullPath -eq $Configuration } |
37+
# Select-Object -First 1
2738
if (-not $Config) {
28-
throw "Could not find configuration $Configuration."
39+
throw "Could not find configuration '$Configuration'."
2940
}
3041

3142

3243
$OverwriteDataSources = $false
33-
if ($Config.Options.SelectSingleNode('OverwriteDataSources')) {
34-
$OverwriteDataSources = [Convert]::ToBoolean($Config.Options.OverwriteDataSources)
44+
if ($Config.SelectSingleNode('OverwriteDataSources')) {
45+
$OverwriteDataSources = [Convert]::ToBoolean($Config.OverwriteDataSources)
3546
}
3647

3748
$OverwriteDatasets = $false
38-
if ($Config.Options.SelectSingleNode('OverwriteDatasets')) {
39-
$OverwriteDatasets = [Convert]::ToBoolean($Config.Options.OverwriteDatasets)
49+
if ($Config.SelectSingleNode('OverwriteDatasets')) {
50+
$OverwriteDatasets = [Convert]::ToBoolean($Config.OverwriteDatasets)
4051
}
4152

4253

4354
return New-Object -TypeName PSObject -Property @{
44-
ServerUrl = $Config.Options.TargetServerUrl
45-
Folder = Normalize-SSRSFolder -Folder $Config.Options.TargetFolder
46-
DataSourceFolder = Normalize-SSRSFolder -Folder $Config.Options.TargetDataSourceFolder
47-
DataSetFolder = Normalize-SSRSFolder -Folder $Config.Options.TargetDataSetFolder
48-
OutputPath = $Config.Options.OutputPath
55+
ServerUrl = $Config.TargetServerUrl
56+
Folder = Normalize-SSRSFolder -Folder $Config.TargetReportFolder
57+
DataSourceFolder = Normalize-SSRSFolder -Folder $Config.TargetDataSourceFolder
58+
DataSetFolder = Normalize-SSRSFolder -Folder $Config.TargetDataSetFolder
59+
OutputPath = $Config.OutputPath
4960
OverwriteDataSources = $OverwriteDataSources
5061
OverwriteDatasets = $OverwriteDatasets
5162
}

ssrs-powershell-deploy/SSRS/New-SSRSReport.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function New-SSRSReport (
22
$Proxy,
3-
[string]$RdlPath
3+
[string]$RdlPath,
4+
$RdlName
45
)
56
{
67
$script:ErrorActionPreference = 'Stop'
@@ -10,7 +11,7 @@ function New-SSRSReport (
1011

1112
$RawDefinition = Get-Content -Encoding Byte -Path $RdlPath
1213

13-
$Name = $_.Name -replace '\.rdl$',''
14+
$Name = $RdlName -replace '\.rdl$',''
1415

1516
$DescProp = New-Object -TypeName SSRS.ReportingService2010.Property
1617
$DescProp.Name = 'Description'

ssrs-powershell-deploy/SSRS/Publish-SSRSProject.ps1

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@
140140
New-SSRSFolder -Proxy $Proxy -Name $DataSetFolder
141141

142142
$DataSourcePaths = @{}
143-
$Project.SelectNodes('Project/DataSources/ProjectItem') |
144-
ForEach-Object {
145-
$RdsPath = $ProjectRoot | Join-Path -ChildPath $_.FullPath
143+
for($i = 0; $i -lt $Project.Project.ItemGroup[0].DataSource.Count; $i++) {
144+
$RdsPath = $ProjectRoot | Join-Path -ChildPath $Project.Project.ItemGroup[0].DataSource[$i].Include
146145

147-
$DataSource = New-SSRSDataSource -Proxy $Proxy -RdsPath $RdsPath -Folder $DataSourceFolder -Overwrite $OverwriteDataSources
148-
$DataSourcePaths.Add($DataSource.Name, $DataSource.Path)
149-
}
146+
$DataSource = New-SSRSDataSource -Proxy $Proxy -RdsPath $RdsPath -Folder $DataSourceFolder -Overwrite $OverwriteDataSources
147+
$DataSourcePaths.Add($DataSource.Name, $DataSource.Path)
148+
}
150149

151150
$DataSetPaths = @{}
152151
$Project.SelectNodes('Project/DataSets/ProjectItem') |
@@ -159,13 +158,14 @@
159158
}
160159
}
161160

162-
$Project.SelectNodes('Project/Reports/ResourceProjectItem') |
163-
ForEach-Object {
164-
if($_.MimeType.StartsWith('image/'))
165-
{
161+
for($i = 0; $i -lt $Project.Project.ItemGroup[1].Report.Count; $i++) {
166162

167-
$Path = $ProjectRoot | Join-Path -ChildPath $_.FullPath
168-
$RawDefinition = Get-Content -Encoding Byte -Path $Path
163+
$extension = $Project.Project.ItemGroup[1].Report[$i].Include.Substring($Project.Project.ItemGroup[1].Report[$i].Include.length - 3 , 3)
164+
165+
if(ImageExtensionValid -ext $extension){
166+
167+
$PathImage = $ProjectRoot | Join-Path -ChildPath $Project.Project.ItemGroup[1].Report[$i].Include
168+
$RawDefinition = Get-Content -Encoding Byte -Path $PathImage
169169

170170
$DescProp = New-Object -TypeName SSRS.ReportingService2010.Property
171171
$DescProp.Name = 'Description'
@@ -175,27 +175,37 @@
175175
$HiddenProp.Value = 'false'
176176
$MimeProp = New-Object -TypeName SSRS.ReportingService2010.Property
177177
$MimeProp.Name = 'MimeType'
178-
$MimeProp.Value = $_.MimeType
178+
$MimeProp.Value = 'image/' + $extension
179179

180180
$Properties = @($DescProp, $HiddenProp, $MimeProp)
181181

182-
if($_.FullPath.StartsWith('_'))
183-
{
184-
$HiddenProp.Value = 'true'
185-
}
186-
187-
$Name = $_.FullPath
182+
$Name = $Project.Project.ItemGroup[1].Report[$i].Include
188183
Write-Verbose "Creating resource $Name"
189184
$warnings = $null
190-
$Results = $Proxy.CreateCatalogItem("Resource", $_.FullPath, $Folder, $true, $RawDefinition, $Properties, [ref]$warnings)
185+
$Results = $Proxy.CreateCatalogItem("Resource", $Project.Project.ItemGroup[1].Report[$i].Include, $Folder, $true, $RawDefinition, $Properties, [ref]$warnings)
191186
}
192187
}
193188

194-
$Project.SelectNodes('Project/Reports/ProjectItem') |
195-
ForEach-Object {
196-
$CompiledRdlPath = $ProjectRoot | Join-Path -ChildPath $OutputPath | join-path -ChildPath $_.FullPath
197-
New-SSRSReport -Proxy $Proxy -RdlPath $CompiledRdlPath
198-
}
189+
for($i = 0; $i -lt $Project.Project.ItemGroup[1].Report.Count; $i++) {
190+
if($Project.Project.ItemGroup[1].Report[$i].Include.EndsWith('.rdl')){
191+
$CompiledRdlPath = $ProjectRoot | Join-Path -ChildPath $OutputPath | join-path -ChildPath $Project.Project.ItemGroup[1].Report[$i].Include
192+
New-SSRSReport -Proxy $Proxy -RdlPath $CompiledRdlPath -RdlName $Project.Project.ItemGroup[1].Report[$i].Include
193+
}
194+
}
195+
196+
Write-host "Completed."
197+
}
198+
199+
function ImageExtensionValid($ext){
200+
$valid = 0;
201+
202+
Switch($ext)
203+
{
204+
'png' { $valid = 1; }
205+
'bmp' { $valid = 1; }
206+
'gif' { $valid = 1; }
207+
'jpg' { $valid = 1; }
208+
}
199209

200-
Write-Verbose "Completed."
210+
return $valid;
201211
}

0 commit comments

Comments
 (0)