@@ -75,7 +75,7 @@ Private policies As Policy() = Nothing
7575Private srcSiteUrl As String = Nothing
7676Private snkSiteUrl As String = Nothing
7777
78- Private logFilePath As String = "MigrationLog.txt "
78+ Private logFilePath As String = "MigrationLog.csv "
7979
8080''''''''''''''''''''''''''''''''''''''''''''''
8181Sub Main()
@@ -241,8 +241,8 @@ Sub Main()
241241 RsSnk.CreateFolder(folderName, parentFolder, Nothing)
242242 Catch er As Exception
243243 If (er.Message.Contains("Microsoft.ReportingServices.Diagnostics.Utilities.ItemAlreadyExistsException"))
244- Console.ForegroundColor = ConsoleColor.Yellow
245- Console.WriteLine("Folder already exists." )
244+ Console.ForegroundColor = ConsoleColor.Gray
245+ Console.WriteLine("Folder already exists: " + folderName )
246246 Console.ResetColor()
247247 Else
248248 Throw ' Unknown Exception
@@ -478,7 +478,7 @@ Function MigrateDataSource(srcItem As CatalogItem) As CatalogItem
478478 Console.WriteLine(warningMsg)
479479 Console.ResetColor()
480480
481- LogErrorToFile("CATALOGITEM", "Warning" , warningMsg)
481+ LogErrorToFile("CATALOGITEM", "Warning: " + result.Path , warningMsg)
482482
483483 End If
484484
@@ -567,7 +567,7 @@ Function MigrateCatalogItem(srcItem As CatalogItem) As CatalogItem
567567 Console.WriteLine(warningMsg)
568568 Console.ResetColor()
569569
570- LogErrorToFile("CATALOGITEM", "Warning" , warningMsg)
570+ LogErrorToFile("CATALOGITEM", "Warning: " + result.TypeName , warningMsg)
571571 End If
572572 End If
573573 Next
@@ -742,7 +742,7 @@ Sub MigrateReportSubscriptions(snkReport As CatalogItem, srcReport As CatalogIte
742742 Console.Write(description)
743743 If Not dataRetrievalPlan Is Nothing And TypeOf dataRetrievalPlan.Item Is DataSourceReference Then
744744 Dim item As DataSourceReference = dataRetrievalPlan.Item
745- Dim ref As String = GetSnkPath (item.Reference)
745+ Dim ref As String = GetSnkPathRef (item.Reference)
746746 item.Reference = ref
747747 End If
748748 RsSnk.CreateDataDrivenSubscription(snkReport.Path, extensionSettings, dataRetrievalPlan, description, eventType, GetMatchData(matchData, RsSnk), parameters)
@@ -756,7 +756,7 @@ Sub MigrateReportSubscriptions(snkReport As CatalogItem, srcReport As CatalogIte
756756 Console.WriteLine(warningMsg)
757757 Console.ResetColor()
758758
759- LogErrorToFile("SUBSCRIPTIONS", "Warning" , warningMsg)
759+ LogErrorToFile("SUBSCRIPTIONS", "Warning: " + snkReport.Path , warningMsg)
760760
761761 End If
762762 End If
@@ -795,9 +795,9 @@ Sub MigrateReportSubscriptions(snkReport As CatalogItem, srcReport As CatalogIte
795795 Console.WriteLine(warningMsg)
796796 Console.ResetColor()
797797
798- LogErrorToFile("SUBSCRIPTIONS", "Warning" , warningMsg)
798+ LogErrorToFile("SUBSCRIPTIONS", "Warning: " + snkReport.Path , warningMsg)
799799
800- End If
800+ End If
801801 Next
802802
803803 Catch ex As Exception
@@ -990,10 +990,19 @@ End Sub
990990
991991'Helper function to link snk reference with relative paths
992992Function GetSnkPathRef(srcPath As String) As String
993- Dim snkPath = srcPath
994- If srcSiteUrl isNot Nothing
995- snkPath = srcPath.Remove(0, srcSiteUrl.LastIndexOf("/"))
996- End If
993+ Dim snkPath = srcPath
994+
995+ If Not SrcIsNative Then
996+ 'SharePoint integrated mode, will assume /sites server relative URL delimeter
997+ If srcSiteUrl isNot Nothing
998+ Dim delimeter = "/sites/"
999+ snkPath = srcPath.Remove(0, srcSiteUrl.IndexOf(delimeter) + delimeter.Length-1)
1000+ End If
1001+ Else
1002+ 'Treat path reference like other scenarios if not intergated mode
1003+ snkPath = GetSnkPath(srcPath)
1004+ End If
1005+
9971006 Return snkPath
9981007End Function
9991008
@@ -1189,12 +1198,18 @@ Sub LogErrorToFile(source As String, errItem as String, message As String)
11891198 Dim writer as StreamWriter
11901199
11911200 Try
1201+ Dim fileExists As Boolean = Not File.Exists(logFilePath) OrElse New FileInfo(logFilePath).Length = 0
1202+
11921203 ' Create a StreamWriter object
11931204 writer = New StreamWriter(logFilePath, True)
11941205
1206+ If fileExists Then
1207+ writer.WriteLine("DateTime, Source, ErrorItem, ErrorMessage")
1208+ End If
1209+
11951210 ' Format log message with timestamp
11961211 Dim timeStamp As String = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
1197- Dim formattedMessage as String = String.Format("{0}, {1}, {2}, ""{3}""", timeStamp, source, errItem, message.Replace(Environment.NewLine, ""))
1212+ Dim formattedMessage as String = String.Format("{0}, {1}, {2}, ""{3}""", timeStamp, source, errItem, message.Replace(Environment.NewLine, " "))
11981213
11991214 ' Write the log entry to file
12001215 writer.WriteLine(formattedMessage)
0 commit comments