Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
 private void ListOpenService()
 {
     Console.WriteLine("所有启动的服务");
     CommandColor.SetGreen();
     foreach (string value in this.wcfmanage.GetOpenService().Keys)
     {
         Console.WriteLine(value);
     }
     CommandColor.SetWhite();
 }
Ejemplo n.º 3
0
 private void ShowAllAss()
 {
     Console.WriteLine("所有加载的程序集");
     CommandColor.SetGreen();
     foreach (string value in this.listass.Keys)
     {
         Console.WriteLine(value);
     }
     CommandColor.SetWhite();
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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();
            }
        }
Ejemplo n.º 7
0
 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();
     }
 }
Ejemplo n.º 8
0
        public static void Run()
        {
            CommandColor.SetBackWhite();
            CommandColor.SetBlack();
            Console.WriteLine("...启动服务...");
            CommandColor.SetBackBlack();
            CommandColor.SetWhite();
            LoadAllServer.LoadAllService();
            CacheAllUser.caching();
            AssManage assManage = new AssManage();

            assManage.LoadAllAss();
            WCFServiceManage wCFServiceManage = new WCFServiceManage(assManage.AssTable);

            wCFServiceManage.StartAllService();
            CommandColor.SetBackWhite();
            CommandColor.SetBlack();
            Console.WriteLine("...启动完成...");
            CommandColor.SetBackBlack();
            CommandColor.SetWhite();
            CommandHelp.showhelp();
            new HandleCommand(wCFServiceManage, assManage.AssTable).LoopCommand();
        }
Ejemplo n.º 9
0
 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();
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
        public void LoopCommand()
        {
            Console.WriteLine("查看命令帮助 help ");
            Console.Write("WCF>");
            bool flag = true;

            while (flag)
            {
                string[] strArray = Console.ReadLine().Split(' ');
                switch (strArray[0])
                {
                case "exit":
                    this.wcfmanage.StopAllService();
                    flag = false;
                    break;

                case "help":
                    CommandHelp.showhelp();
                    break;

                case "la":
                    this.ShowAllAss();
                    break;

                case "lapp":
                    this.ListAssService();
                    break;

                case "los":
                    this.ListOpenService();
                    break;

                case "startall":
                    this.wcfmanage.StartAllService();
                    break;

                case "stopall":
                    this.wcfmanage.StopAllService();
                    break;

                case "restart":
                    this.wcfmanage.StopAllService();
                    this.wcfmanage.RefreshApp();
                    this.wcfmanage.StartAllService();
                    break;

                case "rapp":
                    this.wcfmanage.RefreshApp();
                    break;

                case "start":
                    if (strArray.Length == 2)
                    {
                        this.wcfmanage.StartService(strArray[1]);
                        break;
                    }
                    CommandColor.SetRed();
                    Console.WriteLine("必须有参数 ,服务的名称!傻瓜^_^");
                    CommandColor.SetWhite();
                    break;

                case "stop":
                    if (strArray.Length == 2)
                    {
                        this.wcfmanage.StopService(strArray[1]);
                        break;
                    }
                    CommandColor.SetRed();
                    Console.WriteLine("必须有参数 ,服务的名称!傻瓜^_^");
                    CommandColor.SetWhite();
                    break;

                case "cacheinfo":
                    Console.WriteLine("当前缓存个数为" + Service.GetCacheHelp().GetCurrentCount().ToString());
                    break;

                default:
                    Console.WriteLine("命令打错了,笨蛋!^_^");
                    break;
                }
                Console.Write("\n");
                Console.Write("WCF>");
            }
        }