Exemplo n.º 1
0
        public void GetForumGroup()
        {
            int    forumGroupID   = ProviderBase.Framework.Utility.GetFormValue <int>("ID", 0);
            string templatePrefix = ProviderBase.Framework.Utility.GetFormValue <string>("TemplatePrefix", "");
            string templateName   = "ForumGroupRepeat.htm";
            string templateFinal  = "";

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

            if (forumGroupID > 0)
            {
                ForumGroup forumGroupItem = null;

                forumGroupItem = DataProvider.SelectSingleFull(new ForumGroup()
                {
                    ForumGroupID = forumGroupID
                }, this.Website.WebsiteConnection.ConnectionString);

                if (forumGroupItem?.ForumGroupID > 0)
                {
                    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)
                    {
                        TemplateFile templateFileTemp = null;

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

                        templateFileTemp.BindTemplateFileContentRepeat(forumGroupItem);

                        foreach (ForumArea forumAreaItem in forumGroupItem.ThreadAreaList)
                        {
                            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);
                        }

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

                        this.AjaxResult.Data.Add(templateFinal);
                        this.AjaxResult.Message = "Get forum group success";
                        this.AjaxResult.Status  = AjaxResultStatus.Success;
                    }
                    else
                    {
                        this.AjaxResult.Redirect = Utility.GetRedirect(this.Context, RedirectReason.InvalidPermission);
                        this.AjaxResult.Status   = AjaxResultStatus.Redirect;
                    }
                }
                else
                {
                    this.AjaxResult.Message = "No forum group found";
                    this.AjaxResult.Status  = AjaxResultStatus.Failed;
                }
            }
            else
            {
                this.AjaxResult.Message = "No forum group ID supplied";
                this.AjaxResult.Status  = AjaxResultStatus.Failed;
            }
        }
Exemplo n.º 2
0
        public void GetForumArea()
        {
            int    forumAreaID    = ProviderBase.Framework.Utility.GetFormValue <int>("ID", 0);
            int    pageCurrent    = ProviderBase.Framework.Utility.GetFormValue <int>("PageCurrent", 1);
            int    pageSize       = ProviderBase.Framework.Utility.GetFormValue <int>("PageSize", 10);
            string templatePrefix = ProviderBase.Framework.Utility.GetFormValue <string>("TemplatePrefix", "");
            string templateName   = "ForumAreaRepeat.htm";
            string templateFinal  = "";

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

            if (forumAreaID > 0)
            {
                ForumArea forumAreaItem         = null;
                DataProviderResultFilter paging = null;

                paging = new DataProviderResultFilter();
                paging.SetPaging(typeof(ForumArea), typeof(List <ForumThread>), pageCurrent, pageSize);

                forumAreaItem = ProviderBase.Data.Providers.DataProvider.SelectSingleFull(new ForumArea()
                {
                    ForumAreaID = forumAreaID
                }, this.Website.WebsiteConnection.ConnectionString, paging);

                if (forumAreaItem?.ForumAreaID > 0)
                {
                    ForumGroupUserRoleLink forumGroupUserRoleLink = null;

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

                    if (forumGroupUserRoleLink?.UserRoleLevelID > 0)
                    {
                        TemplateFile templateFileTemp = null;

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

                        templateFileTemp.BindTemplateFileContent(forumAreaItem);
                        templateFileTemp.BindTemplateFileContentRepeat(forumAreaItem);

                        if (forumAreaItem?.ThreadList.Count > 0)
                        {
                            PagingItem pagingItem = null;

                            pagingItem = ProviderBase.Data.Utility.XMLDeseralize <PagingItem>(this.Context.Server.MapPath(@"/Resource/XML/") + "Conquest/ConquestGamingPaging.xml");

                            templateFileTemp.BindTemplateFileContentSingle("$PAGING$", Utility.GeneratePaging(pagingItem, forumAreaItem.ThreadList[0].PageCurrent, forumAreaItem.ThreadList[0].PageTotal));
                            templateFileTemp.BindTemplateFileContentSingle("$PAGESIZE$", pageSize);

                            foreach (ForumThread forumThreadItem in forumAreaItem.ThreadList)
                            {
                                int           postCount     = 0;
                                int           threadViews   = 0;
                                CharacterUser characterUser = null;

                                postCount   = DataProvider.SelectCount <ForumThread, ForumThreadMessage>(forumThreadItem, this.Website.WebsiteConnection.ConnectionString);
                                threadViews = DataProvider.SelectCount <ForumThread, ForumThreadView>(forumThreadItem, this.Website.WebsiteConnection.ConnectionString);

                                characterUser = DataProvider.SelectSingleFull <CharacterUser>(new CharacterUser()
                                {
                                    UserID = forumThreadItem.CharacterUserID
                                }, this.Website.WebsiteConnection.ConnectionString);

                                templateFileTemp.BindTemplateFileContentRepeatItem(new List <object>()
                                {
                                    forumThreadItem, characterUser
                                });

                                templateFileTemp.BindTemplateFileContentRepeatItemSingle("$FORUMTHREADMESSAGECOUNT$", (postCount - 1));
                                templateFileTemp.BindTemplateFileContentRepeatItemSingle("$FORUMTHREADVIEWCOUNT$", threadViews);
                            }
                        }
                        else
                        {
                            templateFileTemp.BindTemplateFileContentSingle("$PAGING$", "");
                        }

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

                        this.AjaxResult.Data.Add(templateFinal);
                        this.AjaxResult.Message = "Get forum area success";
                        this.AjaxResult.Status  = AjaxResultStatus.Success;
                    }
                    else
                    {
                        this.AjaxResult.Redirect = Utility.GetRedirect(this.Context, RedirectReason.InvalidPermission);
                        this.AjaxResult.Status   = AjaxResultStatus.Redirect;
                    }
                }
                else
                {
                    this.AjaxResult.Message = "No forum area found";
                    this.AjaxResult.Status  = AjaxResultStatus.Failed;
                }
            }
            else
            {
                this.AjaxResult.Message = "No forum area ID supplied";
                this.AjaxResult.Status  = AjaxResultStatus.Failed;
            }
        }