예제 #1
0
        private static List <long> beginImportPrivate(ImportState ts)
        {
            long id = ts.TemplateId;

            SpiderImport item = SpiderImport.findById(id);

            List <SpiderArticle> articles = SpiderArticle
                                            .find("SpiderTemplateId in (" + item.DataSourceIds + ") and Id>" + item.LastImportId + " order by Id")
                                            .list();

            List <ContentSection> sections = ContentSection.find("Id in (" + item.SectionIds + ")").list();

            if (sections.Count == 0)
            {
                throw new Exception("导入的目标section不存在");
            }

            ContentSection section = null;
            List <long>    results = new List <long>();

            for (int i = 0; i < articles.Count; i++)
            {
                if (articleExist(articles[i]))
                {
                    ts.Log.AppendLine("pass..." + articles[i].Title);
                    continue;
                }

                section = getNextSection(sections, section);   // 均匀分散到各目标section中
                ContentApp app = getApp(section);

                if (item.IsApprove == 1)
                {
                    importToTemp(articles[i], item, section, app);
                }
                else
                {
                    long newArticleId = importDirect(articles[i], item, section, app);
                    results.Add(newArticleId);
                }

                ts.Log.AppendLine("导入:" + articles[i].Title);
            }

            if (articles.Count > 0)
            {
                item.LastImportId = articles[articles.Count - 1].Id;
                item.update("LastImportId");
                ts.Log.AppendLine("导入完毕(操作结束)");
            }
            else
            {
                ts.Log.AppendLine("没有新条目可导入(操作结束)");
            }


            return(results);
        }
예제 #2
0
        public void DoRefresh(int id)
        {
            set("processLink", to(Process, id));

            StringBuilder sb = LogCacher.GetNewImportLog("log" + ctx.viewer.Id);
            ImportState   ts = new ImportState();

            ts.TemplateId = id;
            ts.Log        = sb;

            new Thread(ImportUtil.BeginImport).Start(ts);
        }
예제 #3
0
        private static List<long> beginImportPrivate( ImportState ts ) {

            long id = ts.TemplateId;

            SpiderImport item = SpiderImport.findById( id );

            List<SpiderArticle> articles = SpiderArticle
                .find( "SpiderTemplateId in (" + item.DataSourceIds + ") and Id>" + item.LastImportId + " order by Id" )
                .list();

            List<ContentSection> sections = ContentSection.find( "Id in (" + item.SectionIds + ")" ).list();
            if (sections.Count == 0) throw new Exception( "导入的目标section不存在" );

            ContentSection section = null;
            List<long> results = new List<long>();
            for (int i = 0; i < articles.Count; i++) {

                if (articleExist( articles[i] )) {
                    ts.Log.AppendLine( "pass..." + articles[i].Title );
                    continue;
                }

                section = getNextSection( sections, section ); // 均匀分散到各目标section中
                ContentApp app = getApp( section );

                if (item.IsApprove == 1) {
                    importToTemp( articles[i], item, section, app );
                }
                else {
                    long newArticleId = importDirect( articles[i], item, section, app );
                    results.Add( newArticleId );
                }

                ts.Log.AppendLine( "导入:" + articles[i].Title );

            }

            if (articles.Count > 0) {
                item.LastImportId = articles[articles.Count - 1].Id;
                item.update( "LastImportId" );
                ts.Log.AppendLine( "导入完毕(操作结束)" );
            }
            else {
                ts.Log.AppendLine( "没有新条目可导入(操作结束)" );
            }


            return results;
        }
예제 #4
0
        public static void BeginImport(object param)
        {
            ImportState ts = param as ImportState;

            try {
                beginImportPrivate(ts);
            }
            catch (Exception ex) {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                ts.Log.AppendLine(ex.Message);
                ts.Log.AppendLine(ex.StackTrace);

                DbContext.closeConnectionAll();
            }
        }
예제 #5
0
파일: ImportJob.cs 프로젝트: Boshin/wojilu
        public void Execute()
        {
            List<SpiderImport> items = SpiderImport.find( "IsDelete=0" ).list();
            DbContext.closeConnectionAll();
            logger.Info( "begin ImportJob=" + items.Count );

            StringBuilder log = new StringBuilder();
            foreach (SpiderImport item in items) {

                ImportState ts = new ImportState();
                ts.TemplateId = item.Id;
                ts.Log = log;

                ImportUtil.BeginImport( ts );

                DbContext.closeConnectionAll();

            }
        }
예제 #6
0
파일: ImportJob.cs 프로젝트: zhdwwf/wojilu
        public void Execute()
        {
            List <SpiderImport> items = SpiderImport.find("IsDelete=0").list();

            DbContext.closeConnectionAll();
            logger.Info("begin ImportJob=" + items.Count);

            StringBuilder log = new StringBuilder();

            foreach (SpiderImport item in items)
            {
                ImportState ts = new ImportState();
                ts.TemplateId = item.Id;
                ts.Log        = log;

                ImportUtil.BeginImport(ts);

                DbContext.closeConnectionAll();
            }
        }
예제 #7
0
        public virtual void DoRefresh( long id ) {

            set( "processLink", to( Process, id ) );

            StringBuilder sb = LogCacher.GetNewImportLog( "log" + ctx.viewer.Id );
            ImportState ts = new ImportState();
            ts.TemplateId = id;
            ts.Log = sb;

            new Thread( ImportUtil.BeginImport ).Start( ts );
        }