public void StopService(string serviceTypeName) { Console.Write(" 关闭服务" + serviceTypeName + ".........."); object obj = this.ServiceTable[serviceTypeName]; if (obj != null) { ServiceHost serviceHost = (ServiceHost)obj; try { serviceHost.Close(); } catch (Exception value) { Console.WriteLine(value); return; } this.ServiceTable.Remove(serviceTypeName); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); } else { CommandColor.SetRed(); Console.WriteLine("服务不存在"); CommandColor.SetWhite(); } }
private void ListOpenService() { Console.WriteLine("所有启动的服务"); CommandColor.SetGreen(); foreach (string value in this.wcfmanage.GetOpenService().Keys) { Console.WriteLine(value); } CommandColor.SetWhite(); }
private void ShowAllAss() { Console.WriteLine("所有加载的程序集"); CommandColor.SetGreen(); foreach (string value in this.listass.Keys) { Console.WriteLine(value); } CommandColor.SetWhite(); }
private void ListAssService() { Console.WriteLine("所有配置的服务"); CommandColor.SetGreen(); string[] appService = this.wcfmanage.GetAppService(); for (int i = 0; i < appService.Length; i++) { string value = appService[i]; Console.WriteLine(value); } CommandColor.SetWhite(); }
public static void LoadAllService() { Console.Write(" 加载基础服务.........."); ServicesManager servicesManager = ServicesManager.GetServicesManager(); servicesManager.AddService("db", new DBAdaptor()); servicesManager.AddService("log", new LogHelp("db")); servicesManager.AddService("cache", new CacheHelp()); servicesManager.AddService("app", new AppHelp()); servicesManager.AddService("except", new ExceptionHelp("log")); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); }
public void LoadAllAss() { DirectoryInfo directoryInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "loaddll"); FileInfo[] files = directoryInfo.GetFiles("*.dll"); for (int i = 0; i < files.Length; i++) { FileInfo fileInfo = files[i]; Console.Write(" 加载程序集:" + fileInfo.Name + "...."); Assembly value = Assembly.LoadFile(fileInfo.FullName); this.AssTable.Add(fileInfo.Name, value); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); } }
internal static void caching() { if (!string.IsNullOrEmpty(Service.GetAppHelp().GetAppSetting("userdbname"))) { Console.Write(" 缓存所有用户:...."); DataSet dataSet = CacheData.SelectAllUser(); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { Service.GetCacheHelp().Add(dataRow[1].ToString(), dataRow[0].ToString()); } CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); Console.Write(" 缓存行政区划:...."); DataSet cacheo = CacheData.SelectProvince(); DataSet cacheo2 = CacheData.SelectCity(); DataSet cacheo3 = CacheData.SelectCounty(); DataSet cacheo4 = CacheData.SelectStreet(); Service.GetCacheHelp().AddFile("ProvinceCache", cacheo, Service.GetAppHelp().GetAppSetting("ProvinceCache")); Service.GetCacheHelp().AddFile("CityCache", cacheo2, Service.GetAppHelp().GetAppSetting("CityCache")); Service.GetCacheHelp().AddFile("CountyCache", cacheo3, Service.GetAppHelp().GetAppSetting("CountyCache")); Service.GetCacheHelp().AddFile("StreetCache", cacheo4, Service.GetAppHelp().GetAppSetting("StreetCache")); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); Console.Write(" 缓存功能菜单:...."); DataSet cacheo5 = CacheData.SelectMenu(); Service.GetCacheHelp().AddFile("MenuCache", cacheo5, Service.GetAppHelp().GetAppSetting("MenuCache")); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); Console.Write(" 缓存枚举:...."); DataSet cacheo6 = CacheData.SelectEunm(); Service.GetCacheHelp().AddFile("EunmCache", cacheo6, Service.GetAppHelp().GetAppSetting("EunmCache")); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); } }
public void StartService(string serviceTypeName) { Console.Write(" 启动服务" + serviceTypeName + ".........."); if (this.GetServiceState(serviceTypeName)) { CommandColor.SetYellow(); Console.WriteLine("服务运行中"); CommandColor.SetWhite(); } else { int num = serviceTypeName.IndexOf('.', 4); if (num == -1) { CommandColor.SetRed(); Console.WriteLine("失败"); Console.WriteLine("服务名称格式错误"); CommandColor.SetWhite(); } else { string str = serviceTypeName.Substring(0, num); Assembly assembly = (Assembly)this.asstable[str + ".dll"]; if (assembly == null) { CommandColor.SetRed(); Console.WriteLine("失败"); Console.WriteLine("服务程序集不存在"); CommandColor.SetWhite(); } else { ServiceHost value = null; Type type = assembly.GetType(serviceTypeName, true); if (type == null) { CommandColor.SetRed(); Console.WriteLine("失败"); Console.WriteLine("服务类型不存在"); CommandColor.SetWhite(); } else { try { value = this.starthostaddvalidation(type); } catch (Exception ex) { CommandColor.SetRed(); Console.Write("失败"); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); CommandColor.SetWhite(); return; } this.ServiceTable.Add(serviceTypeName, value); CommandColor.SetGreen(); Console.WriteLine("完成"); CommandColor.SetWhite(); } } } } }