public TopicSearchResults SearchTopics(int portalId, int moduleId, int userId, string forumIds, string searchText, int rowIndex, int maxRows, string searchId, SettingsInfo mainSettings)
        {
            int searchIdValue;
            int.TryParse(searchId, out searchIdValue);

            var result = new TopicSearchResults();

            if (!string.IsNullOrWhiteSpace(forumIds))
                forumIds = forumIds.Replace(';', ':');

            var ds = ActiveForums.DataProvider.Instance().Search(portalId, moduleId, userId, searchIdValue, rowIndex, maxRows, searchText, 0, 0, 0, 0, null, forumIds, null, 0, 0, 1, mainSettings.FullText);

            if(ds.Tables.Count > 2)
                return null;

            var dtSummary = ds.Tables[0];
            var dtResults = ds.Tables[1];

            result.SearchId = dtSummary.Rows[0].GetInt("SearchId");
            result.TotalTopics = dtSummary.Rows[0].GetInt("TotalRecords");
            result.Topics = new List<ForumTopic>(dtResults.Rows.Count);

            foreach(var row in dtResults.AsEnumerable())
            {
                ((List<ForumTopic>)result.Topics).Add(new ForumTopic
                                                          {
                                                            ForumId = row.GetInt("ForumId"),
                                                            ForumName = row.GetString("ForumName"),
                                                            LastReplyId = row.GetInt("LastReplyId"),
                                                            TopicId = row.GetInt("TopicId"),
                                                            ViewCount = row.GetInt("ViewCount"),
                                                            ReplyCount = row.GetInt("ReplyCount"),
                                                            IsLocked = row.GetBoolean("IsLocked"),
                                                            IsPinned = row.GetBoolean("IsPinned"),
                                                            TopicIcon = row.GetString("TopicIcon"),
                                                            StatusId = row.GetInt("StatusId"),
                                                            AnnounceStart = row.GetDateTime("AnnounceStart"),
                                                            AnnounceEnd = row.GetDateTime("AnnounceEnd"),
                                                            TopicType = row.GetString("TopicType"),
                                                            Subject = row.GetString("Subject"),
                                                            Summary = row.GetString("Summary"),
                                                            AuthorId = row.GetInt("AuthorId"),
                                                            AuthorName = row.GetString("AuthorName"),
                                                            Body = row.GetString("Body"),
                                                            LastReplyBody = row.GetString("LastReplyBody"),
                                                            DateCreated = row.GetDateTime("DateCreated"),
                                                            AuthorUserName = row.GetString("AuthorUserName"),
                                                            AuthorFirstName = row.GetString("AuthorFirstName"),
                                                            AuthorLastName = row.GetString("AuthorLastName"),
                                                            AuthorDisplayName = row.GetString("AuthorDisplayName"),
                                                            LastReplySubject = row.GetString("LastReplySubject"),
                                                            LastReplySummary = row.GetString("LastReplySummary"),
                                                            LastReplyAuthorId = row.GetInt("LastReplyAuthorId"),
                                                            LastReplyAuthorName = row.GetString("LastReplyAuthorName"),
                                                            LastReplyUserName = row.GetString("LastReplyUserName"),
                                                            LastReplyFirstName = row.GetString("LastReplyFirstName"),
                                                            LastReplyLastName = row.GetString("LastReplyLastName"),
                                                            LastReplyDisplayName = row.GetString("LastReplyDisplayName"),
                                                            LastReplyDate = row.GetDateTime("LastReplyDate"),
                                                            UserLastReplyRead = row.GetInt("UserLastReplyRead"),
                                                            UserLastTopicRead = row.GetInt("UserLastTopicRead"),
                                                            SubscriptionType = row.GetInt("SubscriptionType")
                                                          });
            }

            return result;
        }
예제 #2
0
        public TopicSearchResults SearchTopics(int portalId, int moduleId, int userId, string forumIds, string searchText, int rowIndex, int maxRows, string searchId, SettingsInfo mainSettings)
        {
            int searchIdValue;

            int.TryParse(searchId, out searchIdValue);

            var result = new TopicSearchResults();

            if (!string.IsNullOrWhiteSpace(forumIds))
            {
                forumIds = forumIds.Replace(';', ':');
            }

            var ds = ActiveForums.DataProvider.Instance().Search(portalId, moduleId, userId, searchIdValue, rowIndex, maxRows, searchText, 0, 0, 0, 0, null, forumIds, null, 0, 0, 1, mainSettings.FullText);

            if (ds.Tables.Count > 2)
            {
                return(null);
            }

            var dtSummary = ds.Tables[0];
            var dtResults = ds.Tables[1];

            result.SearchId    = dtSummary.Rows[0].GetInt("SearchId");
            result.TotalTopics = dtSummary.Rows[0].GetInt("TotalRecords");
            result.Topics      = new List <ForumTopic>(dtResults.Rows.Count);

            foreach (var row in dtResults.AsEnumerable())
            {
                ((List <ForumTopic>)result.Topics).Add(new ForumTopic
                {
                    ForumId              = row.GetInt("ForumId"),
                    ForumName            = row.GetString("ForumName"),
                    LastReplyId          = row.GetInt("LastReplyId"),
                    TopicId              = row.GetInt("TopicId"),
                    ViewCount            = row.GetInt("ViewCount"),
                    ReplyCount           = row.GetInt("ReplyCount"),
                    IsLocked             = row.GetBoolean("IsLocked"),
                    IsPinned             = row.GetBoolean("IsPinned"),
                    TopicIcon            = row.GetString("TopicIcon"),
                    StatusId             = row.GetInt("StatusId"),
                    AnnounceStart        = row.GetDateTime("AnnounceStart"),
                    AnnounceEnd          = row.GetDateTime("AnnounceEnd"),
                    TopicType            = row.GetString("TopicType"),
                    Subject              = row.GetString("Subject"),
                    Summary              = row.GetString("Summary"),
                    AuthorId             = row.GetInt("AuthorId"),
                    AuthorName           = row.GetString("AuthorName"),
                    Body                 = row.GetString("Body"),
                    LastReplyBody        = row.GetString("LastReplyBody"),
                    DateCreated          = row.GetDateTime("DateCreated"),
                    AuthorUserName       = row.GetString("AuthorUserName"),
                    AuthorFirstName      = row.GetString("AuthorFirstName"),
                    AuthorLastName       = row.GetString("AuthorLastName"),
                    AuthorDisplayName    = row.GetString("AuthorDisplayName"),
                    LastReplySubject     = row.GetString("LastReplySubject"),
                    LastReplySummary     = row.GetString("LastReplySummary"),
                    LastReplyAuthorId    = row.GetInt("LastReplyAuthorId"),
                    LastReplyAuthorName  = row.GetString("LastReplyAuthorName"),
                    LastReplyUserName    = row.GetString("LastReplyUserName"),
                    LastReplyFirstName   = row.GetString("LastReplyFirstName"),
                    LastReplyLastName    = row.GetString("LastReplyLastName"),
                    LastReplyDisplayName = row.GetString("LastReplyDisplayName"),
                    LastReplyDate        = row.GetDateTime("LastReplyDate"),
                    UserLastReplyRead    = row.GetInt("UserLastReplyRead"),
                    UserLastTopicRead    = row.GetInt("UserLastTopicRead"),
                    SubscriptionType     = row.GetInt("SubscriptionType")
                });
            }

            return(result);
        }