Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

Welcome to the Digizuite C# SDK documentation. Here you will find documentation on how to use the sdk and some tips and tricks for interacting with the Digizuite in general.

Setup

To get started with the Digizuite SDK, you should first install the Digizuite packages from nuget.org https://www.nuget.org/packages/Digizuite.Sdk.
Additionally the SDK has to be initialized. If you are using dotnet, an extension method AddDigizuite is provided. Use the extension method AddDigizuite for inspiration.

A simple example of how the initialization code looks in a console application is as follows:

var serviceCollection = new ServiceCollection(); 

var config = new DigizuiteConfiguration()
{
	BaseUrl = new Uri("https://<Digizuite url>.com/"),
	SystemUsername = "<Username>",
	SystemPassword = "<Password>"
};

serviceCollection.AddDigizuite(config)
            .AddDigizuiteLogging()
            .AddConsoleSink();
serviceCollection.AddSingleton(typeof(ILogger<>), typeof(ConsoleLogger<>));
var serviceProvider = serviceCollection.BuildServiceProvider(true);

In the following we show how you can update the different metafield types on an asset.

  1. BIT
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of BitMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new BitMetadataUpdate
    {
        Value = true,
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  2. INT
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of IntMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new IntMetadataUpdate
    {
        Value = 99,
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  3. STRING
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of StringMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new StringMetadataUpdate
    {
        Value = "Update metafield string",
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  4. COMBOVALUE
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of ComboValueMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update.
    The ComboValue can either be set to an existing combovalue or create an new combovalue.
    new ExistingCombo(50170) or new DynamicCombo { Label = "test" , OptionValue = "test" }.
    As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new ComboValueMetadataUpdate
    {
        ComboValue = new ExistingCombo(50170),
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  5. MULTICOMBOVALUE
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of MultiComboValueMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update.
    The ComboValues can either be a set of existings combovalues or create an new combovalues.
    new ExistingCombo(50170) or new DynamicCombo { Label = "test" , OptionValue = "test" }.
    As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new MultiComboValueMetadataUpdate
    {
        ComboValues = new List<BaseInputCombo>
        {
            new ExistingCombo(50175),
            new ExistingCombo(50174)
        },
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  6. DATETIME
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of DateTimeMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new DateTimeMetadataUpdate
    {
        Value = DateTime.Now,
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  7. TREE
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of TreeMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update.
    The TreeValues can eather be a set of existings ExistingTreeNode or create new treenodes by using the DynamicTopDownTreeNode.
    As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new TreeMetadataUpdate
    {
        TreeValues = new ValueList<BaseTreeNodeUpdate>
        {
            new ExistingTreeNode(2)
        },
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  8. EDITCOMBOVALUE
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of EditComboValueMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new EditComboValueMetadataUpdate
    {
        ComboValue = "Test edit value",
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  9. EDITMULTICOMBOVALUE
    Use the Digizuite service IAssetSearchService and IMetadataValueService.
    First we fetch the asset. Then creates a new instance of EditMultiComboValueMetadataUpdate. The TargetItemIds is the itemId of the asset we just fetched. The MetaFieldItemGuid is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.

    var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>();
    var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>();
    var asset = await assetSearchService.GetAsset(75);
    var metadataUpdate = new EditMultiComboValueMetadataUpdate
    {
        ComboValues = new HashSet<string>
        {
          "test 3",
          "demo"
        },
        TargetItemIds = new HashSet<int> { asset.ItemId },
        MetaFieldItemGuid = Guid.Parse("<GUID of Metafield>")
    };
    await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { metadataUpdate});

  • No labels