IProductionPlaceholderManagerCreateSingleAsync Method

Relativity.Productions.API
Creates a placeholder in the workspace

Namespace:  Relativity.Productions.Services
Assembly:  Relativity.Productions.Services.Interfaces (in Relativity.Productions.Services.Interfaces.dll) Version: 11.1.0.1 9c084404c128f715df772c7792aa49f21535523c
Syntax

Task<int> CreateSingleAsync(
	int workspaceArtifactID,
	ProductionPlaceholder placeholder
)

Parameters

workspaceArtifactID
Type: SystemInt32
Workspace artifact ID.
placeholder
Type: Relativity.Productions.ServicesProductionPlaceholder
An instance of ProductionPlaceholder object.

Return Value

Type: TaskInt32
The ProductionPlaceholder artifactID of the newly created placeholder
Remarks

If PlaceholderType is Custom, then the CustomText must be specified. It is possible to create a blank placeholder using a CustomText with an empty string.

If PlaceholderType is Image, then the FileData and Filename properties must be specified.

Examples

Create Image Placeholder Example
using Relativity.Productions.Services;
using Relativity.Services.ServiceProxy;
using Relativity.Services.Exceptions;

public partial class Example
{
    public async Task CreateImagePlaceholder_Example()
    {
        var workspaceID     = 11111;                // ArtifactID of Workspace where Placeholder exists
        var userName        = "user@test.com";      // User's login
        var userPassword    = "abc123456!";         // User's password

        var relativityServicesUri = @"http://localhost/relativity.services";
        var relativityRestUri     = @"http://localhost/relativity.rest/api";

        var usernamePasswordCredentials = new UsernamePasswordCredentials(userName, userPassword);
        ServiceFactorySettings settings = new ServiceFactorySettings(new Uri(relativityServicesUri), new Uri(relativityRestUri), usernamePasswordCredentials);
        ServiceFactory serviceFactory   = new ServiceFactory(settings);

        string fileLocation = @"\\servername\share\Placeholder.jpg";
        string filename     = Path.GetFileName(fileLocation);
        byte[] fileData     = ReadFully(fileLocation);

        using (IProductionPlaceholderManager productionPlaceholderManager = serviceFactory.CreateProxy<IProductionPlaceholderManager>())
        {
            try
            {

                ProductionPlaceholder placeholder = new ProductionPlaceholder()
                {
                    Name            = "Placeholder for excel sheets",
                    PlaceholderType = PlaceholderType.Image,
                    Filename        = filename,
                    FileData        = fileData
                };
                placeholder.ArtifactID = await productionPlaceholderManager.CreateSingleAsync(workspaceID, placeholder);

            }
            catch (ValidationException e)
            {
                // Log validation exception details
                Console.WriteLine("There were validation errors: {0}", e.Message);
            }
            catch (ServiceException es)
            {
                // Log service exception details
                Console.WriteLine("There were errors: {0}", es.Message);
            }
        }
    }

    private byte[] ReadFully(string fileLocation)
    {
        MemoryStream ms = new MemoryStream();
        byte[] buffer = new byte[16 * 1024];
        int read;
        using (FileStream reader = new FileStream(fileLocation, FileMode.Open))
        {
            while ((read = reader.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
        }
        return ms.ToArray();
    }
}
Create Custom Placeholder Example
using Relativity.Productions.Services;
using Relativity.Services.ServiceProxy;
using Relativity.Services.Exceptions;

public partial class Example
{
    public async Task CreateCustomPlaceholder_Example()
    {
        var workspaceID  = 11111;                    // ArtifactID of Workspace where Placeholder exists
        var userName     = "user@test.com";          // User's login
        var userPassword = "abc123456!";             // User's password

        var relativityServicesUri = @"http://localhost/relativity.services";
        var relativityRestUri     = @"http://localhost/relativity.rest/api";

        var usernamePasswordCredentials = new UsernamePasswordCredentials(userName, userPassword);
        ServiceFactorySettings settings = new ServiceFactorySettings(new Uri(relativityServicesUri), new Uri(relativityRestUri), usernamePasswordCredentials);
        ServiceFactory serviceFactory   = new ServiceFactory(settings);

        using (IProductionPlaceholderManager productionPlaceholderManager = serviceFactory.CreateProxy<IProductionPlaceholderManager>())
        {
            try
            {

                ProductionPlaceholder placeholder = new ProductionPlaceholder()
                {
                    Name            = "Placeholder for excel sheets",
                    PlaceholderType = PlaceholderType.Custom,
                    CustomText      = "This is an excel sheet."
                };
                placeholder.ArtifactID = await productionPlaceholderManager.CreateSingleAsync(workspaceID, placeholder);

            }
            catch (ValidationException e)
            {
                // Log validation exception details
                Console.WriteLine("There were validation errors: {0}", e.Message);
            }
            catch (ServiceException es)
            {
                // Log service exception details
                Console.WriteLine("There were errors: {0}", es.Message);
            }
        }
    }
}
See Also

Reference