コード例 #1
0
ファイル: BexisIndexer.cs プロジェクト: navabpourn/Core
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        public void updateIndex(Dictionary <long, IndexingAction> datasetsToIndex)
        {
            using (DatasetManager dm = new DatasetManager())
            {
                try
                {
                    if (!isIndexConfigured)
                    {
                        this.configureBexisIndexing(false);
                    }
                    foreach (KeyValuePair <long, IndexingAction> pair in datasetsToIndex)
                    {
                        if (pair.Value == IndexingAction.CREATE)
                        {
                            Query   query = new TermQuery(new Term("doc_id", pair.Key.ToString()));
                            TopDocs tds   = BexisIndexSearcher.getIndexSearcher().Search(query, 1);

                            if (tds.TotalHits < 1)
                            {
                                writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key));
                            }
                            else
                            {
                                indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString()));
                                autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString()));
                                writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key));
                            }
                        }
                        else if (pair.Value == IndexingAction.DELETE)
                        {
                            indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString()));
                            autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString()));
                        }
                        else if (pair.Value == IndexingAction.UPDATE)
                        {
                            indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString()));
                            autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString()));
                            writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key));
                        }
                    }
                    indexWriter.Commit();
                    autoCompleteIndexWriter.Commit();
                    BexisIndexSearcher.searcher             = new IndexSearcher(indexWriter.GetReader());
                    BexisIndexSearcher._Reader              = indexWriter.GetReader();
                    BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    autoCompleteIndexWriter.Dispose();
                    indexWriter.Dispose();

                    BexisIndexSearcher.searcher             = new IndexSearcher(indexWriter.GetReader());
                    BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader());
                }
            }
        }
コード例 #2
0
ファイル: BexisIndexer.cs プロジェクト: payamad/Core
        public void updateSingleDatasetIndex(long datasetId, IndexingAction indAction)
        {
            try
            {
                if (!isIndexConfigured)
                {
                    this.configureBexisIndexing(false);
                }
                DatasetManager dm = new DatasetManager();
                if (indAction == IndexingAction.CREATE)
                {
                    Query   query = new TermQuery(new Term("doc_id", datasetId.ToString()));
                    TopDocs tds   = BexisIndexSearcher.getIndexSearcher().Search(query, 1);

                    this.includePrimaryData = false;

                    if (tds.TotalHits < 1)
                    {
                        writeBexisIndex(datasetId, dm.GetDatasetLatestMetadataVersion(datasetId));
                    }
                    else
                    {
                        indexWriter.DeleteDocuments(new Term("doc_id", datasetId.ToString()));
                        autoCompleteIndexWriter.DeleteDocuments(new Term("id", datasetId.ToString()));
                        writeBexisIndex(datasetId, dm.GetDatasetLatestMetadataVersion(datasetId));
                    }
                }
                else if (indAction == IndexingAction.DELETE)
                {
                    indexWriter.DeleteDocuments(new Term("doc_id", datasetId.ToString()));
                    autoCompleteIndexWriter.DeleteDocuments(new Term("id", datasetId.ToString()));
                }
                else if (indAction == IndexingAction.UPDATE)
                {
                    indexWriter.DeleteDocuments(new Term("doc_id", datasetId.ToString()));
                    autoCompleteIndexWriter.DeleteDocuments(new Term("id", datasetId.ToString()));
                    writeBexisIndex(datasetId, dm.GetDatasetLatestMetadataVersion(datasetId));
                }

                indexWriter.Commit();
                autoCompleteIndexWriter.Commit();
                BexisIndexSearcher.searcher             = new IndexSearcher(indexWriter.GetReader());
                BexisIndexSearcher._Reader              = indexWriter.GetReader();
                BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                BexisIndexSearcher.searcher             = new IndexSearcher(indexWriter.GetReader());
                BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader());

                indexWriter.Dispose();
                autoCompleteIndexWriter.Dispose();
            }
        }
コード例 #3
0
        public ActionResult Reset()
        {
            //public ActionResult LoadMetadata(long datasetId, bool locked = false, bool created = false, bool fromEditMode = false, bool resetTaskManager = false, XmlDocument newMetadata = null)

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager != null)
            {
                DatasetManager dm               = new DatasetManager();
                long           datasetid        = -1;
                bool           resetTaskManager = true;
                XmlDocument    metadata         = null;
                bool           editmode         = false;
                bool           created          = false;

                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
                {
                    datasetid = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                }

                if (datasetid > -1 && dm.IsDatasetCheckedIn(datasetid))
                {
                    metadata = dm.GetDatasetLatestMetadataVersion(datasetid);
                    editmode = true;
                    created  = true;
                }

                return(RedirectToAction("LoadMetadata", "Form", new { area = "Dcm", entityId = datasetid, locked = false, created = created, fromEditMode = editmode, resetTaskManager = resetTaskManager, newMetadata = metadata }));
            }

            return(RedirectToAction("StartMetadataEditor", "Form"));
        }
コード例 #4
0
ファイル: BexisIndexer.cs プロジェクト: navabpourn/Core
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        public void Index()
        {
            configureBexisIndexing(true);
            // there is no need for the metadataAccess class anymore. Talked with David and deleted. 30.18.13. Javad/ compare to the previous version to see the deletions
            DatasetManager dm     = new DatasetManager();
            List <string>  errors = new List <string>();

            try
            {
                IList <long> ids = dm.GetDatasetLatestIds();

                //ToDo only enitities from type dataset should be indexed in this index

                foreach (var id in ids)
                {
                    try
                    {
                        writeBexisIndex(id, dm.GetDatasetLatestMetadataVersion(id));
                        //GC.Collect();
                    }
                    catch (Exception ex)
                    {
                        errors.Add(string.Format("Enountered a probelm indexing dataset '{0}'. Details: {1}", id, ex.Message));
                    }
                }
                //GC.Collect();

                indexWriter.Optimize();
                autoCompleteIndexWriter.Optimize();

                if (!reIndex)
                {
                    indexWriter.Dispose();
                    autoCompleteIndexWriter.Dispose();
                }
                if (errors.Count > 0)
                {
                    throw new Exception(string.Join("\n\r", errors));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dm.Dispose();
                GC.Collect();

                var es = new EmailService();
                es.Send(MessageHelper.GetSearchReIndexHeader(),
                        MessageHelper.GetSearchReIndexMessage(errors),
                        ConfigurationManager.AppSettings["SystemEmail"]);
            }
        }
コード例 #5
0
        public StructuredDataStructure GetDataStructureByID(long ID)
        {
            DataStructureManager    dsm = new DataStructureManager();
            StructuredDataStructure structuredDataStructure = dsm.StructuredDataStructureRepo.Get(ID);

            this.dataStructure = structuredDataStructure;

            if (this.dataStructure != null)
            {
                this.variables = getOrderedVariables(structuredDataStructure);

                if (this.dataStructure.Datasets == null)
                {
                    inUse = false;
                }
                else
                {
                    if (this.dataStructure.Datasets.Count > 0)
                    {
                        inUse = true;
                        DatasetListElement datasetListElement = new DatasetListElement();
                        DatasetManager     dm = new DatasetManager();
                        foreach (Dataset d in structuredDataStructure.Datasets)
                        {
                            if (dm.GetDatasetLatestMetadataVersion(d.Id) != null)
                            {
                                datasetListElement = new DatasetListElement(d.Id, XmlDatasetHelper.GetInformation(d, AttributeNames.title));
                            }
                            else
                            {
                                datasetListElement = new DatasetListElement(0, "");
                            }
                            datasets.Add(datasetListElement);
                        }
                    }
                    else
                    {
                        inUse = false;
                    }
                }
                this.BuildDataTable();
                return(structuredDataStructure);
            }
            else
            {
                this.dataStructure = new StructuredDataStructure();
                return(structuredDataStructure);
            }
        }