コード例 #1
0
ファイル: UpgradeService.cs プロジェクト: zkorey/FreeHttp
        public void StartCheckUpgrade()
        {
            //Task checkUpgradeCheckUpgrade = new Task(CheckUpgrade);
            //checkUpgradeCheckUpgrade.Start();
            //checkUpgradeCheckUpgrade.ContinueWith((task) => { StartCheckUpgrade(); });

            Task <UpgradeServiceEventArgs> checkUpgradeTask = new Task <UpgradeServiceEventArgs>(() =>
            {
                string tempResponse = myHttp.SendData(string.Format(@"https://api.lulianqi.com/UpdateCheck/v1.1?user={0}", UserComputerInfo.GetComputerMac()));
                string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse);
                string url          = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse);
                string message      = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse);
                if (string.IsNullOrEmpty(isNeedUpdata))
                {
                    return(new UpgradeServiceEventArgs(false, null));
                }
                if (isNeedUpdata == "true")
                {
                    return(new UpgradeServiceEventArgs(true, url));
                }
                return(null);
            });

            checkUpgradeTask.Start();
            checkUpgradeTask.ContinueWith((task) => { if (checkUpgradeTask.Result != null)
                                                      {
                                                          this.GetUpgradeMes(this, checkUpgradeTask.Result);
                                                      }
                                          });
        }
コード例 #2
0
        public static void DotestForMyhttp()
        {
            MyWebTool.MyHttp myHttp = new MyWebTool.MyHttp(false, true);
            myHttp.SendData("http://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou1.txt");
            myHttp.SendData("http://pv.sohu.com/cityjson", "ie=utf-8", "GET");
            myHttp.SendData("http://pv.sohu.com/cityjson", "ie=utf-8", "POST");
            myHttp.SendData("http://pv.sohu.com/cityjson", "ie=utf-8", "POST", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, null, null);

            List <MyWebTool.HttpMultipartDate> hml = new List <MyWebTool.HttpMultipartDate>();

            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", "file name", null, false, "test data"));
            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", null, "comtenttype", false, "test data"));

            myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, "body data", hml, null, null);
            myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, "body data", hml, "a=1&b=2&c=4", null);
            hml.Add(new MyWebTool.HttpMultipartDate("multipart name", "file name", "comtenttype", true, @"D:\shou1.txt"));

            myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("name", "DotestForMyhttp")
            }, "body data", hml, "a=1&b=2&c=4", null);
        }
コード例 #3
0
        public void StartCheckUpgrade()
        {
            //Task checkUpgradeCheckUpgrade = new Task(CheckUpgrade);
            //checkUpgradeCheckUpgrade.Start();
            //checkUpgradeCheckUpgrade.ContinueWith((task) => { StartCheckUpgrade(); });

            Task <UpgradeServiceEventArgs> checkUpgradeTask = new Task <UpgradeServiceEventArgs>(() =>
            {
                string tempResponse = myHttp.SendData(string.Format(@"{0}freehttp/UpdateCheck/v{1}?user={2}&dotnetrelease={3}", ConfigurationData.BaseUrl, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), UserComputerInfo.GetComputerMac(), UserComputerInfo.GetDotNetRelease()));
                string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse);
                string url          = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse);
                string message      = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse);
                if (string.IsNullOrEmpty(isNeedUpdata))
                {
                    return(new UpgradeServiceEventArgs(false, null));
                }
                if (isNeedUpdata == "true")
                {
                    return(new UpgradeServiceEventArgs(true, url));
                }
                return(null);
            });

            checkUpgradeTask.Start();
            checkUpgradeTask.ContinueWith((task) => { if (checkUpgradeTask.Result != null)
                                                      {
                                                          this.GetUpgradeMes(this, checkUpgradeTask.Result);
                                                      }
                                          });
        }
コード例 #4
0
        public static void RunMyHttpTest()
        {
            for (int m = 0; m < 100; m++)
            {
                Console.ReadLine();
                Console.WriteLine(Environment.TickCount);
                long          l1  = DateTime.Now.Ticks;
                StringBuilder xxb = new StringBuilder("");
                for (int i = 0; i < 100; i++)
                {
                    xxb.Append("123456789abcdefg");
                }
                xxb.ToString();

                long   l2 = DateTime.Now.Ticks;
                string xx = "";
                for (int i = 0; i < 100; i++)
                {
                    xx += "123456789abcdefg";
                }

                long l3 = DateTime.Now.Ticks;
                Console.WriteLine(string.Format("{0}\r\n{1}\r\n{2}\r\n{3}\r\n{4}", l1, l2, l3, l2 - l1, l3 - l2));
            }
            Console.ReadLine();
            Console.WriteLine(myHttp.SendData("http://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou.txt"));
            Console.WriteLine(myHttp.SendData("http://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou.txt"));
            Console.WriteLine(myHttp.SendData("http://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou.txt"));
            Console.WriteLine(myHttp.SendData("https://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou.txt"));
            Console.WriteLine(myHttp.SendData("https://pv.sohu.com/cityjson?ie=utf-8", null, "POST", null, @"D:\shou.txt"));
            Console.ReadLine();
            Console.WriteLine(myHttp.SendData("http://www.baidu.com", null, "Get", null, @"D:\baidu.txt"));
            Console.ReadLine();
            List <MyWebTool.HttpMultipartDate>    ntds  = new List <MyWebTool.HttpMultipartDate>();
            List <KeyValuePair <string, string> > heads = new List <KeyValuePair <string, string> >();

            heads.Add(new KeyValuePair <string, string>("Hostx", "HttpPostData"));
            heads.Add(new KeyValuePair <string, string>("xxx", "HttpPostData"));

            ntds.Add(new MyWebTool.HttpMultipartDate("name", "filename", null, false, "test data"));
            ntds.Add(new MyWebTool.HttpMultipartDate("name", "filename", "type", false, "test data"));
            ntds.Add(new MyWebTool.HttpMultipartDate(null, null, "type", false, ""));
            ntds.Add(new MyWebTool.HttpMultipartDate(null, null, "type", false, null));
            ntds.Add(new MyWebTool.HttpMultipartDate("name", "filename", null, true, @"C:\Users\administer\Desktop\new 2")); //@"C:\Users\cllq\Desktop\CSV\my.csv"

            Console.WriteLine(myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", null, null, null, null, null));
            Console.WriteLine(myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", null, null, ntds, null, null));
            Console.WriteLine(myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", heads, "body", ntds, "a=1&b=2", Encoding.UTF8));
            Console.ReadLine();
            Console.WriteLine(myHttp.SendData("http://pv.sohu.com/cityjson?ie=utf-8", null, "Get"));
            Console.WriteLine(myHttp.HttpPostData("http://pv.sohu.com/cityjson?ie=utf-8", heads, "body", ntds, "a=1&b=2", Encoding.UTF8));
            Console.ReadLine();
        }
コード例 #5
0
ファイル: UpgradeService.cs プロジェクト: yesnomore/FreeHttp
        private void CheckUpgrade()
        {
            string tempResponse = myHttp.SendData(string.Format(@"http://api.lulianqi.com/UpdateCheck/v1?user={0}", UserComputerInfo.GetComputerMac()));
            string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse);
            string url          = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse);
            string message      = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse);

            if (string.IsNullOrEmpty(isNeedUpdata))
            {
                this.GetUpgradeMes(this, new UpgradeServiceEventArgs(false, null));
            }
            if (isNeedUpdata == "true")
            {
                this.GetUpgradeMes(this, new UpgradeServiceEventArgs(true, url));
            }
        }
コード例 #6
0
        /// <summary>
        /// give up maintenance
        /// </summary>
        private void CheckUpgrade()
        {
            string tempResponse = myHttp.SendData(string.Format(@"{0}freehttp/UpdateCheck/v1.1?user={1}", ConfigurationData.BaseUrl, UserComputerInfo.GetComputerMac()));
            string isNeedUpdata = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"isNeedUpdata\":", ",", tempResponse);
            string url          = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"url\":", ",", tempResponse);
            string message      = FreeHttp.AutoTest.ParameterizationPick.ParameterPickHelper.PickStrParameter("\"message\":", ",", tempResponse);

            if (string.IsNullOrEmpty(isNeedUpdata))
            {
                this.GetUpgradeMes(this, new UpgradeServiceEventArgs(false, null));
            }
            if (isNeedUpdata == "true")
            {
                this.GetUpgradeMes(this, new UpgradeServiceEventArgs(true, new UpdateInfo()
                {
                    url = url
                }));
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: lulianqi/AutoTest
 static void CheckUpgrade()
 {
     myHttp.SendData("http://lulianqi.com/sns/hello", null, "GET", null, null, mr);
 }