private void FindSceneIndex()
    {
        json = File.ReadAllText(presetFilePath);
        Debug.Log("JSON read: " + json);
        TaskVariable taskVar = JsonUtility.FromJson <TaskVariable>(json);

        sceneIndex = taskVar.task;
    }
Пример #2
0
        public PagedCollectionResponse <IEnumerable <Task> > GetTasksForDOssierIdAndRole(Guid dossierId, string role, int?page, int?size)
        {
            var tasks = new List <Task>();

            WorkflowInstanceOut         processInstance = null;
            List <WorkflowTaskVariable> variables       = null;

            if (dossierId != Guid.Empty)
            {
                processInstance = _workflowService.GetWorkflorInstanceByDossierId(dossierId).Result;
            }
            var workflowTasks = _workflowService.GetTasksForDossierIdAndRole(processInstance != null ? processInstance.Id : (int?)null, role);

            foreach (var workflowTask in workflowTasks.Result)
            {
                variables = _workflowService.GetTaskVariables(workflowTask.Id).Result;

                //Create the task
                var task = new Task
                {
                    Id   = workflowTask.Id,
                    Name = workflowTask.Name,
                    ProcessInstanceId = workflowTask.ProcessInstanceId
                };
                //Add to the list
                tasks.Add(task);

                //Get the formfields
                var form = _workflowService.GetFormFieldsForTaskId((workflowTask.Id)).Result;

                task.Form = new Form()
                {
                    FormKey = form.FormKey
                };

                if (form != null)
                {
                    //First loop over the formfields and create them in the task & find the value in the variables list of the worklow task
                    foreach (var workFlowFormField in form.FormProperties)
                    {
                        //Create the formfield
                        var formField = new TaskVariable()
                        {
                            Id         = workFlowFormField.Id,
                            Name       = workFlowFormField.Name,
                            Type       = workFlowFormField.Type,
                            Readable   = workFlowFormField.Readable,
                            Required   = workFlowFormField.Required,
                            Writable   = workFlowFormField.Writable,
                            EnumValues = workFlowFormField.EnumValues
                        };

                        //Find the variable in the task that holds the value
                        var valueVariable = variables.FirstOrDefault(x => x.Name == workFlowFormField.Id);
                        if (valueVariable != null)
                        {
                            formField.Value = valueVariable.Value;
                        }

                        task.Form.FormFields.Add(formField);
                    }
                }

                //Next find the variables that are not formfields and add these to the taskvariable collection
                foreach (var workflowVariable in variables.Where(x => task.Form == null || task.Form.FormFields.All(y => x.Name != y.Id)))
                {
                    //Create the formfield
                    var taskVariable = new TaskVariable()
                    {
                        Id    = workflowVariable.Name,
                        Name  = workflowVariable.Name,
                        Type  = workflowVariable.Type,
                        Value = workflowVariable.Value
                    };

                    task.Variables.Add(taskVariable);
                }
            }
            var pageCollection = new PagedCollectionResponse <IEnumerable <Task> >();

            pageCollection.Data = tasks;

            return(pageCollection);
        }