static void TestWebClient() { //创建对象 //ReplyClientCallBack callback = new ReplyClientCallBack(); ClientLink clientlink = new ClientLink("TestWcfPerformance", "Books.Service"); begintime(); //2.创建连接 clientlink.CreateConnection(); Console.WriteLine("2.创建连接时间(毫秒):" + endtime()); //Console.WriteLine("输入请求数据条数:"); //string num = Console.ReadLine(); string num = "100"; begintime(); //Action<ClientRequestData> requestAction = ((ClientRequestData request) => //{ // //request.Iscompressjson = false; // //request.Isencryptionjson = false; // //request.Serializetype = WcfFrame.SDMessageHeader.SerializeType.Newtonsoft; // request.AddData(num); //}); ////3.同步请求数据 //clientlink.Request("Books.Service@bookWcfController", "Test191", requestAction); //Console.WriteLine("3.请求数据时间(毫秒):" + endtime()); //begintime(); ////3.同步请求数据 //clientlink.Request("Books.Service@bookWcfController", "Test191", requestAction); //Console.WriteLine("3.请求数据时间(毫秒):" + endtime()); Console.Read(); string s; begintime(); s = clientlink.UpLoadFile(@"D:\DCWriter.rar", (delegate(int _num) { Console.WriteLine("4.文件上传进度:%" + _num); })); Console.WriteLine("4.文件上传时间(毫秒):" + endtime() + "|" + s); begintime(); s = clientlink.DownLoadFile("DCWriter.rar", (delegate(int _num) { Console.WriteLine("5.文件下载进度:%" + _num); })); Console.WriteLine("5.文件下载时间(毫秒):" + endtime() + "|" + s); begintime(); //5.关闭连接 clientlink.UnConnection(); Console.WriteLine("6.关闭连接时间(毫秒):" + endtime()); Console.ReadLine(); }
private static void CreateSuperClient() { //就算上级中间件重启了,下级中间件创建链接的时候会重新注册本地插件 superClientLink = new ClientLink(WcfGlobal.HostName, "SuperPlugin", null, WcfGlobal.Identify, null); try { superClientLink.CreateConnection(); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "连接上级中间件失败!" + e.Message); } }
public string TestRemoteService(string identify, string plugin, string controller, string method, string para) { Action <ClientRequestData> requestAction = ((ClientRequestData request) => { request.Iscompressjson = false; request.Isencryptionjson = false; request.Serializetype = SerializeType.Newtonsoft; request.LoginRight = new SysLoginRight(1); request.SetJsonData(para); }); ClientLink link = new ClientLink(null, plugin, null, null, null, identify); link.CreateConnection(); ServiceResponseData response = link.Request(controller, method, requestAction); return(response.GetJsonData()); }
static void CallService() { ClientLink clientlink = new ClientLink("Books.Service"); clientlink.CreateConnection(); Action <ClientRequestData> _requestAction = ((ClientRequestData request) => { request.LoginRight = new EFWCoreLib.CoreFrame.Business.SysLoginRight(1); }); ServiceResponseData retData = clientlink.Request("bookWcfController", "GetBooks", _requestAction); string data = retData.GetJsonData(); clientlink.UnConnection(); Console.WriteLine(data); }
static void TestConcurrency() { try { ClientLink clientlink = new ClientLink("TestWcfPerformance", "Books.Service"); clientlink.CreateConnection(); int num = 100; while (num > 0) { //num -= 1; clientlink.Request("bookWcfController", "GetDiseaseData", null); Thread.Sleep(time); } clientlink.Dispose(); } catch (Exception err) { Console.WriteLine(err.Message); } }
public static ClientLink superclient;//连接上级中间件超级客户端 public static void CreateSuperClient() { //就算上级中间件重启了,下级中间件创建链接的时候会重新注册本地插件 superclient = new ClientLink(WcfGlobal.HostName, null); try { superclient.CreateConnection((() => { //以后可以做成配置方式 //foreach (var item in PublishServiceManage.serviceDic.Keys) //{ // superclient.Subscribe(item);//订阅服务? //} }), null); } catch (Exception e) { MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "连接上级中间件失败!" + e.Message); } }
public Object GetRemoteServices(string identify) { ClientLink link = new ClientLink(null, "Test", null, null, null, identify); link.CreateConnection(); List <dwPlugin> plist = link.RootRemoteGetServices(identify); List <amazeuitreenode> tree = new List <amazeuitreenode>(); foreach (var p in plist) { amazeuitreenode nodep = new amazeuitreenode(); nodep.title = p.pluginname; nodep.type = "folder"; nodep.childs = new List <amazeuitreenode>(); tree.Add(nodep); foreach (var c in p.controllerlist) { amazeuitreenode nodec = new amazeuitreenode(); nodec.title = c.controllername; nodec.type = "folder"; nodec.childs = new List <amazeuitreenode>(); nodep.childs.Add(nodec); foreach (var m in c.methodlist) { amazeuitreenode nodem = new amazeuitreenode(); nodem.title = m; nodem.type = "item"; nodem.attr = new Dictionary <string, string>(); nodem.attr.Add("plugin", p.pluginname); nodem.attr.Add("controller", c.controllername); nodem.attr.Add("method", m); nodec.childs.Add(nodem); } } } return(tree); }
public static void CreateSuperClient() { //就算上级中间件重启了,下级中间件创建链接的时候会重新注册本地插件 superclient = new ClientLink(WcfServerManage.HostName, (() => { //注册本地插件到上级中间件 superclient.RegisterReplyPlugin(WcfServerManage.Identify, localPlugin.PluginDic.Keys.ToArray()); (superclient.mConn.ClientService as ReplyClientCallBack).SuperReplyClientAction = ((HeaderParameter para, string plugin, string controller, string method, string jsondata) => { return(ProcessReply(para, plugin, controller, method, jsondata)); }); //同步缓存到上级中间件 DistributedCacheManage.SyncAllCache(); })); try { superclient.CreateConnection(); } catch { ShowHostMsg(Color.Red, DateTime.Now, "连接上级中间件失败!"); } }
private void button1_Click(object sender, EventArgs e) { clientlink = new ClientLink("TestWcfPerformance", "Books.Service"); clientlink.CreateConnection(); }
static void TestWebClient() { //创建对象 //ReplyClientCallBack callback = new ReplyClientCallBack(); ClientLink clientlink = new ClientLink("TestWcfPerformance", "Books.Service"); begintime(); //2.创建连接 clientlink.CreateConnection(); Console.WriteLine("2.创建连接时间(毫秒):" + endtime()); //Console.WriteLine("输入请求数据条数:"); //string num = Console.ReadLine(); //string num = "100"; begintime(); //Action<ClientRequestData> requestAction = ((ClientRequestData request) => //{ // //request.Iscompressjson = false; // //request.Isencryptionjson = false; // //request.Serializetype = WcfFrame.SDMessageHeader.SerializeType.Newtonsoft; // request.AddData(num); //}); ////3.同步请求数据 //clientlink.Request("Books.Service@bookWcfController", "Test191", requestAction); //Console.WriteLine("3.请求数据时间(毫秒):" + endtime()); //begintime(); ////3.同步请求数据 //clientlink.Request("Books.Service@bookWcfController", "Test191", requestAction); //Console.WriteLine("3.请求数据时间(毫秒):" + endtime()); Console.Read(); string s; //begintime(); //s = clientlink.UpLoadFile(@"D:\trace.svclog", (delegate (int _num) //{ // Console.WriteLine("4.文件上传进度:%" + _num); //})); //Console.WriteLine("4.文件上传时间(毫秒):" + endtime() + "|" + s); begintime(); //s = clientlink.DownLoadFile("636266367544280000.svclog", (delegate (int _num) //{ // Console.WriteLine("5.文件下载进度:%" + _num); //})); DownFile df = new DownFile(); df.clientId = Guid.NewGuid().ToString(); df.DownKey = Guid.NewGuid().ToString(); df.FileName = "636266367544280000.svclog"; df.FileType = 0; FileStream fs = new FileStream(@"c:\1.log", FileMode.Create, FileAccess.Write); clientlink.RootDownLoadFile(df, fs, (delegate(int _num) { Console.WriteLine("5.文件下载进度:%" + _num); })); Console.WriteLine("5.文件下载时间(毫秒):" + endtime()); begintime(); //5.关闭连接 clientlink.UnConnection(); Console.WriteLine("6.关闭连接时间(毫秒):" + endtime()); Console.ReadLine(); }