Exemplo n.º 1
0
        private static void GraphViz()
        {
            var    settings       = new SettingsManager(configXml, "graphviz");
            string baseFolderPath = settings.SelectElementValue("baseFolderPath");
            string inputFileName  = settings.SelectElementValue("inputFileName");
            string outputPath     = settings.SelectElementValue("outputPath");

            Log("Starting creating GraphViz...");
            List <string> extensions = new List <string>()
            {
                "png", "ico", "tiff", "jpg"
            };
            List <string> commands = new List <string>()
            {
                "all", "dot", "neato", "fdp", "sfdp", "twopi", "circo"
            };
            // Input file
            string inputFolder = baseFolderPath;
            string Yes         = Enums.YN.Y.ToString();
            string answer      = cw.Ask(new QAManager(Enums.QAType.YN, Yes, string.Format("Use input directory '{0}'?", inputFolder)));

            if (answer != Yes)
            {
                inputFolder = cw.AskDir(new QAManager(Enums.QAType.Dir));
            }
            answer = cw.Ask(new QAManager(Enums.QAType.YN, Yes, string.Format("Use filename '{0}'?", inputFileName)));
            if (answer != Yes)
            {
                inputFileName = cw.AskFileName(new QAManager(Enums.QAType.File), inputFolder);
            }

            string command   = cw.Ask(new QAManager(commands, "all", "GraphViz command"));
            string extension = cw.Ask(new QAManager(extensions, "png", "Extension"));

            // Canceled
            if (cw.CancelMode)
            {
                Log(string.Format("Processing has been canceled by the enduser."));
            }
            else
            {
                try
                {
                    // Verify
                    string filename = Path.GetFileNameWithoutExtension(inputFileName);
                    string path     = Path.Combine(inputFolder, inputFileName);
                    string outpFile = string.Concat(filename, ".", extension);
                    Log("-------------------------------------------------------------------");
                    Log(string.Format("Input folder.........: {0}", inputFolder));
                    Log(string.Format("Input file...........: {0}", inputFileName));
                    Log(string.Format("Output file..........: {0}", outpFile));
                    Log(string.Format("Output folder........: {0}", outputPath));
                    Log(string.Format("GraphViz command.....: {0}", command));
                    Log(string.Format("Extension............: {0}", extension));
                    Log("-------------------------------------------------------------------");
                    cw.Pause();
                    // Output file
                    string outPathPrefix = Path.Combine(outputPath, filename);
                    if (command.ToLower() == "all")
                    {
                        ExecuteGraphViz("dot", path, outPathPrefix, extension);
                        ExecuteGraphViz("neato", path, outPathPrefix, extension);
                        ExecuteGraphViz("fdp", path, outPathPrefix, extension);
                        ExecuteGraphViz("sfdp", path, outPathPrefix, extension);
                        ExecuteGraphViz("twopi", path, outPathPrefix, extension);
                        ExecuteGraphViz("circo", path, outPathPrefix, extension);
                    }
                    else
                    {
                        ExecuteGraphViz(command, path, outPathPrefix, extension);
                    }
                }
                catch (Exception e)
                {
                    LogUtil.Instance.AddException(e);
                }
            }
        }