using CommonAI.Zone.Helper;
using CommonLang;
using CommonLang.IO;
using CommonLang.XCSV;
using CommonNetwork.Http;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace TestCDNBenchMark
{
    static class Program
    {
        [STAThread]
        static void Main(params string[] args)
        {
            try
            {
#if false
           Uri uri = new Uri("http://192.168.1.44:18080/passport/common?type=2&username=mfmf002&appid=80&channel=0&ostype=6&logintype=0&version=10000&mac=&password=98CFC52EE234E1D20F9B58D1169F352DFB3E5F01F87901872FA5872B8C826B79B21DC41C73A72944656F883B7FA31A891DD4C587CF1B4BB02EC14E08D837B1E4");
                             WebClient.PostAsync(uri, CUtils.UTF8, (string rst) =>
                             {
                                 Console.WriteLine(rst);
                             });
                "3;url='regiest.jsp'", 
                             Application.EnableVisualStyles();
                             Application.SetCompatibleTextRenderingDefault(false);
                             Application.Run(new TestForm());
#endif
#if false
            Uri uri = new Uri("http://192.168.1.81:5580/XSangoBattleWebService/api/report?abc");
 
             WebClient www = new WebClient(uri);
             www.Request.Method = HttpRequest.METHOD_POST;
             www.Request.Content = File.ReadAllBytes(@"C:\Users\zhangyifei.MOREFUNTEK\Desktop\Report_PVP");
             www.Request.ContentType = HttpRequest.CONTENT_TYPE_OCTET_STREAM;
             Stream stream = www.Connect();
             byte[] data = IOUtil.ReadExpect(stream, www.Response.ContentLength);
             string result = CUtils.UTF8.GetString(data);
             Console.Write(result);
#endif
#if false
            //http://dl.xsg.moreu.cn/appstore/1.3.6/assets/IOS/mpq/res_20150509171637.mpq.z
            //Uri uri = new Uri("http://dl.xsg.moreu.cn/appstore/1.3.6/assets/IOS/mpq/res_20150609095228.mpq.z");
            for (int i = 0; i < 100; i++)
            {
                Uri uri = new Uri("http://dl.xsg.moreu.cn/appstore/1.3.6/assets/IOS/mpq/res_20150509171637.mpq.z");
                WebClient www = new WebClient(uri);
                Stream stream = www.Connect();
                byte[] data = IOUtil.ReadExpect(stream, www.Response.ContentLength);
                Console.WriteLine("Done");
            }
#endif
#if false
            int time1 = MoveHelper.CalculateFlyTimeMS(0, 4, 0, 9.8f, 10);
            int time3 = MoveHelper.CalculateFlyTimeMS(0, 4, 0, 9.8f);

            Console.Write(time1);
#endif
#if true
                //Uri uri = new Uri("https://www.visualstudio.com");
                //Uri uri = new Uri("https://www.alipay.com/");
                Uri uri = new Uri("https://cdn.morefuntek.com/source/xsg_plist/test/assets/Android/version.json");
                WebClient www = new WebClient(uri);
                www.Request.SslProtocol = System.Security.Authentication.SslProtocols.Tls;
                Stream stream = www.Connect();
                Console.WriteLine(www.Response);
                byte[] data = IOUtil.ReadExpect(stream, www.Response.ContentLength);
                string html = CUtils.UTF8.GetString(data);
                Console.WriteLine(html);
                Console.WriteLine("Done");
                File.WriteAllText(Application.StartupPath + "/doc.html", html, CUtils.UTF8);
#endif
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }


        }
    }
}