⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recyle.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 3 页
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using NetCMS.Model;
using NetCMS.DALFactory;
using NetCMS.DALProfile;
using NetCMS.Config;

namespace NetCMS.DALSQLServer
{
    public class Recyle : DbBase, IRecyle
    {
        private string SiteID = NetCMS.Global.Current.SiteID;
        public Recyle()
        {
        }

        public DataTable getList(string type)
        {
            string str_Sql = GetSql(type);
            string str_TName = Pre + "news";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            if (type == "NList")
            {
                DataTable dv = getNewsTable();
                if (dv != null)
                {
                    for (int i = 0; i < dv.Rows.Count; i++)
                    {
                        string str_TempName = dv.Rows[i][0].ToString();
                        if (str_TempName.ToUpper() != str_TName.ToUpper())
                        {
                            str_Sql = "Select Id,NewsID,NewsTitle From " + dv.Rows[i][0].ToString() + " Where isRecyle=1 and " +
                                       "SiteID='" + SiteID + "'";
                            DataTable dc = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
                            dt.Merge(dc);
                        }
                    }
                }
            }
            return dt;
        }

        protected string GetSql(string type)
        {
            string str_Sql = "";
            switch (type)
            {
                case "NCList":      //新闻栏目列表
                    str_Sql = "Select Id,ClassID,ClassCName From " + Pre + "news_Class Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "NList":       //新闻列表
                    str_Sql = "Select Id,NewsID,NewsTitle From " + Pre + "news Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "CList":       //频道列表
                    str_Sql = "Select Id,ChannelID,CName From " + Pre + "news_site Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "SList":       //专题列表
                    str_Sql = "Select Id,SpecialID,SpecialCName From " + Pre + "news_special Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "LCList":      //标签栏目列表
                    str_Sql = "Select Id,ClassID,ClassName From " + Pre + "sys_LabelClass Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "LList":       //标签列表
                    str_Sql = "Select Id,LabelID,Label_Name From " + Pre + "sys_Label Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "StCList":     //样式栏目列表
                    str_Sql = "Select Id,ClassID,Sname From " + Pre + "sys_styleclass Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "StList":       //样式列表
                    str_Sql = "Select Id,styleID,StyleName From " + Pre + "sys_LabelStyle Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
                case "PSFList":     //PSF结点列表
                    str_Sql = "Select Id,psfID,psfName From " + Pre + "sys_PSF Where isRecyle=1 and SiteID='" + SiteID + "'";
                    break;
            }
            return str_Sql;
        }

        public void RallNCList()
        {
            string str_Sql = "Update " + Pre + "news_Class Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }

        public void RallNList(string classid)
        {
            DataTable dt = getNewsTable();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string tbname = dt.Rows[i][0].ToString();
                    string str_Sql = "Select NewsID,ClassID,NewsProperty,NewsType,DataLib From " + tbname + " Where isRecyle=1 And SiteID='" + SiteID + "' And isRecyle=1";
                    DataTable dv = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
                    if (dv != null)
                    {
                        for (int j = 0; j < dv.Rows.Count; j++)
                        {
                            string str_Sql1 = "";
                            string newsclassid = dv.Rows[j]["ClassID"].ToString();
                            string newsid = dv.Rows[j]["NewsID"].ToString();

                            string Prot = dv.Rows[j]["NewsProperty"].ToString();
                            string[] getProt = Prot.Split(',');
                            int isRec = int.Parse(getProt[0]);
                            int isMarquee = int.Parse(getProt[1]);
                            int isHOT = int.Parse(getProt[2]);
                            int isFilt = int.Parse(getProt[3]);
                            int isTT = int.Parse(getProt[4]);
                            int isAnnouce = int.Parse(getProt[5]);
                            int isWap = int.Parse(getProt[6]);
                            int isJC = int.Parse(getProt[7]);
                            //string sTF = "select id from " + Pre + "news_temp where NewsID='" + newsid + "' and DataLib='" + dv.Rows[j]["DataLib"].ToString() + "' order by id desc";
                            //DataTable dtTF = DbHelper.ExecuteTable(CommandType.Text, sTF, null);
                            //if (dtTF != null)
                            //{
                            //    if (dtTF.Rows.Count == 0)
                            //    {
                                    int NewsType = int.Parse(dv.Rows[j]["NewsType"].ToString());
                                    DateTime CreatTime = DateTime.Parse(dv.Rows[j]["CreatTime"].ToString());
                                    int isConstr = 0;
                                    if (NetCMS.Common.Input.IsInteger(dv.Rows[j]["isConstr"].ToString()))
                                    {
                                        isConstr = int.Parse(dv.Rows[j]["isConstr"].ToString());
                                    }
                                    string ClassID = "";
                                    if (checkParIsDel(newsclassid, "news_Class") == true) { ClassID = classid; }
                                    else { ClassID = dv.Rows[j]["ClassID"].ToString(); }
                                    //string Sql = "insert into " + Pre + "news_temp (NewsID,DataLib,NewsType,CreatTime,IsRec,isHot,isTT,isAnnounce,isMarQuee,isConstr,isJC,isWap,isFilt,ClassID)";
                                    //Sql += " VALUES ('" + newsid + "','" + dv.Rows[j]["DataLib"].ToString() + "'," + NewsType + ",'" + CreatTime + "'," + isRec + "," + isHOT + "," + isTT + "," + isAnnouce + "," + isMarquee + "," + isConstr + "," + isJC + "," + isWap + "," + isFilt + ",'" + ClassID + "')";
                                    //DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
                            //    }
                            //    dtTF.Clear(); dtTF.Dispose();
                            //}
                        //删除多余的信息
                        RandFirst:
                            //string SqlTf = "select ID from " + Pre + "news_temp order by id desc";
                            //DataTable rTF = DbHelper.ExecuteTable(CommandType.Text, SqlTf, null);
                            //if (rTF.Rows.Count > 3000)
                            //{
                            //    string SQL1 = "delete from " + Pre + "news_temp where id=(select top 1 id from " + Pre + "news_temp order by id asc)";
                            //    DbHelper.ExecuteNonQuery(CommandType.Text, SQL1, null);
                            //    rTF.Clear(); rTF.Dispose();
                            //    goto RandFirst;
                            //}




                            if (checkParIsDel(newsclassid, "news_Class") == true)
                            {
                                str_Sql1 = "Update " + tbname + " Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
                            }
                            else
                            {

                                str_Sql1 = "Update " + tbname + " Set isRecyle=0 Where SiteID='" + SiteID + "' and NewsID='" + newsid + "'";
                            }
                            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
                            raDComment(newsid, false);
                        }
                        dv.Clear();
                        dv.Dispose();
                    }
                }
                dt.Clear();
                dt.Dispose();
            }
        }

        public void RallCList()
        {
            string str_Sql = "Update " + Pre + "news_site Set isRecyle=0 Where SiteID='" + SiteID + "'  And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void RallSList()
        {
            string str_Sql = "Update " + Pre + "news_special Set isRecyle=0 Where SiteID='" + SiteID + "'  And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void RallLCList()
        {
            string str_Sql = "Update " + Pre + "sys_LabelClass Set isRecyle=0 Where SiteID='" + SiteID + "'  And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void RallLList(string classid)
        {
            string str_Sql = "Select LabelID,ClassID From " + Pre + "sys_Label Where isRecyle=1 And SiteID='" + SiteID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            if (dt != null)
            {
                string str_Sql1 = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string labelclassid = dt.Rows[i]["ClassID"].ToString();
                    string labelid = dt.Rows[i]["LabelID"].ToString();

                    if (checkParIsDel(labelclassid, "sys_LabelClass") == true)
                        str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' And LabelID='" + labelid + "'";
                    else
                        str_Sql1 = "Update " + Pre + "sys_Label Set isRecyle=0 Where SiteID='" + SiteID + "' And LabelID='" + labelid + "'";

                    DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
                }
                dt.Clear();
                dt.Dispose();
            }
        }
        public void RallStCList()
        {
            string str_Sql = "Update " + Pre + "sys_styleclass Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void RallStList(string classid)
        {
            string str_Sql = "Select styleID,ClassID From " + Pre + "sys_styleclass Where isRecyle=1 And SiteID='" + SiteID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            if (dt != null)
            {
                string str_Sql1 = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string styleclassid = dt.Rows[i]["ClassID"].ToString();
                    string styleid = dt.Rows[i]["styleID"].ToString();

                    if (checkParIsDel(styleclassid, "sys_styleclass") == true)
                        str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0,ClassID='" + classid + "' Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";
                    else
                        str_Sql1 = "Update " + Pre + "sys_LabelStyle Set isRecyle=0 Where SiteID='" + SiteID + "' And styleID='" + styleid + "'";

                    DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
                }
                dt.Clear();
                dt.Dispose();
            }
        }
        public void RallPSFList()
        {
            string str_Sql = "Update " + Pre + "sys_PSF Set isRecyle=0 Where SiteID='" + SiteID + "' And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        //---------------------------------------------------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------------------------------------------------
        public void DallNCList()
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                DataTable dt = getNewsTable();
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tbname = dt.Rows[i][0].ToString();
                        string str_Sql = "Delete From " + tbname + " Where ClassID In (Select ClassID " +
                                         "From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1)";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
                        string str_Sql1 = "Delete From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
                    }
                    tran.Commit();
                    dt.Clear(); dt.Dispose();
                }
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public void DallNList()
        {
            DataTable dt = getNewsTable();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string tbname = dt.Rows[i][0].ToString();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -