Пример #1
0
        /// <summary>
        /// 前処理コンテナを削除し、ステータスを変更する。
        /// 削除可否の判断が必要なら、呼び出しもとで判定すること。
        /// </summary>
        /// <param name="preprocessHistory">対象前処理履歴</param>
        /// <param name="force">他テナントに対する変更を許可するか</param>
        public async Task <bool> DeleteAsync(PreprocessHistory preprocessHistory, bool force)
        {
            // 前処理結果を削除
            bool result = true;

            foreach (var outputDataId in preprocessHistoryRepository.GetPreprocessOutputs(preprocessHistory.Id))
            {
                //1件でも失敗したら結果はfalse。ただし、エラーが出ても最後まで消し切る。
                result &= await dataLogic.DeleteDataAsync(outputDataId);
            }

            // 前処理履歴の削除
            preprocessHistoryRepository.Delete(preprocessHistory, force);

            // 結果に関わらずコミット
            unitOfWork.Commit();

            var status = ContainerStatus.Convert(preprocessHistory.Status);

            if (status.Exist())
            {
                //コンテナが動いていれば、停止する
                await clusterManagementLogic.DeleteContainerAsync(
                    ContainerType.Preprocessing, preprocessHistory.Name, CurrentUserInfo.SelectedTenant.Name, force);
            }

            return(result);
        }
Пример #2
0
        public async Task <IActionResult> DeleteDataAsync(long?id, [FromServices] IDataSetRepository dataSetRepository, [FromServices] ITagRepository tagRepository)
        {
            if (id == null)
            {
                //IDが指定されていなければエラー
                return(JsonBadRequest("Invalid inputs."));
            }
            //Dataとそれに紐づくSectionimageをDBから取得
            var data = await dataRepository.GetDataIncludeAllAsync(id.Value);

            if (data == null)
            {
                return(JsonNotFound($"Data ID {id.Value} is not found."));
            }

            var checkResult = await CheckDataIsLocked(data, dataSetRepository);

            if (checkResult != null)
            {
                return(checkResult);
            }

            // 削除処理
            bool result = await dataLogic.DeleteDataAsync(id.Value);

            // DBへの編集内容を一旦確定させるためコミット
            unitOfWork.Commit();

            // 未使用タグ削除
            tagRepository.DeleteUnUsedTags();

            // DBへタグ削除結果のコミット
            unitOfWork.Commit();

            if (result)
            {
                return(JsonNoContent());
            }
            else
            {
                return(JsonError(HttpStatusCode.ServiceUnavailable, $"Failed to delete data {data.Name}. Please contact your server administrator."));
            }
        }