// Stage the production public async Task StageProductionAsync(int workspaceArtifactId, int productionArtifactId) { Console2.WriteDisplayStartLine("Staging Production"); try { ProductionJobResult productionJobResult = await ProductionManager.StageProductionAsync(workspaceArtifactId, productionArtifactId); ProductionStatusDetailsResult productionStatusDetailsResult = await ProductionManager.GetProductionStatusDetails(workspaceArtifactId, productionArtifactId); const int maxTimeInMilliseconds = (Constants.Waiting.MAX_WAIT_TIME_IN_MINUTES * 60 * 1000); const int sleepTimeInMilliSeconds = Constants.Waiting.SLEEP_TIME_IN_SECONDS * 1000; int currentWaitTimeInMilliseconds = 0; while (currentWaitTimeInMilliseconds < maxTimeInMilliseconds && (string)productionStatusDetailsResult.StatusDetails.FirstOrDefault().Value != "Staged") { Thread.Sleep(sleepTimeInMilliSeconds); productionStatusDetailsResult = await ProductionManager.GetProductionStatusDetails(workspaceArtifactId, productionArtifactId); currentWaitTimeInMilliseconds += sleepTimeInMilliSeconds; } if (productionJobResult.Errors.Count != 0) { const string errorMessage = "There was an error when Staging Production"; Console2.WriteDebugLine(errorMessage); foreach (string item in productionJobResult.Errors) { Console2.WriteDebugLine(item); } throw new Exception(errorMessage); } foreach (string item in productionJobResult.Messages) { Console2.WriteDebugLine(item); } Console2.WriteDebugLine(productionStatusDetailsResult.StatusDetails.Last() + "\r\n"); Console2.WriteDisplayEndLine("Staged Production!"); } catch (Exception ex) { throw new Exception("An error occured when Staging Production", ex); } }