public ActionResult Publish(int id) { Services.EditorService editor = new Services.EditorService(); string libFolder = ConfigurationManager.AppSettings["LibraryFolder"]; string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { return(View("Error")); } var result = editor.Initialise(id, filename, libFolder, false); if (!result.Success) { return(View("Error")); } string outputFolder = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(filename), "Output"); System.IO.Directory.CreateDirectory(outputFolder); string outputFilename = System.IO.Path.Combine( outputFolder, System.IO.Path.GetFileNameWithoutExtension(filename) + ".quest"); if (System.IO.File.Exists(outputFilename)) { System.IO.File.Delete(outputFilename); } editor.Publish(outputFilename); string url = ConfigurationManager.AppSettings["PublishURL"] + id; return(Redirect(url)); }
public ActionResult Publish(int id) { Services.EditorService editor = new Services.EditorService(); string libFolder = ConfigurationManager.AppSettings["LibraryFolder"]; string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { return View("Error"); } var result = editor.Initialise(id, filename, libFolder, false); if (!result.Success) { return View("Error"); } string outputFolder = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(filename), "Output"); System.IO.Directory.CreateDirectory(outputFolder); string outputFilename = System.IO.Path.Combine( outputFolder, System.IO.Path.GetFileNameWithoutExtension(filename) + ".quest"); if (System.IO.File.Exists(outputFilename)) { System.IO.File.Delete(outputFilename); } editor.Publish(outputFilename); string url = ConfigurationManager.AppSettings["PublishURL"] + id; return Redirect(url); }
public ActionResult Publish(int id) { Logging.Log.InfoFormat("Publishing game {0}", id); Services.EditorService editor = new Services.EditorService(); string libFolder = Server.MapPath("~/bin/Core/"); string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { Logging.Log.InfoFormat("Publish failed for {0} - couldn't get file", id); return(View("Error")); } var result = editor.Initialise(id, filename, libFolder, false); if (!result.Success) { Logging.Log.InfoFormat("Publish failed for {0} - failed to initialise editor", id); return(View("Error")); } if (Config.AzureFiles) { var uploadPath = Services.FileManagerLoader.GetFileManager().UploadPath(id); var container = GetAzureBlobContainer("editorgames"); var blobs = container.ListBlobs(uploadPath + "/"); var includeFiles = new List <EditorController.PackageIncludeFile>(); foreach (var blob in blobs.OfType <CloudBlockBlob>()) { if (blob.Name.EndsWith(".aslx")) { continue; } var blobReference = container.GetBlockBlobReference(blob.Name); var ms = new MemoryStream(); blobReference.DownloadToStream(ms); ms.Position = 0; includeFiles.Add(new EditorController.PackageIncludeFile { Filename = Path.GetFileName(blob.Uri.ToString()), Content = ms }); } using (var outputStream = new MemoryStream()) { editor.Publish(null, includeFiles, outputStream); outputStream.Position = 0; var blob = container.GetBlockBlobReference(uploadPath + "/Output/" + Path.GetFileNameWithoutExtension(filename) + ".quest"); blob.UploadFromStream(outputStream); } foreach (var stream in includeFiles.Select(i => i.Content)) { stream.Dispose(); } } else { string outputFolder = Path.Combine(Path.GetDirectoryName(filename), "Output"); Directory.CreateDirectory(outputFolder); string outputFilename = Path.Combine( outputFolder, Path.GetFileNameWithoutExtension(filename) + ".quest"); if (System.IO.File.Exists(outputFilename)) { System.IO.File.Delete(outputFilename); } Logging.Log.InfoFormat("Publishing {0} as {1}", id, outputFilename); editor.Publish(outputFilename, null, null); UploadOutputToAzure(outputFilename); Logging.Log.InfoFormat("Publish succeeded for {0}", id); } string url = ConfigurationManager.AppSettings["PublishURL"] + id; return(Redirect(url)); }
public ActionResult Publish(int id) { Logging.Log.InfoFormat("Publishing game {0}", id); Services.EditorService editor = new Services.EditorService(); string libFolder = Server.MapPath("~/bin/Core/"); string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { Logging.Log.InfoFormat("Publish failed for {0} - couldn't get file", id); return View("Error"); } var result = editor.Initialise(id, filename, libFolder, false); if (!result.Success) { Logging.Log.InfoFormat("Publish failed for {0} - failed to initialise editor", id); return View("Error"); } if (Config.AzureFiles) { var uploadPath = Services.FileManagerLoader.GetFileManager().UploadPath(id); var container = GetAzureBlobContainer("editorgames"); var blobs = container.ListBlobs(uploadPath + "/"); var includeFiles = new List<EditorController.PackageIncludeFile>(); foreach (var blob in blobs.OfType<CloudBlockBlob>()) { if (blob.Name.EndsWith(".aslx")) continue; var blobReference = container.GetBlockBlobReference(blob.Name); var ms = new MemoryStream(); blobReference.DownloadToStream(ms); ms.Position = 0; includeFiles.Add(new EditorController.PackageIncludeFile { Filename = Path.GetFileName(blob.Uri.ToString()), Content = ms }); } using (var outputStream = new MemoryStream()) { editor.Publish(null, includeFiles, outputStream); outputStream.Position = 0; var blob = container.GetBlockBlobReference(uploadPath + "/Output/" + Path.GetFileNameWithoutExtension(filename) + ".quest"); blob.UploadFromStream(outputStream); } foreach (var stream in includeFiles.Select(i => i.Content)) { stream.Dispose(); } } else { string outputFolder = Path.Combine(Path.GetDirectoryName(filename), "Output"); Directory.CreateDirectory(outputFolder); string outputFilename = Path.Combine( outputFolder, Path.GetFileNameWithoutExtension(filename) + ".quest"); if (System.IO.File.Exists(outputFilename)) { System.IO.File.Delete(outputFilename); } Logging.Log.InfoFormat("Publishing {0} as {1}", id, outputFilename); editor.Publish(outputFilename, null, null); UploadOutputToAzure(outputFilename); Logging.Log.InfoFormat("Publish succeeded for {0}", id, outputFilename); } string url = ConfigurationManager.AppSettings["PublishURL"] + id; return Redirect(url); }