protected override object Process()
        {
            //place in log that it is processing the list of files found in the directory.
            ReportProgress(new ProgressStatus(ProcessName, string.Format("Processing directory: {0}", m_SourceDirectory)));

            //obtain a list of files that meet log filter specifications
            fileEntries = Directory.GetFiles(m_SourceDirectory, LogFilter);

            //place in log number of files found in directory
            ReportProgress(new ProgressStatus(ProcessName, string.Format("{0} files found.", fileEntries.Length)));
            if (fileEntries.Length != 0)
            {
                foreach (string fileName in fileEntries)
                {
                    ActualFileName = fileName.Substring(m_SourceDirectory.Length + 1);

                    //post to log the file being processed
                    ReportProgress(new ProgressStatus(ProcessName, string.Format("Processing file:{0} ...", ActualFileName)));

                    //check to see if the current file has already processed
                    if (!HasLogProcessed(ActualFileName))
                    {
                        //if not then run import method
                        ImportFile(fileName);
                    }
                    else
                    {
                        // otherwise log message that file already exists
                        ReportProgress(new ProgressStatus(ProcessName, string.Format("This log: {0} has already been processed and loaded to database", ActualFileName)));
                    }

                    Archiver compress = new Archiver();
                    compress.Zip(fileName, m_SourceDirectory);
                    compress.Zip(fileName.Replace(".log", ".Exceptions"), m_SourceDirectory);
                    //increment files counters
                    rnPackageFilesProcessed++;
                    ReportProgress(new ProgressStatus(ProcessName, string.Format(" complete. {0} of {1} file(s) processed.", rnPackageFilesProcessed, fileEntries.Length), rnPackageFilesProcessed, fileEntries.Length));
                    if (rnPackageFilesProcessed == fileEntries.Length)
                    {
                        rnFilesComplete = true;
                    }
                    else
                    {
                        rnFilesComplete = false;
                    }
                }
            }
            else
            {
                rnFilesComplete = true;
            }
            return(null);
        }
Esempio n. 2
0
        void BackgroundWorkerArchiver_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerBase workerBaseArchiver = null;

            try
            {
                BackgroundWorker backgroundWorker = (BackgroundWorker)sender;
                workerBaseArchiver = new Archiver(backgroundWorker, e);
                workerBaseArchiver.DoWork();
            }
            catch (Exception ex)
            {
                m_logging.Write(string.Format("{0} failed at {1}.", workerBaseArchiver.GetType(), ex));
                totalFail++;
            }
        }
Esempio n. 3
0
        protected override object Process()
        {
            //place in log that it is processing the list of files found in the directory.
            ReportProgress(new ProgressStatus(ProcessName, string.Format("Processing directory: {0}", m_SourceDirectory)));

            //obtain a list of files that meet log filter specifications
            fileEntries = Directory.GetFiles(m_SourceDirectory, LogFilter);

            //place in log number of files found in directory
            ReportProgress(new ProgressStatus(ProcessName, string.Format("{0} files found.", fileEntries.Length)));

            foreach (string fileName in fileEntries)
            {
                ftpFilesProcessed++;

                ActualFileName = fileName.Substring(m_SourceDirectory.Length);

                ReportProgress(new ProgressStatus(ProcessName, string.Format("Processing file:{0} ...", ActualFileName)));
                ReportProgress(new ProgressStatus(ProcessName, null, ftpFilesProcessed, fileEntries.Length));

                //check to see if current file has already processed
                if (!HasLogProcessed(ActualFileName))
                {
                    ImportFile(fileName);
                }
                else
                {
                    // otherwise place msg in log that file already exists
                    ReportProgress(new ProgressStatus(ProcessName, string.Format("This log: {0} has already been processed and loaded to database", ActualFileName)));
                }

                Archiver compress = new Archiver();
                compress.Zip(fileName, m_SourceDirectory);
                compress.Zip(fileName.Replace(".log", ".Exceptions"), m_SourceDirectory);

                ReportProgress(new ProgressStatus(ProcessName, string.Format(" complete. {0} file(s) processed.", ftpFilesProcessed), ftpFilesProcessed, fileEntries.Length));
            }

            return(null);
        }