GetDocuments() static private method

static private GetDocuments ( IEnumerable versionIdSet ) : IEnumerable
versionIdSet IEnumerable
return IEnumerable
Exemplo n.º 1
0
        private static void UpdateDirtyDocuments(List <VersionInfo> infoList)
        {
            //-- select dirty documents
            var dirtyVersions = infoList.Where(i => !i.IsActualDocument &&
                                               (i.OriginalIsPublic != i.ExpectedIsPublic || i.OriginalIsMajor != i.ExpectedIsMajor ||
                                                i.OriginalIsLastDraft != i.ExpectedIsLastDraft || i.OriginalIsLastPublic != i.ExpectedIsLastPublic)).ToArray();

            //-- play dirty documents
            var docs = IndexDocumentInfo.GetDocuments(dirtyVersions.Select(d => d.VersionId));

            foreach (var doc in docs)
            {
                var versionId = Int32.Parse(doc.Get(LucObject.FieldName.VersionId));
                foreach (var dirtyVersion in dirtyVersions)
                {
                    if (dirtyVersion.VersionId == versionId)
                    {
                        dirtyVersion.Document = doc;
                        SetDocumentFlags(dirtyVersion);
                        var delTerm = new Term(KeyFieldName, Lucene.Net.Util.NumericUtils.IntToPrefixCoded(dirtyVersion.VersionId));

                        //_writerRestartLock.EnterReadLock();
                        //try
                        //{
                        //    //in case the system was shut down in the meantime
                        //    if (!LuceneManager.Running)
                        //        return;

                        //    _writer.UpdateDocument(delTerm, dirtyVersion.Document);
                        //}
                        //finally
                        //{
                        //    _writerRestartLock.ExitReadLock();
                        //}
                        using (var wrFrame = IndexWriterFrame.Get(false)) // // UpdateDirtyDocuments
                        {
                            //in case the system was shut down in the meantime
                            if (!LuceneManager.Running)
                            {
                                return;
                            }

                            _writer.UpdateDocument(delTerm, dirtyVersion.Document);
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static IEnumerable <DocumentUpdate> GetUpdates(VersioningInfo versioning)
        {
            var result = new List <DocumentUpdate>(versioning.Reindex.Length);

            var updates = IndexDocumentInfo.GetDocuments(versioning.Reindex);

            foreach (var doc in updates)
            {
                var verId = GetVersionIdFromDocument(doc);
                SetDocumentFlags(doc, verId, versioning);
                result.Add(new DocumentUpdate {
                    UpdateTerm = GetVersionIdTerm(verId), Document = doc
                });
            }

            return(result);
        }