示例#1
0
        public void GetForumThreadNew()
        {
            int    forumAreaID    = ProviderBase.Framework.Utility.GetFormValue <int>("ID", 0);
            string templatePrefix = ProviderBase.Framework.Utility.GetFormValue <string>("TemplatePrefix", "");
            string templateName   = "ForumThreadNew.htm";
            string templateFinal  = "";

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

            if (forumAreaID > 0)
            {
                ForumArea    forumArea        = null;
                TemplateFile templateFileTemp = null;

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

                forumArea = DataProvider.SelectSingle <ForumArea>(new ForumArea()
                {
                    ForumAreaID = forumAreaID
                }, this.Website.WebsiteConnection.ConnectionString);

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

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

                    if (forumGroupUserRoleLink?.UserRoleLevelID > 0)
                    {
                        templateFileTemp.BindTemplateFileContent(forumArea);

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

                        this.AjaxResult.Data.Add(templateFinal);
                        this.AjaxResult.Message = "Get forum thread 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 ID supplied";
                this.AjaxResult.Status  = AjaxResultStatus.Failed;
            }
        }
示例#2
0
        public void NewForumThreadMessage()
        {
            int    forumThreadID          = ProviderBase.Framework.Utility.GetFormValue <int>("ForumThreadID", 0);
            string forumThreadMessageText = ProviderBase.Framework.Utility.GetFormValue <string>("ForumThreadMessage", "");
            string action = ProviderBase.Framework.Utility.GetFormValue <string>("Action", "");

            switch (action.ToLower())
            {
            case "submit":
                if (forumThreadID > 0)
                {
                    ForumThread forumThreadItem = null;

                    forumThreadItem = ProviderBase.Data.Providers.DataProvider.SelectSingle <ForumThread>(new ForumThread()
                    {
                        ForumThreadID = forumThreadID
                    }, this.Website.WebsiteConnection.ConnectionString);

                    if (forumThreadItem?.ForumThreadID > 0)
                    {
                        ForumArea forumArea = null;

                        forumArea = ProviderBase.Data.Providers.DataProvider.SelectSingle <ForumArea>(new ForumArea()
                        {
                            ForumAreaID = forumThreadItem.ForumAreaID
                        }, this.Website.WebsiteConnection.ConnectionString);

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

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

                            if (forumGroupUserRoleLink?.UserRoleLevelID > 0)
                            {
                                if (string.IsNullOrEmpty(forumThreadMessageText) == false)
                                {
                                    CharacterUser      characterUser      = null;
                                    ForumThreadMessage forumThreadMessage = null;

                                    characterUser = ProviderBase.Data.Providers.DataProvider.SelectSingle <CharacterUser>(new CharacterUser()
                                    {
                                        UserID = this.User.UserID
                                    }, this.Website.WebsiteConnection.ConnectionString);

                                    forumThreadMessage = new ForumThreadMessage();
                                    forumThreadMessage.ForumThreadID            = forumThreadID;
                                    forumThreadMessage.ForumThreadMessageTypeID = ForumThreadMessageType.Header;
                                    forumThreadMessage.CharacterUserID          = characterUser.CharacterUserID;
                                    forumThreadMessage.MessageText          = forumThreadMessageText;
                                    forumThreadMessage.ForumThreadMessageID = ProviderBase.Data.Providers.DataProvider.Insert <ForumThreadMessage>(forumThreadMessage, this.Website.WebsiteConnection.ConnectionString);

                                    this.AjaxResult.Status  = AjaxResultStatus.Success;
                                    this.AjaxResult.Message = "New forum thread success";
                                }
                                else
                                {
                                    this.AjaxResult.Status  = AjaxResultStatus.Failed;
                                    this.AjaxResult.Message = "No forum thread message supplied";
                                }
                            }
                            else
                            {
                                this.AjaxResult.Redirect = Utility.GetRedirect(this.Context, RedirectReason.InvalidPermission);
                                this.AjaxResult.Status   = AjaxResultStatus.Redirect;
                            }
                        }
                        else
                        {
                            this.AjaxResult.Status  = AjaxResultStatus.Failed;
                            this.AjaxResult.Message = "Invalid forum area";
                        }
                    }
                    else
                    {
                        this.AjaxResult.Status  = AjaxResultStatus.Failed;
                        this.AjaxResult.Message = "Invalid forum thread ID supplied";
                    }
                }
                else
                {
                    this.AjaxResult.Status  = AjaxResultStatus.Failed;
                    this.AjaxResult.Message = "No forum thread ID supplied";
                }
                break;

            case "preview":
                this.AjaxResult.Data.Add(NewForumThreadMessagePreview());
                this.AjaxResult.Status  = AjaxResultStatus.Success;
                this.AjaxResult.Message = "New forum thread preview success";
                break;
            }
        }
示例#3
0
        public void GetForumThread()
        {
            int    forumThreadID  = 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   = "ForumThreadRepeat.htm";
            string templateFinal  = "";

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

            if (forumThreadID > 0)
            {
                ForumThread forumThreadItem     = null;
                DataProviderResultFilter paging = null;

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

                forumThreadItem = DataProvider.SelectSingleFull(new ForumThread()
                {
                    ForumThreadID = forumThreadID
                }, this.Website.WebsiteConnection.ConnectionString, paging);

                if (forumThreadItem?.ForumThreadID > 0)
                {
                    ForumArea forumAreaItem = null;

                    forumAreaItem = ProviderBase.Data.Providers.DataProvider.SelectSingle <ForumArea>(new ForumArea()
                    {
                        ForumAreaID = forumThreadItem.ForumAreaID
                    }, this.Website.WebsiteConnection.ConnectionString);

                    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;
                            ForumThreadView forumThreadView  = null;

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

                            forumThreadItem.PageSize = pageSize; // Override page size so BindTemplateFileContentRepeat is correct

                            templateFileTemp.BindTemplateFileContent(forumAreaItem, "FORUMAREA");
                            templateFileTemp.BindTemplateFileContent(forumThreadItem);
                            templateFileTemp.BindTemplateFileContentRepeat(forumThreadItem);

                            if (forumThreadItem.ThreadMessageList?.Count > 0)
                            {
                                PagingItem pagingItem = null;

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

                                templateFileTemp.BindTemplateFileContentRepeatSingle("$PAGING$", Utility.GeneratePaging(pagingItem, forumThreadItem.ThreadMessageList[0].PageCurrent, forumThreadItem.ThreadMessageList[0].PageTotal));
                                templateFileTemp.BindTemplateFileContentRepeatSingle("$PAGESIZE$", pageSize);

                                foreach (ForumThreadMessage forumThreadMessageItem in forumThreadItem.ThreadMessageList)
                                {
                                    CharacterUser characterUser = null;

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

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

                                forumThreadView = new ForumThreadView();
                                forumThreadView.CharacterUserID   = this.User.UserID;
                                forumThreadView.ForumThreadID     = forumThreadID;
                                forumThreadView.CreateDate        = DateTime.Now;
                                forumThreadView.ForumThreadViewID = DataProvider.Insert <ForumThreadView>(forumThreadView, this.Website.WebsiteConnection.ConnectionString);
                            }
                            else
                            {
                                templateFileTemp.BindTemplateFileContentSingle("$PAGING$", "");
                            }

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

                            this.AjaxResult.Data.Add(templateFinal);
                            this.AjaxResult.Message = "Get forum thread 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 thread found";
                    this.AjaxResult.Status  = AjaxResultStatus.Failed;
                }
            }
            else
            {
                this.AjaxResult.Message = "No forum thread ID supplied";
                this.AjaxResult.Status  = AjaxResultStatus.Failed;
            }
        }