Torna al Thread
Imports CrystalDecisions.CrystalReports.Engine, _
CrystalDecisions.Shared, _
com.XXX.dotnet.crr.util.MCRUtil, _
com.XXX.dotnet.crr.util.MCRRUtil
Module Module1
Sub Main()
Dim i As Integer
Dim arg As String
Dim tbname As String
Dim rptname As String
Dim kv() As String
Dim reportdoc As ReportDocument
rptname = Nothing
For Each arg In My.Application.CommandLineArgs
If arg.StartsWith("-rpt:") Then
rptname = GetKeyValue(arg, ":")(1)
End If
Next
If rptname Is Nothing OrElse rptname <> "" Then
rptname = My.Application.Info.DirectoryPath & "\Report1.doc"
If Not My.Computer.FileSystem.FileExists(rptname) Then
rptname = Nothing
End If
End If
If rptname Is Nothing Then
rptname = My.MySettings.Default.rptname
End If
reportdoc = Nothing
Try
reportdoc = New ReportDocument()
Console.WriteLine("Elenco tabelle in " & "(" & rptname & ")")
reportdoc.Load(rptname, OpenReportMethod.OpenReportByDefault)
For i = 0 To reportdoc.ReportClientDocument.DatabaseController.Database.Tables.Count - 1
tbname = reportdoc.ReportClientDocument.DatabaseController.Database.Tables.Item(i).QualifiedName
Console.WriteLine("Table(" & CStr(i) & "): " & tbname)
kv = GetKeyValue(tbname, ".")
If kv(0) = "SCHEMA_DA_SOSTITUIRE" Then
kv(0) = "NUOVO_SCHEMA"
tbname = kv(0) & "." & kv(1)
reportdoc.ReportClientDocument.DatabaseController.Database.Tables.Item(i).QualifiedName = tbname
rptname &= ".new.rpt"
reportdoc.SaveAs(rptname, False)
End If
Next
If rptname.EndsWith(".new.rpt") Then
'ExeLauncher(My.Application.Info.DirectoryPath & "\" & My.Application.Info.AssemblyName & ".exe", "-rpt:" & rptname, True)
End If
Catch ex As Exception
Console.WriteLine(ex.Message & vbCrLf & ex.StackTrace)
Finally
If Not reportdoc Is Nothing Then
reportdoc.Close()
End If
Console.ReadKey()
End Try
End Sub
End Module