public JsonResult Load(int id, bool simpleMode) { Services.EditorService editor = new Services.EditorService(); EditorDictionary[id] = editor; string libFolder = Server.MapPath("~/bin/Core/"); string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { Logging.Log.InfoFormat("Invalid game {0}", id); return(Json(new { error = "Invalid ID" }, JsonRequestBehavior.AllowGet)); } var result = editor.Initialise(id, filename, libFolder, simpleMode); if (!result.Success) { Logging.Log.InfoFormat("Failed to load game {0} - {1}", id, result.Error); return(Json(new { error = result.Error.Replace(Environment.NewLine, "<br/>") }, JsonRequestBehavior.AllowGet)); } string playFilename = Services.FileManagerLoader.GetFileManager().GetPlayFilename(id); return(Json(new { tree = editor.GetElementTreeForJson(), editorstyle = editor.Style, playurl = ConfigurationManager.AppSettings["PlayURL"] + "?id=editor/" + HttpUtility.UrlEncode(playFilename), }, JsonRequestBehavior.AllowGet)); }
public JsonResult Load(int id, bool simpleMode) { Logging.Log.DebugFormat("{0}: Load (simpleMode={1})", id, simpleMode); Services.EditorService editor = new Services.EditorService(); EditorDictionary[id] = editor; string libFolder = ConfigurationManager.AppSettings["LibraryFolder"]; string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { return Json(new { error = "Invalid ID" }, JsonRequestBehavior.AllowGet); } var result = editor.Initialise(id, filename, libFolder, simpleMode); if (!result.Success) { return Json(new { error = result.Error.Replace(Environment.NewLine, "<br/>") }, JsonRequestBehavior.AllowGet); } return Json(new { tree = editor.GetElementTreeForJson(), editorstyle = editor.Style }, JsonRequestBehavior.AllowGet); }
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 JsonResult Load(int id, bool simpleMode) { Logging.Log.DebugFormat("{0}: Load (simpleMode={1})", id, simpleMode); Services.EditorService editor = new Services.EditorService(); EditorDictionary[id] = editor; string libFolder = ConfigurationManager.AppSettings["LibraryFolder"]; string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { return(Json(new { error = "Invalid ID" }, JsonRequestBehavior.AllowGet)); } var result = editor.Initialise(id, filename, libFolder, simpleMode); if (!result.Success) { return(Json(new { error = result.Error.Replace(Environment.NewLine, "<br/>") }, JsonRequestBehavior.AllowGet)); } return(Json(new { tree = editor.GetElementTreeForJson(), editorstyle = editor.Style }, JsonRequestBehavior.AllowGet)); }
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) { 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, outputFilename); } string url = ConfigurationManager.AppSettings["PublishURL"] + id; return Redirect(url); }
public JsonResult Load(int id, bool simpleMode) { Services.EditorService editor = new Services.EditorService(); EditorDictionary[id] = editor; string libFolder = Server.MapPath("~/bin/Core/"); string filename = Services.FileManagerLoader.GetFileManager().GetFile(id); if (filename == null) { Logging.Log.InfoFormat("Invalid game {0}", id); return Json(new { error = "Invalid ID" }, JsonRequestBehavior.AllowGet); } var result = editor.Initialise(id, filename, libFolder, simpleMode); if (!result.Success) { Logging.Log.InfoFormat("Failed to load game {0} - {1}", id, result.Error); return Json(new { error = result.Error.Replace(Environment.NewLine, "<br/>") }, JsonRequestBehavior.AllowGet); } string playFilename = Services.FileManagerLoader.GetFileManager().GetPlayFilename(id); return Json(new { tree = editor.GetElementTreeForJson(), editorstyle = editor.Style, playurl = ConfigurationManager.AppSettings["PlayURL"] + "?id=editor/" + playFilename, }, JsonRequestBehavior.AllowGet); }