July 18, 2013 at 7:09 am
I am trying to use SSIS 2008 R2 to move some files and then delete them from the source.
I created a script task to get the list of file names, modifying some code I found on the internet, but it will not compile.
I get the following errors:
Error 1 The type or namespace name 'SSISScriptTaskEntryPointAttributeAttribute' does not exist in the namespace 'Microsoft.SqlServer.Dts.Tasks.ScriptTask' (are you missing an assembly reference?) C:\Users\Potterd\AppData\Local\Temp\49\SSIS\fa887f142f8340d3bd98ccb513dd0024\ScriptMain.cs 14 43 st_1d747df439f54db2a433b54c4e1c0786
Error 2 The type or namespace name 'SSISScriptTaskEntryPointAttribute' does not exist in the namespace 'Microsoft.SqlServer.Dts.Tasks.ScriptTask' (are you missing an assembly reference?) C:\Users\Potterd\AppData\Local\Temp\49\SSIS\fa887f142f8340d3bd98ccb513dd0024\ScriptMain.cs 14 43 st_1d747df439f54db2a433b54c4e1c0786
Generated from the following code:
namespace ST_e10d8186ebb34debbc31bb734b0e29a5
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain :
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
private string NETWORK_PATH;
private string FILE_PATTREN;
private bool isCheckForNewer = true;
int fileAgeLimit;
private ArrayList listForEnumerator = new ArrayList();
private void GetFilesInFolder(string folderPath)
{
string[] AllFiles;
DateTime fileChangeDate;
TimeSpan fileAge;
int fileAgeInDays;
try
{
AllFiles = Directory.GetFiles(folderPath, FILE_PATTREN);
foreach (string fileName in AllFiles)
{
fileChangeDate = File.GetLastWriteTime(fileName);
fileAge = DateTime.Now.Subtract(fileChangeDate);
fileAgeInDays = fileAge.Days;
CheckAgeOfFile(fileName, fileAgeInDays);
}
if (Directory.GetDirectories(folderPath).Length > 0)
{
foreach (string childFolder in Directory.GetDirectories(folderPath))
{
GetFilesInFolder(childFolder);
}
}
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show("Exception caught: " + e.ToString(), "Results",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CheckAgeOfFile(string fileName, int fileAgeInDays)
{
if (isCheckForNewer)
{
if (fileAgeInDays <= fileAgeLimit)
{
listForEnumerator.Add(fileName);
}
}
else
{
if (fileAgeInDays > fileAgeLimit)
{
listForEnumerator.Add(fileName);
}
}
}
public void Main()
{
// Initializing class variables with package variables
fileAgeLimit = (int)(Dts.Variables["User::varFileAgeLimit"].Value);
NETWORK_PATH = (string)(Dts.Variables["User::varNetworkPath"].Value);
FILE_PATTREN = (string)(Dts.Variables["User::varFilePattern"].Value); ;
if (fileAgeLimit < 0)
{
isCheckForNewer = false;
}
fileAgeLimit = Math.Abs(fileAgeLimit);
GetFilesInFolder(NETWORK_PATH);
// Return the list of files to the variable
// for later use by the Foreach from Variable enumerator.
Dts.Variables["User::varFileList"].Value = listForEnumerator;
Dts.TaskResult = (int)ScriptResults.Success;
}
July 18, 2013 at 8:51 am
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply