Exemple #1
0
        static void Main(string[] args)
        {
            var aa = new CdmCliComNs.CDMCCom();

            if (args.Length < 1)
            {
                Console.WriteLine("please input method");
                return;
            }
            switch (args[0])
            {
            case "getordinal":
                var input = new BusinessModel {
                    countyCode = "haiyang", businessCategory = "yew1", userName = "******", password = "******"
                };
                var json = JsonConvert.SerializeObject(input);
                Console.WriteLine("input=" + json);
                Console.WriteLine("output = " + aa.RestHttpClientGet(homeurl, "getordinal", json));
                break;

            case "getordinal2":
                Console.WriteLine(aa.RestHttpClientGet(homeurl, "getordinal2", "?code=334&category=0334"));
                break;

            case "GET_VERSION":
                var haha = JsonConvert.SerializeObject(new BusinessModel {
                    businessCategory = "HE", address = "wolong"
                });
                //    var dict = new Dictionary<string, string>
                //{
                //    {"UserName","param1. userName"},
                //    {"Password"," param1.password"},
                //    {"grant_type", "password"}
                //};
                Console.WriteLine("输入:" + haha + "     输出" + aa.SendRestHttpClientRequest(homeurl, "GET_VERSION", haha));
                break;

            default:
                Console.WriteLine("no this method");
                break;
            }
        }
Exemple #2
0
        private void OneThread(object parama)
        {
            try
            {
                var paramb = (Threadparam)parama;
                //BeginInvoke(new UpdateStatusDelegate(UpdateStatus),
                //                new object[] { string.Format("OneThread starting") });
                var    homeurl = paramb.Server;
                string param;
                var    method = paramb.Method;
                var    volume = paramb.Volume;

                var aa = new CdmCliComNs.CDMCCom();
                for (int i = 0; i < volume; i++)
                {
                    //BeginInvoke(new UpdateStatusDelegate(UpdateStatus),
                    //              new object[] { string.Format("business {0}", i) });
                    var watch = new Stopwatch();
                    watch.Start();
                    switch (method)
                    {
                    case "PostBusinessFormInfo":
                        param =
                            JsonConvert.SerializeObject(new BusinessModel
                        {
                            businessCategory = "HE",
                            userName         = paramb.UserName,
                            countyCode       = paramb.CountyCode,
                            queueNum         = "50010",
                            type             = paramb.Type,
                            address          = "wolong"
                        });
                        var ret = aa.SendRestHttpClientRequest(homeurl, method, param);
                        //  richTextBox1.AppendText(Environment.NewLine + "输入:" + param + "     输出:" + aa.SendRestHttpClientRequest(homeurl, method, param));
                        watch.Stop();
                        BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[]
                        {
                            string.Format("thread {1},{0} transaction, result = {2}, elapsed time {3} milliseconds,",
                                          method, paramb.Ordinal,
                                          // ret, //url={4}
                                          JsonConvert.DeserializeObject <ResultModel>(ret).statusCode,
                                          watch.ElapsedMilliseconds, homeurl)
                        });
                        //BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[]
                        //{
                        //    string.Format("{0} transaction, elapsed time {3} milliseconds, input:{1},output:{2}",
                        //        method, param, ret, watch.ElapsedMilliseconds)
                        //});
                        break;

                    case "getordinal":
                        var input = new BusinessModel
                        {
                            countyCode       = "haiyang",
                            businessCategory = "yew1",
                            userName         = "******",
                            password         = "******"
                        };
                        var json = JsonConvert.SerializeObject(input);
                        Console.WriteLine("input=" + json);
                        Console.WriteLine("output = " + aa.RestHttpClientGet(textBoxurl.Text, "getordinal", json));
                        break;

                    case "getordinal2":
                        Console.WriteLine(aa.RestHttpClientGet(textBoxurl.Text, "getordinal2",
                                                               "?code=334&category=0334"));
                        break;

                    case "GET_VERSION":
                        var haha =
                            JsonConvert.SerializeObject(new BusinessModel
                        {
                            businessCategory = "HE",
                            address          = "wolong"
                        });
                        //    var dict = new Dictionary<string, string>
                        //{
                        //    {"UserName","param1. userName"},
                        //    {"Password"," param1.password"},
                        //    {"grant_type", "password"}
                        //};
                        Console.WriteLine("输入:" + haha + "     输出" +
                                          aa.SendRestHttpClientRequest(homeurl, "GET_VERSION", haha));
                        break;

                    default:
                        BeginInvoke(new UpdateStatusDelegate(UpdateStatus),
                                    new object[] { string.Format("no this method" + comboBoxmethods.Text) });
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                BeginInvoke(new UpdateStatusDelegate(UpdateStatus),
                            new object[] { string.Format("some error occurred,{0}", ex.Message) });
            }
        }