OSDN Git Service

v1.1.6.6
[kybernetes/Kybernetes.git] / main / command / batch / batchCommand.cs
index 54fbd74..09a9de5 100644 (file)
@@ -18,12 +18,12 @@ namespace com.andoutomo.kybernetes.command.batch
             if (param.needSelect)\r
             {\r
                 batchFilePath = form.invokeShellDialog();\r
-                 batchArgs = new string[0];\r
+                batchArgs = new string[0];\r
             }\r
             else\r
             {\r
                 batchFilePath = param.BatchFilePath;\r
-                 batchArgs = param.BatchArguments;    \r
+                batchArgs = param.BatchArguments;    \r
             }\r
 \r
             if (string.IsNullOrEmpty(batchFilePath))\r
@@ -35,24 +35,33 @@ namespace com.andoutomo.kybernetes.command.batch
             string strCmd="";\r
             try\r
             {\r
-                using (StreamReader sr = new StreamReader(\r
-                    batchFilePath, Encoding.GetEncoding("Shift_JIS")))\r
+                if (File.Exists(batchFilePath))\r
                 {\r
-\r
-                    while ((strCmd = sr.ReadLine()) != null)\r
+                    using (StreamReader sr = new StreamReader(\r
+                        batchFilePath, Encoding.GetEncoding("Shift_JIS")))\r
                     {\r
-                        for (int i = 0; i < batchArgs.Length; i++)\r
-                        {\r
-                            strCmd = strCmd.Replace("%" + (i + 1), batchArgs[i]);\r
-                        }\r
-                        if (strCmd.Contains('%'))\r
+\r
+                        while ((strCmd = sr.ReadLine()) != null)\r
                         {\r
-                            return false;\r
-                        }\r
+                            for (int i = 0; i < batchArgs.Length; i++)\r
+                            {\r
+                                strCmd = strCmd.Replace("%" + (i + 1), batchArgs[i]);\r
+                            }\r
+                            if (strCmd.Contains('%'))\r
+                            {\r
+                                message = "パラメータが設定されていないため、処理できません。";\r
+                                return false;\r
+                            }\r
 \r
-                        form.cmdForBatch(strCmd);\r
+                            form.cmdForBatch(strCmd);\r
+                        }\r
                     }\r
                 }\r
+                else\r
+                {\r
+                    message = "対象バッチファイルがありません。処理を中断します";\r
+                    return true;\r
+                }\r
             }\r
             catch (Exception e)\r
             {\r
@@ -69,7 +78,14 @@ namespace com.andoutomo.kybernetes.command.batch
 \r
         protected override string turnErrorMessage()\r
         {\r
-            return base.DefaultErrorMessage;\r
+            if (string.IsNullOrEmpty(message))\r
+            {\r
+                return base.DefaultErrorMessage;\r
+            }\r
+            else\r
+            {\r
+                return message;\r
+            }\r
         }\r
 \r
         protected override string turnSplitErrorMessage()\r