Exemplo n.º 1
0
        private static void ReindexRecord(IBaseWindow baseWin, WritableDatabase database, TermGenerator indexer, GDMRecord record)
        {
            uint docid = FindDocId(baseWin, database, record.XRef);

            if (docid != 0)
            {
                // checking for needed updates
                string recLastchange = record.ChangeDate.ToString();
                string docLastchange;

                using (Document curDoc = database.GetDocument(docid)) {
                    docLastchange = curDoc.GetValue(0);
                }

                // updating a record
                if (!string.Equals(recLastchange, docLastchange))
                {
                    using (Document doc = new Document())
                    {
                        if (SetDocumentContext(baseWin, doc, indexer, record))
                        {
                            database.ReplaceDocument(docid, doc);
                        }
                    }
                }
            }
            else
            {
                // only adding
                using (Document doc = new Document())
                {
                    if (SetDocumentContext(baseWin, doc, indexer, record))
                    {
                        database.AddDocument(doc);
                    }
                }
            }
        }