Exemplo n.º 1
0
        public void LoadFile(WatchFolderDetails wfd, string infile)
        {
            string jobName = wfd.JobName;

            if (jobWrappers.ContainsKey(jobName))
            {
                ((JobExeWrapper)jobWrappers[jobName]).ChangeMode(State.ExecutionModeEnum.Execution);

                log.InfoFormat("Launching job {0} from file {1}", jobName, infile);
                LaunchJob(jobName, infile);
            }
            else
                log.ErrorFormat("Job wrapper collection does not contain job {0}", jobName);
        }
Exemplo n.º 2
0
        public override StateEnums.Status Initialize(IJob _job)
        {
            job = _job;
            WatchFolderDetails detail = new WatchFolderDetails();
            detail.WatcherModes = watcherModes;
            detail.Path = path;
            detail.FileName = fileName;
            detail.Filter = filter;
            detail.FilterExclude = filterExclude;
            detail.Separator = separator;
            detail.IfHeaderContainsFieldName = ifHeaderContainsFieldName;
            detail.HeaderRowsToSkip = headerRowsToSkip;
            detail.TrailerRowsToSkip = trailerRowsToSkip;
            detail.AdapterType = "FileLoaderAdapter";
            detail.JobName = jobName;
            detail.IfResetOnEachRun = IfResetOnEachRun;
            detail.IsJamsEnabled = isJamsEnabled;

            //non-empty filename overrides watcher
            if (fileName.Equals(String.Empty))
                this.flatFileLoader.AddWatcher(detail, true);

            log.InfoFormat(_job.KeyHash, "FlatFileLoaderCSV initialized.");
            return StateEnums.Status.WaitingForFile;
        }
Exemplo n.º 3
0
 	//VJ private static Dictionary<string, string> environmentMetatagsDictionary = null;
 	//private static Dictionary<string, string> runtimeMetatagsDictionary = null;
     public static void GetInitialRunDateTime(WatchFolderDetails details, ref DateTime earliestDate, ref DateTime latestDate)
     {
         ConvertTimestringToDateTime(ref earliestDate, details.EarliestRunTime);
         ConvertTimestringToDateTime(ref latestDate, details.LatestRunTime);
     }			
Exemplo n.º 4
0
        public override StateEnums.Status Initialize(IJob _job)
        {
            job = _job;
            WatchFolderDetails detail = new WatchFolderDetails();

            detail.JobName = jobName;
            detail.Path = path;
            detail.FileName = fileName;
            detail.Filter = filter;
            detail.AdapterType = adapterType;
            detail.FieldNames = fieldnames;
            detail.IfFirstRowIsHeader = ifFirstRowIsHeader;
            detail.IfResetOnEachRun = IfResetOnEachRun;

            this.flatFileLoader.AddWatcher(job, detail, true);

            log.InfoFormat(_job.KeyHash, "FlatFileLoaderXls initialized.");
            return StateEnums.Status.WaitingForFile;
        }
Exemplo n.º 5
0
        public override StateEnums.Status Initialize(IJob _job)
        {
            job = _job;
            WatchFolderDetails detail = new WatchFolderDetails();
            detail.WatcherModes = watcherModes;
            detail.Path = path;
            detail.FileName = fileName;
            detail.Filter = filter;
            detail.FilterExclude = filterExclude;
            detail.AdapterType = "FileLoaderAdapter";
            detail.JobName = jobName;
            detail.IfResetOnEachRun = IfResetOnEachRun;

            detail.EarliestRunTime = earliestRunTime;
            detail.LatestRunTime = latestRunTime;
            detail.IsJamsEnabled = isJamsEnabled;

            flatFileLoader.AddWatcher(detail, true);

            log.InfoFormat(_job.KeyHash, "FlatFileLoaderXml initialized.");
            return StateEnums.Status.WaitingForFile;
        }
Exemplo n.º 6
0
        public void AddWatcher(IJob job, WatchFolderDetails detail, bool autoStart)
        {
            FileSystemEventHandler fileReceivedHandler = new FileSystemEventHandler(FileReceivedHandler);

            detail.Path = detail.Path.Replace("*JOB_DROP_PATH*", globalConfig.JobDropPath);
            if (detail.JobName == null || detail.JobName.Equals(String.Empty))
                detail.JobName = "JobFolder";

            filewatcherDetailsDictionary[detail.JobName] = detail;

            //define watcher
            FileSystemWatcher watcher = null;

            //filewatcherDictionary uniquely identifies each watcher by folder
            string path = ConfigUtils.MetaTagReplacer(globalConfig, detail.Path);
            if (!filewatcherDictionary.ContainsKey(detail.Path))
            {
                watcher = new FileSystemWatcher();
                watcher.InternalBufferSize = 32768;
                watcher.Path = path;
                watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.Attributes;

                AddHandlersToFileWatcher(detail, fileReceivedHandler, watcher);
                if (autoStart) watcher.EnableRaisingEvents = true;

                filewatcherDictionary[path] = watcher;
            }
            else
                watcher = filewatcherDictionary[path];

            log.InfoFormat(@"Watching {0}\{1}", path, detail.Filter);
        }
Exemplo n.º 7
0
 public void AddWatcher(WatchFolderDetails detail, bool autoStart)
 {
     AddWatcher(null, detail, autoStart);
 }
Exemplo n.º 8
0
 public void AddWatcher(WatchFolderDetails detail)
 {
     AddWatcher(detail, true);
 }
Exemplo n.º 9
0
 private static void AddHandlersToFileWatcher(WatchFolderDetails detail, FileSystemEventHandler fileReceivedHandler, FileSystemWatcher watcher)
 {
     if (detail.WatcherModes != null)
     {
         string[] watcherModes = detail.WatcherModes.Split(',');
         if (watcherModes != null)
         {
             foreach (string s in watcherModes)
             {
                 if (s.Equals("Created") || s.Equals(String.Empty))
                     watcher.Created += fileReceivedHandler;
                 else if (s.Equals("Changed"))
                     watcher.Changed += fileReceivedHandler;
             }
         }
         else
             watcher.Created += fileReceivedHandler;
     }
     else
         watcher.Created += fileReceivedHandler;
 }
Exemplo n.º 10
0
        public void AddWatcher(IJob job, WatchFolderDetails detail, bool autoStart)
        {
            //filewatcherDictionary uniquely identifies each watcher detail by job
            filewatcherDetailsDictionary[detail.JobName] = detail;

            //filewatcherDictionary uniquely identifies each watcher by folder
            FileSystemWatcherEnhanced watcher = null;
            if (!filewatcherDictionary.ContainsKey(detail.JobName))
            {
                FileSystemEventHandler fileReceivedHandler = new FileSystemEventHandler(FileReceivedHandler);

                watcher = new FileSystemWatcherEnhanced(fileReceivedHandler);
                watcher.BeginInit();
                watcher.InternalBufferSize = 32768;
                watcher.Path = detail.Path;

                if (!detail.IsJamsEnabled)
                {
                    watcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.FileName | NotifyFilters.Attributes;
                    watcher.EnableMonitoring();
                    if (autoStart) watcher.EnableRaisingEvents = true;
                }
                else
                {
                    watcher.EnableRaisingEvents = false;
                }

                AddHandlersToFileWatcher(detail, fileReceivedHandler, watcher);
                watcher.EndInit();

                lock (s_lock)
                {
                    filewatcherDictionary[detail.JobName] = watcher;
                }
            }
            else
                watcher = filewatcherDictionary[detail.JobName];

            log.InfoFormat(@"Watching {0}\{1}", detail.Path, detail.Filter);
        }