Exemplo n.º 1
0
        public async Task DeleteDependantResourcesForMarkSession(
            MarkSessionModel markSessionModel
            )
        {
            var taskList = new List <Task>();

            foreach (var dependantResourceModel in markSessionModel.DependantResources)
            {
                switch (dependantResourceModel.ResourceType)
                {
                case ResourceTypeEnum.Project:
                    // The project must not be deleted !
                    break;

                case ResourceTypeEnum.Metadata:
                    taskList.Add(
                        _fileClient.DeleteResource(dependantResourceModel)
                        );
                    break;

                case ResourceTypeEnum.Scenario:
                    taskList.Add(
                        _scenarioClient.DeleteResource(dependantResourceModel)
                        );
                    break;

                case ResourceTypeEnum.ResultConfig:
                    taskList.Add(
                        _resultConfigClient.DeleteResource(dependantResourceModel)
                        );
                    break;

                case ResourceTypeEnum.SimPlan:
                    taskList.Add(
                        _simPlanClient.DeleteResource(dependantResourceModel, markSessionModel.ProjectId)
                        );
                    break;

                case ResourceTypeEnum.SimRun:
                    taskList.Add(
                        _simRunClient.DeleteResource(dependantResourceModel, markSessionModel.ProjectId)
                        );
                    break;

                case ResourceTypeEnum.ResultData:
                    taskList.Add(
                        _resultDataClient.DeleteResource(dependantResourceModel)
                        );
                    break;

                default:
                    throw new UnknownResourceTypeExcetion(
                              $"{dependantResourceModel.ResourceType} is unknown!"
                              );
                }
            }

            await TaskUtil.ExecuteTasksInParallel(taskList);
        }