diff --git a/MyBlog/Blog.Domain/ArticelService.cs b/MyBlog/Blog.Domain/ArticelService.cs
index 2b823e2..e3e3e71 100644
--- a/MyBlog/Blog.Domain/ArticelService.cs
+++ b/MyBlog/Blog.Domain/ArticelService.cs
@@ -9,293 +9,309 @@
namespace Blog.Domain
{
- ///
- /// 文章业务类
- ///
- public class ArticleService : IArticleService
- {
- ///
- /// 依赖注入赋值
- ///
- private IArticleRepository _articleRepository;
- private IRoleService _roleService;
- private ISettingService _settingService;
- private IUserService _userService;
- private ICategoryService _categoryService;
-
- public ArticleService (ICategoryService categoryService, IArticleRepository articleRepository, IRoleService roleService, ISettingService settingService, IUserService userService)
- {
- _userService = userService;
- _articleRepository = articleRepository;
- _roleService = roleService;
- _settingService = settingService;
- _categoryService = categoryService;
- }
-
- public int AddArticle (Model.Article article)
- {
-
- if (_roleService.AddArticlePower ()) {
- if (string.IsNullOrEmpty (article.Title)) {
- throw new DomainException ("Title", "文章标题不能为空!");
- } else if (string.IsNullOrEmpty (article.Content)) {
- throw new DomainException ("Content", "文章内容不能为空!");
- } else if (article.Categorys.Count == 0) {
- throw new DomainException ("Category", "文章必须要有一个分类!");
- }
- article.Status = ArticleStatus.Open;
- article.Author = _userService.GetLoginUser ();
- IList categorys = article.Categorys;
- article.Categorys = null;
- int id = _articleRepository.Add (article);
- article.Categorys = categorys;
- _articleRepository.Update (article);
- return id;
- } else {
- throw new DomainException ("NoPower", "对不起,您没有权限添加文章。");
- }
- }
-
- public void UpdateArticle (Model.Article article)
- {
- Article article2 = _articleRepository.Get (article.ArticleId);
- if (article2 == null) {
- throw new DomainException ("NoFind", "对不起,该文章不存在或已经被删除。");
- }
- if (!_roleService.EditArticlePower ()) {
- throw new DomainException ("NoPower", "对不起,您没有权限编辑该文章。");
- } else {
- article.ModifyDate = DateTime.Now;
- _articleRepository.Update (article);
- }
- }
-
- public void DeleteArticle (int id)
- {
- Article article = _articleRepository.Get (id);
- if (article == null) {
- throw new DomainException ("NoFind", "对不起,该文章不存在或已经被删除。");
- }
- if (_roleService.DeleteArticlePower ()) {
- _articleRepository.BeginTransaction ();
- try {
- _articleRepository.Update ("delete from Comment where ArticleId=" + id);
- _articleRepository.Update ("delete from Attach where ArticleId=" + id);
- _articleRepository.Update ("delete from CategoryRelationShip where ArticleId=" + id);
- _articleRepository.Update ("delete from Article where ArticleId=" + id);
- foreach (var category in article.Categorys) {
- category.Count = category.Count - 1 >= 0 ? category.Count - 1 : 0;
- _categoryService.UpdateCategory (category);
- }
- } catch (Exception ex) {
- _articleRepository.RollbackTransaction ();
- throw new DomainException ("DatabaseError", ex.Message);
- }
- _articleRepository.CommitTransaction ();
- } else {
- throw new DomainException ("NoPower", "对不起,您没有权限删除该文章。");
- }
- }
-
- public Model.Article GetArticle (int id)
- {
- Article article = (Article)HttpRuntime.Cache.Get ("Article_" + id);
- if (article != null)
- return article;
- article = _articleRepository.Get (id);
- if (article == null) {
- throw new DomainException ("NoFind", "对不起,该文章不存在或已经被删除。");
- }
- HttpRuntime.Cache.Insert ("Article_" + id, article, new SqlCacheDependency ("Default", "Article"), DateTime.MaxValue, TimeSpan.FromSeconds (30));
- return article;
- }
-
- public PageInfo FindArticleByTitle (string title, int pageIndex)
- {
- int pageSize = int.Parse (_settingService.GetSetting ("ArticlePageSize"));
- PageInfo pageInfo = new PageInfo ();
- pageInfo.PageSize = pageSize;
-
- int totalItem = (int)_articleRepository.Single (
- qeruy => qeruy
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Title.Contains (title))
- .Count ()
- );
-
- pageInfo.TotalItem = totalItem;
- pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
- pageIndex = pageIndex <= 0 ? 1 : pageIndex;
- IList list = _articleRepository.Find (
- Query => Query
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Title.Contains (title))
- .OrderByDescending (a => a.CreateDate)
- .Skip ((pageIndex - 1) * pageSize).Take (pageSize)
- );
-
- pageInfo.PageItems = list;
- pageInfo.PageIndex = pageIndex;
-
- return pageInfo;
- }
-
- public PageInfo GetArticleByCategory (int categoryId, int pageIndex)
- {
- PageInfo articles = (PageInfo)HttpRuntime.Cache.Get ("Article_Category" + categoryId + "_" + pageIndex);
- if (articles != null)
- return articles;
- int pageSize = int.Parse (_settingService.GetSetting ("ArticlePageSize"));
- PageInfo pageInfo = new PageInfo ();
- pageInfo.PageSize = pageSize;
- int totalItem = (int)_articleRepository.Single (
- qeruy => qeruy
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Categorys.Where (c => c.CategoryId == categoryId).Count () > 0)
- .Count ()
- );
- pageInfo.TotalItem = totalItem;
- pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
-
- IList list = _articleRepository.Find (
- Query => Query
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Categorys.Where (c => c.CategoryId == categoryId).Count () > 0)
- .OrderByDescending (a => a.CreateDate)
- .Skip ((pageIndex - 1) * pageSize).Take (pageSize)
- );
- pageInfo.PageItems = list;
- pageInfo.PageIndex = pageIndex;
- HttpRuntime.Cache.Insert ("Article_Category" + categoryId + "_" + pageIndex, pageInfo, new SqlCacheDependency ("Default", "Article"), DateTime.MaxValue, TimeSpan.FromSeconds (30));
- return pageInfo;
- }
-
- public PageInfo FindArticleByMonth (DateTime month, int pageIndex)
- {
- int pageSize = int.Parse (_settingService.GetSetting ("ArticlePageSize"));
-
- PageInfo pageInfo = new PageInfo ();
- pageInfo.PageSize = pageSize;
-
- int totalItem = (int)_articleRepository.Single (
- qeruy => qeruy
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Year == month.Year && a.CreateDate.Month == month.Month)
- .Count ()
- );
- pageInfo.TotalItem = totalItem;
- pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
- pageIndex = pageIndex <= 0 ? 1 : pageIndex;
- IList list = _articleRepository.Find (
- Query => Query
- .Where (a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Year == month.Year && a.CreateDate.Month == month.Month)
- );
- pageInfo.PageItems = list;
- pageInfo.PageIndex = pageIndex;
- return pageInfo;
- }
-
- public PageInfo FindArticleByDay (DateTime day, int pageIndex)
- {
-
- PageInfo articles = (PageInfo)HttpRuntime.Cache.Get ("Article_day" + day + "_" + pageIndex);
- if (articles != null)
- return articles;
-
- int pageSize = int.Parse (_settingService.GetSetting ("ArticlePageSize"));
- PageInfo pageInfo = new PageInfo ();
- pageInfo.PageSize = pageSize;
- int totalItem = (int)_articleRepository.Single (
- qeruy => qeruy
- .Where (
- a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Day == day.Day && a.CreateDate.Month == day.Month && a.CreateDate.Year == day.Year
- )
- .Count ()
- );
- pageInfo.TotalItem = totalItem;
- pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
-
- IList list = _articleRepository.Find (
- query => query.Where (
- a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Day == day.Day && a.CreateDate.Month == day.Month && a.CreateDate.Year == day.Year
- )
- .OrderByDescending (a => a.CreateDate)
- .Skip ((pageIndex - 1) * pageSize).Take (pageSize)
- );
- pageInfo.PageItems = list;
- pageInfo.PageIndex = pageIndex;
- HttpRuntime.Cache.Insert ("Article_day" + day + "_" + pageIndex, pageInfo, new SqlCacheDependency ("Default", "Article"), DateTime.MaxValue, TimeSpan.FromSeconds (30));
- return pageInfo;
- }
-
- public IList GetLastBlog ()
- {
- IList LastBlog = null;
- int count = int.Parse (_settingService.GetSetting ("LastArticleCount"));
- LastBlog = _articleRepository.Find (
- query => query.Where (
- a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open
- )
- .OrderByDescending (a => a.CreateDate)
- .Take (count)
- );
- return LastBlog;
- }
-
- public IList GetLastPage ()
- {
- IList LastPage = (IList)HttpRuntime.Cache.Get ("Article_LastPage");
- if (LastPage != null) {
- return LastPage;
- }
- int count = int.Parse (_settingService.GetSetting ("LastArticleCount"));
- LastPage = _articleRepository.Find (
- query => query.Where (
- a => a.Type == ArticleType.Page && a.Status == ArticleStatus.Open
- )
- .OrderByDescending (a => a.CreateDate)
- .Take (count)
- );
- HttpRuntime.Cache.Insert ("Article_LastPage", LastPage, new SqlCacheDependency ("Default", "Article"), DateTime.MaxValue, TimeSpan.FromMinutes (1));
- return LastPage;
- }
-
- public Article BrowseArticle (int articleId)
- {
- Article article = GetArticle (articleId);
-
- if (article.Status == ArticleStatus.Delete) {
- throw new DomainException ("NoFind", "对不起,该文章不存在或已经被删除。");
- } else if (_roleService.ReadArticelPower (article)) {
- article.Browse++;
- _articleRepository.Update (article);
- return article;
- } else {
- throw new DomainException ("NoPower", "对不起,您没有权限查看该文章。");
- }
- }
-
- public PageInfo FindArticlesByQuery (Func, IQueryable> expr, int pageIndex, int pageSize)
- {
- if (!_roleService.AddArticlePower ()) {
- throw new DomainException ("NoPower", "对不起,您没有权限!");
- }
-
- pageIndex = pageIndex > 0 ? pageIndex : 1;
-
- int count = (int)_articleRepository.Single (query => expr (query).Count ());
-
- PageInfo info = new PageInfo () {
- PageIndex = pageIndex,
- PageSize = pageSize,
- TotalItem = count
- };
- info.PageIndex = info.PageIndex > info.TotalPage ? info.TotalPage : info.PageIndex;
-
- IList list = _articleRepository.Find (query => expr (query).Skip ((pageIndex - 1) * pageSize).Take (pageSize));
-
- info.PageItems = list;
- return info;
- }
-
- public object GetArticleSingle (Func, object> expr)
- {
- return _articleRepository.Single (expr);
- }
- }
+ ///
+ /// 文章业务类
+ ///
+ public class ArticleService : IArticleService
+ {
+ ///
+ /// 依赖注入赋值
+ ///
+ private IArticleRepository _articleRepository;
+ private IRoleService _roleService;
+ private ISettingService _settingService;
+ private IUserService _userService;
+ private ICategoryService _categoryService;
+
+ public ArticleService(ICategoryService categoryService, IArticleRepository articleRepository, IRoleService roleService, ISettingService settingService, IUserService userService)
+ {
+ _userService = userService;
+ _articleRepository = articleRepository;
+ _roleService = roleService;
+ _settingService = settingService;
+ _categoryService = categoryService;
+ }
+
+ public int AddArticle(Model.Article article)
+ {
+
+ if (_roleService.AddArticlePower())
+ {
+ if (string.IsNullOrEmpty(article.Title))
+ {
+ throw new DomainException("Title", "文章标题不能为空!");
+ }
+ else if (string.IsNullOrEmpty(article.Content))
+ {
+ throw new DomainException("Content", "文章内容不能为空!");
+ }
+ else if (article.Categorys.Count == 0)
+ {
+ throw new DomainException("Category", "文章必须要有一个分类!");
+ }
+ article.Status = ArticleStatus.Open;
+ article.Author = _userService.GetLoginUser();
+ IList categorys = article.Categorys;
+ article.Categorys = null;
+ int id = _articleRepository.Add(article);
+ article.Categorys = categorys;
+ _articleRepository.Update(article);
+ return id;
+ }
+ else
+ {
+ throw new DomainException("NoPower", "对不起,您没有权限添加文章。");
+ }
+ }
+
+ public void UpdateArticle(Model.Article article)
+ {
+ Article article2 = _articleRepository.Get(article.ArticleId);
+ if (article2 == null)
+ {
+ throw new DomainException("NoFind", "对不起,该文章不存在或已经被删除。");
+ }
+ if (!_roleService.EditArticlePower())
+ {
+ throw new DomainException("NoPower", "对不起,您没有权限编辑该文章。");
+ }
+ else
+ {
+ article.ModifyDate = DateTime.Now;
+ _articleRepository.Update(article);
+ }
+ }
+
+ public void DeleteArticle(int id)
+ {
+ Article article = _articleRepository.Get(id);
+ if (article == null)
+ {
+ throw new DomainException("NoFind", "对不起,该文章不存在或已经被删除。");
+ }
+ if (_roleService.DeleteArticlePower())
+ {
+ _articleRepository.BeginTransaction();
+ try
+ {
+ _articleRepository.Update("delete from Comment where ArticleId=" + id);
+ _articleRepository.Update("delete from Attach where ArticleId=" + id);
+ _articleRepository.Update("delete from CategoryRelationShip where ArticleId=" + id);
+ _articleRepository.Update("delete from Article where ArticleId=" + id);
+ foreach (var category in article.Categorys)
+ {
+ category.Count = (category.Count - 1) >= 0 ? (category.Count - 1) : 0;
+ _categoryService.UpdateCategory(category);
+ }
+ }
+ catch (Exception ex)
+ {
+ _articleRepository.RollbackTransaction();
+ throw new DomainException("DatabaseError", ex.Message);
+ }
+ _articleRepository.CommitTransaction();
+ }
+ else
+ {
+ throw new DomainException("NoPower", "对不起,您没有权限删除该文章。");
+ }
+ }
+
+ public Model.Article GetArticle(int id)
+ {
+ Article article = null;
+ article = _articleRepository.Get(id);
+ if (article == null)
+ {
+ throw new DomainException("NoFind", "对不起,该文章不存在或已经被删除。");
+ }
+ return article;
+ }
+
+ public PageInfo FindArticleByTitle(string title, int pageIndex)
+ {
+ int pageSize = int.Parse(_settingService.GetSetting("ArticlePageSize"));
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.PageSize = pageSize;
+
+ int totalItem = (int)_articleRepository.Single(
+ qeruy => qeruy
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Title.Contains(title))
+ .Count()
+ );
+
+ pageInfo.TotalItem = totalItem;
+ pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
+ pageIndex = pageIndex <= 0 ? 1 : pageIndex;
+ IList list = _articleRepository.Find(
+ Query => Query
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Title.Contains(title))
+ .OrderByDescending(a => a.CreateDate)
+ .Skip((pageIndex - 1) * pageSize).Take(pageSize)
+ );
+
+ pageInfo.PageItems = list;
+ pageInfo.PageIndex = pageIndex;
+
+ return pageInfo;
+ }
+
+ public PageInfo GetArticleByCategory(int categoryId, int pageIndex)
+ {
+ int pageSize = int.Parse(_settingService.GetSetting("ArticlePageSize"));
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.PageSize = pageSize;
+ int totalItem = (int)_articleRepository.Single(
+ qeruy => qeruy
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Categorys.Where(c => c.CategoryId == categoryId).Count() > 0)
+ .Count()
+ );
+ pageInfo.TotalItem = totalItem;
+ pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
+ pageIndex = pageIndex < 1 ? 1 : pageIndex;
+
+ IList list = _articleRepository.Find(
+ Query => Query
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.Categorys.Where(c => c.CategoryId == categoryId).Count() > 0)
+ .OrderByDescending(a => a.CreateDate)
+ .Skip((pageIndex - 1) * pageSize).Take(pageSize)
+ );
+ pageInfo.PageItems = list;
+ pageInfo.PageIndex = pageIndex;
+ return pageInfo;
+ }
+
+ public PageInfo FindArticleByMonth(DateTime month, int pageIndex)
+ {
+ int pageSize = int.Parse(_settingService.GetSetting("ArticlePageSize"));
+
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.PageSize = pageSize;
+
+ int totalItem = (int)_articleRepository.Single(
+ qeruy => qeruy
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Year == month.Year && a.CreateDate.Month == month.Month)
+ .Count()
+ );
+ pageInfo.TotalItem = totalItem;
+ pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
+ pageIndex = pageIndex <= 0 ? 1 : pageIndex;
+
+ IList list = _articleRepository.Find(
+ Query => Query
+ .Where(a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Year == month.Year && a.CreateDate.Month == month.Month)
+ );
+ pageInfo.PageItems = list;
+ pageInfo.PageIndex = pageIndex;
+ return pageInfo;
+ }
+
+ public PageInfo FindArticleByDay(DateTime day, int pageIndex)
+ {
+
+ PageInfo articles = null;
+
+ int pageSize = int.Parse(_settingService.GetSetting("ArticlePageSize"));
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.PageSize = pageSize;
+ int totalItem = (int)_articleRepository.Single(
+ qeruy => qeruy
+ .Where(
+ a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Day == day.Day && a.CreateDate.Month == day.Month && a.CreateDate.Year == day.Year
+ )
+ .Count()
+ );
+ pageInfo.TotalItem = totalItem;
+ pageIndex = pageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : pageIndex;
+
+ IList list = _articleRepository.Find(
+ query => query.Where(
+ a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open && a.CreateDate.Day == day.Day && a.CreateDate.Month == day.Month && a.CreateDate.Year == day.Year
+ )
+ .OrderByDescending(a => a.CreateDate)
+ .Skip((pageIndex - 1) * pageSize).Take(pageSize)
+ );
+ pageInfo.PageItems = list;
+ pageInfo.PageIndex = pageIndex;
+ return pageInfo;
+ }
+
+ public IList GetLastBlog()
+ {
+ IList LastBlog = null;
+ int count = int.Parse(_settingService.GetSetting("LastArticleCount"));
+ LastBlog = _articleRepository.Find(
+ query => query.Where(
+ a => a.Type == ArticleType.Blog && a.Status == ArticleStatus.Open
+ )
+ .OrderByDescending(a => a.CreateDate)
+ .Take(count)
+ );
+ return LastBlog;
+ }
+
+ public IList GetLastPage()
+ {
+ IList LastPage = null;
+ int count = int.Parse(_settingService.GetSetting("LastArticleCount"));
+ LastPage = _articleRepository.Find(
+ query => query.Where(
+ a => a.Type == ArticleType.Page && a.Status == ArticleStatus.Open
+ )
+ .OrderByDescending(a => a.CreateDate)
+ .Take(count)
+ );
+ return LastPage;
+ }
+
+ public Article BrowseArticle(int articleId)
+ {
+ Article article = GetArticle(articleId);
+
+ if (article.Status == ArticleStatus.Delete)
+ {
+ throw new DomainException("NoFind", "对不起,该文章不存在或已经被删除。");
+ }
+ else if (_roleService.ReadArticelPower(article))
+ {
+ article.Browse++;
+ _articleRepository.Update(article);
+ return article;
+ }
+ else
+ {
+ throw new DomainException("NoPower", "对不起,您没有权限查看该文章。");
+ }
+ }
+
+ public PageInfo FindArticlesByQuery(Func, IQueryable> expr, int pageIndex, int pageSize)
+ {
+ if (!_roleService.AddArticlePower())
+ {
+ throw new DomainException("NoPower", "对不起,您没有权限!");
+ }
+
+ pageIndex = pageIndex > 0 ? pageIndex : 1;
+
+ int count = (int)_articleRepository.Single(query => expr(query).Count());
+
+ PageInfo info = new PageInfo()
+ {
+ PageIndex = pageIndex,
+ PageSize = pageSize,
+ TotalItem = count
+ };
+ info.PageIndex = info.PageIndex > info.TotalPage ? info.TotalPage : info.PageIndex;
+
+ IList list = _articleRepository.Find(query => expr(query).Skip((pageIndex - 1) * pageSize).Take(pageSize));
+
+ info.PageItems = list;
+ return info;
+ }
+
+ public object GetArticleSingle(Func, object> expr)
+ {
+ return _articleRepository.Single(expr);
+ }
+ }
}
diff --git a/MyBlog/Blog.Domain/CategoryService.cs b/MyBlog/Blog.Domain/CategoryService.cs
index 0036cfb..68cf1f3 100644
--- a/MyBlog/Blog.Domain/CategoryService.cs
+++ b/MyBlog/Blog.Domain/CategoryService.cs
@@ -45,20 +45,12 @@ public CategoryService(ICategoryRepository categoryRepository, IRoleService role
public IDictionary GetMonthCategory()
{
- IDictionary cache = (IDictionary)HttpRuntime.Cache.Get("Category_Month");
- if (cache != null)
- {
- return cache;
- }
-
IList months = _categoryRepository.GetMonthCategory();
IDictionary monthCategory = new Dictionary();
foreach (string month in months)
{
monthCategory.Add(month, month.Insert(4, " 年") + "月");
}
-
- HttpRuntime.Cache.Insert("Category_Month", monthCategory, new SqlCacheDependency("Default", "Category"), DateTime.UtcNow.AddDays(1), TimeSpan.Zero);
return monthCategory;
}
@@ -81,7 +73,7 @@ public Model.Category GetCategoryById(int categoryId)
public Model.Category FindTagByName(string name)
{
- IList categorys = _categorys.Where(c => c.Name == name).ToList();
+ IList categorys = this.GetAllCategory().Where(c => c.Name == name).ToList();
if (categorys.Count > 0)
{
@@ -128,6 +120,7 @@ public void UpdateCategory(Category category)
{
throw new DomainException("NoFind", "没有找到该分类!");
}
+ _categorys = null;
_categoryRepository.Update(category);
}
diff --git a/MyBlog/Blog.Domain/CommentService.cs b/MyBlog/Blog.Domain/CommentService.cs
index 916a96d..31bdad2 100644
--- a/MyBlog/Blog.Domain/CommentService.cs
+++ b/MyBlog/Blog.Domain/CommentService.cs
@@ -38,12 +38,7 @@ public CommentService(IArticleService articleService, ICommentRepository comment
public IList GetLastComments()
{
//缓存加载
- IList comments = (IList)HttpRuntime.Cache.Get("Comment_LastComment");
-
- if (comments != null)
- {
- return comments;
- }
+ IList comments = null;
int count = int.Parse(_settiongService.GetSetting("LastCommentCount"));
comments = _commentRepository.Find(
query => query.Where(
@@ -53,7 +48,6 @@ public CommentService(IArticleService articleService, ICommentRepository comment
);
//加入缓存
- HttpRuntime.Cache.Insert("Comment_LastComment", comments, new SqlCacheDependency("Default", "Comment"), DateTime.UtcNow.AddMinutes(1), TimeSpan.Zero);
return comments;
}
@@ -66,12 +60,7 @@ public CommentService(IArticleService articleService, ICommentRepository comment
public PageInfo GetCommentsByArticleId(int articleId, int pageIndex)
{
//缓存加载
- PageInfo page = (PageInfo)HttpRuntime.Cache.Get("Comment_ArticlePage" + articleId + "_" + pageIndex);
-
- if (page != null)
- {
- return page;
- }
+ PageInfo page = null;
page = new PageInfo();
int userId = _sessionManager.User == null ? 0 : _sessionManager.User.UserId;
@@ -92,9 +81,6 @@ public PageInfo GetCommentsByArticleId(int articleId, int pageIndex)
page.PageIndex = pageIndex;
-
- ///加入缓存
- HttpRuntime.Cache.Insert("Comment_ArticlePage" + articleId + "_" + pageIndex, page, new SqlCacheDependency("Default", "Comment"), DateTime.UtcNow.AddMilliseconds(30), TimeSpan.Zero);
return page;
}
@@ -211,12 +197,7 @@ public Comment GetComment(int id)
public int GetCommentPageIndex(int commentId)
{
//缓存开启
- int? pageIndex = (int?)HttpRuntime.Cache.Get("Comment_PageIndex" + commentId);
-
- if (pageIndex != null)
- {
- return pageIndex.Value;
- }
+ int pageIndex = 0;
Comment comment = _commentRepository.Get(commentId);
while (comment.Parent != null)
@@ -234,8 +215,7 @@ public int GetCommentPageIndex(int commentId)
pageIndex = (int)Math.Ceiling(count / (double)pageSize);
//加入缓存
- HttpRuntime.Cache.Insert("Comment_PageIndex" + commentId, pageIndex, new SqlCacheDependency("Default", "Comment"), DateTime.MaxValue, TimeSpan.FromMinutes(1));
- return pageIndex.Value;
+ return pageIndex;
}
///
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.dll b/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.dll
index 918bafe..ded928a 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.dll and b/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.pdb b/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.pdb
index 2c79e6a..44bf043 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.pdb and b/MyBlog/Blog.Domain/bin/Debug/Blog.Domain.pdb differ
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Model.dll b/MyBlog/Blog.Domain/bin/Debug/Blog.Model.dll
index 112f52a..2077dcc 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Model.dll and b/MyBlog/Blog.Domain/bin/Debug/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Model.pdb b/MyBlog/Blog.Domain/bin/Debug/Blog.Model.pdb
index 04511a7..ea00d51 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Model.pdb and b/MyBlog/Blog.Domain/bin/Debug/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.dll b/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.dll
index ae4d326..cdb8f03 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.dll and b/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.pdb b/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.pdb
index 0d61408..126687f 100644
Binary files a/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.pdb and b/MyBlog/Blog.Domain/bin/Debug/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Domain.dll b/MyBlog/Blog.Domain/bin/Release/Blog.Domain.dll
index 8168be3..25c148f 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Domain.dll and b/MyBlog/Blog.Domain/bin/Release/Blog.Domain.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Domain.pdb b/MyBlog/Blog.Domain/bin/Release/Blog.Domain.pdb
index 70279a9..a8e3d7e 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Domain.pdb and b/MyBlog/Blog.Domain/bin/Release/Blog.Domain.pdb differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Model.dll b/MyBlog/Blog.Domain/bin/Release/Blog.Model.dll
index 9478438..bdad411 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Model.dll and b/MyBlog/Blog.Domain/bin/Release/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Model.pdb b/MyBlog/Blog.Domain/bin/Release/Blog.Model.pdb
index 27a217f..a15fbf7 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Model.pdb and b/MyBlog/Blog.Domain/bin/Release/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Repository.dll b/MyBlog/Blog.Domain/bin/Release/Blog.Repository.dll
index 42c7047..bce3ddc 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Repository.dll and b/MyBlog/Blog.Domain/bin/Release/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Domain/bin/Release/Blog.Repository.pdb b/MyBlog/Blog.Domain/bin/Release/Blog.Repository.pdb
index 7ad4513..ae4d6fc 100644
Binary files a/MyBlog/Blog.Domain/bin/Release/Blog.Repository.pdb and b/MyBlog/Blog.Domain/bin/Release/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.csprojResolveAssemblyReference.cache b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.csprojResolveAssemblyReference.cache
index f892602..b554176 100644
Binary files a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.csprojResolveAssemblyReference.cache and b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.csprojResolveAssemblyReference.cache differ
diff --git a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.dll b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.dll
index 918bafe..ded928a 100644
Binary files a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.dll and b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.dll differ
diff --git a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.pdb b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.pdb
index 2c79e6a..44bf043 100644
Binary files a/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.pdb and b/MyBlog/Blog.Domain/obj/Debug/Blog.Domain.pdb differ
diff --git a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csproj.FileListAbsolute.txt b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csproj.FileListAbsolute.txt
index 3e99f4c..ed13221 100644
--- a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csproj.FileListAbsolute.txt
+++ b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csproj.FileListAbsolute.txt
@@ -11,3 +11,16 @@ C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Domain\bin\Release\Iesi.Collecti
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Domain\obj\Release\Blog.Domain.csprojResolveAssemblyReference.cache
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Domain\obj\Release\Blog.Domain.dll
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Domain\obj\Release\Blog.Domain.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Domain.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Domain.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Model.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Repository.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\NHibernate.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Iesi.Collections.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Model.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Blog.Repository.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\NHibernate.xml
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\bin\Release\Iesi.Collections.xml
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\obj\Release\Blog.Domain.csprojResolveAssemblyReference.cache
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\obj\Release\Blog.Domain.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Domain\obj\Release\Blog.Domain.pdb
diff --git a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csprojResolveAssemblyReference.cache b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csprojResolveAssemblyReference.cache
index 691089b..6ad18ea 100644
Binary files a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csprojResolveAssemblyReference.cache and b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.csprojResolveAssemblyReference.cache differ
diff --git a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.dll b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.dll
index 8168be3..25c148f 100644
Binary files a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.dll and b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.dll differ
diff --git a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.pdb b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.pdb
index 70279a9..a8e3d7e 100644
Binary files a/MyBlog/Blog.Domain/obj/Release/Blog.Domain.pdb and b/MyBlog/Blog.Domain/obj/Release/Blog.Domain.pdb differ
diff --git a/MyBlog/Blog.Domain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/MyBlog/Blog.Domain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache
index dbe7413..95bf5d2 100644
Binary files a/MyBlog/Blog.Domain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/MyBlog/Blog.Domain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/MyBlog/Blog.Model/Article.cs b/MyBlog/Blog.Model/Article.cs
index e8c67b7..d32edea 100644
--- a/MyBlog/Blog.Model/Article.cs
+++ b/MyBlog/Blog.Model/Article.cs
@@ -5,6 +5,7 @@ namespace Blog.Model
///
/// 文章类
///
+ [Serializable]
public class Article
{
///
diff --git a/MyBlog/Blog.Model/ArticleExtend.cs b/MyBlog/Blog.Model/ArticleExtend.cs
index eba5173..6e33b3e 100644
--- a/MyBlog/Blog.Model/ArticleExtend.cs
+++ b/MyBlog/Blog.Model/ArticleExtend.cs
@@ -4,7 +4,8 @@ namespace Blog.Model
{
///
/// 文章扩展类
- ///
+ ///
+ [Serializable]
public class ArticleExtend
{
///
diff --git a/MyBlog/Blog.Model/Attach.cs b/MyBlog/Blog.Model/Attach.cs
index 55dacca..c5b2074 100644
--- a/MyBlog/Blog.Model/Attach.cs
+++ b/MyBlog/Blog.Model/Attach.cs
@@ -3,7 +3,8 @@ namespace Blog.Model
{
///
/// 附件表
- ///
+ ///
+ [Serializable]
public class Attach
{
///
diff --git a/MyBlog/Blog.Model/Category.cs b/MyBlog/Blog.Model/Category.cs
index 7bfda5d..fa6c1fa 100644
--- a/MyBlog/Blog.Model/Category.cs
+++ b/MyBlog/Blog.Model/Category.cs
@@ -4,7 +4,8 @@ namespace Blog.Model
{
///
/// 分类表
- ///
+ ///
+ [Serializable]
public class Category
{
///
diff --git a/MyBlog/Blog.Model/CategoryRelationShip.cs b/MyBlog/Blog.Model/CategoryRelationShip.cs
index d132488..c40ec19 100644
--- a/MyBlog/Blog.Model/CategoryRelationShip.cs
+++ b/MyBlog/Blog.Model/CategoryRelationShip.cs
@@ -4,7 +4,8 @@ namespace Blog.Model
{
///
/// 文章分类对应表
- ///
+ ///
+ [Serializable]
public class CategoryRelationShip
{
///
diff --git a/MyBlog/Blog.Model/Comment.cs b/MyBlog/Blog.Model/Comment.cs
index 236709c..800c5e1 100644
--- a/MyBlog/Blog.Model/Comment.cs
+++ b/MyBlog/Blog.Model/Comment.cs
@@ -6,6 +6,7 @@ namespace Blog.Model
///
/// 评论类
///
+ [Serializable]
public class Comment
{
///
diff --git a/MyBlog/Blog.Model/Setting.cs b/MyBlog/Blog.Model/Setting.cs
index d9720de..e119abf 100644
--- a/MyBlog/Blog.Model/Setting.cs
+++ b/MyBlog/Blog.Model/Setting.cs
@@ -4,7 +4,8 @@ namespace Blog.Model
{
///
/// 设置类
- ///
+ ///
+ [Serializable]
public class Setting
{
///
diff --git a/MyBlog/Blog.Model/User.cs b/MyBlog/Blog.Model/User.cs
index cefa8ed..971160b 100644
--- a/MyBlog/Blog.Model/User.cs
+++ b/MyBlog/Blog.Model/User.cs
@@ -5,6 +5,7 @@ namespace Blog.Model
///
/// 用户类
///
+ [Serializable]
public class User
{
///
diff --git a/MyBlog/Blog.Model/UserExtend.cs b/MyBlog/Blog.Model/UserExtend.cs
index e565fa3..bc296e2 100644
--- a/MyBlog/Blog.Model/UserExtend.cs
+++ b/MyBlog/Blog.Model/UserExtend.cs
@@ -5,6 +5,7 @@ namespace Blog.Model
///
/// 用户信息扩展类
///
+ [Serializable]
public class UserExtend
{
///
diff --git a/MyBlog/Blog.Model/bin/Debug/Blog.Model.dll b/MyBlog/Blog.Model/bin/Debug/Blog.Model.dll
index 112f52a..2077dcc 100644
Binary files a/MyBlog/Blog.Model/bin/Debug/Blog.Model.dll and b/MyBlog/Blog.Model/bin/Debug/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Model/bin/Debug/Blog.Model.pdb b/MyBlog/Blog.Model/bin/Debug/Blog.Model.pdb
index 04511a7..ea00d51 100644
Binary files a/MyBlog/Blog.Model/bin/Debug/Blog.Model.pdb and b/MyBlog/Blog.Model/bin/Debug/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Model/bin/Release/Blog.Model.dll b/MyBlog/Blog.Model/bin/Release/Blog.Model.dll
index 9478438..bdad411 100644
Binary files a/MyBlog/Blog.Model/bin/Release/Blog.Model.dll and b/MyBlog/Blog.Model/bin/Release/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Model/bin/Release/Blog.Model.pdb b/MyBlog/Blog.Model/bin/Release/Blog.Model.pdb
index 27a217f..a15fbf7 100644
Binary files a/MyBlog/Blog.Model/bin/Release/Blog.Model.pdb and b/MyBlog/Blog.Model/bin/Release/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Model/obj/Debug/Blog.Model.dll b/MyBlog/Blog.Model/obj/Debug/Blog.Model.dll
index 112f52a..2077dcc 100644
Binary files a/MyBlog/Blog.Model/obj/Debug/Blog.Model.dll and b/MyBlog/Blog.Model/obj/Debug/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Model/obj/Debug/Blog.Model.pdb b/MyBlog/Blog.Model/obj/Debug/Blog.Model.pdb
index 04511a7..ea00d51 100644
Binary files a/MyBlog/Blog.Model/obj/Debug/Blog.Model.pdb and b/MyBlog/Blog.Model/obj/Debug/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Model/obj/Release/Blog.Model.csproj.FileListAbsolute.txt b/MyBlog/Blog.Model/obj/Release/Blog.Model.csproj.FileListAbsolute.txt
index 17d8202..a69d4e8 100644
--- a/MyBlog/Blog.Model/obj/Release/Blog.Model.csproj.FileListAbsolute.txt
+++ b/MyBlog/Blog.Model/obj/Release/Blog.Model.csproj.FileListAbsolute.txt
@@ -3,3 +3,8 @@ C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Model\bin\Release\Blog.Model.pdb
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Model\obj\Release\Blog.Model.dll
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Model\obj\Release\Blog.Model.pdb
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Model\obj\Release\Blog.Model.csprojResolveAssemblyReference.cache
+C:\Users\Administrator\Desktop\MyBlog\Blog.Model\bin\Release\Blog.Model.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Model\bin\Release\Blog.Model.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Model\obj\Release\Blog.Model.csprojResolveAssemblyReference.cache
+C:\Users\Administrator\Desktop\MyBlog\Blog.Model\obj\Release\Blog.Model.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Model\obj\Release\Blog.Model.pdb
diff --git a/MyBlog/Blog.Model/obj/Release/Blog.Model.dll b/MyBlog/Blog.Model/obj/Release/Blog.Model.dll
index 9478438..bdad411 100644
Binary files a/MyBlog/Blog.Model/obj/Release/Blog.Model.dll and b/MyBlog/Blog.Model/obj/Release/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Model/obj/Release/Blog.Model.pdb b/MyBlog/Blog.Model/obj/Release/Blog.Model.pdb
index 27a217f..a15fbf7 100644
Binary files a/MyBlog/Blog.Model/obj/Release/Blog.Model.pdb and b/MyBlog/Blog.Model/obj/Release/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Model/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/MyBlog/Blog.Model/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache
index 0904fed..a9ffc9d 100644
Binary files a/MyBlog/Blog.Model/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/MyBlog/Blog.Model/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/MyBlog/Blog.Repository/Blog.Repository.csproj b/MyBlog/Blog.Repository/Blog.Repository.csproj
index 9cf160e..4b4e4b7 100644
--- a/MyBlog/Blog.Repository/Blog.Repository.csproj
+++ b/MyBlog/Blog.Repository/Blog.Repository.csproj
@@ -38,7 +38,9 @@
..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll
-
+
+ ..\packages\MySql.Data.6.7.4\lib\net40\MySql.Data.dll
+
..\packages\NHibernate.3.3.3.4000\lib\Net35\NHibernate.dll
diff --git a/MyBlog/Blog.Repository/CategoryRepository.cs b/MyBlog/Blog.Repository/CategoryRepository.cs
index f832c9e..1258259 100644
--- a/MyBlog/Blog.Repository/CategoryRepository.cs
+++ b/MyBlog/Blog.Repository/CategoryRepository.cs
@@ -2,6 +2,7 @@
using NHibernate;
using Blog.Repository.Interface;
using Blog.Model;
+using System.Collections.Generic;
namespace Blog.Repository
{
@@ -17,11 +18,20 @@ public System.Collections.Generic.IList GetMonthCategory()
//string sql = "select SUBSTRING( CONVERT(varchar,CreateDate,112),0,7) from Article Group by SUBSTRING( CONVERT(varchar,CreateDate,112),0,7)";
string sql = "SELECT LEFT( CreateDate, 7 ) AS lefttime FROM Article GROUP BY lefttime";
var query = session.CreateSQLQuery(sql);
- var list = query.List();
-
- for (int i = 0; i < list.Count; i++)
+ IList list = new List();
+ foreach (var obj in query.List())
{
- list[i] = list[i].Replace("-", string.Empty);
+ string str = null;
+ if (obj is string)
+ {
+ str = (string)obj;
+ }
+ else
+ {
+ str = System.Text.Encoding.Default.GetString((byte[])obj);
+ }
+ str = str.Replace("-", string.Empty);
+ list.Add(str);
}
return list;
}
diff --git a/MyBlog/Blog.Repository/bin/Debug/Blog.Model.dll b/MyBlog/Blog.Repository/bin/Debug/Blog.Model.dll
index 112f52a..2077dcc 100644
Binary files a/MyBlog/Blog.Repository/bin/Debug/Blog.Model.dll and b/MyBlog/Blog.Repository/bin/Debug/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Repository/bin/Debug/Blog.Model.pdb b/MyBlog/Blog.Repository/bin/Debug/Blog.Model.pdb
index 04511a7..ea00d51 100644
Binary files a/MyBlog/Blog.Repository/bin/Debug/Blog.Model.pdb and b/MyBlog/Blog.Repository/bin/Debug/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.dll b/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.dll
index ae4d326..cdb8f03 100644
Binary files a/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.dll and b/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.pdb b/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.pdb
index 0d61408..126687f 100644
Binary files a/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.pdb and b/MyBlog/Blog.Repository/bin/Debug/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Repository/bin/Debug/MySql.Data.dll b/MyBlog/Blog.Repository/bin/Debug/MySql.Data.dll
new file mode 100644
index 0000000..87aabe6
Binary files /dev/null and b/MyBlog/Blog.Repository/bin/Debug/MySql.Data.dll differ
diff --git a/MyBlog/Blog.Repository/bin/Release/Blog.Model.dll b/MyBlog/Blog.Repository/bin/Release/Blog.Model.dll
index 9478438..bdad411 100644
Binary files a/MyBlog/Blog.Repository/bin/Release/Blog.Model.dll and b/MyBlog/Blog.Repository/bin/Release/Blog.Model.dll differ
diff --git a/MyBlog/Blog.Repository/bin/Release/Blog.Model.pdb b/MyBlog/Blog.Repository/bin/Release/Blog.Model.pdb
index 27a217f..a15fbf7 100644
Binary files a/MyBlog/Blog.Repository/bin/Release/Blog.Model.pdb and b/MyBlog/Blog.Repository/bin/Release/Blog.Model.pdb differ
diff --git a/MyBlog/Blog.Repository/bin/Release/Blog.Repository.dll b/MyBlog/Blog.Repository/bin/Release/Blog.Repository.dll
index 42c7047..bce3ddc 100644
Binary files a/MyBlog/Blog.Repository/bin/Release/Blog.Repository.dll and b/MyBlog/Blog.Repository/bin/Release/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Repository/bin/Release/Blog.Repository.pdb b/MyBlog/Blog.Repository/bin/Release/Blog.Repository.pdb
index 7ad4513..ae4d6fc 100644
Binary files a/MyBlog/Blog.Repository/bin/Release/Blog.Repository.pdb and b/MyBlog/Blog.Repository/bin/Release/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Repository/bin/Release/MySql.Data.dll b/MyBlog/Blog.Repository/bin/Release/MySql.Data.dll
new file mode 100644
index 0000000..87aabe6
Binary files /dev/null and b/MyBlog/Blog.Repository/bin/Release/MySql.Data.dll differ
diff --git a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csproj.FileListAbsolute.txt b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csproj.FileListAbsolute.txt
index e093e49..af9faf3 100644
--- a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csproj.FileListAbsolute.txt
+++ b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csproj.FileListAbsolute.txt
@@ -28,6 +28,7 @@ C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\Blog.Repository.
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\Blog.Repository.pdb
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\Blog.Model.dll
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\Iesi.Collections.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\MySql.Data.dll
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\NHibernate.dll
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\NHibernate.Linq.dll
C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Debug\Blog.Model.pdb
diff --git a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csprojResolveAssemblyReference.cache b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csprojResolveAssemblyReference.cache
index d2ff001..9202c2a 100644
Binary files a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csprojResolveAssemblyReference.cache and b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.csprojResolveAssemblyReference.cache differ
diff --git a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.dll b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.dll
index ae4d326..cdb8f03 100644
Binary files a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.dll and b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.pdb b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.pdb
index 0d61408..126687f 100644
Binary files a/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.pdb and b/MyBlog/Blog.Repository/obj/Debug/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Repository/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/MyBlog/Blog.Repository/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 3ccb65f..6a50ded 100644
Binary files a/MyBlog/Blog.Repository/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/MyBlog/Blog.Repository/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csproj.FileListAbsolute.txt b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csproj.FileListAbsolute.txt
index 7421bde..6d70fb0 100644
--- a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csproj.FileListAbsolute.txt
+++ b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csproj.FileListAbsolute.txt
@@ -11,3 +11,17 @@ C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Repository\bin\Release\NHibernat
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Repository\obj\Release\Blog.Repository.csprojResolveAssemblyReference.cache
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Repository\obj\Release\Blog.Repository.dll
C:\Users\Administrator\Desktop\demo\MyBlog\Blog.Repository\obj\Release\Blog.Repository.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Blog.Repository.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Blog.Repository.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Blog.Model.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Iesi.Collections.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\MySql.Data.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\NHibernate.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\NHibernate.Linq.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Blog.Model.pdb
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\Iesi.Collections.xml
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\NHibernate.xml
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\bin\Release\NHibernate.Linq.xml
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\obj\Release\Blog.Repository.csprojResolveAssemblyReference.cache
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\obj\Release\Blog.Repository.dll
+C:\Users\Administrator\Desktop\MyBlog\Blog.Repository\obj\Release\Blog.Repository.pdb
diff --git a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csprojResolveAssemblyReference.cache b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csprojResolveAssemblyReference.cache
index 7cfdb17..772ca6e 100644
Binary files a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csprojResolveAssemblyReference.cache and b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.csprojResolveAssemblyReference.cache differ
diff --git a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.dll b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.dll
index 42c7047..bce3ddc 100644
Binary files a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.dll and b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.dll differ
diff --git a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.pdb b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.pdb
index 7ad4513..ae4d6fc 100644
Binary files a/MyBlog/Blog.Repository/obj/Release/Blog.Repository.pdb and b/MyBlog/Blog.Repository/obj/Release/Blog.Repository.pdb differ
diff --git a/MyBlog/Blog.Repository/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/MyBlog/Blog.Repository/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache
index 2d5a752..f1ab72f 100644
Binary files a/MyBlog/Blog.Repository/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/MyBlog/Blog.Repository/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/MyBlog/Blog.Repository/packages.config b/MyBlog/Blog.Repository/packages.config
index bd1ab58..763f3a6 100644
--- a/MyBlog/Blog.Repository/packages.config
+++ b/MyBlog/Blog.Repository/packages.config
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CategoryController.cs b/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CategoryController.cs
index 7e1665f..e4abfd3 100644
--- a/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CategoryController.cs
+++ b/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CategoryController.cs
@@ -99,7 +99,7 @@ public JsonResult AjaxAdd(string name, int parentId, int articleId)
}
Category category = new Category() { Name = name, Type = CategoryType.Category, Parent = parent };
_categoryService.AddCategory(category);
- Article article = _articleService.GetArticle(articleId);
+ Article article = articleId > 0 ? _articleService.GetArticle(articleId) : new Article();
MvcHtmlString categoryList = CategoryHelper.BulidArticleCategory(null, article);
return Json(new { success = true, data = categoryList.ToString(), data2 = CategoryHelper.BulidCategoryList(null).ToString() });
}
diff --git a/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CommentController.cs b/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CommentController.cs
index eae7078..6fe2be9 100644
--- a/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CommentController.cs
+++ b/MyBlog/Blog.WebUI/Areas/Admin/Controllers/CommentController.cs
@@ -50,7 +50,7 @@ public ActionResult Index(CommentSearchModel model, string message = null, strin
pageInfo.PageSize = model.PageSize.Value;
model.PageIndex = model.PageIndex > pageInfo.TotalPage ? pageInfo.TotalPage : model.PageIndex;
- model.PageIndex = model.PageIndex <= 0 ? 1 : model.PageIndex;
+ model.PageIndex = model.PageIndex < 1 ? 1 : model.PageIndex;
IList list = _commentService.Find(query => BulidCommentQuery(query, model).OrderByDescending(c => c.CreateDate).Skip((model.PageIndex - 1) * model.PageSize.Value).Take(model.PageSize.Value));
pageInfo.PageItems = list;
diff --git a/MyBlog/Blog.WebUI/Areas/Admin/Models/CommentSearchModel.cs b/MyBlog/Blog.WebUI/Areas/Admin/Models/CommentSearchModel.cs
index d015c10..506581b 100644
--- a/MyBlog/Blog.WebUI/Areas/Admin/Models/CommentSearchModel.cs
+++ b/MyBlog/Blog.WebUI/Areas/Admin/Models/CommentSearchModel.cs
@@ -15,7 +15,7 @@ public class CommentSearchModel
public string Search { get; set; }
- public int PageIndex { get { return pageIndex; } set { if (pageIndex > 0) { pageIndex = value; } } }
+ public int PageIndex { get { return pageIndex; } set { if (value > 0) { pageIndex = value; } } }
public int? PageSize { get; set; }
diff --git a/MyBlog/Blog.WebUI/Areas/Admin/Views/Article/Add.cshtml b/MyBlog/Blog.WebUI/Areas/Admin/Views/Article/Add.cshtml
index 2027fd5..5475e39 100644
--- a/MyBlog/Blog.WebUI/Areas/Admin/Views/Article/Add.cshtml
+++ b/MyBlog/Blog.WebUI/Areas/Admin/Views/Article/Add.cshtml
@@ -88,7 +88,7 @@
-