private static void Main(string[] args)
 {
     if ((args == null) || (args.Length != 2))
     {
         throw new ArgumentException(WrapperSR.GetString("InvalidArgumentsToMain"), "args");
     }
     CompilerInput input = ReadCompilerInput(args[0]);
     WorkflowCompilerResults results = new WorkflowCompiler().Compile(MultiTargetingInfo.MultiTargetingUtilities.RenormalizeReferencedAssemblies(input.Parameters), input.Files);
     WriteCompilerOutput(args[1], results);
 }
Example #2
0
        static void Main(string[] args)
        {
            using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                AutoResetEvent waitHandle = new AutoResetEvent(false);

                WorkflowCompiler compiler = new WorkflowCompiler();
                WorkflowCompilerParameters compilerParameters = new WorkflowCompilerParameters();
                compilerParameters.GenerateInMemory = true;

                String[] workflowFilenames = GetWorkflowFilenames();
                
                WorkflowCompilerResults results = compiler.Compile(compilerParameters, workflowFilenames);
                if (results.Errors.Count > 0)
                {
                    Console.WriteLine("Errors occurred while building the workflow:");
                    foreach (WorkflowCompilerError compilerError in results.Errors)
                    {
                        Console.WriteLine(compilerError.Line.ToString() + "," + compilerError.Column.ToString() + " : " + compilerError.ErrorText);
                    }

                    return;
                }

                Type workflowType = results.CompiledAssembly.GetType("Microsoft.Samples.Workflow.SimpleInMemorySample.SequentialWorkflow");

                workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) 
                {
                    string orderStatus = e.OutputParameters["Status"].ToString();
                    Console.WriteLine("Order was " + orderStatus);
                    waitHandle.Set();
                };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("Amount", 300);

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(workflowType, parameters);
                instance.Start();

                waitHandle.WaitOne();

                workflowRuntime.StopRuntime();
            }
            
        }
        private void completeBtn_Click(object sender, EventArgs e)
        {
            // �ۑ�
            loader.Flush();

            // �R���p�C�����s
            WorkflowCompiler compiler = new WorkflowCompiler();
            WorkflowCompilerParameters parameters = new WorkflowCompilerParameters();

            string[] compileFiles = new string[3];
            compileFiles[0] = loader.FileName;
            compileFiles[1] = Path.Combine(projectpath, "Workflow1.xoml.cs");
            compileFiles[2] = Path.Combine(projectpath, "IWorkflow1.cs");

            // (�ȉ��A���[���t�@�C��������ꍇ�̃T���v��)
            //string ruleFile = ... ;
            //string resources = @"/resource:" + ruleFile + ",namespace.type.rules";
            //parameters.CompilerOptions += resources;

            parameters.ReferencedAssemblies.Add(Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), @"Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll"));
            parameters.ReferencedAssemblies.Add(Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), @"Reference Assemblies\Microsoft\Framework\v3.5\System.WorkflowServices.dll"));
            parameters.ReferencedAssemblies.Add(@"..\..\..\CustomActivityLibrary\bin\Debug\CustomActivityLibrary.dll");

            parameters.OutputAssembly = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\CustomWorkflowConsole\bin\Debug\CustomWorkflowLibrary.dll");

            WorkflowCompilerResults results = compiler.Compile(parameters, compileFiles);

            int i;
            for (i = 0; i < results.Errors.Count; i++)
            {
                if (!results.Errors[i].IsWarning)
                {
                    MessageBox.Show(results.Errors[i].ErrorText, "�R���p�C���̕�", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            if(i == results.Errors.Count)
                MessageBox.Show("�R���p�C�������ł�!");
            else
                MessageBox.Show("�G���[���������܂���");
        }
Example #4
0
        private void CompileWorkflowButton(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.xamlFile))
                return;
            if (!File.Exists(this.xamlFile))
            {
                MessageBox.Show(this, "Cannot locate XAML file: " + Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), xamlFile), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            compileWorkflowButton.Enabled = false;
            Cursor cursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
            try
            {
                // Compile the workflow
                String[] assemblyNames = { "ReadEmailActivity.dll" };
                WorkflowCompiler compiler = new WorkflowCompiler();
                WorkflowCompilerParameters parameters = new WorkflowCompilerParameters(assemblyNames);
                parameters.LibraryPaths.Add(Path.GetDirectoryName(typeof(BaseMailbox).Assembly.Location));
                parameters.OutputAssembly = "CustomOutlookWorkflow" +  Guid.NewGuid().ToString()  + ".dll";
                results = compiler.Compile(parameters, this.xamlFile);

                StringBuilder errors = new StringBuilder();
                foreach (CompilerError compilerError in results.Errors)
                {
                    errors.Append(compilerError.ToString() + '\n');
                }

                if (errors.Length != 0)
                {
                    MessageBox.Show(this, errors.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    compileWorkflowButton.Enabled = true;
                }
                else
                {
                    MessageBox.Show(this, "Workflow compiled successfully. Compiled assembly:\n" + results.CompiledAssembly.GetName(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    startWorkflowButton.Enabled = true;
                }
            }
            finally
            {
                this.Cursor = cursor;
            }
        }