public async Task <JsonResult> GetAvaibleStatuses(int taskStatus, BrigadeType executorBrigadeType)
        {
            await CheckPermission();

            var permissions = (await GetCurrentUser()).Role.Permissions;
            var sqlR        = new TaskStatusRepository(_logger);
            var result      = sqlR.GetAvailableStatusesNewTask((TaskStatus)taskStatus, executorBrigadeType, permissions);

            return(Json(result));
        }
Esempio n. 2
0
        public static string ShortDescription(this BrigadeType type)
        {
            switch (type)
            {
            case BrigadeType.Locomotiv:
                return("ЛБ");

            case BrigadeType.Depo:
                return("БД");

            case BrigadeType.Receiver:
                return("ПР");

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 3
0
        public static string GetDescription(this BrigadeType type)
        {
            switch (type)
            {
            case BrigadeType.Locomotiv:
                return("Локомотивная бригада");

            case BrigadeType.Depo:
                return("Бригада Депо");

            case BrigadeType.Receiver:
                return("Приемщики");

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 4
0
        private static string GetStringBrigadeType(BrigadeType brigadeType)
        {
            switch (brigadeType)
            {
            case BrigadeType.Locomotiv:
                return("ЛБ");

            case BrigadeType.Depo:
                return("БД");

            case BrigadeType.Receiver:
                return("БП");

            default:
                return("?");
            }
        }
Esempio n. 5
0
        public static string GetDescription(this CheckListType type, BrigadeType brigade)
        {
            switch (type)
            {
            case CheckListType.TO1:
                return("ТО-1");

            case CheckListType.TO2:
                return("ТО-2");

            case CheckListType.Inspection:
                return("Приемка");

            case CheckListType.Surrender:
                return(brigade == BrigadeType.Locomotiv ? "Сдача":"Выпуск");

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 6
0
        public async Task <TaskByIdDto> GetTaskById(int id, int permissions = -1)
        {
            using (var conn = new SqlConnection(AppSettings.ConnectionString))
            {
                var sqlRExecutor   = new ExecutorRepository(_logger);
                var sqlRTaskStatus = new TaskStatusRepository(_logger);
                var sqlRTask       = new TaskSqls();


                var fromSql = (await conn.QueryAsync <TaskDetailFromSql>(sqlRTask.GetTrainTaskByIdAndAttributeId(id))).ToList();

                var task = fromSql.First();

                var result = new TaskByIdDto
                {
                    Id             = task.Id,
                    Data           = task.CreateDate,
                    InitiatorName  = task.InitiatorName,
                    TrainName      = task.TrainName,
                    EquipmentName  = task.EquipmentName,
                    CarriageSerial = task.CarriageSerial, //CreateCarriageName(task.TrainName, task.CarriageNumber),
                    TaskType       = task.TaskType
                };

                //Текущий статус
                var taskStatuses = await sqlRTaskStatus.ByTaskId(id);

                var currentTaskStatus = taskStatuses.Last().Status;
                result.StatusId = (int)currentTaskStatus;

                //Текущий исполнитель
                var taskExecutors = await sqlRExecutor.GetByTaskId(id);

                BrigadeType currentTaskExecutor = 0;
                if (taskExecutors.Count > 0)
                {
                    currentTaskExecutor = taskExecutors.Last().BrigadeType;
                    result.BrigadeType  = (int)currentTaskExecutor;
                }

                //Уровень задачи
                var taskLevel = fromSql.OrderBy(x => x.TaskLevel).Select(x => x.TaskLevel).First();
                result.TaskLevel = taskLevel.HasValue ? (int)taskLevel : 0;

                //Доступные статусы
                var possibleTaskStatuses = sqlRTaskStatus.GetAvailableStatusesNewTask(currentTaskStatus, currentTaskExecutor, permissions);
                result.PossibleTaskStatuses = possibleTaskStatuses.Select(x => (int)x).ToList();

                //Неисправности из атрибутов
                result.Faults      = new List <FaultTaskDto>();
                result.Inspections = new List <InspectionTaskDto>();
                foreach (var item in fromSql)
                {
                    if (item.AttributeFaultId != null)
                    {
                        await AddFaultData(result, item);
                    }

                    if (item.AttributeInspectionId != 0)
                    {
                        await AddInspectionData(result, item);
                    }
                }
                //Добавить в фаулты данные по чеклистам из инпекции
                var withCheckListEquipmentId = fromSql.Where(x => x.AttributeCheckListEquipmentId != null)
                                               .DistinctBy(y => y.AttributeCheckListEquipmentId).ToList();
                foreach (var item in withCheckListEquipmentId)
                {
                    await AddFaultDataFromCheckListEquipmentId(result, item);
                }

                result.History = await AddHistoryData(id);

                return(result);
            }
        }