Exemplo n.º 1
0
        static ProcessStartInfo GetPrjProcessStartInfo(PrjRequest request)
        {
            var startInfo = new ProcessStartInfo();

            startInfo.FileName = FindPrjExePath();

            var argStr = "\"{0}\" \"{1}\" {2} {3}"
                         .Fmt(
                request.ConfigPath, request.ProjectName,
                ToPlatformDirStr(request.Platform), request.RequestId);

            if (request.Param1 != null)
            {
                argStr += " \"{0}\"".Fmt(request.Param1);
            }

            if (request.Param2 != null)
            {
                argStr += " \"{0}\"".Fmt(request.Param2);
            }

            startInfo.Arguments              = argStr;
            startInfo.CreateNoWindow         = true;
            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;

            Log.Debug("Running command '{0} {1}'".Fmt(startInfo.FileName, startInfo.Arguments));

            return(startInfo);
        }
Exemplo n.º 2
0
        static IEnumerator UpdateLinksAsyncInternal(PrjRequest req)
        {
            var runner = PrjInterface.RunPrjAsync(req);

            while (runner.MoveNext() && !(runner.Current is PrjResponse))
            {
                yield return(runner.Current);
            }

            yield return(CreateStandardResponse((PrjResponse)runner.Current));
        }
Exemplo n.º 3
0
        // This will yield string values that contain some status message
        // until finally yielding a value of type PrjResponse with the final data
        public static IEnumerator RunPrjAsync(PrjRequest request)
        {
            Process proc = new Process();

            proc.StartInfo = GetPrjProcessStartInfo(request);

            proc.EnableRaisingEvents = true;

            bool hasExited = false;

            proc.Exited += delegate
            {
                hasExited = true;
            };

            proc.Start();

            var errorLines = new List <string>();

            proc.ErrorDataReceived += (sender, outputArgs) => errorLines.Add(outputArgs.Data);

            var outputLines = new List <string>();

            proc.OutputDataReceived += (sender, outputArgs) => outputLines.Add(outputArgs.Data);

            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();

            while (!hasExited)
            {
                if (outputLines.IsEmpty())
                {
                    yield return(null);
                }
                else
                {
                    var newLines = outputLines.ToList();
                    outputLines.Clear();
                    yield return(newLines);
                }
            }

            yield return(RunPrjCommonEnd(
                             proc, errorLines.Join(Environment.NewLine)));
        }
Exemplo n.º 4
0
        public static PrjResponse RunPrj(PrjRequest request)
        {
            Process proc = new Process();

            proc.StartInfo = GetPrjProcessStartInfo(request);

            proc.Start();

            var errorLines = new List <string>();

            proc.ErrorDataReceived += (sender, outputArgs) => errorLines.Add(outputArgs.Data);

            var outputLines = new List <string>();

            proc.OutputDataReceived += (sender, outputArgs) => outputLines.Add(outputArgs.Data);

            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();

            proc.WaitForExit();

            return(RunPrjCommonEnd(
                       proc, errorLines.Join(Environment.NewLine)));
        }
Exemplo n.º 5
0
        static ProcessStartInfo GetPrjProcessStartInfo(PrjRequest request)
        {
            var startInfo = new ProcessStartInfo();

            startInfo.FileName = PrjEditorApiPath;

            var argStr = "\"{0}\" \"{1}\" {2} {3}"
                .Fmt(
                    request.ConfigPath, request.ProjectName,
                    ToPlatformDirStr(request.Platform), request.RequestId);

            if (request.Param1 != null)
            {
                argStr += " \"{0}\"".Fmt(request.Param1);
            }

            if (request.Param2 != null)
            {
                argStr += " \"{0}\"".Fmt(request.Param2);
            }

            if (request.Param3 != null)
            {
                argStr += " \"{0}\"".Fmt(request.Param3);
            }

            startInfo.Arguments = argStr;
            startInfo.CreateNoWindow = true;
            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError = true;

            Log.Debug("Running command '{0} {1}'".Fmt(startInfo.FileName, startInfo.Arguments));

            return startInfo;
        }
Exemplo n.º 6
0
        // This will yield string values that contain some status message
        // until finally yielding a value of type PrjResponse with the final data
        public static IEnumerator RunPrjAsync(PrjRequest request)
        {
            Process proc = new Process();
            proc.StartInfo = GetPrjProcessStartInfo(request);

            proc.EnableRaisingEvents = true;

            bool hasExited = false;
            proc.Exited += delegate
            {
                hasExited = true;
            };

            proc.Start();

            var errorLines = new List<string>();
            proc.ErrorDataReceived += (sender, outputArgs) => errorLines.Add(outputArgs.Data);

            var outputLines = new List<string>();
            proc.OutputDataReceived += (sender, outputArgs) => outputLines.Add(outputArgs.Data);

            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();

            while (!hasExited)
            {
                if (outputLines.IsEmpty())
                {
                    yield return null;
                }
                else
                {
                    var newLines = outputLines.ToList();
                    outputLines.Clear();
                    yield return newLines;
                }
            }

            yield return RunPrjCommonEnd(
                proc, errorLines.Join(Environment.NewLine));
        }
Exemplo n.º 7
0
        public static PrjResponse RunPrj(PrjRequest request)
        {
            Process proc = new Process();
            proc.StartInfo = GetPrjProcessStartInfo(request);

            proc.Start();

            var errorLines = new List<string>();
            proc.ErrorDataReceived += (sender, outputArgs) => errorLines.Add(outputArgs.Data);

            var outputLines = new List<string>();
            proc.OutputDataReceived += (sender, outputArgs) => outputLines.Add(outputArgs.Data);

            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();

            proc.WaitForExit();

            return RunPrjCommonEnd(
                proc, errorLines.Join(Environment.NewLine));
        }
Exemplo n.º 8
0
        static IEnumerator UpdateLinksAsyncInternal(PrjRequest req)
        {
            var runner = PrjInterface.RunPrjAsync(req);

            while (runner.MoveNext() && !(runner.Current is PrjResponse))
            {
                yield return runner.Current;
            }

            yield return CreateStandardResponse((PrjResponse)runner.Current);
        }