示例#1
0
        DMS.JobProgressInfo DMS.IWorker.GetProgressInfo(DMS.Job job)
        {
            try
            {
                FileClassificatorProgressInfo pinfo = null;
                if (job.JobId == cjob.JobId)
                {
                    pinfo = new FileClassificatorProgressInfo(job.JobId, job.JobState, server.DirCount, server.FileCount, cjob.results.Rows.Count);
                }
                else
                {
                    Job tjob = (Job)job;
                    pinfo = new FileClassificatorProgressInfo(tjob.JobId, tjob.JobState, tjob.CountDirs, tjob.CountFiles, tjob.results.Rows.Count);
                }

                return(pinfo);
            }
            catch (InvalidCastException)
            {
                Trace.Fail("FCWorker/GetProgressInfo/InvalidCastException");
                return(null);
            }
            catch (Exception ex)
            {
                Trace.Fail(string.Format("FCWorker/GetProgressInfo/Exception: {0}", ex.Message));
                return(null);
            }
        }
示例#2
0
        void DMS.IWorker.doIt(DMS.Job currentJob)
        {
            try
            {
                cjob = (Job)currentJob;
                Debug.WriteLine("Job " + currentJob.JobId + " in AppDomain " + AppDomain.CurrentDomain.FriendlyName + " wird ausgeführt");

                if (server.scanDir(cjob.dir))
                {
                    cjob.CountDirs  = server.DirCount;
                    cjob.CountFiles = server.FileCount;
                    return;
                }
                else
                {
                    Trace.WriteLine(string.Format("FCWorker/doIt/scanner.scanDir({0}): mit false geendet", cjob.dir));
                    return;
                }
            }
            catch (Exception ex)
            {
                Trace.Fail(string.Format("FCWorker/doIt/Exception: {0}", ex.Message));
                return;
            }
        }
示例#3
0
        public DMS.JobProgressInfo GetProgressInfo(DMS.Job job)
        {
            // Downcast der Job- Referenz in eine Referenz vom Typ PageDownloadJob
            PickLinksJob pJob = job as PickLinksJob;

            Debug.Assert(pJob != null);

            DMS.JobProgressInfo pinfo = new DMS.JobProgressInfo(pJob.JobId, pJob.JobState);
            return(pinfo);
        }
示例#4
0
        public void doIt(DMS.Job currentJob)
        {
#if (DEBUG)
            Debug.Assert(System.Text.RegularExpressions.Regex.IsMatch("href   =\"http://www.mkoit.de\"", HRefRegEx));
            Debug.Assert(System.Text.RegularExpressions.Regex.IsMatch("href = http://www.mkoit.de", HRefRegEx));
            Debug.Assert(System.Text.RegularExpressions.Regex.IsMatch("href=http://www.mkoit.de", HRefRegEx));

            Debug.Assert(System.Text.RegularExpressions.Regex.IsMatch("href=\"http://www.mkoit.de\"", HRefRegEx));

            //Debug.Assert(!System.Text.RegularExpressions.Regex.IsMatch("href=\"https:/www.mkoit.de\"", HRefRegEx));
#endif


            // Downcast in PickLinksJob
            PickLinksJob pJob = currentJob as PickLinksJob;
            Debug.Assert(pJob != null);

            int NewDeept = pJob.ActDeept - 1;

            // Alle Urls aus dem HTML- Text extrahieren
            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(
                HRefRegEx,
                RegexOptions.IgnoreCase | RegexOptions.Compiled);

            MatchCollection mc = regEx.Matches(pJob.HtmlText);
            Debug.WriteLine("PC: Deept= " + pJob.ActDeept + " JobId= " + pJob.JobId + " #Urls = " + mc.Count);

            // Iteration durch alle Treffer des regulären Ausdrucks
            foreach (System.Text.RegularExpressions.Match match in mc)
            {
                // Für jede Url einen neuen PageDownload Job erzeugen
                Debug.Assert(pageDownloadQueue != null);

                string Url;
                if (GetInternetLink(match.Captures[0].Value, out Url))
                {
                    PageDownloadJob downloadJob = new PageDownloadJob();

                    // Job wird nach der Fertigstellung automatisch entfernt
                    downloadJob.OneWay = true;
                    downloadJob.JobId  = pageDownloadQueue.NewJobId();
                    downloadJob.Url    = Url;

                    downloadJob.ActDeept = NewDeept;

                    // Rückkopplung: Herunterladen der Seite, auf die der Link aus der aktuellen verweist
                    pageDownloadQueue.pushJob(downloadJob);
                }
            }

            pJob.SetFinished();
        }
示例#5
0
        public DMS.JobProgressInfo GetProgressInfo(DMS.Job job)
        {
            // Downcast der Job- Referenz in eine Referenz vom Typ PageDownloadJob
            PageDownloadJob downloadJob = job as PageDownloadJob;

            Debug.Assert(downloadJob != null);
            lock (Visited)
            {
                PageDownloadJobProgressInfo pinfo = new PageDownloadJobProgressInfo(
                    downloadJob.Url,
                    Visited.Count,
                    downloadJob.JobId,
                    downloadJob.JobState);
                return(pinfo);
            }
        }
        bool IBatchProcessing.DeliverFinishedJob(int JobId, out Job job)
        {
            lock (JobStorage)
            {
                if (JobStorage.ContainsKey(JobId))
                {
                    if (JobStorage[JobId].JobState == Job.JobStates.finished)
                    {
                        job = JobStorage[JobId];
                        JobStorage.Remove(JobId);
                        return(true);
                    }
                }
            }

            // Undefinierten Job ausgeben
            job = new DMS.Job(-1);
            Trace.WriteLineIf(ts.TraceWarning, string.Format("BatchProcessor.DeliverFinishedJob: Zur JobId {0:D} existiert kein Job", JobId));
            return(false);
        }
示例#7
0
 bool DMS.IWorker.setup(DMS.Job currentJob)
 {
     try
     {
         // ContentVec- Tabelle dem writer bekanntmachen
         writer.SetContentVecTab(((Job)currentJob).results);
         server.reset();
         Debug.WriteLine("Job " + currentJob.JobId + " in AppDomain " + AppDomain.CurrentDomain.FriendlyName + " wird gestartet");
         log.Log(mko.Log.RC.CreateMsg("Job " + currentJob.JobId + " in AppDomain " + AppDomain.CurrentDomain.FriendlyName + " wird gestartet"));
         return(true);
     }
     catch (InvalidCastException)
     {
         Trace.Fail("FCWorker/InvalidCastException");
         return(false);
     }
     catch (Exception ex)
     {
         Trace.Fail(string.Format("FCWorker/setup/Exception: {0}", ex.Message));
         return(false);
     }
 }
示例#8
0
        /// <summary>
        /// 2011.05.09, mko
        /// In vorausgegangenen Versionen wurde der Fall nicht berücksichtigt, das ein auf die
        /// Verarbeitung wartender Job bereits abgebrochen werden kann. Durch eine Schleife,
        /// die alle bereits abgebrochenen Jobs überspringt, wurde dies jetzt korrigiert
        /// </summary>
        private void ProcessNextJob()
        {
            // Sind weitere Jobs in der Job-Queue, dann wird die Arbeit mit dem nächsten Job
            // aus der Queue unmittelbar fortgesetzt
            if (JobQueue.Count > 0 && !_pause)
            {
                // Alle abgebrochenen Jobs überspringen
                do
                {
                    currentJob = JobQueue.Dequeue();
                    if (currentJob.JobState == Job.JobStates.aborted)
                    {
                        if (currentJob.OneWay)
                        {
                            JobStorage.Remove(currentJob.JobId);
                        }
                        currentJob = null;
                    }
                } while (JobQueue.Count > 0 && currentJob == null);

                if (currentJob != null)
                {
                    currentJob.SetProcessing();

                    // Konfigurieren der FeatureCollectoren
                    if (worker.setup(currentJob))
                    {
                        busy             = true;
                        asyncResultDoJob = asyncDoIt.BeginInvoke(currentJob, new AsyncCallback(JobFinished), null);
                    }
                    else
                    {
                        // Job abbrechen
                        currentJob.SetAborted();
                        JobFinished();
                    }
                }
            }
        }
示例#9
0
 public bool setup(DMS.Job currentJob)
 {
     return(true);
 }
示例#10
0
        public void doIt(DMS.Job currentJob)
        {
            // Downcast der Job- Referenz in eine Referenz vom Typ PageDownloadJob
            PageDownloadJob downloadJob = currentJob as PageDownloadJob;

            Debug.Assert(downloadJob != null);
            Debug.WriteLine("PD: Deept= " + downloadJob.ActDeept + " JobId= " + downloadJob.JobId + " Url=" + downloadJob.Url);

            try
            {
                // Prüfen, ob die max. Tiefe beim crawlen erreicht wurde
                if (downloadJob.ActDeept <= 0)
                {
                    if (EventEndOfCrawl != null)
                    {
                        lock (Visited)
                        {
                            EventEndOfCrawl(
                                new PageDownloadJobProgressInfo(
                                    downloadJob.Url,
                                    Visited.Count,
                                    downloadJob.JobId,
                                    downloadJob.JobState));
                        }
                    }
                    return;
                }

                // Prüfen, ob Seite bereits besucht wurde
                if (Visited.Any(r => r == downloadJob.Url))
                {
                    return;
                }

                // Seite herunterladen
                System.Net.WebRequest  request  = null;
                System.Net.WebResponse response = null;

                System.Net.NetworkCredential cred = new NetworkCredential(
                    //System.Security.Principal.WindowsIdentity.GetCurrent().Name,
                    "Administrator",
                    "schulung");

                //System.Net.WebProxy myProxy = new System.Net.WebProxy("http://10.7.252.34:80", true);
                //myProxy.Credentials = cred;


                request = System.Net.WebRequest.Create(downloadJob.Url);
                //request.Proxy = myProxy;
                response = request.GetResponse();

                // Seite als besucht verzeichnen
                Visited.Add(downloadJob.Url);

                // Inhalt der Seite auslesen

                System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
                string HtmlText = reader.ReadToEnd();

                // Neuen PickLinJob in die Queue von PickLinks stellen
                PickLinksJob pickJob = new PickLinksJob();

                // Job wird nach der Fertigstellung automatisch entfernt
                pickJob.OneWay   = true;
                pickJob.JobId    = pickLinksBp.NewJobId();
                pickJob.HtmlText = HtmlText;
                pickJob.ActDeept = downloadJob.ActDeept;

                pickLinksBp.pushJob(pickJob);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Fehler beim Herunterladen: " + ex.Message);
            }
            finally
            {
                downloadJob.SetFinished();
            }
        }