Example #1
0
        public ZeusProcess(ZeusProcessType type, ZeusProcessStatusDelegate callback, params string[] args)
        {
            ProcessStartInfo si = new ProcessStartInfo();

            if (args.Length > 0)
            {
                si.FileName               = FileTools.ApplicationPath + "\\ZeusCmd.exe";
                si.CreateNoWindow         = true;
                si.UseShellExecute        = false;
                si.RedirectStandardOutput = true;
                string cmdArgs = "-internaluse ";
                if (type == ZeusProcessType.ExecuteTemplate)
                {
                    cmdArgs += "-t \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteSavedInput)
                {
                    cmdArgs += "-i \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.RecordTemplateInput)
                {
                    cmdArgs += "-t \"" + args[0] + "\" -c \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProject)
                {
                    cmdArgs += "-p \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProjectModule)
                {
                    cmdArgs += "-p \"" + args[0] + "\" -m \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProjectItem)
                {
                    cmdArgs += "-p \"" + args[0] + "\" -ti \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.RecordProjectItem)
                {
                    //filename, instancePath, templateFilename
                    //-internaluse  -t "C:\projects\mygeneration\trunk\templates\HTML\HTML_DatabaseReport.csgen" -p "c:\PrjRoot.zprj" -rti "/PrjRoot/testInstance"
                    cmdArgs += "-t \"" + args[2] + "\" -p \"" + args[0] + "\" -rti \"" + args[1] + "\"";
                }
                if (!string.IsNullOrEmpty(cmdArgs))
                {
                    si.Arguments = cmdArgs;
                }
            }

            Process process = new Process();

            process.StartInfo = si;
            ParameterizedThreadStart ts = new ParameterizedThreadStart(Start);

            t  = new Thread(ts);
            td = new ThreadData(callback, process, _id);
        }
        public ZeusProcess(ZeusProcessType type, ZeusProcessStatusDelegate callback, params string[] args)
        {
            ProcessStartInfo si = new ProcessStartInfo();

            if (args.Length > 0)
            {
                si.FileName = FileTools.ApplicationPath + "\\ZeusCmd.exe";
                si.CreateNoWindow = true;
                si.UseShellExecute = false;
                si.RedirectStandardOutput = true;
                string cmdArgs = "-internaluse ";
                if (type == ZeusProcessType.ExecuteTemplate)
                {
                    cmdArgs += "-t \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteSavedInput)
                {
                    cmdArgs += "-i \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.RecordTemplateInput)
                {
                    cmdArgs += "-t \"" + args[0] + "\" -c \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProject)
                {
                    cmdArgs += "-p \"" + args[0] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProjectModule)
                {
                    cmdArgs += "-p \"" + args[0] + "\" -m \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.ExecuteProjectItem)
                {
                    cmdArgs += "-p \"" + args[0] + "\" -ti \"" + args[1] + "\"";
                }
                else if (type == ZeusProcessType.RecordProjectItem)
                {
                    //filename, instancePath, templateFilename
                    //-internaluse  -t "C:\projects\mygeneration\trunk\templates\HTML\HTML_DatabaseReport.csgen" -p "c:\PrjRoot.zprj" -rti "/PrjRoot/testInstance"
                    cmdArgs += "-t \"" + args[2] + "\" -p \"" + args[0] + "\" -rti \"" + args[1] + "\"";
                }
                if (!string.IsNullOrEmpty(cmdArgs)) si.Arguments = cmdArgs;
            }
            
            Process process = new Process();
            process.StartInfo = si;
            ParameterizedThreadStart ts = new ParameterizedThreadStart(Start);
            t = new Thread(ts);
            td = new ThreadData(callback, process, _id);

        }