Beispiel #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);
        }
Beispiel #2
0
        //----------------------------------------------------------------------------------------------------------

        public virtual void Trans(String postIds, String targetSectionIds)
        {
            List <ContentPost> posts = ContentPost.find("Id in (" + postIds + ") ").list();

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

            foreach (ContentPost x in posts)
            {
                transOne(x, sections);
            }
        }
Beispiel #3
0
        private StringBuilder getTargetInfo(SpiderImport it)
        {
            StringBuilder         sb       = new StringBuilder();
            List <ContentSection> sections = ContentSection.find("Id in (" + it.SectionIds + ")").list();

            for (int i = 0; i < sections.Count; i++)
            {
                sb.Append(sections[i].Title);
                if (i < sections.Count - 1)
                {
                    sb.Append(",");
                }
            }
            return(sb);
        }
        private List <ContentApp> getApps(Service service)
        {
            List <ContentSection> sections = ContentSection.find("ServiceId=" + service.Id).list();

            if (sections.Count == 0)
            {
                return(new List <ContentApp>());
            }

            String ids = strUtil.GetIds(sections);

            if (strUtil.IsNullOrEmpty(ids))
            {
                return(new List <ContentApp>());
            }

            return(ContentApp.find("Id in (" + ids + ")").list());
        }
Beispiel #5
0
        public void Add(int id)
        {
            if (id > 0)
            {
                SpiderImport item = importService.GetById(id);
                if (item == null)
                {
                    echoRedirect(lang("exDataNotFound"));
                    return;
                }
                set("itemJson", Json.ToString(new ImportJson(item)));
            }
            else
            {
                set("itemJson", "{Id:0}");
            }

            set("step3Action", to(Save));
            set("returnUrl", to(List));

            List <SpiderTemplate> list = templateService.GetAll();

            checkboxList("dataSrc", list, "SiteName=Id", null);

            //dataTarget
            List <ContentApp> apps  = ContentApp.find("OwnerType=:otype").set("otype", typeof(Site).FullName).list();
            IBlock            block = getBlock("apps");

            foreach (ContentApp app in apps)
            {
                block.Set("appId", app.Id);

                IMemberApp ma = appService.GetByApp(app);
                if (ma == null)
                {
                    continue;
                }

                block.Set("appName", ma.Name);
                List <ContentSection> sections = ContentSection.find("AppId=" + app.Id).list();
                block.Set("dataTarget", Html.CheckBoxList(sections, "dataTarget", "Title", "Id", null));
                block.Next();
            }
        }
Beispiel #6
0
        public void Trans()
        {
            target(TransSave);

            String ids = ctx.GetIdList("ids");

            set("ids", ids);

            List <ContentApp> apps  = ContentApp.find("OwnerType=:otype order by Id").set("otype", typeof(Site).FullName).list();
            IBlock            block = getBlock("apps");
            List <Dictionary <String, String> > xlist = new List <Dictionary <String, String> >();

            foreach (ContentApp app in apps)
            {
                block.Set("app.Id", app.Id);

                IMemberApp ma = appService.GetByApp(app);
                if (ma == null)
                {
                    continue;
                }

                block.Set("app.Name", ma.Name);
                List <ContentSection> sections = ContentSection.find("AppId=" + app.Id + " order by Id").list();
                if (sections.Count == 0)
                {
                    continue;
                }

                Dictionary <String, String> obj = new Dictionary <String, String>();
                obj["Id"]   = app.Id.ToString();
                obj["Name"] = ma.Name;
                xlist.Add(obj);

                block.Set("dataTarget", Html.CheckBoxList(sections, "dataTarget", "Title", "Id", null));
                block.Next();
            }

            bindList("xlist", "x", xlist);
        }