Пример #1
0
        private void transSectionOne( ContentPost x )
        {
            if (x.PageSection == null || x.PageSection.Id <= 0) return;

            int sectionId = x.PageSection.Id;

            ContentPostSection ps = hasTrans( x, sectionId );

            if (ps != null) {

                ps.SaveStatus = x.SaveStatus;
                ps.update();

            }
            else {

                ContentPostSection newPs = new ContentPostSection();
                newPs.Post = x;
                newPs.Section = x.PageSection;
                newPs.SaveStatus = x.SaveStatus;

                newPs.insert();

                logger.Info( "transSectionOne=> postId=" + x.Id + ", sectionId=" + x.PageSection.Id );
            }
        }
Пример #2
0
        public virtual void Insert(ContentPost post, string sectionIds, string tagList)
        {
            int[] ids = cvt.ToIntArray(sectionIds);

            post.PageSection    = new ContentSection(); // 不再使用旧版一对多关系
            post.PageSection.Id = ids[0];
            post.insert();


            // 多对多处理
            ContentPostSection ps = new ContentPostSection();

            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }

            // 旧版一对多兼容处理
            foreach (int sectionId in ids)
            {
                updateCachePostIds(sectionId);
            }

            post.Tag.Save(tagList);
        }
Пример #3
0
        public virtual void Insert(ContentPost post, string sectionIds, string tagList)
        {
            int[] ids = cvt.ToIntArray(sectionIds);
            if (ids.Length == 0)
            {
                throw new ArgumentException("sectionIds");
            }

            // 保存
            post.PageSection = new ContentSection {
                Id = ids[0]
            };                                                     // 缓存Section
            post.insert();

            // 多对多处理
            ContentPostSection ps = new ContentPostSection();

            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;
                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }

            // tag
            post.Tag.Save(tagList);
        }
Пример #4
0
        private void transOne(ContentPost x, List <ContentSection> sections)
        {
            if (sections.Count == 0)
            {
                return;
            }

            // 0. 先更新post
            x.AppId       = sections[0].AppId;
            x.PageSection = sections[0];
            x.update();

            // 1. 删除旧有关系
            ContentPostSection.deleteBatch("PostId=" + x.Id);

            // 2. 挪到新section中
            foreach (ContentSection section in sections)
            {
                // 多对多处理
                ContentPostSection ps = new ContentPostSection();
                ps.Post    = x;
                ps.Section = section;
                ps.insert();
            }
        }
Пример #5
0
        private void transSectionOne(ContentPost x)
        {
            if (x.PageSection == null || x.PageSection.Id <= 0)
            {
                return;
            }

            int sectionId = x.PageSection.Id;

            ContentPostSection ps = hasTrans(x, sectionId);

            if (ps != null)
            {
                ps.SaveStatus = x.SaveStatus;
                ps.update();
            }
            else
            {
                ContentPostSection newPs = new ContentPostSection();
                newPs.Post       = x;
                newPs.Section    = x.PageSection;
                newPs.SaveStatus = x.SaveStatus;

                newPs.insert();

                logger.Info("transSectionOne=> postId=" + x.Id + ", sectionId=" + x.PageSection.Id);
            }
        }
Пример #6
0
        private static void insertPostSectionShip(long sectionId, ContentPost post)
        {
            // page section
            ContentSection section = new ContentSection();

            section.Id = sectionId;

            // 缓存原始section
            post.PageSection = section;
            post.update();

            // 多对多关系
            ContentPostSection ps = new ContentPostSection();

            ps.Post    = post;
            ps.Section = section;
            ps.insert();
        }
Пример #7
0
        public virtual void Update(ContentPost post, String sectionIds, String tagList)
        {
            if (db.update(post).IsValid)
            {
                post.Tag.Save(tagList);
            }

            List <ContentPostSection> oldPsList = ContentPostSection.find("PostId=" + post.Id).list();

            // 多对多处理
            ContentPostSection.deleteBatch("PostId=" + post.Id);

            ContentPostSection ps = new ContentPostSection();

            int[] ids = cvt.ToIntArray(sectionIds);
            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }

            post.PageSection    = new ContentSection(); // 不再使用旧版一对多关系
            post.PageSection.Id = ids[0];
            post.update();


            // 更新旧的section关系
            foreach (ContentPostSection p in oldPsList)
            {
                updateCachePostIds(p.Section.Id);
            }
            // 更新新的section关系
            foreach (int sectionId in ids)
            {
                updateCachePostIds(sectionId);
            }
        }
Пример #8
0
        public virtual void Update(ContentPost post, String sectionIds, String tagList)
        {
            // 保存
            if (db.update(post).IsValid)
            {
                post.Tag.Save(tagList);
            }

            // 多对多处理
            ContentPostSection.deleteBatch("PostId=" + post.Id);
            ContentPostSection ps = new ContentPostSection();

            int[] ids = cvt.ToIntArray(sectionIds);
            foreach (int sectionId in ids)
            {
                ContentSection section = new ContentSection();
                section.Id = sectionId;
                ps.Post    = post;
                ps.Section = section;
                ps.insert();
            }
        }
Пример #9
0
        public virtual void Update( ContentPost post, String sectionIds, String tagList )
        {
            // 保存
            if (db.update( post ).IsValid) {
                post.Tag.Save( tagList );
            }

            // 多对多处理
            ContentPostSection.deleteBatch( "PostId=" + post.Id );
            ContentPostSection ps = new ContentPostSection();
            int[] ids = cvt.ToIntArray( sectionIds );
            foreach (int sectionId in ids) {
                ContentSection section = new ContentSection();
                section.Id = sectionId;
                ps.Post = post;
                ps.Section = section;
                ps.insert();
            }
        }
Пример #10
0
        public virtual void Insert( ContentPost post, string sectionIds, string tagList )
        {
            int[] ids = cvt.ToIntArray( sectionIds );
            if (ids.Length == 0) throw new ArgumentException( "sectionIds" );

            // 保存
            post.PageSection = new ContentSection { Id = ids[0] }; // 缓存Section
            post.insert();

            // 多对多处理
            ContentPostSection ps = new ContentPostSection();
            foreach (int sectionId in ids) {
                ContentSection section = new ContentSection();
                section.Id = sectionId;
                ps.Post = post;
                ps.Section = section;
                ps.insert();
            }

            // tag
            post.Tag.Save( tagList );
        }
Пример #11
0
        private void transOne( ContentPost x, List<ContentSection> sections ) {

            if (sections.Count == 0) return;

            // 0. 先更新post
            x.AppId = sections[0].AppId;
            x.PageSection = sections[0];
            x.update();

            // 1. 删除旧有关系
            ContentPostSection.deleteBatch( "PostId=" + x.Id );

            // 2. 挪到新section中
            foreach (ContentSection section in sections) {

                // 多对多处理
                ContentPostSection ps = new ContentPostSection();
                ps.Post = x;
                ps.Section = section;
                ps.insert();

            }
        }
Пример #12
0
        public virtual void Update( ContentPost post, String sectionIds, String tagList )
        {
            if (db.update( post ).IsValid) {
                post.Tag.Save( tagList );
            }

            List<ContentPostSection> oldPsList = ContentPostSection.find( "PostId=" + post.Id ).list();

            // ��Զദ��
            ContentPostSection.deleteBatch( "PostId=" + post.Id );

            ContentPostSection ps = new ContentPostSection();
            int[] ids = cvt.ToIntArray( sectionIds );
            foreach (int sectionId in ids) {

                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post = post;
                ps.Section = section;
                ps.insert();
            }

            post.PageSection = new ContentSection(); // ����ʹ�þɰ�һ�Զ��ϵ
            post.PageSection.Id = ids[0];
            post.update();

            // ���¾ɵ�section��ϵ
            foreach (ContentPostSection p in oldPsList) {
                updateCachePostIds( p.Section.Id );
            }
            // �����µ�section��ϵ
            foreach (int sectionId in ids) {
                updateCachePostIds( sectionId );
            }
        }
Пример #13
0
        public virtual void Insert( ContentPost post, string sectionIds, string tagList )
        {
            int[] ids = cvt.ToIntArray( sectionIds );

            post.PageSection = new ContentSection(); // ����ʹ�þɰ�һ�Զ��ϵ
            post.PageSection.Id = ids[0];
            post.insert();

            // ��Զദ��
            ContentPostSection ps = new ContentPostSection();
            foreach (int sectionId in ids) {

                ContentSection section = new ContentSection();
                section.Id = sectionId;

                ps.Post = post;
                ps.Section = section;
                ps.insert();
            }

            // �ɰ�һ�Զ���ݴ���
            foreach (int sectionId in ids) {
                updateCachePostIds( sectionId );
            }

            post.Tag.Save( tagList );
        }