/// <summary>
        /// Generates a graph based on the dot file passed in.
        /// </summary>
        /// <param name="dotFile">
        /// A string representation of a dot file.
        /// </param>
        /// <param name="returnType">
        /// The type of file to be returned.
        /// </param>
        /// <returns>
        /// a byte array.
        /// </returns>
        public byte[] GenerateGraph(string dotFile, Enums.GraphReturnType returnType)
        {
            byte[] output;

            //if (!ConfigExists)
            //{
            //    //this.registerLayoutPlugincommand.Invoke(FilePath, this.RenderingEngine);
            //}

            string fileType = this.GetReturnType(returnType);

            var processStartInfo = this.GetProcessStartInfo(fileType);

            using (var process = this.startProcessQuery.Invoke(processStartInfo))
            {
                process.BeginErrorReadLine();
                using (var stdIn = process.StandardInput)
                {
                    stdIn.WriteLine(dotFile);
                }
                using (var stdOut = process.StandardOutput)
                {
                    var baseStream = stdOut.BaseStream;
                    output = this.ReadFully(baseStream);
                }

                //using (var stdErr = process.StandardError)
                //{
                //    Console.Error.WriteLine(stdErr.ReadToEnd());
                //}
            }

            return(output);
        }
Пример #2
0
        /// <summary>
        /// Generates a graph based on the dot file passed in.
        /// </summary>
        /// <param name="dotFile">
        /// A string representation of a dot file.
        /// </param>
        /// <param name="returnType">
        /// The type of file to be returned.
        /// </param>
        /// <returns>
        /// a byte array.
        /// </returns>
        public byte[] GenerateGraph(string dotFile, Enums.GraphReturnType returnType)
        {
            byte[] output;

            if (!ConfigExists)
            {
                this.registerLayoutPlugincommand.Invoke(FilePath, this.RenderingEngine);
            }

            string fileType = this.GetReturnType(returnType);

            var processStartInfo = this.GetProcessStartInfo(fileType);

            using (var process = this.startProcessQuery.Invoke(processStartInfo))
            {
                using (var stdIn = process.StandardInput)
                {
                    stdIn.WriteLine(dotFile);
                }

                using (var stdOut = process.StandardOutput)
                {
                    var baseStream = stdOut.BaseStream;
                    output = this.ReadFully(baseStream);
                }
            }

            return(output);
        }
Пример #3
0
        /// <summary>
        /// Generates a graph based on the dot file passed in.
        /// </summary>
        /// <param name="dotFile">
        /// A string representation of a dot file.
        /// </param>
        /// <param name="returnType">
        /// The type of file to be returned.
        /// </param>
        /// <returns>
        /// a byte array.
        /// </returns>
        public byte[] GenerateGraph(string dotFile, Enums.GraphReturnType returnType)
        {
            byte[] output;

            registerLayoutPlugincommand.Invoke(FilePath, RenderingEngine);

            string fileType = GetReturnType(returnType);

            var processStartInfo = GetProcessStartInfo(fileType);

            using (var process = startProcessQuery.Invoke(processStartInfo))
            {
                process.BeginErrorReadLine();
                using (var stdIn = process.StandardInput)
                {
                    stdIn.WriteLine(dotFile);
                }
                using (var stdOut = process.StandardOutput)
                {
                    var baseStream = stdOut.BaseStream;
                    output = ReadFully(baseStream);
                }
            }

            return(output);
        }
Пример #4
0
        /// <summary>
        /// Generiert einen gerenderten Netzplan zu dem im übergebenen Prozessablaufplan
        /// beschriebenen Prozess.
        /// </summary>
        /// <param name="processTitle">Titel des im Prozessplan beschriebenen Prozesses.</param>
        /// <param name="processPlan">
        /// Prozessablaufplan der den Prozess beschreibt, welcher gerendert wird.
        /// </param>
        /// <param name="format">Grafikformat der Netzplangrafik.</param>
        /// <returns>Gerenderter Netzplan.</returns>
        public byte[] GeneratePrecedenceDiagram(string processTitle, string[] processPlan, GraphicFormat format)
        {
            Process process    = new Process(processTitle, processPlan);
            string  diagramDot = process.GetDot();

            Enums.GraphReturnType gVFormat = ConvertToGraphVizEnum(format);
            return(wrapper.GenerateGraph(diagramDot, gVFormat));
        }
Пример #5
0
        private string GetReturnType(Enums.GraphReturnType returnType)
        {
            var nameValues = new Dictionary <Enums.GraphReturnType, string>
            {
                { Enums.GraphReturnType.Png, "png" },
                { Enums.GraphReturnType.Jpg, "jpg" },
                { Enums.GraphReturnType.Pdf, "pdf" }
            };

            return(nameValues[returnType]);
        }
Пример #6
0
        /// <summary>
        /// Generates a graph based on the dot file passed in.
        /// </summary>
        /// <param name="dotGraph"> A string representation of a dot file.</param>
        /// <param name="returnType"> The type of file to be returned. </param>
        /// <returns> a byte array. </returns>
        public byte[] GenerateGraphDirectly(string dotGraph, Enums.GraphReturnType returnType)
        {
            if (!ConfigExists)
            {
                this.registerLayoutPlugincommand.Invoke(FilePath, this.RenderingEngine);
            }

            string fileType         = this.GetReturnType(returnType);
            var    processStartInfo = this.GetProcessStartInfo(fileType);

            return(GenerateGraphBinary(dotGraph, processStartInfo));
        }
Пример #7
0
        /// <summary>
        ///  Generates a graph based on the dot file passed in.
        ///  It will generate temporary dot file before generating output.
        /// </summary>
        /// <param name="dotGraph">dot graph text</param>
        /// <param name="returnType"> The type of file to be returned. </param>
        /// <returns> a byte array. </returns>
        public byte[] GenerateGraphViaFile(string dotGraph, Enums.GraphReturnType returnType)
        {
            if (!ConfigExists)
            {
                this.registerLayoutPlugincommand.Invoke(FilePath, this.RenderingEngine);
            }

            string inputFile        = WriteFileOfUTF8WithoutBOM(dotGraph);
            string fileType         = this.GetReturnType(returnType);
            var    processStartInfo = this.GetProcessStartInfo(fileType, inputFile);
            var    binary           = GenerateGraphBinary(null, processStartInfo);

            File.Delete(inputFile);

            return(binary);
        }
Пример #8
0
 static void GenerateGraphFile(string data, string filename, Enums.GraphReturnType filetype)
 {
     Console.WriteLine($"filetype: {filetype}\n");
     System.IO.File.WriteAllText($"./{filename}.gv", data);
 }