Exemplo n.º 1
0
        public EsentCrawlerHistoryService(string basePath, Uri baseUri, bool resume)
        {
            this.m_Resume           = resume;
            this.m_DatabaseFileName = Path.GetFullPath(
                Path.Combine(basePath, "NCrawlHist{0}\\Hist.edb".FormatWith(baseUri.GetHashCode())));

            if (!resume)
            {
                this.ClearHistory();
            }

            this.m_EsentInstance = new EsentInstance(this.m_DatabaseFileName, (session, dbid) =>
            {
                EsentTableDefinitions.CreateGlobalsTable(session, dbid);
                EsentTableDefinitions.CreateHistoryTable(session, dbid);
            });

            // Get columns
            this.m_EsentInstance.Cursor((session, dbid) =>
            {
                Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.GlobalsTableName,
                                     EsentTableDefinitions.GlobalsCountColumnName, out this.historyCountColumn);
                Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.HistoryTableName,
                                     EsentTableDefinitions.HistoryTableUrlColumnName, out this.historyUrlColumn);
            });
        }
Exemplo n.º 2
0
        public EsentCrawlQueueService(string basePath, Uri baseUri, bool resume)
        {
            this.m_DatabaseFileName = Path.GetFullPath(
                Path.Combine(basePath, "NCrawlQueue{0}\\Queue.edb".FormatWith(baseUri.GetHashCode())));

            if (!resume && File.Exists(this.m_DatabaseFileName))
            {
                ClearQueue();
            }

            this.m_EsentInstance = new EsentInstance(this.m_DatabaseFileName, (session, dbid) =>
            {
                EsentTableDefinitions.CreateGlobalsTable(session, dbid);
                EsentTableDefinitions.CreateQueueTable(session, dbid);
            });

            // Get columns
            this.m_EsentInstance.Cursor((session, dbid) =>
            {
                Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.GlobalsTableName,
                                     EsentTableDefinitions.GlobalsCountColumnName,
                                     out this.queueCountColumn);
                Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.QueueTableName,
                                     EsentTableDefinitions.QueueTableDataColumnName,
                                     out this.dataColumn);
            });
        }