public void Delete(string id)
        {
            BlobHelper blobHelper;

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    throw new Exception("ID inválido");
                }
                else
                {
                    blobHelper = new BlobHelper(_loggerFactory, _config);

                    blobHelper.Delete(id);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 配布内容を更新する
        /// </summary>
        /// <param name="id"></param>
        /// <param name="distributionInfo">配布物</param>
        /// <param name="remarks">備考</param>
        /// <returns></returns>
        public async Task <DistributionTask> UpdateAsync(int id, DistributionInfo distributionInfo, string remarks = null)
        {
            try
            {
                if (id == 0)
                {
                    throw new Exception("parameter 'id' is required.");
                }
                if (distributionInfo == null)
                {
                    throw new Exception("parameter 'distributionItem' is required.");
                }

                return(await ExecuteAsync(
                           () =>
                {
                    var original = FindById(id);
                    var oldBlobName = original.BlobName;

                    original.BlobName = Guid.NewGuid().ToString();
                    original.Remarks = remarks;

                    operationHelper.MaintenanceDbRepository.SaveChanges();

                    var blob = new BlobHelper(operationHelper.StorageConnectionKey, $"distribution-{original.EnvironmentInfoId}");
                    blob.Delete($"{oldBlobName}");
                    blob.Upload($"{original.BlobName}", distributionInfo.Serialize());

                    return original;
                }));
            }
            catch (Exception ex)
            {
                await SendmessageAsync(ex);

                throw;
            }
        }
Example #3
0
 public void DeleteBlob(string blobUrl)
 {
     BlobHelper.Delete(Request.Cookies[SiteHelper.ACCOUNT].Value, Request.Cookies[SiteHelper.KEY].Value, blobUrl);
     grdBlobs.DataBind();
 }