Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the to pass the model
        /// </summary>
        /// <param name="model"></param>
        public void Initialize(DocumentWorkflowConfiguration model)
        {
            this.workflowOrganizationUnitService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IWorkflowOrganizationUnitService>();
            if (model == null)
            {
                model = new DocumentWorkflowConfiguration();
            }

            Model = model;
            var stateProviderList  = CommonServiceLocator.ServiceLocator.Current.GetAllInstances <IDocumentWorkflowStateProvider>();
            var accessProviderList = CommonServiceLocator.ServiceLocator.Current.GetAllInstances <IDocumentWorkflowAccessProvider>();

            userService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IUserService>();

            foreach (var provider in stateProviderList)
            {
                stateProviders.Add(provider.Name);
            }

            RaisePropertyChanged(nameof(StateProviders));

            foreach (var provider in accessProviderList)
            {
                accessProviders.Add(provider.Name);
            }

            RaisePropertyChanged(nameof(AccessProviders));

            workflowOrganizationUnits = new ObservableCollection <SelectWorkflowOrganizationUnitViewModel>(workflowOrganizationUnitService.GetAll().Select(x => new SelectWorkflowOrganizationUnitViewModel(x)
            {
                Parent = this
            }).ToList());
            assignments = new ObservableCollection <WorkflowOrganizationUnitAssignmentViewModel>(Model.OrganizationUnits.GetAsObservableCollection().Select(y => new WorkflowOrganizationUnitAssignmentViewModel(y, this)
            {
            }));
            CollectionNotifyPropertyChanged(assignments, model.OrganizationUnits, x => x.Model);
            addTab = new RelayCommand(o => Add());

            if (assignments.Any())
            {
                selectedAssignment = assignments.FirstOrDefault();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new tab with
        /// </summary>
        private void Add()
        {
            if (workflowOrganzitationUnit == null)
            {
                return;
            }

            //Assignment is not initialized
            if (assignments == null)
            {
                assignments = new ObservableCollection <WorkflowOrganizationUnitAssignmentViewModel>();
            }

            //Assignment has already the wou inside
            if (assignments.Any(x => x.Model.WorkflowOrganisationUnitId == workflowOrganzitationUnit.Guid))
            {
                return;
            }


            var workflow = new WorkflowOrganizationUnitAssignmentViewModel(new WorkflowOrganizationUnitAssignment {
                WorkflowOrganisationUnitId = workflowOrganzitationUnit.Guid
            }, this)
            {
                Header = workflowOrganzitationUnit?.Name,
            };

            if (string.IsNullOrWhiteSpace(workflow.Header))
            {
                return;
            }

            assignments.Add(workflow);
            selectedAssignment = workflow;

            RaisePropertyChanged(nameof(Tabs));
            RaisePropertyChanged(nameof(SelectedAssignment));
        }