CommunityStarterKit之SectionInfo类及数据库中表和操作

原创 2007年10月09日 10:37:00

namespace ASPNET.StarterKit.Communities {

 

    using System;

    using System.Collections;

    using System.Data;

    //*********************************************************************

    //

    // SectionInfo Class

    //

    // Represents all the information about a section.

    //

    //*********************************************************************

 

    public class SectionInfo {

        int _id;

        int _communityID;

        string _name;

        string _title;

        string _menuTitle;

        string _path;

        string _description;

        bool _isEnabled;

        bool _isSystem;

        int _pageType;

        bool _isWebBoxesInherited;

        string[] _webBoxes;

        int _webBoxDisplayMode;

        bool _isWebServiceBoxesInherited;

        string[] _webServiceBoxes;

        int _webServiceBoxDisplayMode;

        string _skin;

        string _style;

        int _parentSectionID;

        string _logo;

        string _pageHeader;

        string _pageFooter;

        string _footer;

        string _pageMetaKeys;

        string _pageMetaDesc;

        string[] _viewRoles;

        string[] _addRoles;

        string[] _editRoles;

        string[] _deleteRoles;

        int _recordsPerPage = 10;

        bool _enableTopics;

        bool _enableComments;

        string[] _commentRoles;

        bool _enableModeration;

        string[] _moderateRoles;

        bool _enableRatings;

        bool _enableCommentRatings;

        string[] _rateRoles;

        bool _enableNotifications;

        bool _inheritTransformations;

        string _transformations;

        bool _isSectionWebService;

        string _webServicePassword;

        AllowHtml _allowHtmlInput;

        AllowHtml _allowCommentHtmlInput;

        string _content;

 

 

        //*********************************************************************

        //

        // ID Property

        //

        // Represents the section ID.

        //

        //*********************************************************************

 

        public int ID {

            get { return _id; }

        }

 

 

        //*********************************************************************

        //

        // CommunityID Property

        //

        // Represents the community associated with the section.

        //

        //*********************************************************************

 

        public int CommunityID {

            get { return _communityID; }

        }

 

 

        //*********************************************************************

        //

        // Name Property

        //

        // Represents the section name which is used when building

        // the section URL.

        //

        //*********************************************************************

       

        public string Name {

            get { return _name; }

        }

 

 

        //*********************************************************************

        //

        // Path Property

        //

        // Represents the section URL.

        //

        //*********************************************************************

 

        public string Path {

            get { return _path; }

        }

 

 

 

        //*********************************************************************

        //

        // Title Property

        //

        // Represents the full name of the section.

        //

        //*********************************************************************

       

        public string Title {

            get { return _title; }

        }

 

 

 

        //*********************************************************************

        //

        // MenuTitle Property

        //

        // Represents the title of the section displayed in menus.

        //

        //*********************************************************************

       

        public string MenuTitle {

            get { return _menuTitle; }

        }

 

 

        //*********************************************************************

        //

        // BriefDescription Property

        //

        // Represents the brief description of the section.

        //

        //*********************************************************************

 

        public string Description {

            get { return _description; }

        }

 

 

 

 

        //*********************************************************************

        //

        // IsEnabled Property

        //

        // When false, section is not displayed in menus.

        //

        //*********************************************************************

       

        public bool IsEnabled {

            get { return _isEnabled;}

        }

 

 

 

        //*********************************************************************

        //

        // IsSystem Property

        //

        // When true, section is a system section (for example, the home section).

        //

        //*********************************************************************

       

        public bool IsSystem {

            get { return _isSystem;}

        }

 

 

 

        //*********************************************************************

        //

        // PageType Property

        //

        // Represents the type of content contained in the section.

        //

        //*********************************************************************

       

        public int PageType {

            get { return _pageType; }

        }

 

 

 

 

        //*********************************************************************

        //

        // IsWebBoxesInherited Property

        //

        // Indicates whether Web boxes are inherited from parent section.

        //

        //*********************************************************************

       

        public bool IsWebBoxesInherited {

            get { return _isWebBoxesInherited; }

        }

 

 

        //*********************************************************************

        //

        // WebBoxes Property

        //

        // Represents the Web boxes displayed in this section.

        //

        //*********************************************************************

       

        public string[] WebBoxes {

            get { return _webBoxes; }

            set { _webBoxes = value; }

        }

 

 

        //*********************************************************************

        //

        // WebBoxDisplayMode Property

        //

        // Indicates how Web boxes should be displayed.

        //

        //*********************************************************************

       

        public int WebBoxDisplayMode {

            get { return _webBoxDisplayMode; }

        }

 

 

        //*********************************************************************

        //

        // IsWebSeriveBoxesInherited Property

        //

        // Indicates whether Web service boxes are inherited

        // from parent section.

        //

        //*********************************************************************

       

        public bool IsWebServiceBoxesInherited {

            get { return _isWebServiceBoxesInherited; }

        }

 

 

        //*********************************************************************

        //

        // WebServiceBoxes Property

        //

        // Represents the Web service boxes for this section.

        //

        //*********************************************************************

       

        public string[] WebServiceBoxes {

            get { return _webServiceBoxes; }

            set { _webServiceBoxes = value; }

        }

 

 

        //*********************************************************************

        //

        // WebServiceBoxDisplayMode Property

        //

        // Indicates how Web service boxes are displayed.

        //

        //*********************************************************************

       

        public int WebServiceBoxDisplayMode {

            get { return _webServiceBoxDisplayMode; }

        }

 

 

        //*********************************************************************

        //

        // Skin Property

        //

        // Represents the page skin used for this section.

        //

        //*********************************************************************

       

        public string Skin {

            get { return _skin; }

        }

       

 

        //*********************************************************************

        //

        // Style Property

        //

        // Represents the cascading style sheet applied to this section.

        //

        //*********************************************************************

        

        public string Style {

            get { return _style; }

        }

       

 

        //*********************************************************************

        //

        // ParentSectionID Property

        //

        // Represents the parent section of this section.

        //

        //*********************************************************************

       

        public int ParentSectionID {

            get { return _parentSectionID; }

        }

 

 

        //*********************************************************************

        //

        // Logo Property

        //

        // Represents the image that appears for this section.

        //

        //*********************************************************************

        

        public string Logo {

            get { return _logo; }

        }

 

 

        //*********************************************************************

        //

        // Page Header Property

        //

        // Represents the page header text.

        //

        //*********************************************************************

       

        public string PageHeader {

            get { return _pageHeader; }

        }

 

        //*********************************************************************

        //

        // Page Footer Property

        //

        // Represents the page footer text.

        //

        //*********************************************************************

       

        public string PageFooter {

            get { return _pageFooter; }

        }

 

 

        //*********************************************************************

        //

        // Footer Property

        //

        // Represents the very bottom footer text.

        //

        //*********************************************************************

       

        public string Footer {

            get { return _footer; }

        }

 

 

        //*********************************************************************

        //

        // PageMetaDesc Property

        //

        // Represents the meta description.

        //

        //*********************************************************************

       

        public string PageMetaDesc {

            get { return _pageMetaDesc; }

        }

 

 

        //*********************************************************************

        //

        // PageMetaKeys Property

        //

        // Represents the page meta keys.

        //

        //*********************************************************************

       

        public string PageMetaKeys {

            get { return _pageMetaKeys; }

        }

 

 

        //*********************************************************************

        //

        // ViewRoles Property

        //

        // Represents the roles of users who can view pages in this section.

        //

        //*********************************************************************

               

        public string[] ViewRoles {

            get { return _viewRoles; }

        }

 

 

        //*********************************************************************

        //

        // AddRoles Property

        //

        // Represents the roles of users who can add pages to this section.

        //

        //*********************************************************************

                       

        public string[] AddRoles {

            get { return _addRoles; }

        }

 

 

        //*********************************************************************

        //

        // EditRoles Property

        //

        // Represents the roles of users who can edit pages in this section.

        //

        //*********************************************************************

                       

        public string[] EditRoles {

            get { return _editRoles; }

        }

 

 

        //*********************************************************************

        //

        // DeleteRoles Property

        //

        // Represents the roles of users who can delete pages in this section.

        //

        //*********************************************************************

                       

        public string[] DeleteRoles {

            get { return _deleteRoles; }

        }

     

 

        //*********************************************************************

        //

        // RecordsPerPage Property

        //

        // Represents the number of content items to display in the

        // section default page.

        //

        //*********************************************************************

                       

        public int RecordsPerPage {

            get { return _recordsPerPage; }

        }

 

 

        //*********************************************************************

        //

        // EnableTopics Property

        //

        // Indicates whether content in this section should be

        // categorized by topic.

        //

        //*********************************************************************

                        

        public bool EnableTopics {

            get { return _enableTopics; }

        }

 

 

        //*********************************************************************

        //

        // EnableComments Property

        //

        // Indicates whether users should be allowed to add comments to

        // content items in this section.

        //

        //*********************************************************************

                       

        public bool EnableComments {

            get { return _enableComments; }

        }

 

 

        //*********************************************************************

        //

        // CommentRoles Property

        //

        // Represents the roles of users who can comment on pages in this section.

        //

        //*********************************************************************

                       

        public string[] CommentRoles {

            get { return _commentRoles; }

        }

 

 

        //*********************************************************************

        //

        // EnableModeration Property

        //

        // Indicates whether content must be moderated before it is

        // displayed..

        //

        //*********************************************************************

                       

        public bool EnableModeration {

            get { return _enableModeration; }

        }

 

 

        //*********************************************************************

        //

        // ModerateRoles Property

        //

        // Represents the roles of users who can moderate pages in this section.

        //

        //*********************************************************************

                       

        public string[] ModerateRoles {

            get { return _moderateRoles; }

       

        }

 

 

        //*********************************************************************

        //

        // EnableRatings Property

        //

        // Indicates whether users can rate content in this section.

        //

        //*********************************************************************

                       

        public bool EnableRatings {

            get { return _enableRatings; }

        }

 

 

 

        //*********************************************************************

        //

        // EnableCommentRatings Property

        //

        // Indicates whether users can rate comments in this section.

        //

        //*********************************************************************

                       

        public bool EnableCommentRatings {

            get { return _enableCommentRatings; }

        }

 

 

        //*********************************************************************

        //

        // RateRoles Property

        //

        // Represents the roles of users who can rate pages in this section.

        //

        //*********************************************************************

                       

        public string[] RateRoles {

            get { return _rateRoles; }

        }

 

 

        //*********************************************************************

        //

        // EnableNotifications Property

        //

        // Indicates whether users can receive email notifications when

        // new content is added to this section.

        //

        //*********************************************************************

                           

        public bool EnableNotifications {

            get { return _enableNotifications; }

        }   

 

 

        //*********************************************************************

        //

        // InheritTransformations Property

        //

        // Indicates whether transformations are inherited from the parent

        // section.

        //

        //*********************************************************************

                           

        public bool InheritTransformations {

            get { return _inheritTransformations; }

        }

        

 

        //*********************************************************************

        //

        // Transformations Property

        //

        // Represents the transformations that are applied to text

        // in this section.

        //

        //*********************************************************************

                       

        public string Transformations {

            get { return _transformations; }

        }

 

 

        //*********************************************************************

        //

        // IsSectionWebService Property

        //

        // Indicates whether this section is exposed as a Web service.

        //

        //*********************************************************************

                        

        public bool IsSectionWebService {

            get { return _isSectionWebService; }

        }

       

 

        //*********************************************************************

        //

        // WebServicePassword Property

        //

        // Represents the password needed to access this section's Web service.

        //

        //*********************************************************************

                       

        public string WebServicePassword {

            get { return _webServicePassword; }

        }

 

 

        //*********************************************************************

        //

        // AllowHtmlInput Property

        //

        // Represents whether or not users are allowed to add HTML content to forms.

        //

        //*********************************************************************

                       

        public AllowHtml AllowHtmlInput {

            get { return _allowHtmlInput; }

        }

 

 

 

        //*********************************************************************

        //

        // AllowCommentHtmlInput Property

        //

        // Represents whether or not users are allowed to add HTML content to comments.

        //

        //*********************************************************************

                       

        public AllowHtml AllowCommentHtmlInput {

            get { return _allowCommentHtmlInput; }

        }

       

 

        //*********************************************************************

        //

        // Content Property

        //

        // Represents the fully qualified assembly name that

        // represents the content displayed by this section.

        //

        //*********************************************************************

                       

        public string Content {

            get { return _content; }

        }

 

 

        //*********************************************************************

        //

        // SectionInfo Constructor

        //

        // Initializes the SectionInfo object with a DataRow.

        //

        //*********************************************************************

               

        public SectionInfo(DataRow drowSection, DataRow[] drowSectionSecurity, DataRow[] drowWebBoxes, DataRow[] drowWebServiceBoxes) {

            _id = (int)drowSection[ "section_id" ];

            _communityID = (int)drowSection[ "section_communityID" ];

            _name = (string)drowSection[ "section_name" ];

            _title = (string)drowSection[ "section_title" ];

            _menuTitle = (string)drowSection[ "section_menuTitle" ];

            _description = (string)drowSection[ "section_description" ];

            _isEnabled = (bool)drowSection["section_isEnabled"];

            _isSystem = (bool)drowSection["section_isSystem"];

            _pageType = (int)drowSection[ "section_pageType" ];

            _skin = (string)drowSection[ "section_pageSkin" ];

            _style = (string)drowSection[ "section_pageStyle" ];

            _parentSectionID = (int)drowSection[ "section_parentID" ];

            _isWebBoxesInherited = (bool)drowSection[ "section_isWebBoxesInherited" ];

            _webBoxes = SplitBoxes(drowWebBoxes);

            _webBoxDisplayMode = (int)drowSection[ "section_webBoxDisplayMode" ];

            _isWebServiceBoxesInherited = (bool)drowSection["section_isWebServiceBoxesInherited"];

            _webServiceBoxes = SplitServiceBoxes(drowWebServiceBoxes);

            _webServiceBoxDisplayMode = (int)drowSection["section_webServiceBoxDisplayMode"];

            _logo = (string)drowSection[ "section_logo" ];

            _pageHeader = (string)drowSection[ "section_pageHeader" ];

            _pageFooter = (string)drowSection[ "section_pageFooter" ];   

            _footer = (string)drowSection[ "section_footer" ];

            _pageMetaKeys = (string)drowSection[ "section_pageMetaKeys" ];

            _pageMetaDesc = (string)drowSection[ "section_pageMetaDesc" ];

            _viewRoles = SplitRoles(drowSectionSecurity, RoleType.ViewRole);

            _addRoles = SplitRoles(drowSectionSecurity, RoleType.AddRole);;

            _editRoles = SplitRoles(drowSectionSecurity, RoleType.EditRole);;

            _deleteRoles = SplitRoles(drowSectionSecurity, RoleType.DeleteRole);

            _recordsPerPage = ((int)drowSection[ "section_recordsPerPage" ]);

            _enableTopics = (bool)drowSection[ "section_enableTopics" ];

            _enableComments = (bool)drowSection[ "section_enableComments" ];

            _commentRoles = SplitRoles(drowSectionSecurity, RoleType.CommentRole);

            _enableModeration = (bool)drowSection[ "section_enableModeration" ];

            _moderateRoles = SplitRoles(drowSectionSecurity, RoleType.ModerateRole);

            _enableRatings = (bool)drowSection[ "section_enableRatings" ];

            _enableCommentRatings = (bool)drowSection[ "section_enableCommentRatings" ];

            _rateRoles = SplitRoles(drowSectionSecurity, RoleType.RateRole);

            _enableNotifications = (bool)drowSection["section_enableNotifications"];

            _inheritTransformations = (bool)drowSection[ "section_inheritTransformations" ];

            _transformations = (string)drowSection[ "section_transformations" ];

            _isSectionWebService = (bool)drowSection[ "section_isSectionWebService" ];

            _webServicePassword = (string)drowSection[ "section_webServicePassword" ];

            _allowHtmlInput = (AllowHtml)drowSection["section_allowHtmlInput"];

            _allowCommentHtmlInput = (AllowHtml)drowSection["section_allowCommentHtmlInput"];

            _content = (string)drowSection[ "pageType_pageContent" ];

            _path = (string)drowSection["section_path"];

        }

     

           public SectionInfo(){}

 

       

      private string[] SplitRoles(DataRow[] allRoles, RoleType sectionRoleType) {

            ArrayList colRoles = new ArrayList();

           

           

            foreach (DataRow row in allRoles)

                if ((RoleType)row["ss_roleType"] == sectionRoleType)

                    colRoles.Add( row["ss_role"] );

                 

            return (string[])colRoles.ToArray(typeof(String));

      } 

     

      private string[] SplitBoxes(DataRow[] allBoxes) {

            ArrayList colBoxes = new ArrayList();

            

            foreach (DataRow row in allBoxes)

                colBoxes.Add( row["sw_webBox"] );

               

            return (string[])colBoxes.ToArray(typeof(String));

      }

 

 

     

      private string[] SplitServiceBoxes(DataRow[] allBoxes) {

            ArrayList colBoxes = new ArrayList();

           

            foreach (DataRow row in allBoxes)

                colBoxes.Add( row["sw_webServiceBox"] );

               

            return (string[])colBoxes.ToArray(typeof(String));

      }

 

 

       

    }

}

相对来说,这个类更为复杂,section通用属性,id ,title,name,display,更有section的类别,角色分配(不同的角色权限),更重要的是控件,及控件的格式等.其对应的数据表有:

Community_Sections,Community_SectionSecurity,Community_SectionServerSubscriptions,Community_SectionWebBoxes,Community_SectionWebServiceBoxes.

还有一些存储过程,进行表的操作,不在一一列出.

 

一些对数据库中表的操作

mysql对数据库中表的修改数据 操作:update 表名 set 要修改的属性名称=想要修改成的内容(username='name') ,要修改的属性名称=想要修改成的内容(passwd='pass...
  • qq_35884119
  • qq_35884119
  • 2016年09月03日 10:23
  • 27

MYSQL---数据库中表的操作

在数据库中创建表1.首先选中一个数据库 use example;//example为数据库名2.创建表: create table example0(id int,name varchar(20),...
  • qq_25123049
  • qq_25123049
  • 2016年06月25日 12:02
  • 384

python数据库中表的操作

创建表 [root@localhost ~]# cat 1.py #!/usr/bin/env python import MySQLdb def connect_mysql(): db_...
  • zzh_1032399080
  • zzh_1032399080
  • 2017年11月23日 08:27
  • 73

数据库中表的操作

# 创建数据库 DROP DATABASE `test`; CREATE DATABASE IF NOT EXISTS `test`; USE TEST; -- --和#可以用来创建单行注释 # 表...
  • ShaoqunLiu
  • ShaoqunLiu
  • 2016年08月13日 21:20
  • 167

MySQL数据库操作类(PHP实现,支持连贯操作)

使用过ThinkPHP框架的同学可能会对于其中数据库模型操作特别有好感,ThinkPHP提供了数据库操作的简单的操作,对于连接数据库,数据库的增删改查等数据操作都非常的nice,同时支持连贯操作,对于...
  • helencoder
  • helencoder
  • 2016年04月17日 11:27
  • 12357

C#数据库操作类(完整通用)

using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; ...
  • angela8804100029
  • angela8804100029
  • 2013年04月14日 19:09
  • 1773

pdo数据库操作类

pdo,有不局限数据库,和防止sql注入等很多优点,也是php官方推荐的方式,所以花点时间写个pdo数据库操作类!...
  • gongstrong123
  • gongstrong123
  • 2016年03月08日 21:58
  • 1047

.NET通用的数据库操作类(支持多种数据库)

通用的数据库操作类(支持多种数据库)       我们在软件开发过程中,数据库是一个永久不变的话题,但是根据软件架构与客户要求的不同我们会选择不同的数据库,在C#中不同数据库操作编写代码不尽相同...
  • qq798833488
  • qq798833488
  • 2016年05月13日 11:02
  • 4395

SQL Server数据库操作类(C#)

博文介绍的SQL Server数据库操作类是C#语言的,可实现对SQL Server数据库的增删改查询等操作。并且该操作类可实现对图片的存储,博文的最后附上如何将Image图片转换为byte[]数组类...
  • softimite_zifeng
  • softimite_zifeng
  • 2016年11月06日 11:18
  • 805

MySql数据库操作类

using System; using System.Data; using System.IO; using System.Linq; using System.Text; using MySql....
  • PeterZhuGe
  • PeterZhuGe
  • 2016年12月01日 14:17
  • 970
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CommunityStarterKit之SectionInfo类及数据库中表和操作
举报原因:
原因补充:

(最多只允许输入30个字)