站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
淘特Asp.NetCms 二次开发说明
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
<span style="text-align:center; border:1px solid #000; float:right; padding:6px;"><strong>导航:</strong> [[淘特Asp.NetCms|上一页]]</span> <div style="clear:both;"></div> CMS框架说明及特色: *基于[[MVC]]三层架构,业务、控制、显示层层分离,面向对象的编程思想,扩展开发容易。 *数据库模块统一放置于[[DAO]]中,所有业务逻辑相关操作,由统一的ObjectFactory获取并实例化,便于系统的统一管理。 *统一的[[数据库]]BEAN工厂(DataField),通过引用(import)系统中的DataField类,即可完成数据库中字段的复值、取值。省去了为每个表写单独的实例化信息类了的繁锁。 *系统集成[[Lucene]].net高效索引、[[搜索引擎]],该模块是先将数据库内容采用一定的分词技术生成索引,前台模糊查询时读取的索引文件,因而速度非常快,同时检索的同时不在查询数据库,从而节省了大量资源。 *大量采用了[[Ajax]]技术,后台无限级分类、WEB[[采集]]等模块均加入了Ajax技术异步调用,极大优化了程序代码,真正意义的实现了“无限”级数量级业务。 TotNetCms提供了完整的数据库访问[[框架]],所以在CMS中二次开发只需要引用DB工具类就可以了,它存在TotCms.FrameWork.Db中。下面以TotNetCms中的广告管理类做为说明。 '''事例:广告管理类的设计''' <pre> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TotCms.FrameWork.Db; using TotCms.Web.Admin.UI; using TotCms.FrameWork.Util; namespace TotCms.FrameWork.Dao { public class AdDao { public int GetLastId() { object id; SqlCommand cmd = DbUtil.GetCommand("select top 1 id from t_ad order by id desc", true); id = DbUtil.Instance.ExecuteScalar(cmd); return Convert.ToInt32(id); } public void Add(int categoryid, string title, string content,int adtype, DateTime expirestime, DateTime moditime) { int id = GetLastId()+1; SqlCommand cmd = DbUtil.GetCommand("insert into t_ad(id,CategoryId,Title,Content,AdType,ExpiresTime,ModiTime) values(@id,@CategoryId,@Title,@Content,@AdType,@ExpiresTime,@ModiTime)", true); cmd.Parameters.Add(DataHelper.MakeInParam("@id", SqlDbType.Int, 0, id)); cmd.Parameters.Add(DataHelper.MakeInParam("@CategoryId", SqlDbType.Int, 0, categoryid)); cmd.Parameters.Add(DataHelper.MakeInParam("@Title", SqlDbType.VarChar, 0, title)); cmd.Parameters.Add(DataHelper.MakeInParam("@Content", SqlDbType.Text, 0, content)); cmd.Parameters.Add(DataHelper.MakeInParam("@AdType", SqlDbType.Int, 0, adtype)); cmd.Parameters.Add(DataHelper.MakeInParam("@ExpiresTime", SqlDbType.DateTime, 0, expirestime)); cmd.Parameters.Add(DataHelper.MakeInParam("@ModiTime", SqlDbType.DateTime, 0, moditime)); DbUtil.Instance.ExecuteNonQuery(cmd); } public void Mod(int id, int categoryid, string title, string content, int adtype, DateTime expirestime, DateTime moditime) { SqlCommand cmd = DbUtil.GetCommand("update t_ad set CategoryId=@CategoryId,Title=@Title,Content=@Content, AdType=@AdType,ExpiresTime=@ExpiresTime, ModiTime=@ModiTime where id=@id", true); cmd.Parameters.Add(DataHelper.MakeInParam("@CategoryId", SqlDbType.Int, 0, categoryid)); cmd.Parameters.Add(DataHelper.MakeInParam("@Title", SqlDbType.VarChar, 0, title)); cmd.Parameters.Add(DataHelper.MakeInParam("@Content", SqlDbType.Text, 0, content)); cmd.Parameters.Add(DataHelper.MakeInParam("@AdType", SqlDbType.Int, 0, adtype)); cmd.Parameters.Add(DataHelper.MakeInParam("@ExpiresTime", SqlDbType.DateTime, 0, expirestime)); cmd.Parameters.Add(DataHelper.MakeInParam("@ModiTime", SqlDbType.DateTime, 0, moditime)); cmd.Parameters.Add(DataHelper.MakeInParam("@id", SqlDbType.Int, 0, id)); DbUtil.Instance.ExecuteNonQuery(cmd); } public void Delete(int id) { SqlCommand cmd = DbUtil.GetCommand("delete from t_ad where id=@id", true); cmd.Parameters.Add(DataHelper.MakeInParam("@id", SqlDbType.Int, 0, id)); DbUtil.Instance.ExecuteNonQuery(cmd); } public DataField Get(int id) { SqlCommand cmd = DbUtil.GetCommand("select CategoryId,Title,Content,AdType,ExpiresTime, ModiTime from t_ad where id=@id", true); cmd.Parameters.Add(DataHelper.MakeInParam("@id", SqlDbType.Int, 0, id)); return (DbUtil.Instance.GetFirstData(cmd, "CategoryId,Title,Content,AdType,ExpiresTime,ModiTime")); } public List<DataField> GetList(int categoryid) { string fields = "id,CategoryId,Title,Content,AdType,ExpiresTime,ModiTime"; StringBuilder sql = new StringBuilder(512); sql.Append("select "); sql.Append(fields); sql.Append(" from t_ad where 1=1"); if (categoryid > 0) { sql.Append(" and CategoryId=").Append(categoryid); } sql.Append(" order by id desc"); SqlCommand cmd = DbUtil.GetCommand(sql.ToString(), true); return DbUtil.Instance.GetList(cmd, fields); } public DataTable GetDataTable(int categoryid, string keys, int currentpage, int pagesize) { string fields = "id,CategoryId,Title,Content,AdType,ExpiresTime,ModiTime"; StringBuilder sql = new StringBuilder(512); sql.Append("select top "); sql.Append(pagesize + " "); sql.Append(fields); sql.Append(" from t_ad WHERE (id <=(SELECT MIN(id) FROM (SELECT TOP " + ((currentpage - 1) * pagesize + 1) + " id FROM t_ad where 1=1"); if (categoryid > 0) { sql.Append(" and CategoryId=").Append(categoryid); } if (!string.IsNullOrEmpty(keys)) { sql.Append(" and Title like '%").Append(keys).Append("%'"); } sql.Append(" ORDER BY id DESC) AS t))"); if (categoryid > 0) { sql.Append(" and CategoryId=").Append(categoryid); } if (!string.IsNullOrEmpty(keys)) { sql.Append(" and Title like '%").Append(keys).Append("%'"); } sql.Append(" ORDER BY id DESC"); LogUtil.Debug(sql.ToString()); SqlCommand cmd = DbUtil.GetCommand(sql.ToString(), true); return DbUtil.Instance.GetData(cmd); } public double GetCount(int categoryid, string keys) { double ret = 0D; StringBuilder sql = new StringBuilder(512); sql.Append("select count(*) from t_ad where 1=1"); if (categoryid > 0) { sql.Append(" and CategoryId=").Append(categoryid); } if (!string.IsNullOrEmpty(keys)) { sql.Append(" and Title like '%").Append(keys).Append("%'"); } SqlCommand cmd = DbUtil.GetCommand(sql.ToString(), true); ret = Convert.ToDouble(DbUtil.Instance.ExecuteScalar(cmd)); return ret; } public string GetContent(int id) { SqlCommand cmd = DbUtil.GetCommand("select Content from t_ad where id=@id", true); cmd.Parameters.Add(DataHelper.MakeInParam("@id", SqlDbType.Int, 0, id)); string p = (string)DbUtil.Instance.GetField(cmd); return p; } } } </pre> 以上是广告管理的全部代码,下面重要介绍两个函数: *'''GetList函数:'''此函数返回的是List<DataField>,DataField也就是我们CMS中提供一个数据库字段操作类,通过它可以访问返回的数据库每行的字段值。比如前台可以这么来取数据: <pre> AdDao ad=new AdDao(); List<DataField> list=ad.GetList(); Foreach(DataField df in list){ Response.Write(df.GetFieldValue(“id”));// GetFieldValue函数中参数即为表t_ad中的字段名称 Response.Write(df.GetFieldValue(“Title”)); } </pre> *'''GetDataTable函数:'''此函数返回DataTable对象,DataTable经常用到asp.net数据控件中(如Repeater,GridView),因此在asp.net页面中可以直接通过此函数将数据控制绑定数据。以下是广告管理页面中的绑定代码(为了演示方便,省略了一部分无关代码): '''Admanage.aspx页面''' [[Image:TotNetCMS_Development.gif|Center]] '''Admanage.aspx.cs页面''' <pre> protected void Page_Load(object sender, EventArgs e) { AdDao ad=new AdDao(); this.RepeateList.DataSource = ad.GetDataTable(0, “”, 1, 10); } </pre> 上面代码中,只需要调用AdDao中的GetDataTable就完成了RepeateList绑定。具体的业务逻辑交由实体数据Dao类来管理,从业务层次上比较分明,利于项目的扩展和管理。 ==相关条目== *[[动易]] *[[Drupal]] *[[DedeCMS]] ==参考来源== *[http://www.totcms.com/totnetcms/help/ 参考来源] [[category:淘特Asp.NetCms|E]]
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)