Exemplo n.º 1
0
        private T AnalyzeTSave(TSave tsave, HtmlDocument doc)
        {
            string        xRoot  = tsave.RootxPath;
            List <TField> fields = tsave.TFields;

            HtmlNode hn = doc.DocumentNode.SelectSingleNode(xRoot);

            if (hn == null)
            {
                throw new Exception("root position failed  " + xRoot);
            }

            XmlDocument    xdResult = new XmlDocument();
            XmlDeclaration dec      = xdResult.CreateXmlDeclaration("1.0", null, null);

            xdResult.AppendChild(dec);
            XmlElement root = xdResult.CreateElement(type.Name);

            xdResult.AppendChild(root);

            foreach (TField tfield in fields)
            {
                AnalyzeTField(tfield, hn, root, xdResult);
            }

            using (StringReader reader = new StringReader(xdResult.OuterXml))
            {
                T obj = (T)xs.Deserialize(reader);
                return(obj);
            }
        }
Exemplo n.º 2
0
        private static TPage GetTPage(XmlNode xnPage)
        {
            TSave   tsave   = GetTSave(xnPage);
            TSave_M tsave_m = GetTSave_M(xnPage);
            TPage   tp      = new TPage(tsave, tsave_m);

            return(tp);
        }
Exemplo n.º 3
0
        public void SendEmailAndSaveOrder()
        {
            TSave save = new TSave();

            if (SendEmail(sendMesseg))
            {
                save.SaveOrder(TSave.ChoiceSaveOrder.Txt, GetOrder());
                save.SaveOrder(TSave.ChoiceSaveOrder.Sql, GetOrder());
            }
            else
            {
                MessageBox.Show("Wysłanie wiadomości nie powiodło się. Problem z adres e-mail lub z połaczeniem internetowym");
            }
        }
Exemplo n.º 4
0
        private static TSave GetTSave(XmlNode xnPage)
        {
            XmlNode xnSave = xnPage.SelectSingleNode("./save");

            if (xnSave == null)
            {
                return(null);
            }
            XmlNode       xnRoot = xnSave.Attributes["root"];
            string        root   = xnRoot == null ? "." : xnRoot.Value;
            List <TField> list   = GetTFields(xnSave);
            TSave         ts     = new TSave(root, list);

            return(ts);
        }
Exemplo n.º 5
0
        public T GetEntity(string html, ParseConfig config)
        {
            TSave tsave = config.Page.TSave;

            if (tsave == null)
            {
                throw new ArgumentNullException(tsave.GetType().Name);
            }

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            T obj = AnalyzeTSave(tsave, doc);

            return(obj);
        }
Exemplo n.º 6
0
    public static void Test()
    {
        MyJson.JsonNode_Object objst = MyJson.Parse
                                           ("{\"love\":{\"id\":12345}\"name\":\"aname\",\"age\":123,\"like\":[{\"name\":\"aaa\",\"desc\":\"aaaaaa\"},{\"name\":\"bbb\",\"desc\":\"bbbbbb\"}],\"strs\":[\"aa\",\"bb\"]}")
                                       as MyJson.JsonNode_Object;

        TSave read = CSLEConvert.FromJson("TSave", objst) as TSave;

        Debug.Log("read.name=" + read.name);
        Debug.Log("read.like[0].name=" + read.like[0].name);
        Like l = read.like[0];

        Debug.Log(l.name);

        Debug.Log("read.strs[1]=" + read.strs[1]);
        Debug.Log("read.love.id=" + read.love.id);
        Debug.Log("write" + CSLEConvert.ToJson(read).ToString());
    }
Exemplo n.º 7
0
        public void CopyData(LoadOrder.ChoiceLoadOrder data)
        {
            TSave                 save      = new TSave();
            List <Order>          listOrder = new List <Order>();
            TInsertAndQuestionSQL sql       = new TInsertAndQuestionSQL();

            switch (data)
            {
            case LoadOrder.ChoiceLoadOrder.Sql:
                listOrder = load.LoadOrderList(TLoadOrder.ChoiceLoadOrder.Sql);
                save.SaveOrderList(TSave.ChoiceSaveOrder.Txt, listOrder);
                break;

            case LoadOrder.ChoiceLoadOrder.Txt:
                listOrder = load.LoadOrderList(TLoadOrder.ChoiceLoadOrder.Txt);
                save.SaveOrderList(TSave.ChoiceSaveOrder.Sql, listOrder);
                break;
            }
        }
Exemplo n.º 8
0
    public static void Test()
    {
        MyJson.JsonNode_Object objst = MyJson.Parse
                                           ("{\"love\":{\"id\":12345}\"name\":\"aname\",\"age\":123,\"like\":[{\"name\":\"aaa\",\"desc\":\"aaaaaa\"},{\"name\":\"bbb\",\"desc\":\"bbbbbb\"}],\"strs\":[\"aa\",\"bb\"]}")
                                       as MyJson.JsonNode_Object;

        //throw new NotImplementedException("仍然未改写");
        TSave read = LSharpConvert.FromJson(typeof(TSave), objst) as TSave;

        Logger.Log("read.name=" + read.name);
        Logger.Log("read.like[0].name=" + read.like[0].name);
        Like l = read.like[0];

        Logger.Log(l.name);

        Logger.Log("read.strs[1]=" + read.strs[1]);
        Logger.Log("read.love.id=" + read.love.id);
        Logger.Log("write" + LSharpConvert.ToJson(read).ToString());
    }