예제 #1
0
        public int IndexPublication(Lucene.Net.Store.Directory indexDir, IssueDocumentDto bean)
        {
            IndexWriter writer = null;
            Document doc = null;
            Field field = null;
            IndexWriter idxModif = null;

            int numIndexed = 0;

            try
            {
                if (IndexWriter.IsLocked(indexDir))
                    IndexWriter.Unlock(indexDir);
                idxModif = new IndexWriter(indexDir, this.Analizer, false, new IndexWriter.MaxFieldLength(2500000));

                doc = new Document();

                doc.Add(new Field("issue_id", bean.IssueId.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.CompanyId != -1) doc.Add(new Field("company_id", bean.CompanyId.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.IssueIdPerCompany != -1) doc.Add(new Field("issue_per_company", bean.IssueIdPerCompany.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.PriorityId != -1) doc.Add(new Field("priority_id", bean.PriorityId.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.StatusId != -1) doc.Add(new Field("status_id", bean.StatusId.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (!string.IsNullOrEmpty(bean.CurrentOwner)) doc.Add(new Field("curr_owner", bean.CurrentOwner, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (!string.IsNullOrEmpty(bean.LastOwner)) doc.Add(new Field("last_owner", bean.LastOwner, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (!string.IsNullOrEmpty(bean.ProjectName)) doc.Add(new Field("project_name", bean.ProjectName, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));

                if (bean.AssignedCUDate != DateTime.MinValue) doc.Add(new Field("assigned_cu_date", DateTools.DateToString(bean.AssignedCUDate, DateTools.Resolution.DAY), Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (bean.DestinationDate != DateTime.MinValue) doc.Add(new Field("destination_date", DateTools.DateToString(bean.DestinationDate, DateTools.Resolution.DAY), Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (!string.IsNullOrEmpty(bean.DescLast)) doc.Add(new Field("desc_last", bean.DescLast, Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (bean.ReadUsersBitIds1 != -1) doc.Add(new Field("read_usr_bit1", bean.ReadUsersBitIds1.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.ReadUsersBitIds2 != -1) doc.Add(new Field("read_usr_bit1", bean.ReadUsersBitIds2.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.LastUpdate != DateTime.MinValue) doc.Add(new Field("last_update", DateTools.DateToString(bean.LastUpdate, DateTools.Resolution.DAY), Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (bean.StartDate != DateTime.MinValue) doc.Add(new Field("start_date", DateTools.DateToString(bean.StartDate, DateTools.Resolution.DAY), Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (bean.IsAllDay) doc.Add(new Field("is_all_day", "1", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                else doc.Add(new Field("is_all_day", "0", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));
                if (bean.DestReminderDate != DateTime.MinValue) doc.Add(new Field("dest_rem_date", DateTools.DateToString(bean.DestReminderDate, DateTools.Resolution.DAY), Lucene.Net.Documents.Field.Store.NO, Lucene.Net.Documents.Field.Index.ANALYZED));
                if (bean.ReccurenceId != -1) doc.Add(new Field("reccurence_id", bean.ReccurenceId.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NO));

                idxModif.AddDocument(doc);
                idxModif.Optimize();
                idxModif.Commit();

                numIndexed = idxModif.MaxDoc();
                idxModif.Dispose();

            }
            catch
            {
                if (writer != null)
                {
                    idxModif.Optimize();
                    idxModif.Commit();
                    idxModif.Dispose();
                }
                throw;
            }
            return numIndexed;
        }
예제 #2
0
        /// <summary>
        /// Get publication list
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="lng"></param>
        /// <returns></returns>
        public Dictionary<string, IssueDocumentDto> GetIssuesIndexList(int start, int end, string lng)
        {
            Dictionary<string, IssueDocumentDto> issuesList = new Dictionary<string, IssueDocumentDto>();
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(ConfigurationController.MainConnectionString))
                {
                    SqlCommand command = new SqlCommand("SP_BW_ISSUES_SEARCH", sqlConn);
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@StartRowIndex", start);
                    command.Parameters.AddWithValue("@EndRowIndex", end);

                    sqlConn.Open();
                    SqlDataReader dr = command.ExecuteReader();

                    IssueDocumentDto obj = null;

                    while (dr.Read())
                    {
                        obj = new IssueDocumentDto();
                        obj.Id = dr.GetInt32(dr.GetOrdinal("Issue_ID"));

                        if (!dr.IsDBNull(dr.GetOrdinal("Issue_Company_ID")))
                            obj.CompanyId = dr.GetInt32(dr.GetOrdinal("Issue_Company_ID"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Issue_ID_Per_Company")))
                            obj.IssueIdPerCompany = dr.GetInt32(dr.GetOrdinal("Issue_ID_Per_Company"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Issue_Title")))
                            obj.IssueTitle = dr.GetString(dr.GetOrdinal("Issue_Title"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Priority_ID")))
                            obj.PriorityId = dr.GetInt32(dr.GetOrdinal("Priority_ID"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Status_ID")))
                            obj.StatusId = dr.GetInt32(dr.GetOrdinal("Status_ID"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Cur_Owner")))
                            obj.CurrentOwner = dr.GetString(dr.GetOrdinal("Cur_Owner"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Last_Owner")))
                            obj.LastOwner = dr.GetString(dr.GetOrdinal("Last_Owner"));

                        if (!dr.IsDBNull(dr.GetOrdinal("Project_Name")))
                            obj.ProjectName = dr.GetString(dr.GetOrdinal("Project_Name"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Assigned_CurUser_Date")))
                            obj.AssignedCUDate = dr.GetDateTime(dr.GetOrdinal("Assigned_CurUser_Date"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Destination_Date")))
                            obj.DestinationDate = dr.GetDateTime(dr.GetOrdinal("Destination_Date"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Desc_Last")))
                            obj.DescLast = dr.GetString(dr.GetOrdinal("Desc_Last"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Read_Users_BitIDs1")))
                            obj.ReadUsersBitIds1 = dr.GetInt64(dr.GetOrdinal("Read_Users_BitIDs1"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Read_Users_BitIDs2")))
                            obj.ReadUsersBitIds2 = dr.GetInt64(dr.GetOrdinal("Read_Users_BitIDs2"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Last_Update_Date")))
                            obj.LastUpdate = dr.GetDateTime(dr.GetOrdinal("Last_Update_Date"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Start_Date")))
                            obj.StartDate = dr.GetDateTime(dr.GetOrdinal("Start_Date"));
                        if (!dr.IsDBNull(dr.GetOrdinal("IsAllDay")))
                            obj.IsAllDay = dr.GetBoolean(dr.GetOrdinal("IsAllDay"));
                        if (!dr.IsDBNull(dr.GetOrdinal("Destination_Reminder_Date")))
                            obj.DestReminderDate = dr.GetDateTime(dr.GetOrdinal("Destination_Reminder_Date"));
                        if (!dr.IsDBNull(dr.GetOrdinal("RecurrenceId")))
                            obj.ReccurenceId = dr.GetInt32(dr.GetOrdinal("RecurrenceId"));

                        issuesList.Add("I" + obj.Id.ToString(), obj);
                    }

                    sqlConn.Close();
                }

            }
            catch (Exception ex)
            {
                T.TraceError("Error GetPublicationIndexList CN: {0}, start: {1}, end: {2}, language {3}", CLASS_NAME, start, end, lng);
                T.TraceError(ex);
                throw ex;
            }

            return issuesList;
        }
예제 #3
0
        /// <summary>
        /// Indexing a single publication, passed as parameter
        /// </summary>
        /// <param name="bean"></param>
        /// <param name="lng"></param>
        /// <returns></returns>
        public static int IndexPublication(IssueDocumentDto bean, string lng)
        {
            Analyzer analyzer = new SpanishAnalyzer(ConfigurationController.Stop_Words);

            if (!string.IsNullOrEmpty(ConfigurationController.IndexRootPath))
            {
                Directory indexDir = FSDirectory.Open(new System.IO.DirectoryInfo(ConfigurationController.IndexRootPath + "/ES/IDX"));
                if (!lng.ToLower().Trim().Equals("es"))
                    indexDir = FSDirectory.Open(new System.IO.DirectoryInfo(ConfigurationController.IndexRootPath + "/EN/IDX"));

                LuceneDao dao = new LuceneDao();
                dao.Analizer = analyzer;

                return dao.IndexPublication(indexDir, bean);

            }

            return -1;
        }