Skip to content

Commit

Permalink
fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ss22219 committed Oct 20, 2013
1 parent f35829d commit 5cebc03
Show file tree
Hide file tree
Showing 130 changed files with 1,467 additions and 1,316 deletions.
594 changes: 305 additions & 289 deletions MyBlog/Blog.Domain/ArticelService.cs

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions MyBlog/Blog.Domain/CategoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,12 @@ public CategoryService(ICategoryRepository categoryRepository, IRoleService role

public IDictionary<string, string> GetMonthCategory()
{
IDictionary<string, string> cache = (IDictionary<string, string>)HttpRuntime.Cache.Get("Category_Month");
if (cache != null)
{
return cache;
}

IList<string> months = _categoryRepository.GetMonthCategory();
IDictionary<string, string> monthCategory = new Dictionary<string, string>();
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;
}

Expand All @@ -81,7 +73,7 @@ public Model.Category GetCategoryById(int categoryId)

public Model.Category FindTagByName(string name)
{
IList<Category> categorys = _categorys.Where(c => c.Name == name).ToList();
IList<Category> categorys = this.GetAllCategory().Where(c => c.Name == name).ToList();

if (categorys.Count > 0)
{
Expand Down Expand Up @@ -128,6 +120,7 @@ public void UpdateCategory(Category category)
{
throw new DomainException("NoFind", "没有找到该分类!");
}
_categorys = null;
_categoryRepository.Update(category);
}

Expand Down
28 changes: 4 additions & 24 deletions MyBlog/Blog.Domain/CommentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ public CommentService(IArticleService articleService, ICommentRepository comment
public IList<Model.Comment> GetLastComments()
{
//缓存加载
IList<Comment> comments = (IList<Comment>)HttpRuntime.Cache.Get("Comment_LastComment");

if (comments != null)
{
return comments;
}
IList<Comment> comments = null;
int count = int.Parse(_settiongService.GetSetting("LastCommentCount"));
comments = _commentRepository.Find(
query => query.Where(
Expand All @@ -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;
}

Expand All @@ -66,12 +60,7 @@ public CommentService(IArticleService articleService, ICommentRepository comment
public PageInfo<Comment> GetCommentsByArticleId(int articleId, int pageIndex)
{
//缓存加载
PageInfo<Comment> page = (PageInfo<Comment>)HttpRuntime.Cache.Get("Comment_ArticlePage" + articleId + "_" + pageIndex);

if (page != null)
{
return page;
}
PageInfo<Comment> page = null;

page = new PageInfo<Comment>();
int userId = _sessionManager.User == null ? 0 : _sessionManager.User.UserId;
Expand All @@ -92,9 +81,6 @@ public PageInfo<Comment> 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;
}

Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

/// <summary>
Expand Down
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Domain.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Domain.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Debug/Blog.Repository.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Domain.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Domain.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/bin/Release/Blog.Repository.pdb
Binary file not shown.
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/obj/Debug/Blog.Domain.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/obj/Debug/Blog.Domain.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/obj/Release/Blog.Domain.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Domain/obj/Release/Blog.Domain.pdb
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions MyBlog/Blog.Model/Article.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Blog.Model
/// <summary>
/// 文章类
/// </summary>
[Serializable]
public class Article
{
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion MyBlog/Blog.Model/ArticleExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Blog.Model
{
/// <summary>
/// 文章扩展类
/// </summary>
/// </summary>
[Serializable]
public class ArticleExtend
{
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion MyBlog/Blog.Model/Attach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ namespace Blog.Model
{
/// <summary>
/// 附件表
/// </summary>
/// </summary>
[Serializable]
public class Attach
{
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion MyBlog/Blog.Model/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Blog.Model
{
/// <summary>
/// 分类表
/// </summary>
/// </summary>
[Serializable]
public class Category
{
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion MyBlog/Blog.Model/CategoryRelationShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Blog.Model
{
/// <summary>
/// 文章分类对应表
/// </summary>
/// </summary>
[Serializable]
public class CategoryRelationShip
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions MyBlog/Blog.Model/Comment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Blog.Model
/// <summary>
/// 评论类
/// </summary>
[Serializable]
public class Comment
{
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion MyBlog/Blog.Model/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Blog.Model
{
/// <summary>
/// 设置类
/// </summary>
/// </summary>
[Serializable]
public class Setting
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions MyBlog/Blog.Model/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Blog.Model
/// <summary>
/// 用户类
/// </summary>
[Serializable]
public class User
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions MyBlog/Blog.Model/UserExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Blog.Model
/// <summary>
/// 用户信息扩展类
/// </summary>
[Serializable]
public class UserExtend
{
/// <summary>
Expand Down
Binary file modified MyBlog/Blog.Model/bin/Debug/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Model/bin/Debug/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Model/bin/Release/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Model/bin/Release/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Model/obj/Debug/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Model/obj/Debug/Blog.Model.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified MyBlog/Blog.Model/obj/Release/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Model/obj/Release/Blog.Model.pdb
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion MyBlog/Blog.Repository/Blog.Repository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
<Reference Include="Iesi.Collections">
<HintPath>..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" />
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.7.4\lib\net40\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="NHibernate">
<HintPath>..\packages\NHibernate.3.3.3.4000\lib\Net35\NHibernate.dll</HintPath>
</Reference>
Expand Down
18 changes: 14 additions & 4 deletions MyBlog/Blog.Repository/CategoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NHibernate;
using Blog.Repository.Interface;
using Blog.Model;
using System.Collections.Generic;

namespace Blog.Repository
{
Expand All @@ -17,11 +18,20 @@ public System.Collections.Generic.IList<string> 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<string>();

for (int i = 0; i < list.Count; i++)
IList<string> list = new List<string>();
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;
}
Expand Down
Binary file modified MyBlog/Blog.Repository/bin/Debug/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Debug/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Debug/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Debug/Blog.Repository.pdb
Binary file not shown.
Binary file added MyBlog/Blog.Repository/bin/Debug/MySql.Data.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Release/Blog.Model.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Release/Blog.Model.pdb
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Release/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/bin/Release/Blog.Repository.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/obj/Debug/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/obj/Debug/Blog.Repository.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/obj/Release/Blog.Repository.dll
Binary file not shown.
Binary file modified MyBlog/Blog.Repository/obj/Release/Blog.Repository.pdb
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions MyBlog/Blog.Repository/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net45" />
<package id="MySql.Data" version="6.7.4" targetFramework="net40" />
<package id="NHibernate" version="3.3.3.4000" targetFramework="net45" />
<package id="NHibernate.Linq" version="1.0" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Comment> 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;
Expand Down
2 changes: 1 addition & 1 deletion MyBlog/Blog.WebUI/Areas/Admin/Models/CommentSearchModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
2 changes: 1 addition & 1 deletion MyBlog/Blog.WebUI/Areas/Admin/Views/Article/Add.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</p>
</div>

<form name="post" action="post.php" method="post" id="post">
<form name="post" method="post" id="post">
<input type="hidden" id="_wpnonce" name="_wpnonce" value="a11e7d4610">
<input type="hidden" id="hiddenaction" name="action" value="editpost">
<input type="hidden" id="originalaction" name="originalaction" value="editpost">
Expand Down
Loading

0 comments on commit 5cebc03

Please sign in to comment.