Beispiel #1
0
        public OpenResult GetOpenResult()
        {
            var response = HttpRequestFactory.Get("https://kaijiang.500.com/static/info/kaijiang/xml/index.xml");

            Byte[]      b             = response.Result.Content.ReadAsByteArrayAsync().Result;
            var         streamReceive = new GZipStream(response.Result.Content.ReadAsStreamAsync().Result, CompressionMode.Decompress);
            XmlDocument dom           = new XmlDocument();

            dom.Load(streamReceive);//这个地方需要注意
            XmlNodeList xmlNodeList = dom.SelectNodes("//lottery");
            XmlNode     xmlNode     = null;

            foreach (XmlNode el in xmlNodeList)
            {
                if (el.InnerXml.Contains("qxc") && el.InnerXml.Contains("7星彩"))
                {
                    xmlNode = el;
                }
            }
            lottery l = null;

            if (xmlNode != null)
            {
                l = XMLSerilizable.XMLToObject <lottery>(xmlNode.OuterXml, Encoding.UTF8);
            }
            return(l);
        }
Beispiel #2
0
        public void GetsTest1()
        {
            var response = HttpRequestFactory.Get("https://kaijiang.500.com/static/info/kaijiang/xml/index.xml");

            Byte[]      b             = response.Result.Content.ReadAsByteArrayAsync().Result;
            var         streamReceive = new GZipStream(response.Result.Content.ReadAsStreamAsync().Result, CompressionMode.Decompress);
            XmlDocument dom           = new XmlDocument();

            dom.Load(streamReceive);//这个地方需要注意
            XmlNodeList xmlNodeList = dom.SelectNodes("//lottery");
            XmlNode     xmlNode     = null;

            foreach (XmlNode el in xmlNodeList)
            {
                if (el.InnerXml.Contains("qxc") && el.InnerXml.Contains("7星彩"))
                {
                    xmlNode = el;
                }
            }
            //XmlNode xmlNode1 = dom.SelectSingleNode("//lottery");
            //XmlNode xmlNode = dom.SelectSingleNode("//open");


            //StringBuilder output = new StringBuilder();
            //XmlWriter xmlWriter = XmlWriter.Create(output);
            //xmlNode.WriteTo(xmlWriter);
            //Console.WriteLine(output.ToString());
            if (xmlNode != null)
            {
                lottery l = XMLSerilizable.XMLToObject <lottery>(xmlNode.OuterXml, Encoding.UTF8);
            }
            //open or = XMLSerilizable.XMLToObject<open>(xmlNode.OuterXml, Encoding.UTF8);

            string Flag = "";

            //string Flag = System.Text.Encoding.UTF8.GetString(b, 0, b.Length);
            //string Flag = System.Text.Encoding.Unicode.GetString(b, 0, b.Length);
            //string andy = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(streamReceive, Encoding.UTF8))
            {
                Flag = sr.ReadToEnd();
            }
            Console.WriteLine(Flag);
        }
Beispiel #3
0
        public static DataTable GetTableStruct(SqlBaseItemXml basemodel, string tablename)
        {
            DataTable bulkdata = new DataTable();
            //bulkdata.TableName = tablename;
            //#region
            //bulkdata.Columns.Add("id", typeof(long));
            //bulkdata.Columns.Add("num1", typeof(int));
            //bulkdata.Columns.Add("num2", typeof(long));
            //bulkdata.Columns.Add("num3", typeof(double));
            //bulkdata.Columns.Add("str11", typeof(string));
            //#endregion
            //var t1 = XMLSerilizable.ObjectToXML(bulkdata);
            //FileHelper.WriteText(SqlServerConfig.SqlBaseXmlConfig.TableStructFilePath, t1);

            var fieldcontent = FileHelper.FileToString(basemodel.TableStructFilePath, Encoding.UTF8);

            bulkdata           = XMLSerilizable.XMLToObject <DataTable>(fieldcontent, Encoding.UTF8);
            bulkdata.TableName = tablename;
            return(bulkdata);
        }
Beispiel #4
0
        public static SqlFieldXml LoadSqlFieldXmlConfig(string filepath)
        {
            var fieldcontent = FileHelper.FileToString(filepath, Encoding.UTF8);

            return(XMLSerilizable.XMLToObject <SqlFieldXml>(fieldcontent, Encoding.UTF8));
        }