public void DeletingAndRestoringAsset_WillGiveItSameGuid_AsItHadOriginally()
        {
            var guidA = AssetManager.CreateAsset(new Script(guid), k_ScriptAPath).Guid;
            var guidB = AssetManager.CreateAsset(new Script(guid), k_ScriptBPath).Guid;

            AssetManager.DeleteAsset(k_ScriptBPath);

            CreateDummyScriptWithImporter(k_ScriptBPath);
            AssetManager.Refresh();

            Assert.AreEqual(2, AssetManager.Assets.Count(), "Asset count missmatch");
            Assert.AreEqual(2, AssetGuidManager.Paths.Count(), "Guid-Path map count missmatch");

            Assert.AreEqual(guidA, AssetManager.GetAsset(k_ScriptAPath).Guid, "A path gives correct guid");
            Assert.AreEqual(guidB, AssetManager.GetAsset(k_ScriptBPath).Guid, "B path gives correct guid");
        }
Exemplo n.º 2
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (treeView.SelectedNode.Level == 1)
     {
         var asset = AssetManager.GetAsset(treeView.SelectedNode.Parent.Text, treeView.SelectedNode.Text);
         AssetManager.DeleteAsset(asset.Path);
     }
 }
Exemplo n.º 3
0
        private void DeleteExistingThumbnails(CloudVideoPart part)
        {
            var thumbnailAssets = part.Assets.Where(x => x is ThumbnailAsset);

            foreach (var asset in thumbnailAssets)
            {
                _assetManager.DeleteAsset(asset);
            }
        }
        public void TestRunnerManager_CorrectlyRemovesFixtures_WhenDeletingThemOnDisk()
        {
            var lightFixture = LightTestFixture;

            lightFixture.AddScript(new Script()
            {
                Name = "Test"
            });

            AssetManager.CreateAsset(lightFixture, k_TestAPath);
            AssetManager.CreateAsset(lightFixture, k_TestBPath);
            AssetManager.CreateAsset(lightFixture, k_TestCPath);

            AssetManager.DeleteAsset(k_TestAPath);
            AssetManager.DeleteAsset(k_TestBPath);

            Assert.AreEqual(1, TestRunnerManager.TestFixtures.Count, "Only one test fixture should be present");
            Assert.AreEqual(k_TestCPath, TestRunnerManager.TestFixtures[0].Path, "Test fixture paths missmatched");
            Assert.AreEqual("C", TestRunnerManager.TestFixtures[0].Name, "Test fixture names missmatched");
        }
Exemplo n.º 5
0
        public void DeleteAsset_RemovesFromManager_AndFromDisk()
        {
            AssetManager.CreateAsset(new Script(guid), k_ScriptAPath);
            AssetManager.CreateAsset(new Script(guid), k_ScriptBPath);

            AssetManager.DeleteAsset(k_ScriptAPath);

            Assert.AreEqual(1, AssetManager.Assets.Count());
            Assert.IsFalse(File.Exists(k_ScriptAPath), "Asset A should not exist on disk");
            Assert.IsNull(AssetManager.GetAsset(k_ScriptAPath), "Asset A should not exist anymore");
            Assert.IsNotNull(AssetManager.GetAsset(k_ScriptBPath), "Asset B should exist");
        }
        public async Task <IActionResult> Delete(string id, string driveName = null)
        {
            try
            {
                var asset = _manager.DeleteAsset(id, driveName);

                await _webhookPublisher.PublishAsync("Assets.AssetDeleted", asset.Id.ToString(), asset.Name).ConfigureAwait(false);

                return(await base.DeleteEntity(id));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
Exemplo n.º 7
0
        public ActionResult Delete(int id)
        {
            if (!_authorizer.Authorize(Permissions.ManageCloudMediaContent, T("You are not authorized to manage Microsoft Azure Media content.")))
            {
                return(new HttpUnauthorizedResult());
            }

            Logger.Debug("User requested to delete asset with ID {0}.", id);

            var asset = _assetManager.GetAssetById(id);

            if (asset == null)
            {
                Logger.Warning("User requested to delete asset with ID {0} but no such asset record exists.", id);
                return(HttpNotFound(String.Format("No asset with ID {0} was found.", id)));
            }

            var cloudVideoPart = asset.VideoPart;

            if (cloudVideoPart.MezzanineAsset.Record.Id == asset.Record.Id)
            {
                Logger.Warning("User requested to delete asset with ID {0} but it is the mezzanine asset and cannot be deleted.", id);
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, String.Format("Asset with ID {0} is the mezzanine asset and cannot be deleted.", id)));
            }

            try {
                _assetManager.DeleteAsset(asset);

                Logger.Information("Asset with ID {0} was deleted.", id);
                _notifier.Information(T("The asset '{0}' was successfully deleted.", asset.Name));
            }
            catch (Exception ex) {
                _transactionManager.Cancel();

                Logger.Error(ex, "Error while deleting asset with ID {0}.", id);
                _notifier.Error(T("Ar error occurred while deleting the asset '{0}':\n{1}", asset.Name, ex.Message));
            }

            return(Redirect(Url.ItemEditUrl(cloudVideoPart)));
        }
Exemplo n.º 8
0
 public async Task <AssetContract> Delete(string assetId)
 {
     return(Convert(await _assetManager.DeleteAsset(assetId)));
 }