using System;
using System.Collections.Generic;
using System.Text;
using Fm.DataAccess;
using System.Data;
using System.Data.Common;
using System.Collections;

namespace Fm.Tags
{
    /// <summary>
    /// 标签解析数据读取类
    /// </summary>
    public class Tags_sql
    {
        /// <summary>
        /// 获取公告浏览次数
        /// </summary>
        /// <param name="aff_id"></param>
        /// <returns></returns>
        public IList GetAfficheCount(int aff_id)
        {

            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Fm_GetAffiche_count");
            DataAccess.DataAccess.db.AddInParameter(db, "@aff_id", DbType.Int32, aff_id);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取网站公告信息
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public IList GetAffiche(int count)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Fm_GetAffiche");
            DataAccess.DataAccess.db.AddInParameter(db,"@count",DbType.Int32,count);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
/**************************************文档部分Start*******************************************/
        /// <summary>
        /// 获取文被顶的次数和被踩的次数
        /// </summary>
        /// <param name="docid"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IList GetArticleTopTread(int docid, int type)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_gettoportread");
            DataAccess.DataAccess.db.AddInParameter(db,"@docid",DbType.Int32,docid);
            DataAccess.DataAccess.db.AddInParameter(db,"@type",DbType.Int32,type);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取文章浏览次数
        /// </summary>
        /// <param name="aid"></param>
        /// <returns></returns>
        public IList GetArticleClick(int docid,int page)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getclick");
            DataAccess.DataAccess.db.AddInParameter(db,"@docid",DbType.Int32,docid);
            DataAccess.DataAccess.db.AddInParameter(db, "@page", DbType.Int32, page);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取文章信息
        /// </summary>
        /// <param name="type">文章属性类型</param>
        /// <param name="classid">指定栏目</param>
        /// <param name="count">显示数量</param>
        /// <returns></returns>
        public IList GetArticle(string type, string cid, string count)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getarticle");
            DataAccess.DataAccess.db.AddInParameter(db, "@type", DbType.String, type);
            DataAccess.DataAccess.db.AddInParameter(db, "@cid", DbType.Int32, int.Parse(cid));
            DataAccess.DataAccess.db.AddInParameter(db, "@count", DbType.Int32, int.Parse(count));

            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取上一篇下一篇文章标题
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IList GetNextOrFront(int aid, string type)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getnextorfront");
            DataAccess.DataAccess.db.AddInParameter(db, "@docid", DbType.Int32, aid);
            DataAccess.DataAccess.db.AddInParameter(db, "@type", DbType.String, type);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取文章内容
        /// </summary>
        /// <param name="aid"></param>
        /// <returns></returns>
        public IList GetContent(int docid)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getcontent");
            DataAccess.DataAccess.db.AddInParameter(db, "@docid", DbType.Int32, docid);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
/***********************************文档部分End****************************************/
        /// <summary>
        /// 生成文章需要获取的内容数据
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public IList GetContentView(string where)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Fm_content_view");
            DataAccess.DataAccess.db.AddInParameter(db,"@where",DbType.String,where);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
      
        /// <summary>
        /// 获取网站导航栏目数据
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public IList GetSitemap(int cid)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_sitemap");
            DataAccess.DataAccess.db.AddInParameter(db,"@cid",DbType.Int32,cid);

            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 调用友情连接数据
        /// </summary>
        /// <param name="type">友情连接类型</param>
        /// <param name="count">调用的数量</param>
        /// <returns></returns>
        public IList GetLink(string type, string count)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getlink");
            DataAccess.DataAccess.db.AddInParameter(db, "@type", DbType.String, type);
         
            DataAccess.DataAccess.db.AddInParameter(db, "@count", DbType.Int32, int.Parse(count));


            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
/**************************************栏目调用Start*******************************/
        /// <summary>
        /// 频道信息
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public IList GetChannels(int cid)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_channels");
            DataAccess.DataAccess.db.AddInParameter(db, "@cid", DbType.Int32, cid);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
        /// <summary>
        /// 获取栏目信息
        /// </summary>
        /// <param name="type">栏目类型</param>
        /// <param name="classid">指定栏目ID</param>
        /// <param name="count">显示数量(0为显示全部)</param>
        /// <returns></returns>
        public IList GetMenu(string type, string cid, string count)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Tags_getcolumn");
            DataAccess.DataAccess.db.AddInParameter(db, "@type", DbType.String, type);
            DataAccess.DataAccess.db.AddInParameter(db,"@cid",DbType.Int32,int.Parse(cid));
            DataAccess.DataAccess.db.AddInParameter(db,"@count",DbType.Int32,int.Parse(count));

            return DataAccess.DataAccess.GetData.Select<DbCommand>(db);
        }
/***********************************栏目调用End*************************************/
    }
}
