Пример #1
0
        protected void loadByJsonData(SdNode config, String json)
        {
            ONode list = null;

            ONode obj = ONode.tryLoad(json);

            if (obj.isObject)
            {
                list = obj.get("list").asArray();

                if (TextUtils.isEmpty(name))
                {
                    name = obj.get("name").getString();
                    logo = obj.get("logo").getString();
                }
            }
            else
            {
                list = obj;
            }

            foreach (ONode n in list)
            {
                TxtModel txt = new TxtModel(referer, n.get("d").getString(), n.get("t").getInt(), n.get("c").getString());
                items.Add(txt);
            }
        }
Пример #2
0
        protected void loadByJsonData(SdNode config, String json)
        {
            ONode data = ONode.tryLoad(json);

            if (DdSource.isBook(config))
            {
                if (TextUtils.isEmpty(shop))
                {
                    logo  = data.get("logo").getString();
                    name  = data.get("name").getString();
                    shop  = data.get("shop").getString();
                    intro = data.get("intro").getString();

                    buyUrl = data.get("buyUrl").getString();
                }
            }

            ONode sl = data.get("pictures").asArray();

            foreach (ONode n in sl)
            {
                PicModel pic = new PicModel(bookUrl, n.getString());

                pictures.Add(pic);
            }
        }
Пример #3
0
 public void WriteValue(DateTime val)
 {
     OnWriteBef();
     _Writer.Append('\"');
     _Writer.Append(ONode.TIME_FORMAT_ACTION(val));
     _Writer.Append('\"');
     _LastIsEnd = true;
 }
Пример #4
0
        public void loadByJson(SdNode config, params String[] jsons)
        {
            if (jsons == null || jsons.Length == 0)
            {
                return;
            }

            foreach (String json in jsons)   //支持多个数据块加载
            {
                ONode data = ONode.tryLoad(json).asArray();

                if (DdSource.isHots(config))
                {
                    foreach (ONode n in data)
                    {
                        BookModel b = new BookModel();
                        b.name = n.get("name").getString();
                        b.url  = n.get("url").getString();
                        b.logo = n.get("logo").getString();

                        hotList.Add(b);
                    }
                    return;
                }

                if (DdSource.isUpdates(config))
                {
                    foreach (ONode n in data)
                    {
                        BookUpdateModel b = new BookUpdateModel();
                        b.name       = n.get("name").getString();
                        b.url        = n.get("url").getString();
                        b.logo       = n.get("logo").getString();
                        b.newSection = n.get("newSection").getString();
                        b.updateTime = n.get("updateTime").getString();

                        updateList.Add(b);
                    }
                    return;
                }

                if (DdSource.isTags(config))
                {
                    foreach (ONode n in data)
                    {
                        DdNode t1 = new DdNode(null);
                        t1.title = n.get("title").getString();
                        t1.url   = n.get("url").getString();
                        t1.group = n.get("group").getString();
                        t1.logo  = n.get("logo").getString();

                        doAddTagItem(t1);
                    }
                }
            }
        }
Пример #5
0
        public virtual void loadByJson(SdNode config, params string[] jsons)
        {
            if (jsons == null || jsons.Length == 0)
            {
                return;
            }

            foreach (String json in jsons)
            {
                if (json.StartsWith("{") || json.StartsWith("["))
                {
                    ONode jList = null;

                    ONode obj = ONode.tryLoad(json);
                    if (obj.isObject)
                    {
                        jList = obj.get("list").asArray();

                        if (TextUtils.isEmpty(name))
                        {
                            name = obj.get("name").getString();
                            logo = obj.get("logo").getString();
                        }
                    }
                    else
                    {
                        jList = obj;
                    }

                    foreach (ONode n1 in jList)
                    {
                        items.Add(new MediaModel(n1.get("url").getString(),
                                                 n1.get("type").getString(),
                                                 n1.get("mime").getString(),
                                                 n1.get("logo").getString()));
                    }
                }
                else
                {
                    foreach (String url in json.Split(';'))
                    {
                        if (url.Length > 6)
                        {
                            items.Add(new MediaModel(url));
                        }
                    }
                }
            }
        }
Пример #6
0
        protected void loadByJsonData(SdNode config, String json, StateTag state)
        {
            ONode list = null;
            ONode obj  = ONode.tryLoad(json);

            if (obj.isObject)
            {
                list = obj.get("list").asArray();
                String bg = obj.get("bg").getString();

                if (TextUtils.isEmpty(bg) == false)
                {
                    bgUrl = bg;
                }

                if (TextUtils.isEmpty(name))
                {
                    name = obj.get("name").getString();
                    logo = obj.get("logo").getString();
                }
            }
            else
            {
                list = obj;
            }

            foreach (ONode n in list)
            {
                PicModel pic = null;

                if (n.isObject)
                {
                    pic = new PicModel(section(), n.get("url").getString(), n.get("time").getInt(), state.value);
                }
                else
                {
                    pic = new PicModel(section(), n.getString(), 0, state.value);
                }

                pic.cacheID = items.Count;
                doAddItem(pic, state);

                state.value++;
            }
        }
Пример #7
0
        public virtual void loadByJson(SdNode c, params string[] jsons)
        {
            if (jsons == null || jsons.Length == 0)
            {
                return;
            }

            DdNode config = (DdNode)c;

            foreach (String json in jsons)   //支持多个数据块加载
            {
                ONode data = ONode.tryLoad(json);

                if (data.isArray)
                {
                    foreach (ONode n in data)
                    {
                        String name = n.get("name").getString();

                        if (doFilter(name))
                        {
                            continue;
                        }

                        BookSearchModel b = new BookSearchModel();

                        b.name       = name;
                        b.url        = n.get("url").getString();
                        b.logo       = n.get("logo").getString();
                        b.updateTime = n.get("updateTime").getString();
                        b.newSection = n.get("newSection").getString();
                        b.author     = n.get("author").getString();
                        b.status     = n.get("status").getString();
                        b.source     = config.source.title;
                        b.btag       = n.get("btag").getString();

                        DdNode cfg = config.s().book(b.url);
                        b._dtype = cfg.dtype();
                        b.btype  = cfg.btype();

                        doAddItem(b);
                    }
                }
            }
        }
Пример #8
0
        public virtual void loadByJson(SdNode config, params String[] jsons)
        {
            if (jsons == null || jsons.Length == 0)
            {
                return;
            }

            if (DdSource.isBook(config))
            {
                String json = jsons[0]; //不支持多个数据块加载
                ONode  data = ONode.tryLoad(json);

                name       = data.get("name").getString();
                author     = data.get("author").getString();
                intro      = data.get("intro").getString();
                logo       = data.get("logo").getString();
                updateTime = data.get("updateTime").getString();

                isSectionsAsc = data.get("isSectionsAsc").getInt() > 0;//默认为倒排
            }

            foreach (String json in jsons) //支持多个数据块加载
            {
                ONode data = ONode.tryLoad(json);
                ONode sl   = data.get("sections").asArray();

                foreach (ONode n in sl)
                {
                    SectionModel sec = newSection();
                    sec.name = n.get("name").getString();
                    sec.url  = n.get("url").getString();

                    sec.bookName = name;
                    sec.bookUrl  = bookUrl;

                    sec.orgIndex = total();


                    sections.Add(sec);

                    onAddItem(sec);
                }
            }
        }
Пример #9
0
        private void DoBuild(ObjectModel obj, bool isBatch)
        {
            var cols = viewModel.getPropertyList(currentSource, obj);

            WeedBuilder sdqBuilder = new WeedBuilder(currentSource);

            if (Directory.Exists(Config.DIR_OUT) == false)
            {
                Directory.CreateDirectory(Config.DIR_OUT);
            }



            sdqBuilder.TargetFolder = Config.DIR_OUT;
            sdqBuilder.args         = ONode.tryLoad(args.Text.Trim());
            sdqBuilder.TableName    = obj.Name;
            sdqBuilder.Columns      = cols;

            sdqBuilder.TempletFile = (string)templetBox.SelectedItem;


            sdqBuilder.Build();
        }
Пример #10
0
        public void loadByJson(SdNode c, params string[] jsons)
        {
            if (jsons == null || jsons.Length == 0)
            {
                return;
            }

            foreach (String json in jsons)   //支持多个数据块加载
            {
                ONode data = ONode.tryLoad(json);

                if (data.isArray)
                {
                    foreach (ONode n in data)
                    {
                        String name = n.get("name").getString();

                        if (Session.isVip == 0 && SourceApi.isFilter(name)) //非vip进行过滤
                        {
                            continue;
                        }

                        BookUpdateModel b = new BookUpdateModel();

                        b.name       = name;
                        b.url        = n.get("url").getString();
                        b.logo       = n.get("logo").getString();
                        b.author     = n.get("author").getString();
                        b.newSection = n.get("newSection").getString();
                        b.updateTime = n.get("updateTime").getString();
                        b.status     = n.get("status").getString();

                        list.Add(b);
                    }
                }
            }
        }
Пример #11
0
 public void WriteValue(DateTime value)
 {
     _writer.Append(ONode.TIME_FORMAT_ACTION(value));
 }
Пример #12
0
        public DdSource(String xml) : base()
        {
            if (xml.StartsWith("sited::"))
            {
                int start = xml.IndexOf("::") + 2;
                int end   = xml.LastIndexOf("::");
                var txt   = xml.Substring(start, end - start);
                var key   = xml.Substring(end + 2);
                xml = DdApi.unsuan(txt, key);
            }

            sited = xml;

            DoInit(xml);
            if (schema > 0)
            {
                xmlHeadName   = "meta";
                xmlBodyName   = "main";
                xmlScriptName = "script";
            }
            else
            {
                xmlHeadName   = "meta";
                xmlBodyName   = "main";
                xmlScriptName = "jscript";
            }
            DoLoad();

            meta = (DdNodeSet)head;
            main = (DdNodeSet)body;

            sds       = head.attrs.getString("sds");
            isPrivate = head.attrs.getInt("private") > 0;
            engine    = head.attrs.getInt("engine");
            ver       = head.attrs.getInt("ver");
            vip       = head.attrs.getInt("vip");

            author  = head.attrs.getString("author");
            contact = head.attrs.getString("contact");

            intro = head.attrs.getString("intro");
            logo  = head.attrs.getString("logo");

            if (engine > DdApi.version)
            {
                alert = "此插件需要更高版本引擎支持,否则会出错。建议升级!";
            }
            else
            {
                alert = head.attrs.getString("alert");
            }

            //
            //---------------------
            //
            trace_url = main.attrs.getString("trace");


            home = (DdNodeSet)main.get("home");
            {
                hots    = (DdNode)home.get("hots");
                updates = (DdNode)home.get("updates");
                tags    = (DdNode)home.get("tags");
            }

            search = (DdNode)main.get("search");

            _tag     = main.get("tag");
            _book    = main.get("book");
            _section = main.get("section");
            _object  = main.get("object");

            if (_object.isEmpty())
            {
                if (_section.isEmpty())
                {
                    _object = _book;
                }
                else
                {
                    _object = _section;
                }
            }

            if (schema > 0)
            {
                login  = (DdNode)head.get("login");  //登录
                reward = (DdNode)head.get("reward"); //打赏
            }
            else
            {
                login  = (DdNode)main.get("login");  //登录
                reward = (DdNode)main.get("reward"); //打赏
            }

            //-----------
            ONode json = new ONode();

            json.set("ver", DdApi.version);
            json.set("udid", Session.udid());

            json.set("uid", Session.userID);
            json.set("usex", Session.sex);
            json.set("uvip", Session.isVip);
            json.set("ulevel", Session.level);

            String jsCode = "SiteD=" + json.toJson() + ";";

            loadJs(jsCode);
        }