コード例 #1
0
ファイル: CrawlPlan.cs プロジェクト: brson/beagle-delicious
        public CrawlPlan(LocalManifest localManifest, RemoteManifest remoteManifest, RemoteDataAccess dao)
        {
            Debug.Assert (localManifest != null);
            Debug.Assert (remoteManifest != null);
            Debug.Assert (dao != null);

            this.dao = dao;

            // Clone the local manifest, because we need to make changes to this copy
            BuildCrawlPlan (localManifest.Clone (), remoteManifest);
        }
コード例 #2
0
ファイル: Monitor.cs プロジェクト: zanderphh/candao-pos
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            base.OnDoWork(e);
            LocalManifest  = FileUtil.ReadManifest(_manifestPath);
            RemoteManifest = FileUtil.ReadManifest(LocalManifest.ReleaseUrl + "/" + Manifest.ManifestFileName);


            if (LocalManifest.CompareTo(RemoteManifest) != 0)
            {
                HasNewVersion = true;
                if (!string.IsNullOrEmpty(_tempDir))
                {
                    if (!Directory.Exists(_tempDir))
                    {
                        Directory.CreateDirectory(_tempDir);
                    }
                    RemoteManifest.SaveManifest(Path.Combine(_tempDir, Manifest.ManifestFileName));
                    //download update files silently
                    var loader = new Downloader(LocalManifest, RemoteManifest, _tempDir);
                    loader.RunWorkerAsync();
                }
            }
        }
コード例 #3
0
ファイル: CrawlPlan.cs プロジェクト: brson/beagle-delicious
        void BuildCrawlPlan(LocalManifest localManifest, RemoteManifest remoteManifest)
        {
            Log.Debug ("Building crawl plan");

            foreach (RemoteManifestEntry remoteEntry in remoteManifest)
            {
                PartialCrawlCommand newCommand = PreparePartialCommandFromRemoteEntry (remoteEntry, localManifest);
                if (newCommand != null)
                {
                    partialCommands.Enqueue (newCommand);
                }

                // Remove entries from the local manifest, so we can later
                // tell which entries only exist locally
                if (localManifest.ContainsKey (remoteEntry.UrlHash))
                {
                    localManifest.Remove (remoteEntry.UrlHash);
                }
            }

            // Any entries left in the local manifest don't exist remotely,
            // so they need to be removed
            foreach (KeyValuePair <string, LocalManifestEntry> entryPair in localManifest)
            {
                CrawlCommand newCommand = new CrawlCommand ();
                newCommand.Action = CrawlAction.Remove;
                newCommand.Post = BuildFakePost (entryPair.Value);
                commands.Enqueue (newCommand);
            }
        }