/// <summary> /// Deploys an update to an existing model from a specified package. /// </summary> /// <param name="packageFile">File name of the input package.</param> /// <param name="versionName">Name of the version of master data to update.</param> private static void DeployUpdate(string packageFile, string versionName) { Console.WriteLine("Deploying package {0}, updating version {1} of the master data", packageFile, versionName); ModelDeployer deployer = new ModelDeployer(); ModelReader reader = new ModelReader(); // Deploy it. Warnings errorsAsWarnings = null; using (var package = new PackageReader(packageFile)) { // Get the ID for the model named in the package var firstPackage = package.FirstOrDefault(); if (firstPackage != null) { Identifier modelId = GetModelIdentifier(reader, firstPackage.ModelId.Name); // Now get the version Id for that model and the given version name. reader.ModelId = modelId; } Identifier versionId = GetVersionIdentifier(reader, versionName); errorsAsWarnings = deployer.DeployUpdate(package.GetEnumerator(), true, versionId); } Console.WriteLine("Package was deployed with {0} warnings", errorsAsWarnings.Count); }
/// <summary> /// Deploys a copy of a model from a package, with a new name. /// </summary> /// <param name="packageFile">File name of the input package.</param> /// <param name="modelName">New name for the model being deployed.</param> private static void DeployNew(string packageFile, string modelName) { Console.WriteLine("Deploying package {0} using new model name {1}", packageFile, modelName); ModelDeployer deployer = new ModelDeployer(); // Deploy the package. Warnings errorsAsWarnings = null; using (var package = new PackageReader(packageFile)) { Identifier newId = null; errorsAsWarnings = deployer.DeployNew(package.GetEnumerator(), modelName, out newId); } Console.WriteLine("Package was deployed with {0} warnings", errorsAsWarnings.Count); }