예제 #1
0
        public void Delete(int id)
        {
            SpiderImport s = SpiderImport.findById(id);

            s.IsDelete = 1;
            s.update("IsDelete");
        }
예제 #2
0
        public virtual void Delete(long id)
        {
            SpiderImport s = SpiderImport.findById(id);

            s.IsDelete = 1;
            s.update("IsDelete");
        }
예제 #3
0
        public void Stop(int id)
        {
            SpiderImport item = importService.GetById(id);

            item.IsDelete = 1;
            item.update("IsDelete");
            echoAjaxOk();
        }
예제 #4
0
        public virtual void Start(long id)
        {
            SpiderImport item = importService.GetById(id);

            item.IsDelete = 0;
            item.update("IsDelete");
            echoAjaxOk();
        }
예제 #5
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);
        }
예제 #6
0
        public void Save()
        {
            int    id        = ctx.PostInt("Id");
            int    isApprove = ctx.PostInt("isApprove");
            String name      = ctx.Post("name");
            String srcIds    = ctx.PostIdList("srcIds");
            String targetIds = ctx.PostIdList("targetIds");
            String userName  = ctx.Post("userName");

            if (strUtil.IsNullOrEmpty(name))
            {
                errors.Add("请填写名称");
            }
            if (strUtil.IsNullOrEmpty(srcIds))
            {
                errors.Add("请选择数据源");
            }
            if (strUtil.IsNullOrEmpty(targetIds))
            {
                errors.Add("请选择目标区块");
            }

            User user = userService.GetByName(userName);

            if (user == null)
            {
                errors.Add("用户不存在");
            }

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            SpiderImport it = id > 0 ? importService.GetById(id) : new SpiderImport();

            it.Name          = name;
            it.DataSourceIds = srcIds;
            it.SectionIds    = targetIds;
            it.IsApprove     = isApprove;
            it.Creator       = user;

            if (id > 0)
            {
                it.update();
            }
            else
            {
                it.insert();
            }

            echoJsonMsg("操作成功", true, null);
        }
예제 #7
0
 public void Update( SpiderImport s )
 {
     s.update();
 }
예제 #8
0
 public void Update(SpiderImport s)
 {
     s.update();
 }