November 26, 2012 at 8:32 am
Hello,
I am trying to upgrade an SSIS package to 2008. The package includes a Script task editor with the following code:
---------------------------------------
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports java.util.zip
Imports java.io
<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
Public Sub Main()
Try
Dim strSourceFile As String
Dim strDestinationDirectory As String
strSourceFile = "C:\Visio2020Upload\" & Dts.Variables("file").Value.ToString()
strDestinationDirectory = "C:\Visio2020Upload\"
Dim oFileInputStream As New java.io.FileInputStream(strSourceFile)
Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
Dim bTrue As Boolean = True
Dim sbBuf(1024) As SByte
While 1 = 1
Dim oZipEntry As ZipEntry = oZipInputStream.getNextEntry()
If oZipEntry Is Nothing Then Exit While
If oZipEntry.isDirectory Then
If Not My.Computer.FileSystem.DirectoryExists(strDestinationDirectory & oZipEntry.getName) Then
My.Computer.FileSystem.CreateDirectory(strDestinationDirectory & oZipEntry.getName)
End If
Else
Dim oFileOutputStream As New java.io.FileOutputStream(strDestinationDirectory.Replace("\", "/") & oZipEntry.getName())
While 1 = 1
Dim iLen As Integer = oZipInputStream.read(sbBuf)
If iLen < 0 Then Exit While
oFileOutputStream.write(sbBuf, 0, iLen)
End While
oFileOutputStream.close()
End If
End While
oZipInputStream.close()
oFileInputStream.close()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
End Class
---------------------------------------
I get the following errors when I try to build the code:
Type 'ZipEntry' is not defined.
Type 'java.util.zip.ZipInputStream' is not defined.
Type 'java.io.FileInputStream' is not defined.
Type 'java.io.FileOutputStream' is not defined.
Does someone know if there is a substitute I can use for java.util.zip and java.io ?
Thanks,
Paul
November 26, 2012 at 8:48 am
those two dll's, java.util.zip.dll? and java.io.dll? need to be in the same folder as the script you are calling.
they probably are not,and i'm not sure how to insert them into the global assembly cache so you don't need them locally.
Lowell
November 27, 2012 at 2:22 am
Lowell (11/26/2012)
those two dll's, java.util.zip.dll? and java.io.dll? need to be in the same folder as the script you are calling.they probably are not,and i'm not sure how to insert them into the global assembly cache so you don't need them locally.
Thanks for your reply. I was wondering if you knew how to replace java.io with System.IO and and java.util.zip with ??? (another System function) and then inherit their functionality below in the code ?
in other words:
how can I replace 'Imports java.io' with System.IO and 'Imports java.util.zip' with some other applicable System.??? and then inherit their functionality by replacing the codes below with appropriate System.??? versions :
Dim oFileInputStream As New java.io.FileInputStream(strSourceFile)
Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
Dim oZipEntry As ZipEntry = oZipInputStream.getNextEntry()
Dim oFileOutputStream As New java.io.FileOutputStream(strDestinationDirectory.Replace("\", "/") & oZipEntry.getName())
I do not use and write VB scripts so I am not sure if I am able to explain my situation clearly.
Thanks,
Paul
November 28, 2012 at 6:27 am
I've found that sometimes as well as declaring Imports system.IO (or whichever I need), I have to actually add a reference to it. Open up the script in the editor then use Project, Add Reference and find the appropriate one in the lists and add it.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply