搜索
 设为首页 加入收藏
当前位置>>开源人>>博客>>正文
基于.Net平台的extjs单用户Blog系统
 作者:daxia 2008-04-14 16:41:07.0 网友评论:7条 点击:2605

   

  这是通过Java版本的Wlr单用户Blog系统改写的系统,是一个基于ExtSJ技术实现的简单blog系统,演示了ExtJS的综合应用。

  系统后台使用.Net平台,语言为C#,技术构架为NHibernate+Spring.Net+Vifir实现,支持多种数据库,采用三层结 构,数据访问层DAO、业务逻辑层及表示层完全分离。DAO层使用的泛型DAO,只需要一个DAO接口即可,不需要写具体的实现。

  系统演示:http://www.vifir.com/resources/records/codes/wlrblog-net/wlrblog-net.html

  系统下载地址:http://www.vifir.com/download/extblog-net.zip

  VIP完整源码下载:http://www.vifir.com/portal.ejf?cmd=downloadVipFile&name=codes/extblog-net-src.zip

  下面是系统后台的截图

  

  (登录)

  系统中的一些源码摘要:

  域模型:  

namespace Vifir.Model.Domain
{
public class Topic
{
private long id;

private string title;

private string content;

private string intro;

private TopicCategory category;

private IList<TopicComment> comments = new List<TopicComment>();

private DateTime inputTime = DateTime.Now;

private int readTimes = 0;
public virtual long Id
{
get { return id; }
set { id = value; }
}
public virtual string Title
{
get { return title; }
set { title = value; }
}
public virtual string Content
{
get { return content; }
set { content = value; }
}
public virtual string Intro
{
get { return intro; }
set { intro = value; }
}
public virtual TopicCategory Category
{
get { return category; }
set { category = value; }
}
public virtual IList<TopicComment> Comments
{
get { return comments; }
set { comments = value; }
}
public virtual DateTime InputTime
{
get { return inputTime; }
set { inputTime = value; }
}
public virtual int ReadTimes
{
get { return readTimes; }
set { readTimes = value; }
}
}
}

  DAO接口

namespace Vifir.Model.DAO
{
public interface ITopicDAO : GenericDAO
{
}
}

  泛型DAO配置

<object id="TopicDao" parent="abstractDao">
    <property name="proxyInterfaces" value="Vifir.Model.DAO.ITopicDAO"/>
    <property name="target">
      <object parent="baseDAO" type="Vifir.Core.GenericDAOImpl&lt;Vifir.Model.Domain.Topic>,Vifir.Core" />
    </property>
  </object>

  TopicService业务层实现代码

namespace Vifir.Model.Service.Impl
{
public class TopicServiceImpl:ITopicService
{
private ITopicDAO topicDao;

public ITopicDAO TopicDao
{
set { topicDao = value; }
}


public long addTopic(Topic topic) {
this.topicDao.Save(topic);
return topic.Id;
}

public Topic getTopic(long id) {
Topic topic = this.topicDao.Get(id);
return topic;
}

public bool delTopic(long id) {
Topic topic = this.getTopic(id);
if(topic.Comments.Count>0)throw new LogicException("该文章下还有评论,不能删除!");
if (topic != null) {
this.topicDao.Remove(id);
return true;
}
return false;
}


public IPageList getTopicBy(IQueryObject queryObject) {
return QueryUtil.query(queryObject, typeof(Topic),this.topicDao);
}

public bool updateTopic(long id, Topic topic) {
if (id != default(long))
{
topic.Id=id;
} else {
return false;
}
this.topicDao.Update(topic);
return true;
}
}
}

 Web层的添删改查代码:  

public partial class manage_Topic : BaseAction
{
private ITopicService service;
private ITopicCategoryService categoryService;
public ITopicService Service
{
set { service = value; }
}
public ITopicCategoryService CategoryService
{
set { categoryService = value; }
}

public void List()
{
QueryObject qo = new QueryObject();
ToPo(qo);
string categoryId = Request.Params["categoryId"];
if (categoryId != null && !"".Equals(categoryId))
{
qo.addQuery("obj.Category.id", long.Parse(categoryId), "=");
}
IPageList pageList = service.getTopicBy(qo);
jsonResult = pageList;
}

public void Remove()
{
long id = long.Parse(Request.Params["id"]);
service.delTopic(id);
jsonResult = true;
}

public void Save()
{
Topic obj = new Topic();
ToPo(obj);
string CategoryId = Request.Params["CategoryId"];
if (CategoryId != null && !"".Equals(CategoryId))
{
TopicCategory c = this.categoryService.getTopicCategory(long.Parse(CategoryId));
obj.Category = c;
}
if (!HasError())
service.addTopic(obj);
extFormResult = true;
}

public void Update()
{
long id = long.Parse(Request.Params["id"]);
Topic obj = service.getTopic(id);
ToPo(obj);
string CategoryId = Request.Params["CategoryId"];
if (CategoryId != null && !"".Equals(CategoryId))
{
TopicCategory c = this.categoryService.getTopicCategory(long.Parse(CategoryId));
obj.Category = c;
}
if (!HasError())
service.updateTopic(id, obj);
extFormResult = true;
}
}
 





文章评论

不错,只是在线演示看不到啊

网友:hrj1025  发表于:2008-04-14 17:51:52.0

下载学习一下.

网友:jsycywm  发表于:2008-04-14 18:48:08.0

为什么DLL不完全开放?这叫开源么?

网友:1111111  发表于:2008-05-20 11:19:36.0

能发给我一份资料么还有DLL链接库的那些代码quweijie8@126.com

网友:1111111  发表于:2008-05-20 11:20:27.0

谁告诉你这个DLL是开源的?Core.dll是我们一个内部开发库,如果你是VIP的话可以下到整个示例的源代码,包括业务逻辑层、数据层等具体的内容。Core.dll里面的东西,直接在项目中调用即可。

网友:daxia  发表于:2008-05-21 09:13:25.0

想知道不用那些架构能不能开发出应用?

网友:VIP  发表于:2008-06-06 14:59:07.0

稍微看了一下,在Vifir.Model.dll中,采用了泛型接口,使得具体的某一个DAO中不需要具体的实现,那在Service中为什么又不用泛型接口了呢?其实也可以用泛型接口使得具体的每一个Service实现代码精简了不少啊,这种做法我在项目中就使用,不知道你们这里为什么不用呢?

网友:laudy98  发表于:2008-07-04 12:47:22.0

发表评论
您没有登录,不能发表评论,请先登录

网站简介 | 广告服务 | VIP资费标准 | 银行汇款帐号 | 网站地图 | 帮助 | 联系方式
地址:成都八宝街一号万和苑C座1203 电话:028-86272612 传真: 028-86272612
开源人网站版权所有  渝ICP备06004507号  建议使用1024*768分辨率