SolvedPrivate

SSIS 2008 C# Script task not producing expected outcome

Posted on 2014-03-06
2
24 Views
Last Modified: 2016-02-10
Hi,
I have the following script
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;

namespace ST_07bc0354bae645e8bf2e65be651aeec0.csproj
{
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {

        #region VSTA generated code
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion


       public void Main()
        {
             
            // Create a new FileSystemWatcher and set its properties.
            FileSystemWatcher watcher = new FileSystemWatcher();

            //Watch for changes in the following directory
            watcher.Path = @"C:\Test\";

            /* Watch for changes in  LastWrite times in the  directory. */
            watcher.NotifyFilter = NotifyFilters.LastWrite;

         
            // Add event handlers.
              watcher.Changed += new FileSystemEventHandler(OnChanged);
  
          // Begin watching.
        watcher.EnableRaisingEvents = true;
        watcher.WaitForChanged(WatcherChangeTypes.All, 20000);
       

    }
       
            // Define the event handlers. 
    private static void OnChanged(object source, FileSystemEventArgs e)
    {
        // Specify what is done when a file is  created, 
             MessageBox.Show("Hello, File exists");
    }

        }
    }

Open in new window

which watches the specified folder for a specified time.
If a file is saved to the folder during the watch period, I expect the Message  in the event handler to display.
However, it is not displaying. The task waits for the specified time , the box remaining yellow
scripttaskwaiting.jpgafter the time has elapsed, it finishes, going to green…
FileSystemWatcherTask-suceeds.jpgbut no message box appears,
any guidance appreciated..
0
Comment
Question by:blossompark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 500 total points
ID: 39910578
That IS because that's exactly what is it coded for it to do - check that folder for "specified time." and "after the time has elapsed, it finishes, going to green"
0
 

Author Comment

by:blossompark
ID: 39911147
Hi lcohan,
thanks for your comment.
When I drop the file into the folder during the "watch" period should it not then trigger a call to the onChanged Event Handler which displays the message box?
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question