Exemplo n.º 1
0
        private static void RunInternal <TTask, TConfig>(ITaskController controller, TaskConfigBase <TTask, TConfig> config)
            where TTask : TaskBase <TTask, TConfig>, new()
            where TConfig : TaskConfigBase <TTask, TConfig>, new()
        {
            try
            {
                var configStr = Phase.Run("Serialize config", () => JsonConvert.SerializeObject(config, Formatting.Indented));
                config = Phase.Run("Clone config for run", () => JsonConvert.DeserializeObject <TConfig>(configStr));

                var l = controller.Logger;

                using (l.Context("Config:"))
                    controller.Logger.LogLine(configStr);

                DoRun(controller, config);
                controller.Logger.LogLine("-- Done -- ");
            }
            catch (CancelTaskException)
            {
                controller.Logger.LogLine("Task was canceled at the user's request");
            }
            catch (Exception e)
            {
                controller.Logger.LogException(e);
                throw;
            }
        }
Exemplo n.º 2
0
 public UC_Day(DateTime selectedDate, ITaskController taskController)
 {
     InitializeComponent();
     this.selectedDate   = selectedDate;
     this.labelDate.Text = selectedDate.ToString("dddd, dd MMMM yyyy");
     this.taskController = taskController;
 }
 protected override void DoExecute(ITaskController taskController, TaskResultView taskResultView)
 {
     taskResultView.MarqueeBrowse(MetadataCategory.Artist, Name, Icon);
     //var viewModel = taskController.GetSearchViewModel(string.Empty);
     //viewModel.Filters = SearchFilters.Artists;
     //taskResultView.Search(viewModel);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfiguredTaskAwaiter"/> struct.
 /// </summary>
 internal ConfiguredTaskAwaiter(ITaskController taskController, SystemTasks.Task awaitedTask,
                                bool continueOnCapturedContext)
 {
     this.TaskController = taskController;
     this.AwaitedTask    = awaitedTask;
     this.Awaiter        = awaitedTask.ConfigureAwait(continueOnCapturedContext).GetAwaiter();
 }
Exemplo n.º 5
0
        public void 协同审批分支流程(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, new Dictionary <string, object>
                {
                    ["同意"] = false
                }));

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Thread.Sleep(1000);

                var tasks = AsyncHelper.RunSync(() => tc.MyTasks("8e45aba4-c648-4d71-a1c3-3d15b5518b84"));

                var task = tasks.List.ElementAt(0);

                tc.Approvaled(new ApprovaleTaskCmd {
                    TaskId = task.Id
                });

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);
            });

            Assert.Null(ex);
        }
 protected override void DoExecute(ITaskController taskController, TaskResultView taskResultView)
 {
     taskResultView.MarqueeBrowse(MetadataCategory.Artist, Name, Icon);
     //var viewModel = taskController.GetSearchViewModel(string.Empty);
     //viewModel.Filters = SearchFilters.Artists;
     //taskResultView.Search(viewModel);
 }
        public void Initialize(ILogger logger, ISecurityContext securityContext, IMediaFactory mediaFactory, IMetadataController mediaItemController, ITaskController taskController, ITagController tagController, IVideoPlayer videoPlayer)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (securityContext == null)
                throw new ArgumentNullException("securityContext");
            if (mediaFactory == null)
                throw new ArgumentNullException("mediaFactory");
            if (mediaItemController == null)
                throw new ArgumentNullException("mediaItemController");
            if (taskController == null)
                throw new ArgumentNullException("taskController");
            if (tagController == null)
                throw new ArgumentNullException("tagController");
            if (videoPlayer == null)
                throw new ArgumentNullException("videoPlayer");

            this.logger = logger;
            this.securityContext = securityContext;
            this.mediaFactory = mediaFactory;
            this.taskController = taskController;
            this.mediaItemController = mediaItemController;
            this.tagController = tagController;
            this.videoPlayer = videoPlayer;
        }
Exemplo n.º 8
0
        public async Task 任务转审单人(string bpmnFile)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                string sid = Guid.NewGuid().ToString();
                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { sid }));

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                var tasks = await tc.MyTasks(sid).ConfigureAwait(false);

                var uid = Guid.NewGuid().ToString();

                TaskModel[] model = await tc.TransferTask(new TransferTaskCmd
                {
                    TaskId      = tasks.List.FirstOrDefault().Id,
                    Assignees   = new string[] { uid },
                    Description = "转审测试"
                }).ConfigureAwait(false);

                tasks = await tc.MyTasks(uid).ConfigureAwait(false);

                await tc.CompleteTask(new CompleteTaskCmd
                {
                    TaskId = tasks.List.First().Id
                }).ConfigureAwait(false);

                tasks = await tc.MyTasks(uid).ConfigureAwait(false);
            });

            Assert.Null(ex);
        }
Exemplo n.º 9
0
        public void Initialize(ILogger logger, ICommandController commandController, ITaskController taskController, TaskResultView taskResultView)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (commandController == null)
                throw new ArgumentNullException("commandController");
            if (taskController == null)
                throw new ArgumentNullException("taskController");
            if (taskResultView == null)
                throw new ArgumentNullException("taskResultView");

            this.logger = logger;
            this.commandController = commandController;
            this.taskController = taskController;
            this.taskResultView = taskResultView;

            try
            {
                commandItemContainer.ItemsSource = commandController.Commands;
            }
            catch (Exception ex)
            {
                logger.Error("  CommandView.Initialize", ex);
            }
        }
Exemplo n.º 10
0
        public void Initialize(ILogger logger, ICommandController commandController, ITaskController taskController, TaskResultView taskResultView)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (commandController == null)
            {
                throw new ArgumentNullException("commandController");
            }
            if (taskController == null)
            {
                throw new ArgumentNullException("taskController");
            }
            if (taskResultView == null)
            {
                throw new ArgumentNullException("taskResultView");
            }

            this.logger            = logger;
            this.commandController = commandController;
            this.taskController    = taskController;
            this.taskResultView    = taskResultView;

            try
            {
                commandItemContainer.ItemsSource = commandController.Commands;
            }
            catch (Exception ex)
            {
                logger.Error("  CommandView.Initialize", ex);
            }
        }
Exemplo n.º 11
0
        public static ServiceHost CreateServiceExample(ITaskController taskController)
        {
            ServiceHost <IServiceExample, ServiceExample> host = null;

            try
            {
                var uri = UriFactory.CreateBaseAddress(WcfConfiguration.ServiceExampleName);
                host = new ServiceHost <IServiceExample, ServiceExample>(uri, new ServiceExampleInstanceProvider(taskController));

                var binding = BindingFactory.CreateBinding();
                host.SetBinding(binding);


                var tmp = host;
                host = null;
                return(tmp);
            }
            finally
            {
                if (host != null)
                {
                    host.Close();
                }
            }
        }
Exemplo n.º 12
0
        public void Initialize(ILogger logger, ITaskController taskController, TaskResultView taskResultView)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (taskController == null)
            {
                throw new ArgumentNullException("taskController");
            }
            if (taskResultView == null)
            {
                throw new ArgumentNullException("taskResultView");
            }

            try
            {
                this.logger         = logger;
                this.taskController = taskController;
                this.taskResultView = taskResultView;

                this.taskItemsControl.ItemsSource = taskController.Tasks;
            }
            catch (Exception ex)
            {
                logger.Error("TaskManagerView.Initialize", ex);
            }
        }
Exemplo n.º 13
0
        public async Task 变量抛异常(string bpmnFile)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                string uid = Guid.NewGuid().ToString();
                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[0], new Dictionary <string, object>
                {
                    { "starter", new string[] { uid } }
                }));

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Resources <TaskModel> tasks = await tc.MyTasks(uid).ConfigureAwait(false);

                TaskModel task = tasks.List.FirstOrDefault(x => x.Status == "ASSIGNED");

                await tc.CompleteTask(new CompleteTaskCmd
                {
                    TaskId = task.Id
                }).ConfigureAwait(false);

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);
            }).ConfigureAwait(false);

            Assert.NotNull(ex);
        }
Exemplo n.º 14
0
 public EditView(ITaskController taskController, Task task)
 {
     InitializeComponent();
     this.taskController    = taskController;
     this.task              = task;
     this.textBoxTitle.Text = task.Title;
     this.textBoxDesc.Text  = task.Description;
 }
Exemplo n.º 15
0
 public UC_Task(Task task, ITaskController taskController)
 {
     InitializeComponent();
     this.task            = task;
     this.Name            = task.TaskId.ToString();
     this.labelTitle.Text = task.Title;
     this.labelDesc.Text  = task.Description;
     this.taskController  = taskController;
 }
Exemplo n.º 16
0
        public void Execute(ITaskController taskController, TaskResultView taskResultView)
        {
            if (taskController == null)
                throw new ArgumentNullException("taskController");
            if (taskResultView == null)
                throw new ArgumentNullException("taskResultView");

            DoExecute(taskController, taskResultView);
        }
Exemplo n.º 17
0
        public async Task Start_完成用户注册路径_女(string bpmnFile)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                IProcessDefinitionDeployerController pdc = ctx.CreateWorkflowHttpProxy().GetDefinitionDeployerClient();

                string formKey = Guid.NewGuid().ToString();

                string xml    = IntegrationTestContext.ReadBpmn(bpmnFile);
                XDocument doc = XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(xml)), LoadOptions.PreserveWhitespace);
                var elem      = doc.Descendants(XName.Get("startEvent", BpmnXMLConstants.BPMN2_NAMESPACE)).First();
                elem.Attribute(XName.Get("formKey", BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE)).Value = formKey;

                Deployment deployment = await pdc.Deploy(new ProcessDefinitionDeployer
                {
                    BpmnXML  = doc.ToString(),
                    Name     = Path.GetFileNameWithoutExtension(bpmnFile),
                    TenantId = ctx.TenantId
                }).ConfigureAwait(false);

                string uid = Guid.NewGuid().ToString();
                StartProcessInstanceCmd cmd = new StartProcessInstanceCmd()
                {
                    StartForm = formKey,
                    Variables = new Dictionary <string, object>
                    {
                        { "User", new string[] { uid } }
                    },
                    TenantId = ctx.TenantId
                };

                ProcessInstance[] instances = AsyncHelper.RunSync <ProcessInstance[]>(() => client.Start(new StartProcessInstanceCmd[] { cmd }));

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Resources <TaskModel> myTasks = null;

                while (true)
                {
                    myTasks = await Complete(tc, uid, new Dictionary <string, object>
                    {
                        { "gender", 2 }
                    }).ConfigureAwait(false);

                    if (myTasks == null || myTasks.TotalCount <= 0)
                    {
                        break;
                    }
                }
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
Exemplo n.º 18
0
        private static void DoRun <TTask, TConfig>(ITaskController controller, TaskConfigBase <TTask, TConfig> taskConfig)
            where TTask : TaskBase <TTask, TConfig>, new()
            where TConfig : TaskConfigBase <TTask, TConfig>, new()
        {
            var task         = Phase.Run("Create task", () => new TTask());
            var taskInternal = Phase.Run("Get ITaskInternal", () => (ITaskBaseInternal)task);

            Phase.Run("Set controller", () => taskInternal.Controller = controller);
            Phase.Run("Task run", () => taskInternal.Run((TConfig)taskConfig));
        }
Exemplo n.º 19
0
        public TaskWindow(ITaskController controller, string id)
        {
            InitializeComponent();
            Id             = id;
            _taskViewModel = new TaskViewModel(controller, id);
            DataContext    = _taskViewModel;
            SetLuminance(_taskViewModel.Task.Color.Color);

            this.ShowInTaskbar = false;
        }
Exemplo n.º 20
0
 public WorkflowClientController(WorkflowHttpClientProxyProvider workflowHttpClientProxy, IAccessTokenProvider accessToken, IHttpContextAccessor httpContextAccessor)
 {
     httpContext               = httpContextAccessor.HttpContext;
     this.accessToken          = accessToken;
     processInstanceClient     = workflowHttpClientProxy.GetProcessInstanceClient();
     taskClient                = workflowHttpClientProxy.GetTaskClient();
     taskAdminClient           = workflowHttpClientProxy.GetTaskAdminClient();
     deployerClient            = workflowHttpClientProxy.GetDefinitionDeployerClient();
     processDefinitionClient   = workflowHttpClientProxy.GetProcessDefinitionClient();
     processInstanceTaskClient = workflowHttpClientProxy.GetProcessInstanceTasksClient();
 }
Exemplo n.º 21
0
 public void AddTaskController(ITaskController controller)
 {
     _taskController = controller;
     _taskName       = controller.GetTaskName();
     _processName    = controller.GetProcessManager().GetProcessName();
     if (_valor != null)
     {
         _valor.TaskName    = _taskName;
         _valor.ProcessName = _processName;
     }
 }
Exemplo n.º 22
0
        public void 主活动终止事件同时终止子活动(string bpmnFile, string subBpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string 主任务        = Guid.NewGuid().ToString();
                string 一任务        = Guid.NewGuid().ToString();
                string[] subUsers = new string[]
                {
                    Guid.NewGuid().ToString()
                };
                string[] subUsers1 = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };
                var bizIds = new string[]
                {
                    Guid.NewGuid().ToString()
                };

                ctx.Deploy(bpmnFile);
                ctx.Deploy(subBpmnFile);

                WorkflowVariable vars = new WorkflowVariable();
                vars.AddAssignee(nameof(主任务), 主任务)
                .AddAssignee(nameof(一任务), 一任务)
                .AddAssignee(nameof(subUsers), subUsers)
                .AddAssignee(nameof(subUsers1), subUsers1);
                vars.Add("ids", bizIds);

                string bizId = Guid.NewGuid().ToString();
                ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult();

                ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Assert.NotEmpty(taskClient.MyTasks(主任务).GetAwaiter().GetResult().List);
                Assert.NotEmpty(taskClient.MyTasks(subUsers[0]).GetAwaiter().GetResult().List);

                ///完成主任务节点的任务
                taskClient.CompleteTask(new CompleteTaskCmd
                {
                    BusinessKey = bizId,
                    Assignee    = 主任务
                }).GetAwaiter().GetResult();

                Assert.Empty(taskClient.MyTasks(subUsers[0]).GetAwaiter().GetResult().List);
                Assert.Empty(taskClient.MyTasks(一任务).GetAwaiter().GetResult().List);

                var pi = ctx.CreateWorkflowHttpProxy().GetProcessInstanceClient().GetProcessInstanceById(instances[0].Id).GetAwaiter().GetResult();
            });

            Assert.NotNull(ex);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskSchedulingViewModel"/> class.
        /// </summary>
        public TaskSchedulingViewModel(ITaskController taskController, IFileProvider fileProvider,
                                       IFileDialog fileDialog)
        {
            taskController.ThrowIfNull(nameof(taskController));
            fileProvider.ThrowIfNull(nameof(fileProvider));

            DisplayName     = "Scheduling tasks";
            _taskController = taskController;
            _fileProvider   = fileProvider;
            _fileDialog     = fileDialog;
            //Events subscribe
        }
Exemplo n.º 24
0
        public void Execute(ITaskController taskController, TaskResultView taskResultView)
        {
            if (taskController == null)
            {
                throw new ArgumentNullException("taskController");
            }
            if (taskResultView == null)
            {
                throw new ArgumentNullException("taskResultView");
            }

            DoExecute(taskController, taskResultView);
        }
        protected override void DoExecute(ITaskController taskController, TaskResultView taskResultView)
        {
            var dialog = new System.Windows.Forms.FolderBrowserDialog();
            dialog.Description = "Select A Directory To Catalog";
            dialog.ShowNewFolderButton = true;
            dialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
                return;

            var catalogViewModel = taskController.GetCatalogViewModel(dialog.SelectedPath);
            taskResultView.Catalog(catalogViewModel);
        }
Exemplo n.º 26
0
        private async Task <Resources <TaskModel> > Complete(ITaskController tc, string userId, WorkflowVariable vars)
        {
            Resources <TaskModel> tasks = await tc.MyTasks(userId).ConfigureAwait(false);

            TaskModel task = tasks.List.FirstOrDefault();

            await tc.CompleteTask(new CompleteTaskCmd
            {
                TaskId          = task.Id,
                OutputVariables = vars
            }).ConfigureAwait(false);

            tasks = await tc.MyTasks(userId).ConfigureAwait(false);

            return(tasks);
        }
Exemplo n.º 27
0
        public void 协同审批一票否决(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string[] users = new string[]
                {
                    "8e45aba4-c648-4d71-a1c3-3d15b5518b84",
                    "1f387de4-0e26-47dd-b2f1-57771a268bc5",
                    //"e561d025-76c7-4674-b799-5eae802a4980"
                };

                ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, new Dictionary <string, object>
                {
                    ["UserTask_11w47k9s"] = users
                }));

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                var tasks = AsyncHelper.RunSync(() => tc.MyTasks(users[0]));

                var task = tasks.List.ElementAt(0);

                tc.Approvaled(new ApprovaleTaskCmd {
                    TaskId = task.Id
                });

                Thread.Sleep(1000);

                tasks = AsyncHelper.RunSync(() => tc.MyTasks(users[1]));

                if (tasks.List.Count() > 0)
                {
                    task = tasks.List.ElementAt(0);

                    tc.Reject(new RejectTaskCmd {
                        TaskId = task.Id, RejectReason = "不同意"
                    });
                }

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);
            });

            Assert.Null(ex);
        }
Exemplo n.º 28
0
 public ValoresController(Valor valor, decimal recargo, ITaskController taskController)
 {
     _porcenatjeRecargo      = recargo;
     _idComprobanteTesoreria = valor.IdTDCompTesoreria;
     _idMoneda = valor.IdMoneda;
     _agrupado = mz.erp.businessrules.tfi_TDCompTesoreria.GetByPk(_idComprobanteTesoreria).Agrupado;
     _idMonedaOrigenReadOnly    = true;
     _idTDCompTesoreriaReadOnly = true;
     _idValor = valor.IdValor;
     _valor   = valor;
     //_valor.State  = "EDIT";
     _valor.ValorChange += new mz.erp.businessrules.comprobantes.Valor.ValorChangeEventHandler(_valor_ValorChange);
     _valor.PrepareEdit();
     _taskName          = taskController.GetTaskName();
     _processName       = taskController.GetProcessManager().GetProcessName();
     _valor.TaskName    = _taskName;
     _valor.ProcessName = _processName;
 }
        protected override void DoExecute(ITaskController taskController, TaskResultView taskResultView)
        {
            var dialog = new System.Windows.Forms.FolderBrowserDialog();

            dialog.Description         = "Select A Directory To Catalog";
            dialog.ShowNewFolderButton = true;
            dialog.SelectedPath        = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var catalogViewModel = taskController.GetCatalogViewModel(dialog.SelectedPath);

            taskResultView.Catalog(catalogViewModel);
        }
Exemplo n.º 30
0
        public void Initialize(ILogger logger, ITaskController taskController, TaskResultView taskResultView)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (taskController == null)
            {
                throw new ArgumentNullException("taskController");
            }
            if (taskResultView == null)
            {
                throw new ArgumentNullException("taskResultView");
            }

            this.logger         = logger;
            this.taskController = taskController;
            this.taskResultView = taskResultView;
        }
Exemplo n.º 31
0
        public void Initialize(ILogger logger, ISecurityContext securityContext, IMediaFactory mediaFactory, IMetadataController mediaItemController, ITaskController taskController, ITagController tagController, TaskResultView taskResultView)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (securityContext == null)
            {
                throw new ArgumentNullException("securityContext");
            }
            if (mediaFactory == null)
            {
                throw new ArgumentNullException("mediaFactory");
            }
            if (mediaItemController == null)
            {
                throw new ArgumentNullException("mediaItemController");
            }
            if (taskController == null)
            {
                throw new ArgumentNullException("taskController");
            }
            if (tagController == null)
            {
                throw new ArgumentNullException("tagController");
            }
            if (taskResultView == null)
            {
                throw new ArgumentNullException("taskResultView");
            }

            this.logger              = logger;
            this.securityContext     = securityContext;
            this.mediaFactory        = mediaFactory;
            this.mediaItemController = mediaItemController;
            this.taskController      = taskController;
            this.tagController       = tagController;
            this.taskResultView      = taskResultView;
        }
Exemplo n.º 32
0
        public async Task 定时10秒后执行用户任务(string bpmnFile)
        {
            ProcessInstance[] insts         = null;
            DateTime          timerDateTime = DateTime.Now.AddSeconds(10);
            string            uid           = Guid.NewGuid().ToString();

            var ex = Record.Exception(() =>
            {
                insts = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { uid }, new Dictionary <string, object>
                {
                    { "timerDateTime", timerDateTime }
                }));
            });

            Assert.Null(ex);

            ex = await Record.ExceptionAsync(async() =>
            {
                int retry = 0;
                Resources <TaskModel> tasks = null;
                while (retry != 2)
                {
                    Thread.Sleep(15000);

                    ITaskController client = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                    tasks = await client.MyTasks(uid).ConfigureAwait(false);

                    if (tasks?.List.Count() == 0)
                    {
                        retry += 1;
                        continue;
                    }
                    break;
                }
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
 public ServiceExampleInstanceProvider(ITaskController taskController)
 {
     _taskController = taskController;
 }
 protected override void DoExecute(ITaskController taskController, TaskResultView taskResultView)
 {
     taskResultView.MarqueeBrowse(MetadataCategory.Clip, Name, Icon);
 }
Exemplo n.º 35
0
        public void 部分完成并行子活动(string bpmnFile, string subBpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string teachers   = Guid.NewGuid().ToString();
                string students   = Guid.NewGuid().ToString();
                string[] subUsers = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };
                string[] subUsers1 = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };
                var bizIds = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };

                ctx.Deploy(bpmnFile);
                ctx.Deploy(subBpmnFile);

                WorkflowVariable vars = new WorkflowVariable();
                vars.AddAssignee(nameof(teachers), teachers)
                .AddAssignee(nameof(students), students)
                .AddAssignee(nameof(subUsers), subUsers)
                .AddAssignee(nameof(subUsers1), subUsers1);
                vars.Add("ids", bizIds);

                string bizId = Guid.NewGuid().ToString();
                ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult();

                ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient();
                ///完成子任务节点1的任务
                foreach (var uid in subUsers)
                {
                    var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList();
                    myTasks.ForEach(tsk =>
                    {
                        taskClient.CompleteTask(new CompleteTaskCmd
                        {
                            TaskId = tsk.Id
                        }).GetAwaiter().GetResult();
                    });
                }

                {
                    //任务节点1仅完成子用户1的任务,子活动1应该停在任务节点2
                    var myTask = taskClient.MyTasks(subUsers1[0]).GetAwaiter().GetResult().List.First();
                    _          = taskClient.CompleteTask(new CompleteTaskCmd
                    {
                        TaskId = myTask.Id
                    }).GetAwaiter().GetResult();

                    //完成子活动2的所有任务
                    var myTasks = taskClient.MyTasks(subUsers1[1]).GetAwaiter().GetResult().List.ToList();
                    myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd
                    {
                        TaskId = tsk.Id
                    }).GetAwaiter().GetResult());

                    Assert.NotEmpty(taskClient.MyTasks(subUsers1[0]).GetAwaiter().GetResult().List);
                }

                var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List;

                Assert.Empty(sTasks);
            });

            Assert.Null(ex);
        }
Exemplo n.º 36
0
        public void 调用子活动(string bpmnFile, string subBpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string teachers   = Guid.NewGuid().ToString();
                string students   = Guid.NewGuid().ToString();
                string[] subUsers = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };
                string[] subUsers1 = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };
                var bizIds = new string[]
                {
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString()
                };

                ctx.Deploy(bpmnFile);
                ctx.Deploy(subBpmnFile);

                WorkflowVariable vars = new WorkflowVariable();
                vars.AddAssignee(nameof(teachers), teachers)
                .AddAssignee(nameof(students), students)
                .AddAssignee(nameof(subUsers), subUsers)
                .AddAssignee(nameof(subUsers1), subUsers1);

                string bizId = Guid.NewGuid().ToString();
                ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult();

                ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient();
                TaskModel task             = taskClient.MyTasks(teachers).GetAwaiter().GetResult().List.FirstOrDefault();

                _ = taskClient.CompleteTask(new CompleteTaskCmd
                {
                    TaskId          = task.Id,
                    OutputVariables = WorkflowVariable.FromObject(new
                    {
                        ids = bizIds,
                        完成  = true
                    }),
                    NotFoundThrowError = true
                }).GetAwaiter().GetResult();

                Resources <TaskModel> tasks = ctx.CreateWorkflowHttpProxy().GetProcessInstanceTasksClient()
                                              .GetTasks(new ProcessInstanceTaskQuery()
                {
                    IncludeCompleted  = false,
                    ProcessInstanceId = instances[0].Id
                }).GetAwaiter().GetResult();

                foreach (var uid in subUsers)
                {
                    var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList();
                    myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd {
                        TaskId = tsk.Id
                    }).GetAwaiter().GetResult());
                }

                foreach (var uid in subUsers1)
                {
                    var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList();
                    myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd {
                        TaskId = tsk.Id
                    }).GetAwaiter().GetResult());
                }

                var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List.ToList();
                sTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd {
                    TaskId = tsk.Id
                }).GetAwaiter().GetResult());

                ctx.CreateWorkflowHttpProxy().GetProcessInstanceClient().GetProcessInstanceById(instances[0].Id).GetAwaiter().GetResult();
            });

            Assert.NotNull(ex);
        }
        public void Initialize(ILogger logger, ITaskController taskController, TaskResultView taskResultView)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (taskController == null)
                throw new ArgumentNullException("taskController");
            if (taskResultView == null)
                throw new ArgumentNullException("taskResultView");

            try
            {
                this.logger = logger;
                this.taskController = taskController;
                this.taskResultView = taskResultView;

                this.taskItemsControl.ItemsSource = taskController.Tasks;
            }
            catch (Exception ex)
            {
                logger.Error("TaskManagerView.Initialize", ex);
            }
        }
Exemplo n.º 38
0
 protected abstract void DoExecute(ITaskController taskController, TaskResultView taskResultView);