|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 9:18 AM
Points: 451,
Visits: 1,424
|
|
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
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 11:58 AM
Points: 11,605,
Visits: 27,644
|
|
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
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 9:18 AM
Points: 451,
Visits: 1,424
|
|
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
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Yesterday @ 1:58 AM
Points: 513,
Visits: 1,014
|
|
| 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.
|
|
|
|