static void Main(string[] args) { var aa = new YunYiCdm.YunYiCdm(); if (args.Length < 1) { Console.WriteLine("please input method"); return; } switch (args[0]) { //case "zip": // var zinput = new BusinessModel { countyCode = "zhifu", businessCategory = "yew1", userName = "******", password = "******" ,ID=3032}; // var zjson = JsonConvert.SerializeObject(zinput); // Console.WriteLine("input=" + zjson); // var ret = aa.SendRestHttpClientRequest(homeurl, "BusinessesPictureQuery ", zjson); // Console.WriteLine("ResultToFile output = " + aa.ResultToFile(ret, "d:\\aaaaa")); // // Console.WriteLine("output = " + ret); // var bb = JsonConvert.DeserializeObject<ResultModel>(ret); // Console.WriteLine("output = " + bb.StatusCode); // Console.WriteLine("ByteToFile output = " + aa.ByteToFile(bb.BussinessModel.zipFile, "d:\\aaaaa")); // 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(homeurl, "getordinal", json)); // break; case "getordinal2": Console.WriteLine(aa.RestHttpClientGet(homeurl, "getordinal2", "?code=334&category=0334")); break; case "jss": Console.WriteLine(aa.JsonserializeEx("laizhou", "user1", "pass", "haha", 111, 222, @"E:\cdm\CDMservers\CdmCliComNs\bin\Release\CdmCliComNs.zip")); 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; } Console.ReadKey(); }
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 YunYiCdm.YunYiCdm(); 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 "GetBusinessInfoByOdc": // param = // JsonConvert.SerializeObject(new BusinessModel // { // unloadTaskNum =( paramb.Ordinal+i).ToString(), // 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,{4}", // method, paramb.Ordinal, // // ret, //url={4} // JsonConvert.DeserializeObject<ResultModel>(ret).StatusCode, // watch.ElapsedMilliseconds,ret.Length) // }); // //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 "PostBusinessFormInfo": // param = // JsonConvert.SerializeObject(new BusinessModel // { // businessCategory = "HE", // userName = paramb.UserName, // countyCode = paramb.CountyCode, // unloadTaskNum =( paramb.Ordinal + i).ToString(), // queueNum = "50010", // type = paramb.Type, // checkFile = paramb.Ordinal+i, // zipFile = File.ReadAllBytes(@textBoxsourcefile.Text), // address = "wolong" // }); // var bb = aa.SendRestHttpClientRequest(homeurl, method, param); // // richTextBox1.AppendText(Environment.NewLine + "输入:" + param + " 输出:" + aa.SendRestHttpClientRequest(homeurl, method, param)); // watch.Stop(); // var theret = JsonConvert.DeserializeObject<ResultModel>(bb); // BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[] // { // string.Format("thread {1},{0} transaction, result = {2}, elapsed time {3} milliseconds,{4}", // method, paramb.Ordinal, // // ret, //url={4} // theret.StatusCode, // watch.ElapsedMilliseconds,theret.Result) // }); // //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, " + method) }); break; } } } catch (Exception ex) { BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[] { string.Format("some error occurred,{0}", ex.Message) }); } }