Пример #1
0
        /// <summary>
        /// Run bat file
        /// </summary>
        /// <param name="manager"></param>
        private static void RunBatFile(MappingManager manager)
        {
            //
            // If everything is okay
            // Prompt user to run it or not ?
            bool configDone = false;

            do
            {
                //
                // Prompt user
                // Do we need to run BAT file or not
                LogService.Log.Info("Mapping finished. Do you wish to run the SQL mapping now? Y/N : ");
                ConsoleKeyInfo inputKey = Console.ReadKey();
                if (inputKey.Key == ConsoleKey.Y)
                {
                    LogService.Log.Info("Running SQL Migration script ...");
                    string filePath = manager.GetBATFilePath();


                    //
                    // Exec BAT file
                    filePath = Path.GetFullPath(filePath);
                    string folderPath = Path.GetDirectoryName(filePath);
                    try
                    {
                        ProcessStartInfo processInfo = new ProcessStartInfo();
                        processInfo.WorkingDirectory = folderPath;
                        processInfo.FileName         = "cmd.exe";
                        processInfo.Arguments        = @"/k " + filePath;
                        Process process = Process.Start(processInfo);
                    }
                    catch (Exception exc)
                    {
                        LogService.Log.Error("Can not run path file from this path : " + filePath, exc);
                    }
                    configDone = true;
                }
                else if (inputKey.Key == ConsoleKey.N)
                {
                    configDone = true;
                }
            } while (configDone == false);
        }