using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Solog.IDbTask;
using Solog.Model;
namespace Solog.SQLTask
{
public class SqlProfile:IDataTask
{
public ArticleInfo[] ListArticle(string sqlfilter)
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
if (sqlfilter != string.Empty && sqlfilter!=null)
{
Parameters para = new Parameters();
int cateId = Convert.ToInt32(sqlfilter);
para.Add("@sqlfilter", cateId);
SqlDataReader dr = getdata.GetReader("SP_ListArticleByFilter", para, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
}
else
{
SqlDataReader dr = getdata.GetReader("SP_ListArticle", null, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
}
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//获取top10文章列表
public ArticleInfo[] TopArticles()
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
SqlDataReader dr = getdata.GetReader("SP_TopArticles", null, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//站内搜索
public ArticleInfo[] SearchResult(string searchKey)
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
Parameters para = new Parameters();
para.Add("@searchKey",searchKey);
SqlDataReader dr = getdata.GetReader("SP_SearchResult", para, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//评论列表
public DataSet ListComment()
{
GetData getdata = new GetData();
return getdata.GetDataSet("SP_ListComment",null,true);
}
public DataSet ListCate()
{
DataSet result = new DataSet();
GetData gd = new GetData();
result = gd.GetDataSet("SP_ListCate", null, true);
return result;
}
//获取views.aspx查看文章
public DataSet GetArticle(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId", id);
return getdata.GetDataSet("SP_GetArticle",para, true);
}
public SqlDataReader GetArticleReader(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId", id);
return getdata.GetReader("SP_GetArticleReader", para, true);
}
//获取要编辑的文章内容
public ArticleInfo EditArtInfo(int id)
{
ArticleInfo inf = new ArticleInfo();
SqlDataReader dr = GetArticleReader(id);
while (dr.Read())
{
inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
}
dr.Close();
return inf;
}
//获取ID文章的评论
public DataSet GetComment(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId",id);
return getdata.GetDataSet("SP_GetComment", para, true);
}
//添加评论
public void PostComment(CommentInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@logId",inf.logId);
para.Add("@commContent",inf.commContent);
para.Add("@author",inf.author);
para.Add("@postTime",inf.postTime);
para.Add("@email",inf.email);
para.Add("@web",inf.web);
para.Add("postIp",inf.postIp);
getdata.excNonQuery("SP_PostComment", para, true);
}
//更新查看数据
public void UpdateViewNums(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id",id);
getdata.excNonQuery("SP_UpdateViewNums",para,true);
}
//添加文章
public void AddArticle(ArticleInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateId",inf.cateId);
para.Add("@title",inf.title);
para.Add("@intro",inf.intro);
para.Add("@content",inf.content);
para.Add("@from",inf.from);
para.Add("@DisUbb",inf.DisUbb);
para.Add("@DisComment",inf.DisComment);
para.Add("@isTop",inf.isTop);
para.Add("@isShow",inf.isShow);
getdata.excNonQuery("SP_PostArticle",para,true);
}
//更新文章
public void UpdateArticle(ArticleInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@ID", inf.ID);
para.Add("@title", inf.title);
para.Add("@cateId",inf.cateId);
para.Add("@intro", inf.intro);
para.Add("@content", inf.content);
para.Add("@from", inf.from);
para.Add("@DisUbb", inf.DisUbb);
para.Add("@DisComment", inf.DisComment);
para.Add("@isTop", inf.isTop);
para.Add("@isShow", inf.isShow);
getdata.excNonQuery("SP_UpdateArticle",para,true);
}
//删除指定文章
public void DelArticle(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id", id);
getdata.excNonQuery("SP_DelArticle", para, true);
}
//删除评论
public void DelComment(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id", id);
getdata.excNonQuery("SP_DelComment", para, true);
}
//删除分类
public void DelCate(int cateid)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateid", cateid);
getdata.excNonQuery("SP_DelCate", para, true);
}
//添加分类
public void AddCate(string cateName)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateName",cateName);
getdata.excNonQuery("SP_AddCate", para, true);
}
//仅执行SQL命令
public void ExcuteSQL(string sql)
{
GetData getdata = new GetData();
getdata.excNonQuery(sql);
}
//修改分类
public void EditCateName(string name, int cateId)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@name",name);
para.Add("@cateId",cateId);
getdata.excNonQuery("SP_EditCateName",para,true);
}
//转移分类
public void Transfer(int fromCate, int toCate)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@fromCate",fromCate);
para.Add("@toCate", toCate);
getdata.excNonQuery("SP_TransferCate",para,true);
}
//获取文章数
public int GetArticleNums()
{
GetData getdata = new GetData();
return getdata.excScalar("SP_GetArticleNums", null, true);
}
//获取评论数
public int GetCommentNums()
{
GetData getdata = new GetData();
return getdata.excScalar("SP_GetCommentNums", null, true);
}
//获取评论列表
public CommentInfo[] GetComments()
{
CommentInfo comInf = new CommentInfo();
ArrayList arrCom = new ArrayList();
GetData getdata = new GetData();
SqlDataReader dr = getdata.GetReader("SP_GetComments", null, true);
while (dr.Read())
{
comInf = SqlHelper.ConvertToCommentInfo(dr, new CommentInfo());
arrCom.Add(comInf);
}
dr.Close();
return (CommentInfo[])arrCom.ToArray(typeof(CommentInfo));
}
//统计用户访问记录
public void InsertVistorInfo(VistorInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@IP",inf.IP);
para.Add("@Agent",inf.Agent);
para.Add("@ReferUrl",inf.ReferUrl);
para.Add("@VistorTime", inf.VistorTime);
getdata.excNonQuery("SP_InsertVistorInfo", para, true);
}
//获取访问记录
public VistorInfo[] GetVistorInfo()
{
VistorInfo visInf = new VistorInfo();
ArrayList arrVis = new ArrayList();
GetData getdata = new GetData();
SqlDataReader dr = getdata.GetReader("SP_GetVistorInfo",null,true);
while (dr.Read())
{
visInf = SqlHelper.ConvertToVistorInfo(dr, new VistorInfo());
arrVis.Add(visInf);
}
dr.Close();
return (VistorInfo[])arrVis.ToArray(typeof(VistorInfo));
}
}
}
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Solog.IDbTask;
using Solog.Model;
namespace Solog.SQLTask
{
public class SqlProfile:IDataTask
{
public ArticleInfo[] ListArticle(string sqlfilter)
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
if (sqlfilter != string.Empty && sqlfilter!=null)
{
Parameters para = new Parameters();
int cateId = Convert.ToInt32(sqlfilter);
para.Add("@sqlfilter", cateId);
SqlDataReader dr = getdata.GetReader("SP_ListArticleByFilter", para, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
}
else
{
SqlDataReader dr = getdata.GetReader("SP_ListArticle", null, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
}
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//获取top10文章列表
public ArticleInfo[] TopArticles()
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
SqlDataReader dr = getdata.GetReader("SP_TopArticles", null, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//站内搜索
public ArticleInfo[] SearchResult(string searchKey)
{
GetData getdata = new GetData();
ArrayList arrArt = new ArrayList();
Parameters para = new Parameters();
para.Add("@searchKey",searchKey);
SqlDataReader dr = getdata.GetReader("SP_SearchResult", para, true);
while (dr.Read())
{
ArticleInfo inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
arrArt.Add(inf);
}
dr.Close();
return (ArticleInfo[])arrArt.ToArray(typeof(ArticleInfo));
}
//评论列表
public DataSet ListComment()
{
GetData getdata = new GetData();
return getdata.GetDataSet("SP_ListComment",null,true);
}
public DataSet ListCate()
{
DataSet result = new DataSet();
GetData gd = new GetData();
result = gd.GetDataSet("SP_ListCate", null, true);
return result;
}
//获取views.aspx查看文章
public DataSet GetArticle(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId", id);
return getdata.GetDataSet("SP_GetArticle",para, true);
}
public SqlDataReader GetArticleReader(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId", id);
return getdata.GetReader("SP_GetArticleReader", para, true);
}
//获取要编辑的文章内容
public ArticleInfo EditArtInfo(int id)
{
ArticleInfo inf = new ArticleInfo();
SqlDataReader dr = GetArticleReader(id);
while (dr.Read())
{
inf = SqlHelper.ConvertToArticleInfo(dr, new ArticleInfo());
}
dr.Close();
return inf;
}
//获取ID文章的评论
public DataSet GetComment(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@contentId",id);
return getdata.GetDataSet("SP_GetComment", para, true);
}
//添加评论
public void PostComment(CommentInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@logId",inf.logId);
para.Add("@commContent",inf.commContent);
para.Add("@author",inf.author);
para.Add("@postTime",inf.postTime);
para.Add("@email",inf.email);
para.Add("@web",inf.web);
para.Add("postIp",inf.postIp);
getdata.excNonQuery("SP_PostComment", para, true);
}
//更新查看数据
public void UpdateViewNums(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id",id);
getdata.excNonQuery("SP_UpdateViewNums",para,true);
}
//添加文章
public void AddArticle(ArticleInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateId",inf.cateId);
para.Add("@title",inf.title);
para.Add("@intro",inf.intro);
para.Add("@content",inf.content);
para.Add("@from",inf.from);
para.Add("@DisUbb",inf.DisUbb);
para.Add("@DisComment",inf.DisComment);
para.Add("@isTop",inf.isTop);
para.Add("@isShow",inf.isShow);
getdata.excNonQuery("SP_PostArticle",para,true);
}
//更新文章
public void UpdateArticle(ArticleInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@ID", inf.ID);
para.Add("@title", inf.title);
para.Add("@cateId",inf.cateId);
para.Add("@intro", inf.intro);
para.Add("@content", inf.content);
para.Add("@from", inf.from);
para.Add("@DisUbb", inf.DisUbb);
para.Add("@DisComment", inf.DisComment);
para.Add("@isTop", inf.isTop);
para.Add("@isShow", inf.isShow);
getdata.excNonQuery("SP_UpdateArticle",para,true);
}
//删除指定文章
public void DelArticle(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id", id);
getdata.excNonQuery("SP_DelArticle", para, true);
}
//删除评论
public void DelComment(int id)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@id", id);
getdata.excNonQuery("SP_DelComment", para, true);
}
//删除分类
public void DelCate(int cateid)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateid", cateid);
getdata.excNonQuery("SP_DelCate", para, true);
}
//添加分类
public void AddCate(string cateName)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@cateName",cateName);
getdata.excNonQuery("SP_AddCate", para, true);
}
//仅执行SQL命令
public void ExcuteSQL(string sql)
{
GetData getdata = new GetData();
getdata.excNonQuery(sql);
}
//修改分类
public void EditCateName(string name, int cateId)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@name",name);
para.Add("@cateId",cateId);
getdata.excNonQuery("SP_EditCateName",para,true);
}
//转移分类
public void Transfer(int fromCate, int toCate)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@fromCate",fromCate);
para.Add("@toCate", toCate);
getdata.excNonQuery("SP_TransferCate",para,true);
}
//获取文章数
public int GetArticleNums()
{
GetData getdata = new GetData();
return getdata.excScalar("SP_GetArticleNums", null, true);
}
//获取评论数
public int GetCommentNums()
{
GetData getdata = new GetData();
return getdata.excScalar("SP_GetCommentNums", null, true);
}
//获取评论列表
public CommentInfo[] GetComments()
{
CommentInfo comInf = new CommentInfo();
ArrayList arrCom = new ArrayList();
GetData getdata = new GetData();
SqlDataReader dr = getdata.GetReader("SP_GetComments", null, true);
while (dr.Read())
{
comInf = SqlHelper.ConvertToCommentInfo(dr, new CommentInfo());
arrCom.Add(comInf);
}
dr.Close();
return (CommentInfo[])arrCom.ToArray(typeof(CommentInfo));
}
//统计用户访问记录
public void InsertVistorInfo(VistorInfo inf)
{
GetData getdata = new GetData();
Parameters para = new Parameters();
para.Add("@IP",inf.IP);
para.Add("@Agent",inf.Agent);
para.Add("@ReferUrl",inf.ReferUrl);
para.Add("@VistorTime", inf.VistorTime);
getdata.excNonQuery("SP_InsertVistorInfo", para, true);
}
//获取访问记录
public VistorInfo[] GetVistorInfo()
{
VistorInfo visInf = new VistorInfo();
ArrayList arrVis = new ArrayList();
GetData getdata = new GetData();
SqlDataReader dr = getdata.GetReader("SP_GetVistorInfo",null,true);
while (dr.Read())
{
visInf = SqlHelper.ConvertToVistorInfo(dr, new VistorInfo());
arrVis.Add(visInf);
}
dr.Close();
return (VistorInfo[])arrVis.ToArray(typeof(VistorInfo));
}
}
}