public static bool GetAdapterScript(string pluginname, out string scriptText) { try { if (WcfGlobal.IsRootMNode) { MongoHelper <PluginServiceScript> pshelper = new MongoHelper <PluginServiceScript>(WcfGlobal.MongoConnStr, MonitorPlatformManage.dbName); PluginServiceScript psScript = pshelper.Find(Query.EQ("pluginname", pluginname)); scriptText = psScript.script; return(true); } else { string val = SuperClient.CreateDataClient().RootRequest("adapter_getscript", JsonConvert.SerializeObject(pluginname)); scriptText = JsonConvert.DeserializeObject <String>(val); return(true); } } catch (Exception err) { CoreFrame.Common.MiddlewareLogHelper.WriterLog(err.Message + err.StackTrace); scriptText = null; return(false); } }
static void Main(string[] args) { Console.WriteLine("Client Testes a0.00001"); var client = new SuperClient(); client.Connect("127.0.0.1", 5566); var testesImpl = client.GetInstance <ITestes>(); //testesImpl.Act += () => Console.WriteLine("Action!"); var actImpl = new Func <int, double, string>((a, b) => $"STROKA {a + b}"); testesImpl.Act2 += actImpl; while (Console.ReadLine() != "Exit") { Console.WriteLine(testesImpl.Get1(8, 10.4)); int a = 6; /* * var resultTask = testesImpl.Zar("10"); * resultTask.ContinueWith(t => Console.WriteLine($"testesImpl.Zar({t.Result});")); * try * { * var result = testesImpl.GetStrings(6); * Console.WriteLine($"{string.Join(", ", result)}"); * } * catch (Exception e) * { * Console.Error.WriteLine(e); * } */ } }
public bool Init() { client = new SuperClient(); IPAddress ip = IPAddress.Parse("127.0.0.1"); client.Init(new IPEndPoint(ip, 7777)); return(client.Connect); }
public string CreateDataClient() { ClientLink cl = SuperClient.CreateDataClient(); while (cl.ClientObj.ClientID == null)//解决并发问题,因为创建连接是一个异步过程,等创建成功后再返回ClientID { Thread.Sleep(400); } return(cl.ClientObj.ClientID); }
private void ui_login_Load(object sender, EventArgs e) { try { // string string_host = "120.24.161.40"; // string string_host = "127.0.0.1"; // int i_port = 2017; chat_client = new SuperClient(); if (!chat_client.Start()) { throw new Exception("请检查网络连接"); } // 给线程间通信的委托添加方法 sender_msg = new SendMsg(SetLoginRsult); } catch (Exception ex) { MessageBox.Show(ex.Message); System.Environment.Exit(0); } }
public static void Run(StartType type) { switch (type) { case StartType.BaseService: mAppHost = new ServiceHost(typeof(BaseService)); //初始化连接池,默认10分钟清理连接 ClientLinkPoolCache.Init(true, 200, 30, 600, "wcfserver", 30); AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\"; AppGlobal.appType = AppType.WCF; AppGlobal.IsSaas = System.Configuration.ConfigurationManager.AppSettings["IsSaas"] == "true" ? true : false; AppGlobal.AppStart(); ClientManage.IsHeartbeat = HostSettingConfig.GetValue("heartbeat") == "1" ? true : false; ClientManage.HeartbeatTime = Convert.ToInt32(HostSettingConfig.GetValue("heartbeattime")); ClientManage.IsMessage = HostSettingConfig.GetValue("message") == "1" ? true : false; ClientManage.MessageTime = Convert.ToInt32(HostSettingConfig.GetValue("messagetime")); ClientManage.IsCompressJson = HostSettingConfig.GetValue("compress") == "1" ? true : false; ClientManage.IsEncryptionJson = HostSettingConfig.GetValue("encryption") == "1" ? true : false; ClientManage.IsToken = HostSettingConfig.GetValue("token") == "1" ? true : false; ClientManage.serializeType = (SerializeType)Convert.ToInt32(HostSettingConfig.GetValue("serializetype")); ClientManage.IsOverTime = HostSettingConfig.GetValue("overtime") == "1" ? true : false; ClientManage.OverTime = Convert.ToInt32(HostSettingConfig.GetValue("overtimetime")); ClientManage.StartHost(); mAppHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "数据服务启动完成"); break; case StartType.FileService: AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\"; mFileHost = new ServiceHost(typeof(FileService)); mFileHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "文件服务启动完成"); break; case StartType.RouterBaseService: mRouterHost = new ServiceHost(typeof(RouterBaseService)); RouterManage.Start(); mRouterHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "数据路由服务启动完成"); break; case StartType.RouterFileService: mFileRouterHost = new ServiceHost(typeof(RouterFileService)); mFileRouterHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "文件路由服务启动完成"); break; case StartType.SuperClient: SuperClient.CreateSuperClient(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "超级客户端启动完成"); break; case StartType.MiddlewareTask: MiddlewareTask.StartTask(); //开启定时任务 MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "定时任务启动完成"); break; case StartType.PublishService: //订阅 PublishServiceManage.InitPublishService(); PublishSubManager.StartPublish(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "发布订阅服务完成"); break; case StartType.MongoDB: MongodbManager.StartDB(); //开启MongoDB MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "MongoDB启动完成"); break; case StartType.Nginx: NginxManager.StartWeb(); //开启Nginx MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "Nginx启动完成"); break; case StartType.KillAllProcess: MongodbManager.StopDB(); //停止MongoDB 清理掉所有子进程,因为主进程关闭子进程不关闭的话,占用的端口号一样不会释放 NginxManager.StopWeb(); break; } }
public static void Quit(StartType type) { ClientLinkManage.UnAllConnection();//关闭所有连接 switch (type) { case StartType.BaseService: try { if (mAppHost != null) { EFWCoreLib.WcfFrame.ClientLinkPoolCache.Dispose(); ClientManage.StopHost(); mAppHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "数据服务已关闭!"); } } catch { if (mAppHost != null) { mAppHost.Abort(); } } break; case StartType.FileService: try { if (mFileHost != null) { mFileHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "文件传输服务已关闭!"); } } catch { if (mFileHost != null) { mFileHost.Abort(); } } break; case StartType.RouterBaseService: try { if (mRouterHost != null) { mRouterHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "数据路由服务已关闭!"); } } catch { if (mRouterHost != null) { mRouterHost.Abort(); } } break; case StartType.RouterFileService: try { if (mFileRouterHost != null) { mFileRouterHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "文件路由服务已关闭!"); } } catch { if (mFileRouterHost != null) { mFileRouterHost.Abort(); } } break; case StartType.SuperClient: SuperClient.UnCreateSuperClient(); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "超级客户端已关闭!"); break; case StartType.MiddlewareTask: MiddlewareTask.StopTask(); //停止任务 MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "定时任务已停止!"); break; case StartType.PublishService: //订阅 MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "订阅服务已停止"); break; case StartType.MongoDB: MongodbManager.StopDB(); //停止MongoDB MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "MongoDB已停止"); break; case StartType.Nginx: NginxManager.StopWeb(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "Nginx已停止"); break; } }
public static void Quit(StartType type) { switch (type) { case StartType.BaseService: try { if (mAppHost != null) { //EFWCoreLib.WcfFrame.ClientLinkPoolCache.Dispose(); ClientManage.StopHost(); mAppHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "数据服务已关闭!"); } } catch { if (mAppHost != null) { mAppHost.Abort(); } } break; case StartType.FileService: try { if (mFileHost != null) { mFileHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "文件传输服务已关闭!"); } } catch { if (mFileHost != null) { mFileHost.Abort(); } } break; case StartType.HttpService: try { if (mHttpHost != null) { mHttpHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "Http服务已关闭!"); } } catch { if (mHttpHost != null) { mHttpHost.Abort(); } } break; case StartType.RouterBaseService: try { if (mRouterHost != null) { mRouterHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "数据路由服务已关闭!"); } } catch { if (mRouterHost != null) { mRouterHost.Abort(); } } break; case StartType.RouterFileService: try { if (mFileRouterHost != null) { mFileRouterHost.Close(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "文件路由服务已关闭!"); } } catch { if (mFileRouterHost != null) { mFileRouterHost.Abort(); } } break; case StartType.SuperClient: UpgradeManage.Stop(); UpgradeClient.Stop(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Red, "升级包服务已停止"); SuperClient.Stop(); MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "超级客户端已关闭!"); break; case StartType.MiddlewareTask: MiddlewareTask.StopTask(); //停止任务 MiddlewareLogHelper.WriterLog(LogType.TimingTaskLog, true, System.Drawing.Color.Red, "定时任务已停止!"); break; } }
public static void Run(StartType type) { switch (type) { case StartType.BaseService: mAppHost = new ServiceHost(typeof(BaseService)); //初始化连接池,默认10分钟清理连接 ClientLinkPoolCache.Init(true, 200, 30, 600, "wcfserver", 30); AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\"; AppGlobal.appType = AppType.WCF; AppGlobal.IsSaas = HostSettingConfig.GetValue("issaas") == "1" ? true : false; AppGlobal.AppStart(); ClientManage.IsHeartbeat = HostSettingConfig.GetValue("heartbeat") == "1" ? true : false; ClientManage.HeartbeatTime = Convert.ToInt32(HostSettingConfig.GetValue("heartbeattime")); ClientManage.StartHost(); mAppHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "数据服务启动完成"); break; case StartType.FileService: AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\"; mFileHost = new ServiceHost(typeof(FileService)); mFileHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "文件服务启动完成"); break; case StartType.HttpService: //初始化连接池,默认10分钟清理连接 ClientLinkPoolCache.Init(true, 200, 30, 600, "httpserver", 30); AppGlobal.AppRootPath = System.Windows.Forms.Application.StartupPath + "\\"; mHttpHost = new WebServiceHost(typeof(HttpService)); mHttpHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "Http服务启动完成"); break; case StartType.RouterBaseService: mRouterHost = new ServiceHost(typeof(RouterBaseService)); RouterManage.Start(); mRouterHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由数据服务启动完成"); break; case StartType.RouterFileService: mFileRouterHost = new ServiceHost(typeof(RouterFileService)); mFileRouterHost.Open(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "路由文件服务启动完成"); break; case StartType.SuperClient: SuperClient.Start(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "超级客户端启动完成"); PublisherManage.Start(); SubscriberManager.Start(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "发布订阅启动完成"); DistributedCacheManage.Start(); DistributedCacheClient.Start(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "分布式缓存启动完成"); UpgradeManage.Start(); UpgradeClient.Start(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "升级包管理启动完成"); MonitorTirggerManage.Start(); MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "监视触发器启动完成"); break; case StartType.MiddlewareTask: MiddlewareTask.StartTask(); //开启定时任务 MiddlewareLogHelper.WriterLog(LogType.MidLog, true, Color.Blue, "定时任务启动完成"); break; } }