示例#1
0
 static void Main(string[] args)
 {
     try
     {
         //为防止程序长时间运行,一定时间后自动结束自己,另外SuWar3Tools也启动了线程超过60秒也会结束掉这个外部进程
         int second = ExtLogic.GetTimeOutSecond();
         if (second <= 0)
         {
             second = 60;
         }
         System.Threading.Tasks.Task.Run(async() =>
         {
             await System.Threading.Tasks.Task.Delay(second * 1000);
             System.Environment.Exit(0);
         });
         //读取参数json
         ExtInputArgs inputArgs = null;
         string       runPath   = Assembly.GetEntryAssembly().Location;
         string       jsonFile  = Path.Combine(Path.GetDirectoryName(runPath), Path.GetFileNameWithoutExtension(runPath) + "_ing.json");
         if (File.Exists(jsonFile))
         {
             string jsonStr = GetTextFromFile(jsonFile);
             if (!string.IsNullOrEmpty(jsonStr))
             {
                 try { inputArgs = ParseJson <ExtInputArgs>(jsonStr); } catch { }
             }
             File.Delete(jsonFile);
         }
         if (inputArgs == null)
         {
             string tipMsg = ExtLogic.GetTipMsgWhenHasNoArgs();
             if (!string.IsNullOrEmpty(tipMsg))
             {
                 Console.WriteLine(DefaultTipMsg + "\n" + SepString + "\n" + tipMsg + "\n" + SepString);
             }
             else
             {
                 Console.WriteLine(DefaultTipMsg + "\n" + SepString);
             }
             Console.WriteLine("\n按“y”继续执行将生成返回参数的json文件,否则退出(" + second + "秒后也会自动退出):");
             if (Console.ReadKey().Key.ToString().ToLower() == "y")
             {
                 Task t = MainAsync(args, inputArgs);
                 t.Wait();
             }
         }
         else
         {
             Task t = MainAsync(args, inputArgs);
             t.Wait();
         }
     }
     catch
     {
         return;
     }
 }
示例#2
0
 static async Task MainAsync(string[] launchArgs, ExtInputArgs inputArgs)
 {
     try
     {
         QuitWithArgs(await ExtLogic.ProcessLogic(launchArgs, inputArgs ?? new ExtInputArgs(), new ExtOutputArgs()));
     }
     catch
     {
         System.Environment.Exit(0);
     }
 }