/// <summary> /// Creates a new AppPackage /// </summary> /// <param name="packageId">Unique name identifying the appPackage to be created. AppPackage must not already exist with the same name.</param> /// <param name="packageZipFilePath">Local path to the autoloader bundle after it has been zipped.</param> /// <returns>true if appPackage was created, false otherwise</returns> public static bool CreateAppPackageFromZip(String packageId, string packageZipFilePath) { if (String.IsNullOrEmpty(packageId) || !File.Exists(packageZipFilePath)) { return(false); } AIO.ACES.Models.AppPackage appPackage = null; foreach (AIO.ACES.Models.AppPackage pack in container.AppPackages) { if (pack.Id.Equals(packageId)) { appPackage = pack; break; } } if (appPackage == null) { try { // First step -- query for the url to upload the AppPackage file UriBuilder builder = new UriBuilder(container.BaseUri); builder.Path += "AppPackages/Operations.GetUploadUrl"; var url = container.Execute <string>(builder.Uri, "GET", true, null).First(); // Second step -- upload AppPackage file if (GeneralUtils.UploadObject(url, packageZipFilePath)) { // third step -- after upload, create the AppPackage appPackage = new AIO.ACES.Models.AppPackage() { Id = packageId, Version = 1, RequiredEngineVersion = "20.0", Resource = url }; container.AddToAppPackages(appPackage); container.SaveChanges(); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } return(appPackage != null); }
/// <summary> /// Creates a new AppPackage /// </summary> /// <param name="packageId">Unique name identifying the appPackage to be created. AppPackage must not already exist with the same name.</param> /// <param name="packageZipFilePath">Local path to the autoloader bundle after it has been zipped.</param> /// <returns>true if appPackage was created, false otherwise</returns> public static bool CreateAppPackageFromZip(String packageId, string packageZipFilePath) { if (String.IsNullOrEmpty(packageId) || !File.Exists(packageZipFilePath)) return false; AIO.ACES.Models.AppPackage appPackage = null; foreach (AIO.ACES.Models.AppPackage pack in container.AppPackages) { if (pack.Id.Equals(packageId)) { appPackage = pack; break; } } if (appPackage == null) { try { // First step -- query for the url to upload the AppPackage file UriBuilder builder = new UriBuilder(container.BaseUri); builder.Path += "AppPackages/Operations.GetUploadUrl"; var url = container.Execute<string>(builder.Uri, "GET", true, null).First(); // Second step -- upload AppPackage file if (GeneralUtils.UploadObject(url, packageZipFilePath)) { // third step -- after upload, create the AppPackage appPackage = new AIO.ACES.Models.AppPackage() { Id = packageId, Version = 1, RequiredEngineVersion = "20.0", Resource = url }; container.AddToAppPackages(appPackage); container.SaveChanges(); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } return (appPackage != null); }