From 701dbd865d77bc780d83df04803404142b7b11e9 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 26 Feb 2015 06:36:38 +0100 Subject: [PATCH] Fixes DateTime indexed fields --- OurUmbraco.Site/config/ExamineIndex.config | 5 ++--- .../config/FileIndexerConfig.config | 4 ++-- .../Examine/DocumentationIndexConfig.cs | 2 +- our.umbraco.org/Examine/ExamineHelper.cs | 12 +--------- our.umbraco.org/Examine/ForumDataService.cs | 22 +++++++++---------- .../Examine/ProjectNodeIndexDataService.cs | 2 +- 6 files changed, 18 insertions(+), 29 deletions(-) diff --git a/OurUmbraco.Site/config/ExamineIndex.config b/OurUmbraco.Site/config/ExamineIndex.config index 3542ae8d..3e8df485 100644 --- a/OurUmbraco.Site/config/ExamineIndex.config +++ b/OurUmbraco.Site/config/ExamineIndex.config @@ -43,11 +43,10 @@ More information and documentation can be found on CodePlex: http://umbracoexami - - + @@ -64,7 +63,7 @@ More information and documentation can be found on CodePlex: http://umbracoexami - + diff --git a/OurUmbraco.Site/config/FileIndexerConfig.config b/OurUmbraco.Site/config/FileIndexerConfig.config index bf7482d9..26e19aa6 100644 --- a/OurUmbraco.Site/config/FileIndexerConfig.config +++ b/OurUmbraco.Site/config/FileIndexerConfig.config @@ -1,7 +1,7 @@  - - \ No newline at end of file + \ No newline at end of file diff --git a/our.umbraco.org/Examine/DocumentationIndexConfig.cs b/our.umbraco.org/Examine/DocumentationIndexConfig.cs index 71d99410..8dea1434 100644 --- a/our.umbraco.org/Examine/DocumentationIndexConfig.cs +++ b/our.umbraco.org/Examine/DocumentationIndexConfig.cs @@ -4,7 +4,7 @@ namespace our.Examine { public sealed class DocumentationIndexConfig : ConfigurationSection { - private static DocumentationIndexConfig settings = ConfigurationManager.GetSection("FileIndexerConfig") as DocumentationIndexConfig; + private static DocumentationIndexConfig settings = ConfigurationManager.GetSection("DocumentationIndexConfig") as DocumentationIndexConfig; public static DocumentationIndexConfig Settings { get { return settings; } } diff --git a/our.umbraco.org/Examine/ExamineHelper.cs b/our.umbraco.org/Examine/ExamineHelper.cs index 612662a7..b49340a1 100644 --- a/our.umbraco.org/Examine/ExamineHelper.cs +++ b/our.umbraco.org/Examine/ExamineHelper.cs @@ -25,16 +25,6 @@ namespace our.Examine new Exception(e.Message, e.InnerException)); } - public static string SerializeForLucene(this DateTime dateTime) - { - return dateTime.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture); - } - - public static DateTime DeserializeFromLucene(this string str) - { - return DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); - } - /// /// get dataset for single item reindex via event /// @@ -67,7 +57,7 @@ namespace our.Examine simpleDataSet.RowData.Add("body", body); simpleDataSet.RowData.Add("nodeName", headLine); - simpleDataSet.RowData.Add("updateDate", file.CreationTime.SerializeForLucene()); + simpleDataSet.RowData.Add("updateDate", file.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")); simpleDataSet.RowData.Add("nodeTypeAlias", "documentation"); simpleDataSet.RowData.Add("dateCreated", file.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")); diff --git a/our.umbraco.org/Examine/ForumDataService.cs b/our.umbraco.org/Examine/ForumDataService.cs index b262e202..ce565187 100644 --- a/our.umbraco.org/Examine/ForumDataService.cs +++ b/our.umbraco.org/Examine/ForumDataService.cs @@ -16,9 +16,9 @@ namespace our.Examine /// public class ForumDataService : ISimpleDataService { - private static int m_CurrentId = 0; + private static int _currentId = 0; - private static readonly object m_Locker = new object(); + private static readonly object _locker = new object(); #region ISimpleDataService Members @@ -62,12 +62,12 @@ namespace our.Examine { { "nodeName", SanitizeXmlString(currentTopic.Title.Replace("",string.Empty))}, { "body", SanitizeXmlString(umbraco.library.StripHtml(body.Replace("",string.Empty)))}, - { "updateDate", currentTopic.Updated.SerializeForLucene()}, + { "updateDate", currentTopic.Updated.ToString("yyyy-MM-dd HH:mm:ss")}, { "url", currentTopic.Url}, { "nodeTypeAlias","forum"}, - { "Created", currentTopic.Created.ToString()}, + { "Created", currentTopic.Created.ToString("yyyy-MM-dd HH:mm:ss")}, { "LatestComment", currentTopic.LatestComment.ToString()}, { "LatestReplyAuthor", currentTopic.LatestReplyAuthor.ToString()}, { "Locked", currentTopic.Locked.ToString()}, @@ -89,7 +89,7 @@ namespace our.Examine public SimpleDataSet CreateNewDocument() { - lock (m_Locker) + lock (_locker) { //JobDetailItem jobDetails = new JobDetailItem(); Topic forumTopic = new Topic(); @@ -98,12 +98,12 @@ namespace our.Examine string commentText = String.Empty; return new SimpleDataSet() { - NodeDefinition = new IndexedNode() { NodeId = (++m_CurrentId), Type = "forum" }, + NodeDefinition = new IndexedNode() { NodeId = (++_currentId), Type = "forum" }, RowData = new Dictionary() { { "Title", SanitizeXmlString(forumTopic.Title.Replace("",string.Empty))}, { "Body", SanitizeXmlString(umbraco.library.StripHtml(forumTopic.Body.Replace("",string.Empty)))}, - { "Created", forumTopic.Created.ToString()}, + { "Created", forumTopic.Created.ToString("yyyy-MM-dd HH:mm:ss")}, { "LatestComment", forumTopic.LatestComment.ToString()}, { "LatestReplyAuthor", forumTopic.LatestReplyAuthor.ToString()}, { "Locked", forumTopic.Locked.ToString()}, @@ -112,7 +112,7 @@ namespace our.Examine { "Replies", forumTopic.Replies.ToString()}, { "UrlName", forumTopic.UrlName.ToString()}, {"nodeTypeAlias","forum"}, - { "updateDate", forumTopic.Updated.SerializeForLucene()}, + { "updateDate", forumTopic.Updated.ToString("yyyy-MM-dd HH:mm:ss")}, { "CommentsContent", SanitizeXmlString(commentText.Replace("",string.Empty))} } }; @@ -121,7 +121,7 @@ namespace our.Examine public SimpleDataSet CreateNewDocument(int id) { - lock (m_Locker) + lock (_locker) { //JobDetailItem jobDetails = new JobDetailItem(); using(var ts = new TopicService()) @@ -143,7 +143,7 @@ namespace our.Examine { { "Title", SanitizeXmlString(forumTopic.Title.Replace("",string.Empty))}, { "Body", SanitizeXmlString(umbraco.library.StripHtml(forumTopic.Body.Replace("",string.Empty)))}, - { "Created", forumTopic.Created.ToString()}, + { "Created", forumTopic.Created.ToString("yyyy-MM-dd HH:mm:ss")}, { "LatestComment", forumTopic.LatestComment.ToString()}, { "LatestReplyAuthor", forumTopic.LatestReplyAuthor.ToString()}, { "Locked", forumTopic.Locked.ToString()}, @@ -152,7 +152,7 @@ namespace our.Examine { "Replies", forumTopic.Replies.ToString()}, { "UrlName", forumTopic.UrlName.ToString()}, {"nodeTypeAlias","forum"}, - { "updateDate", forumTopic.Updated.SerializeForLucene()}, + { "updateDate", forumTopic.Updated.ToString("yyyy-MM-dd HH:mm:ss")}, { "CommentsContent", SanitizeXmlString(commentText.Replace("",string.Empty))} } }; diff --git a/our.umbraco.org/Examine/ProjectNodeIndexDataService.cs b/our.umbraco.org/Examine/ProjectNodeIndexDataService.cs index e2789df2..a24b9931 100644 --- a/our.umbraco.org/Examine/ProjectNodeIndexDataService.cs +++ b/our.umbraco.org/Examine/ProjectNodeIndexDataService.cs @@ -26,7 +26,7 @@ namespace our.Examine simpleDataSet.RowData.Add("body", umbraco.library.StripHtml( project.GetProperty("description").Value.ToString() )) ; simpleDataSet.RowData.Add("nodeName", project.Name); - simpleDataSet.RowData.Add("updateDate", project.UpdateDate.SerializeForLucene()); + simpleDataSet.RowData.Add("updateDate", project.UpdateDate.ToString("yyyy-MM-dd HH:mm:ss")); simpleDataSet.RowData.Add("nodeTypeAlias", "project"); simpleDataSet.RowData.Add("url", project.Url );