예제 #1
0
        public virtual void teststopStart()
        {
            MyListener myListener = new MyListener();
            FileInfo   file       = new FileInfo(theHF + Path.DirectorySeparatorChar.ToString() + "f1.txt");
            FileInfo   stFile     = new FileInfo(theStorage + Path.DirectorySeparatorChar.ToString() + "f1.txt");

            SupportClass.FileSupport.CreateNewFile(file);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            Assert.IsFalse(stFile.Exists);
            hf = new QueueHotFolder(theHF, theStorage, null, myListener, null);
            hf.stop();
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsTrue(file.Exists);
            stFile.Refresh();
            Assert.IsFalse(stFile.Exists, "FileInfo is still there after stop");
            Assert.AreEqual(0, myListener.vJMF.Count);
            hf.restart();
            StatusCounter.sleep(3000);
            file.Refresh();
            Assert.IsFalse(file.Exists, "FileInfo is gone after stop");
            stFile.Refresh();
            Assert.IsTrue(stFile.Exists);
            Assert.AreEqual(1, myListener.vJMF.Count);
            JDFJMF elementAt = (JDFJMF)myListener.vJMF[0];

            Assert.AreEqual(JDFMessage.EnumType.SubmitQueueEntry, elementAt.getCommand(0).getEnumType());
            Assert.AreEqual(UrlUtil.fileToUrl(stFile, false), elementAt.getCommand(0).getQueueSubmissionParams(0).getURL());
        }
예제 #2
0
        private readonly JDFCommand queueCommand;     // the jdf command template that is used to generate a new message for each dropped file

        ///
        ///     <summary> *
        ///     * constructor for a simple queue based hotfolder watcher that is automagically started in its own thread
        ///     *  </summary>
        ///     * <param name="_hotFolderDir"> the hot folder directory to watch </param>
        ///     * <param name="_storageDir"> the storage directory wher hot files are moved to </param>
        ///     * <param name="ext"> the file extensions that are moved - if null no filtering </param>
        ///     * <param name="hfListener"> callback that receives the generated JMF - the location of the stored file will be found in the standard command parameters </param>
        ///     * <param name="_queueCommand"> the jmf template that will be used to generate a new message, null creates an empty SubmitQueueEntry template </param>
        ///
        public QueueHotFolder(DirectoryInfo _hotFolderDir, DirectoryInfo _storageDir, string ext, QueueHotFolderListener hfListener, JDFJMF _queueCommand)
        {
            JDFJMF _queueCommandLocal = _queueCommand;

            storageDir = _storageDir;
            if (!storageDir.Exists)
            {
                storageDir.Create(); // just in case
            }
            qhfl = hfListener;
            if (_queueCommandLocal == null)
            {
                _queueCommandLocal = JDFJMF.createJMF(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);
            }

            queueCommand = _queueCommandLocal.getCommand(0);
            hf           = new HotFolder(_hotFolderDir, ext, this);
        }