Queues up the job that will kick off the stage production step.
Namespace: Relativity.Productions.Services
Assembly: Relativity.Productions.Services.Interfaces (in Relativity.Productions.Services.Interfaces.dll) Version: 11.1.0.1 9c084404c128f715df772c7792aa49f21535523c
Syntax
Task<ProductionJobResult> StageProductionAsync( int workspaceArtifactID, int productionArtifactID, bool automaticallyRun )
Parameters
- workspaceArtifactID
- Type: SystemInt32
Workspace artifact ID. - productionArtifactID
- Type: SystemInt32
Production artifact ID. - automaticallyRun
- Type: SystemBoolean
If set, attempt to automatically run the production after staging.
Return Value
Type: TaskProductionJobResultExamples
Stage production example
using Relativity.Productions.Services; using Relativity.Services.ServiceProxy; using Relativity.Services.Exceptions; public partial class Example { public async Task StageProduction_Example() { int workspaceId = 12345; // Workspace Production exists in int productionId = 11111; // Production's ArtifactID var userEmail = "user@test.com"; // User's login var password = "abc123456!"; // User's password var relativityServicesUri = "http://localhost/relativity.services"; var relativityRestUri = "http://localhost/relativity.rest/api"; var usernamePasswordCredentials = new UsernamePasswordCredentials(userEmail, password); ServiceFactorySettings settings = new ServiceFactorySettings(new Uri(relativityServicesUri), new Uri(relativityRestUri), usernamePasswordCredentials); ServiceFactory serviceFactory = new ServiceFactory(settings); using (IProductionManager productionManager = serviceFactory.CreateProxy<IProductionManager>()) { try { ProductionJobResult result = await productionManager.StageProductionAsync(workspaceId, productionId); bool wasJobCreated = result.WasJobCreated; if (!wasJobCreated) { Console.WriteLine(result.Errors); Console.WriteLine(result.Warnings); Console.WriteLine(result.Messages); } else { // You can read the production status and wait until it's staged await WaitStatusToBe(productionManager, workspaceId, productionId, ProductionStatus.Staged); await productionManager.RunProductionAsync(workspaceId, productionId); } } 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); } } } public async Task StageAndRunProduction_Example() { int workspaceId = 12345; // Workspace Production exists in int productionId = 11111; // Production's ArtifactID var userEmail = "user@test.com"; // User's login var password = "abc123456!"; // User's password var relativityServicesUri = "http://localhost/relativity.services"; var relativityRestUri = "http://localhost/relativity.rest/api"; var usernamePasswordCredentials = new UsernamePasswordCredentials(userEmail, password); ServiceFactorySettings settings = new ServiceFactorySettings(new Uri(relativityServicesUri), new Uri(relativityRestUri), usernamePasswordCredentials); ServiceFactory serviceFactory = new ServiceFactory(settings); using (IProductionManager productionManager = serviceFactory.CreateProxy<IProductionManager>()) { try { //Pass automatically run as true to have production run automatically after staging completed ProductionJobResult result = await productionManager.StageProductionAsync(workspaceId, productionId, true); bool wasJobCreated = result.WasJobCreated; if (!wasJobCreated) { Console.WriteLine(result.Errors); Console.WriteLine(result.Warnings); Console.WriteLine(result.Messages); } else { // You can read the production status and wait until it's produced await WaitStatusToBe(productionManager, workspaceId, productionId, ProductionStatus.Produced); } } 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 async Task WaitStatusToBe(IProductionManager productionManager, int workspaceId, int productionId, ProductionStatus expectedStatus) { int timeout = 180; var s = new Stopwatch(); s.Start(); Production production = await productionManager.ReadSingleAsync(workspaceId, productionId); while (production.ProductionMetadata.Status != expectedStatus) { production = await productionManager.ReadSingleAsync(workspaceId, productionId); if (s.Elapsed > TimeSpan.FromSeconds(timeout)) { throw new TimeoutException(string.Format("Failed to get to status: {0}. ", expectedStatus)); } Thread.Sleep(3000); } s.Stop(); } }
See Also