Esempio n. 1
0
        public void GetForumIndex()
        {
            string            templatePrefix = ProviderBase.Framework.Utility.GetFormValue <string>("TemplatePrefix", "");
            string            templateName   = "ForumGroupRepeat.htm";
            string            templateFinal  = "";
            List <ForumGroup> forumGroupList = null;

            if (string.IsNullOrEmpty(templatePrefix))
            {
                templatePrefix = this.Website.WebsiteTemplatePrefix;
            }

            forumGroupList = DataProvider.SelectAll(new ForumGroup(), this.Website.WebsiteConnection.ConnectionString);

            if (forumGroupList?.Count > 0)
            {
                TemplateFile templateFileTemp = null;

                templateFileTemp = new TemplateFile(templatePrefix + templateName, this.Website.WebsiteTemplateFolder);

                foreach (ForumGroup forumGroupItem in forumGroupList)
                {
                    ForumGroupUserRoleLink forumGroupUserRoleLink = null;

                    forumGroupUserRoleLink = ProviderBase.Data.Providers.DataProvider.SelectSingleUsingDefault <ForumGroupUserRoleLink>(new ForumGroupUserRoleLink()
                    {
                        UserRoleTypeID = this.User.UserRoleTypeID,
                        ForumGroupID   = forumGroupItem.ForumGroupID
                    }, this.Website.WebsiteConnection.ConnectionString, "UserRoleTypeID", "ForumGroupID");

                    if (forumGroupUserRoleLink?.UserRoleLevelID > 0)
                    {
                        List <ForumArea> forumAreaList = null;

                        forumAreaList = DataProvider.Select(new ForumArea()
                        {
                            ForumGroupID = forumGroupItem.ForumGroupID
                        }, this.Website.WebsiteConnection.ConnectionString);

                        if (forumAreaList?.Count > 0)
                        {
                            templateFileTemp.BindTemplateFileContentRepeat(forumGroupItem);

                            foreach (ForumArea forumAreaItem in forumAreaList)
                            {
                                int topicCount = 0;
                                int postCount  = 0;
                                ForumThreadMessage forumThreadMessageNewest = null;
                                CharacterUser      characterUserNewestForumThreadMessage = null;

                                topicCount = DataProvider.SelectCount <ForumArea, ForumThread>(forumAreaItem, this.Website.WebsiteConnection.ConnectionString);
                                postCount  = DataProvider.SelectCount <ForumArea, ForumThreadMessage>(forumAreaItem, this.Website.WebsiteConnection.ConnectionString);

                                forumThreadMessageNewest = DataProvider.SelectNewest <ForumArea, ForumThreadMessage>(forumAreaItem, this.Website.WebsiteConnection.ConnectionString);

                                characterUserNewestForumThreadMessage = DataProvider.SelectSingleFull <CharacterUser>(new CharacterUser()
                                {
                                    CharacterUserID = forumThreadMessageNewest.CharacterUserID
                                }, this.Website.WebsiteConnection.ConnectionString);

                                templateFileTemp.BindTemplateFileContentRepeatItem(new List <object>()
                                {
                                    forumAreaItem, forumThreadMessageNewest, characterUserNewestForumThreadMessage
                                });

                                templateFileTemp.BindTemplateFileContentRepeatItemSingle("$FORUMTHREADCOUNT$", topicCount);
                                templateFileTemp.BindTemplateFileContentRepeatItemSingle("$FORUMTHREADMESSAGECOUNT$", postCount);
                            }

                            templateFileTemp.TemplateFinaliseRepeat();
                        }
                    }
                }

                templateFinal += templateFileTemp.TemplateFinalise(this.User);

                this.AjaxResult.Data.Add(templateFinal);
                this.AjaxResult.Message = "Get forum index success";
                this.AjaxResult.Status  = AjaxResultStatus.Success;
            }

            else
            {
                this.AjaxResult.Message = "No forum index data found";
                this.AjaxResult.Status  = AjaxResultStatus.Unassigned;
            }
        }