コード例 #1
0
        public void TestGetNewRandomUnscannedDocument()
        {
            db.Clear();
            int numRecords = 1000;

            Stopwatch timer = new Stopwatch();

            for (int i = 0; i < numRecords; i++)
            {
                CrawlDocument cd = new CrawlDocument();
                cd.Hash      = Guid.NewGuid().ToString();
                cd.Path      = i.ToString();
                cd.ClassName = "File";
                db.InsertIntoFiles(cd);
            }

            CrawlDocument cd1 = db.GetNewRandomUnscannedDocument();

            CrawlDocument cd2 = db.GetNewRandomUnscannedDocument();

            // Random-selected files from 1000 records should differ
            Assert.IsFalse(cd1.FileId == cd2.FileId);

            timer.Stop();
            // Assume 3ms for each record should be enough
            Assert.IsTrue(timer.ElapsedMilliseconds < 3 * numRecords);
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: 15831944/dwg-crawl
        public static void Crawl(bool closeAfterComplete = true)
        {
            DbMongo sqlDB = new DbMongo("SingleFile");
            //While Get random dwg from database that not scanned
            CrawlDocument crawlDoc = sqlDB.GetNewRandomUnscannedDocument();

            while (crawlDoc != null)
            {
                crawlAcDbDocument cDoc = new crawlAcDbDocument(crawlDoc);
                cDoc.sqlDB = sqlDB;
                cDoc.ScanDocument();
                crawlDoc = sqlDB.GetNewRandomUnscannedDocument();
            }
            if (closeAfterComplete)
            {
                HostMgd.ApplicationServices.Application.Quit();
            }
        }