Browse Source

增加读取配置,加载发短信工具

denny 1 year ago
parent
commit
e00db5ed63
3 changed files with 24 additions and 18 deletions
  1. 1 0
      Tools/SmsTool/Program.cs
  2. 21 17
      src/WingApplicationBuilder.cs
  3. 2 1
      src/appsettings.json

+ 1 - 0
Tools/SmsTool/Program.cs

@@ -14,6 +14,7 @@ namespace SmsTool
             TencentHelper.Init();
             var webApiServer = new WebApiServer("SmsTool");
             //webApiServer.Start(args[0]);
+            //工具需要兼容老平台, 上线后保留此发短信工具
             webApiServer.Start(8302);
             Console.WriteLine("SmsTool server started");
             var readLine = Console.ReadLine();

+ 21 - 17
src/WingApplicationBuilder.cs

@@ -35,6 +35,7 @@ namespace WingCloudServer
 
             //启动 工具
             var _dependencies = ConfigurationManager.GetParammeter<StringParameter>("Dependencies", "Apps").Value;
+            var isOpenSmsService = ConfigurationManager.GetParammeter<BoolParameter>("General", "IsOpenSmsService").Value;
             if (!string.IsNullOrEmpty(_dependencies))
             {
                 var dependenciesApps = _dependencies.Split(',');
@@ -42,21 +43,25 @@ namespace WingCloudServer
                 {
                     if (!string.IsNullOrEmpty(item))
                     {
-                       var appItems= item.Split('|');
-                       var appItem="";//application 
-                       var  paramsValue="";
-                       if(appItems.Length>0)
-                       {
-                          appItem=appItems[0];
-                          for (int i = 1; i < appItems.Length; i++)
-                          {
-                              paramsValue +=" "+appItems[i];
-                          }
-                       }
-                       if(string.IsNullOrEmpty(appItem))
-                       {
-                         throw new Exception( " load appsetting:Dependencies.Apps is null");
-                       }
+                        if (item.StartsWith("startsms") && isOpenSmsService == false)
+                        {
+                            continue;
+                        }
+                        var appItems= item.Split('|');
+                        var appItem="";//application 
+                        var  paramsValue="";
+                        if(appItems.Length>0)
+                        {
+                            appItem=appItems[0];
+                            for (int i = 1; i < appItems.Length; i++)
+                            {
+                                paramsValue +=" "+appItems[i];
+                            }
+                        }
+                        if(string.IsNullOrEmpty(appItem))
+                        {
+                            throw new Exception( " load appsetting:Dependencies.Apps is null");
+                        }
                         var  directory= Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Packages");
                         var appPath=Path.Combine(directory,appItem);
                         if(!File.Exists(appPath))
@@ -65,8 +70,7 @@ namespace WingCloudServer
                             appPath=  files.FirstOrDefault(v=>v.Contains(appItem));
                         }
                         ProcessStarter.StartProcess(appPath,paramsValue);
-                         _dependencieNames.Add(appItem);
-
+                        _dependencieNames.Add(appItem);
                     }
                 }
             }

+ 2 - 1
src/appsettings.json

@@ -5,7 +5,8 @@
     "IsMaster": true,
     "MasterUrl": "",
     "ServerID":"1",
-    "IsDeployTool":false
+    "IsDeployTool":false,
+    "IsOpenSmsService": true
   },
   "Gateway": {
     "Host": "http://127.0.0.1/",