Пример #1
0
        public static int Delete(IEnumerable <long> ids)
        {
            if (ids?.Count() == 0)
            {
                return(0);
            }

            string sql =
                "Delete AdsStatisticsLabels Where ID In ({0})\n";

            int num = 0;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) {
                num = conn.Execute(string.Format(sql, string.Join(", ", ids)));
            }

            ParagraphDAO.DeleteBySourceNo(ids);

            return(num);
        }
Пример #2
0
        public static int Delete(long id)
        {
            string sql =
                "Delete Pages Where NO IN (SELECT PageNo From Zones Where No IN (SELECT ZoneNo From Cards WHERE No IN (Select CardNo From ArticleIntro WHERE  ID={0})))\n" +
                "Delete Zones Where No IN (SELECT ZoneNo From Cards WHERE No IN (Select CardNo From ArticleIntro WHERE  ID={0}))\n" +
                "Delete Cards WHERE No IN (Select CardNo From Article WHERE ID={0}) \n" +
                "Delete ArticleIntro Where ID={0} \n";

            int num = 0;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn))
            {
                num = conn.Execute(string.Format(sql, id.ToString()));
            }
            long[] ids = new long[1] {
                id
            };
            ParagraphDAO.DeleteBySourceNo(ids.ToList());

            return(num);
        }
Пример #3
0
        public static void CopyArticle(long sourceId, long targetId, long targetCardNo, long targetMenuId, long targetSiteId, bool forceCopyRelative = false)
        {
            long creator = MemberDAO.SysCurrent.Id;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn))
            {
                string sql = "INSERT Article(ID, SiteID, MenuID, Type, Title, IssueDate, RemarkText, Icon, IsIssue, IssueStart, IssueEnd, Link, IsOpenNew, Archive, CardNo, Clicks, CustomIcon, TmplName, TmplThumb, Sort, Creator, CreateTime, IsShowVideo, VideoImgIsCustom, VideoImg, VideoID, VideoType, SubTitle) " +
                             $"SELECT { targetId }, { targetSiteId }, { targetMenuId }, Type, Title+'- (複製)', IssueDate, RemarkText, Icon, 0, IssueStart, IssueEnd, Link, IsOpenNew, Archive, { targetCardNo }, 0, CustomIcon, TmplName, TmplThumb, Sort, { creator }, GETDATE(), IsShowVideo, VideoImgIsCustom, VideoImg, VideoID, VideoType,SubTitle " +
                             $"FROM Article WHERE ID = { sourceId }";
                conn.Execute(sql);

                if (forceCopyRelative)
                { // 強迫複製關聯或為同一單元,則需要複製 Type 和 Poster
                    sql =
                        $"INSERT ArticleToType(ArticleID, TypeID) SELECT { targetId }, TypeID FROM ArticleToType WHERE ArticleID = { sourceId }\n" +
                        $"INSERT ArticleToPoster(ArticleID, PosterID, Sort) SELECT { targetId }, PosterID, Sort FROM ArticleToPoster WHERE ArticleID = { sourceId }\n";
                    conn.Execute(sql);
                }
            }

            ParagraphDAO.CopyAllInSourceNo(sourceId, targetId, targetSiteId);
        }
Пример #4
0
        public static int Delete(IEnumerable <long> ids)
        {
            if (ids?.Count() == 0)
            {
                return(0);
            }

            string sql =
                "Delete Pages Where NO IN (SELECT PageNo From Zones Where No IN (SELECT ZoneNo From Cards WHERE No IN (Select CardNo From Article WHERE  ID IN ({0}))))\n" +
                "Delete Zones Where No IN (SELECT ZoneNo From Cards WHERE No IN (Select CardNo From Article WHERE  ID IN ({0})))\n" +
                "Delete Cards WHERE No IN (Select CardNo From Article WHERE  ID IN ({0}))\n" +
                "Delete Article Where ID In ({0})\n" +
                "Delete ArticleToPoster Where ArticleID In ({0})\n" +
                "Delete ArticleToType Where ArticleID In ({0})\n";

            int num = 0;

            using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(WebInfo.Conn)) {
                num = conn.Execute(string.Format(sql, string.Join(", ", ids)));
            }
            ParagraphDAO.DeleteBySourceNo(ids);

            return(num);
        }