Skip to content

Commit be61bee

Browse files
authored
Update ssrs_migration.rss with more robust features
Added function to create folder if target does not contain folder. Added helper function to use relative path for linking data source which is helpful in scenarios where data source does not live in the same directory as report file.
1 parent 9dc07a7 commit be61bee

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

samples/features/reporting-services/ssrs-migration-rss/ssrs_migration.rss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,16 @@ Sub Main()
223223

224224
Console.ReadLine()
225225

226-
226+
' Create destination folder if not present
227+
Try
228+
RsSnk.CreateFolder(SnkFolder.Substring(1), "/", Nothing)
229+
Catch ex As Exception
230+
If (ex.Message.Contains("Microsoft.ReportingServices.Diagnostics.Utilities.ItemAlreadyExistsException"))
231+
Console.WriteLine("Folder already exists.")
232+
Else
233+
Console.WriteLine(ex.Message + Environment.NewLine)
234+
End If
235+
End Try
227236

228237
Try
229238
'Roles & Policies
@@ -604,7 +613,7 @@ Sub RelinkItemReferences(snkItem As CatalogItem, srcItem As CatalogItem)
604613
Dim type As String = RsSrc.GetItemType(srcRef.Reference)
605614
Dim snkRef As ItemReference = New ItemReference
606615
snkRef.Name = srcRef.Name
607-
snkRef.Reference = GetSnkFilename(GetSnkPath(srcRef.Reference), type)
616+
snkRef.Reference = GetSnkFilename(GetSnkPathRef(srcRef.Reference), type)
608617

609618
snkReferences.Add(snkRef)
610619
Next
@@ -923,6 +932,12 @@ End Sub
923932
'''''''''''''' Helper Functions '''''''''''''''''''''''
924933
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
925934

935+
'Helper function to link snk reference with relative paths
936+
Function GetSnkPathRef(srcPath As String) As String
937+
Dim snkPath = srcPath.Remove(0, srcSiteUrl.LastIndexOf("/"))
938+
Return snkPath
939+
End Function
940+
926941
'Helper function to construct correctly formatted path
927942
Function GetSnkPath(srcPath As String) As String
928943
If Not SrcIsNative Then

0 commit comments

Comments
 (0)