41
41
using DotNetNuke . Entities . Users ;
42
42
using DotNetNuke . Services . Journal ;
43
43
using DotNetNuke . Services . Search ;
44
+ using DotNetNuke . Services . Search . Entities ;
44
45
using DotNetNuke . Services . Social . Messaging ;
45
46
using DotNetNuke . Services . Social . Notifications ;
46
47
@@ -53,7 +54,7 @@ namespace DotNetNuke.Modules.Announcements.Components.Business
53
54
/// The AnnouncementsController Class represents the Announcments Business Layer
54
55
/// Methods in this class call methods in the Data Layer
55
56
/// </summary>
56
- public class AnnouncementsController : IAnnouncementsController , ISearchable , IPortable
57
+ public class AnnouncementsController : ModuleSearchBase , IAnnouncementsController , IPortable
57
58
{
58
59
59
60
#region Public Methods
@@ -191,7 +192,7 @@ public IEnumerable<AnnouncementInfo> GetExpiredAnnouncements(int moduleId)
191
192
}
192
193
193
194
194
- public void AddAnnouncementToJournal ( AnnouncementInfo announcement , int tabId , String journalType )
195
+ public void AddAnnouncementToJournal ( AnnouncementInfo announcement , String journalType , ModuleInfo moduleInfo )
195
196
{
196
197
197
198
var objJournalType = JournalController . Instance . GetJournalType ( journalType ) ;
@@ -214,7 +215,7 @@ public void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, S
214
215
journalItem . JournalTypeId = objJournalType . JournalTypeId ;
215
216
journalItem . SecuritySet = "E," ;
216
217
217
- JournalController . Instance . SaveJournalItem ( journalItem , tabId ) ;
218
+ JournalController . Instance . SaveJournalItem ( journalItem , moduleInfo ) ;
218
219
219
220
}
220
221
@@ -248,48 +249,46 @@ public void SendNotifications(AnnouncementInfo announcement)
248
249
249
250
#endregion
250
251
251
- #region ISearchable Implementation
252
+ #region ModuleSearchBase Implementation
252
253
253
- /// <summary>
254
- /// GetSearchItems implements the ISearchable Interface
255
- /// </summary>
256
- /// <remarks>
257
- /// </remarks>
258
- public SearchItemInfoCollection GetSearchItems ( ModuleInfo ModInfo )
254
+ public override IList < SearchDocument > GetModifiedSearchDocuments ( ModuleInfo moduleInfo , DateTime beginDateUtc )
259
255
{
260
- Hashtable moduleSettings = Entities . Portals . PortalSettings . GetModuleSettings ( ModInfo . ModuleID ) ;
261
- int descriptionLength = 100 ;
262
- if ( Convert . ToString ( moduleSettings [ "descriptionLength" ] ) != "" )
256
+ var moduleSettings = moduleInfo . ModuleSettings ;
257
+ int descriptionLenght = 100 ;
258
+ if ( moduleSettings [ "descriptionLength" ] . ToString ( ) != "" )
263
259
{
264
- descriptionLength = int . Parse ( Convert . ToString ( moduleSettings [ "descriptionLength" ] ) ) ;
265
- if ( descriptionLength < 1 )
266
- {
267
- descriptionLength = 1950 ;
268
- //max length of description is 2000 char, take a bit less to make sure it fits...
269
- }
260
+ int . TryParse ( moduleSettings [ "descriptionLength" ] . ToString ( ) , out descriptionLenght ) ;
261
+ if ( descriptionLenght < 1 ) { descriptionLenght = 1950 ; }
262
+ //max length of description is 2000 char, take a bit less to make sure it fits...
270
263
}
271
-
272
- var searchItemCollection = new SearchItemInfoCollection ( ) ;
273
-
274
- IEnumerable < AnnouncementInfo > announcements = GetCurrentAnnouncements ( ModInfo . ModuleID , Null . NullDate ) ;
275
-
276
- foreach ( AnnouncementInfo objAnnouncement in announcements )
264
+ var searchDocuments = new List < SearchDocument > ( ) ;
265
+ var announcements = GetAnnouncements ( moduleInfo . ModuleID , beginDateUtc , DateTime . MaxValue ) ;
266
+ foreach ( var announcement in announcements )
277
267
{
278
- var tempVar = objAnnouncement ;
279
- string strContent = System . Web . HttpUtility . HtmlDecode ( tempVar . Title + " " + tempVar . Description ) ;
280
- string strDescription =
281
- HtmlUtils . Shorten ( HtmlUtils . Clean ( System . Web . HttpUtility . HtmlDecode ( tempVar . Description ) , false ) ,
282
- descriptionLength , "..." ) ;
283
- var searchItem = new SearchItemInfo ( ModInfo . ModuleTitle + " - " + tempVar . Title , strDescription ,
284
- tempVar . CreatedByUserID , tempVar . PublishDate . Value , ModInfo . ModuleID ,
285
- tempVar . ItemID . ToString ( CultureInfo . InvariantCulture ) , strContent ,
286
- "ItemID=" + tempVar . ItemID . ToString ( CultureInfo . InvariantCulture ) ) ;
287
- searchItemCollection . Add ( searchItem ) ;
268
+ var document = new SearchDocument ( ) ;
269
+ document . AuthorUserId = announcement . CreatedByUserID ;
270
+ document . Body = announcement . Description ;
271
+ document . CultureCode = moduleInfo . CultureCode ;
272
+ document . Description = announcement . Description ;
273
+ document . IsActive = CheckIfAnnouncementIsActive ( announcement ) ;
274
+ document . ModifiedTimeUtc = announcement . LastModifiedOnDate ;
275
+ document . ModuleDefId = moduleInfo . ModuleDefID ;
276
+ document . ModuleId = moduleInfo . ModuleID ;
277
+ document . PortalId = moduleInfo . PortalID ;
278
+ document . TabId = moduleInfo . TabID ;
279
+ document . Title = announcement . Title ;
280
+ document . UniqueKey = moduleInfo . ModuleID . ToString ( ) ;
281
+ searchDocuments . Add ( document ) ;
288
282
}
283
+ return searchDocuments ;
284
+ }
289
285
290
- return searchItemCollection ;
286
+ private bool CheckIfAnnouncementIsActive ( AnnouncementInfo announcement )
287
+ {
288
+ return ( announcement . PublishDate < DateTime . Now && ( announcement . ExpireDate == null || announcement . ExpireDate > DateTime . Now ) ) ;
291
289
}
292
290
291
+
293
292
#endregion
294
293
295
294
#region IPortable Implementation
@@ -440,7 +439,7 @@ private AnnouncementInfo ImportAnnouncement(XmlNode xmlAnnouncement)
440
439
{
441
440
return null ;
442
441
}
443
- }
442
+ }
444
443
445
444
#endregion
446
445
0 commit comments