Exemplo n.º 1
0
        /// <summary>
        /// Получает список типов обращений.
        /// </summary>
        /// <param name="user_info">Информация о пользователе.</param>
        /// <param name="information_system_code">Код ИС.</param>
        /// <param name="task_code">Код типа задач.</param>
        /// <returns>Список типов обращений.</returns>
        public IEnumerable <Exploration> GetExplorations(UserInfo user_info, string information_system_code, string task_code)
        {
            var product = GetProduct(information_system_code);

            if (product == null)
            {
                return(Enumerable.Empty <Exploration>());
            }

            var wfs = GetAvailableWorkflows(user_info).Where(x => x.ProductId == product.Id && x.TaskCode == task_code);

            return(_explorationRepository.GetAll().Join(wfs, x => x.Id, x => x.ExplorationId, (x, y) => x).Distinct());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Получает список доступных процессов для пользователя.
        /// </summary>
        /// <param name="user_info">Информация о пользователе.</param>
        /// <returns>Список доступных процессов для пользователя.</returns>
        private IEnumerable <Workflow> GetAvailableWorkflows(UserInfo user_info)
        {
            var workflow = _workflowRepository.GetAll();

            var r_to_w = _role2WorkflowRepository.GetAll().Where(x => user_info.Roles != null && user_info.Roles.Contains(x.Role));

            return(workflow.Join(r_to_w, x => x.Id, x => x.WorkflowId, (x, y) => x));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Получает маршрут.
        /// </summary>
        /// <param name="form">Форма для создания задачи.</param>
        /// <param name="user_info">Информация о пользователе.</param>
        /// <returns>Маршрут.</returns>
        private string GetProject(CreateForm form, UserInfo user_info)
        {
            var workflow = GetWorkflow(form, user_info);

            return(_perimeterRepository.GetAll().First(x => x.Key == workflow.PerimeterId).Value);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Получает список информационных систем.
        /// </summary>
        /// <param name="user_info">Информация о пользователе.</param>
        /// <param name="task_code">Код типа задачи.</param>
        /// <returns>Список информационных систем.</returns>
        public IEnumerable <Product> GetProducts(UserInfo user_info, string task_code)
        {
            var wfs = GetAvailableWorkflows(user_info).Where(x => x.TaskCode == task_code);

            return(_productRepository.GetAll().Join(wfs, x => x.Id, x => x.ProductId, (x, y) => x).Distinct());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Получает список типов задач, доступных пользователю.
        /// </summary>
        /// <param name="user_info">Информация о пользователе.</param>
        /// <returns>Список задач.</returns>
        public IEnumerable <Task> GetTasks(UserInfo user_info)
        {
            var wfs = GetAvailableWorkflows(user_info);

            return(_taskRepository.GetAll().Join(wfs, x => x.Code, x => x.TaskCode, (x, y) => x).Distinct());
        }
Exemplo n.º 6
0
        public void SetUp()
        {
            _jiraApiService          = Substitute.For <IJiraApiService>();
            _ldapService             = Substitute.For <ILdapService>();
            _workflowRepository      = Substitute.For <IBaseConfigurationRepository <Workflow> >();
            _taskRepository          = Substitute.For <IBaseConfigurationRepository <Task> >();
            _role2WorkflowRepository = Substitute.For <IBaseConfigurationRepository <Role2Workflow> >();
            _productRepository       = Substitute.For <IBaseConfigurationRepository <Product> >();
            _perimeterRepository     = Substitute.For <IBaseConfigurationRepository <Perimeter> >();
            _explorationRepository   = Substitute.For <IBaseConfigurationRepository <Exploration> >();

            _workflowRepository.GetAll().Returns(new List <Workflow>
            {
                new Workflow
                {
                    Id              = WORKFLOW_ID,
                    ProductId       = PRODUCT_ID,
                    TaskCode        = TaskCode.Explore.ToString(),
                    PerimeterId     = PERIMETER_ID,
                    ExplorationId   = EXPLORATION_ID,
                    CommitRequired  = true,
                    CommentTemplate = "template",
                    BusinessProcess = "619"
                }
            });

            _role2WorkflowRepository.GetAll().Returns(new List <Role2Workflow>
            {
                new Role2Workflow
                {
                    WorkflowId = WORKFLOW_ID,
                    Role       = ROLE
                }
            });

            _productRepository.GetAll().Returns(new List <Product>
            {
                new Product
                {
                    Id   = PRODUCT_ID,
                    Code = PRODUCT_CODE
                }
            });

            _explorationRepository.GetAll().Returns(new List <Exploration>
            {
                new Exploration
                {
                    Id   = EXPLORATION_ID,
                    Name = EXPLORATION_NAME
                }
            });

            _taskRepository.GetAll().Returns(new List <Task>
            {
                new Task
                {
                    Code = TaskCode.Explore.ToString(),
                    Name = EXPLORATION_NAME
                }
            });

            _perimeterRepository.GetAll().Returns(new List <Perimeter>
            {
                new Perimeter
                {
                    Key   = PERIMETER_ID,
                    Value = PERIMETER_VALUE
                }
            });

            _taskCreateService = new TaskCreateService
                                 (
                _jiraApiService,
                _ldapService,
                _taskRepository,
                _workflowRepository,
                _role2WorkflowRepository,
                _productRepository,
                _explorationRepository,
                _perimeterRepository
                                 );
        }