public virtual ActionResult Admin(string view = null, string code = null, string __provider__ = null, string __sid__ = null, string state = null, string providerKey = null) { if (__provider__ == "canvas" && !string.IsNullOrWhiteSpace(__sid__) && !string.IsNullOrWhiteSpace(code) && !string.IsNullOrWhiteSpace(state)) { //// crazy hack for canvas OAuth callback ??!! return(RedirectToAction("callback", "Lti", new { __provider__, __sid__, code, state, providerKey })); } else { var filePattern = (string)Settings.BuildSelector; var path = Server.MapPath("~/Content/swf/admin"); var version = CacheUtility.GetCachedItem(Cache, CachePolicies.Keys.VersionFileName(filePattern), () => _versionProcessor.ProcessVersion(path, filePattern)); var versionFileSwf = filePattern.Replace("*", version.ToString()); return(View( EdugameCloudT4.Home.Views.Admin, new HomeViewModel(this) { BuildUrl = Links.Content.swf.admin.Url(versionFileSwf) })); } }
//file/get-public-build public virtual ActionResult GetPublicBuild() { try { var user = this.CurrentUser; if ((user != null) && (user.Company != null)) { var filePattern = (string)Settings.PublicBuildSelector; var path = Server.MapPath(PublicFolderPath); Version version = _versionProcessor.ProcessVersion(path, filePattern); if (version == null) { _logger.Warn("Could'n find any POD build"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var publicBuild = filePattern.Replace("*", version.ToString()); string physicalPath = Path.Combine(Server.MapPath(PublicFolderPath), publicBuild); Company company = user.Company; if (company.CurrentLicense.With(x => x.LicenseStatus == CompanyLicenseStatus.Enterprise) && (company.Theme != null) && System.IO.File.Exists(physicalPath)) { // NOTE: current POD size is about 960kb var ms = new MemoryStream(960 * 1024); using (var archive = ZipFile.OpenRead(physicalPath)) { using (var arc = new ZipArchive(ms, ZipArchiveMode.Create, true)) { CopyAllFilesExceptConfig(archive, arc); using (var fs = arc.CreateEntry("config.xml").Open()) { var xml = string.Format("<config><themeId>{0}</themeId><gateway>{1}</gateway></config>", company.Theme.With(x => x.Id), Settings.BaseServiceUrl); var xmlBuffer = System.Text.Encoding.ASCII.GetBytes(xml); fs.Write(xmlBuffer, 0, xmlBuffer.Length); } } } ms.Position = 0; return(this.File(ms, "application/zip", Path.GetFileName(physicalPath))); } EnsureServicePathConfigExists(physicalPath); var file = new FileInfo(Path.Combine(Server.MapPath(PublicFolderPath), physicalPath)); if (file.Exists) { return(File(file.FullName, file.Extension.EndsWith("ZIP", StringComparison.OrdinalIgnoreCase) ? "application/zip" : "application/x-shockwave-flash", file.Name)); } return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } } catch (Exception ex) { _logger.Error("BuildDeliverController.GetPublicBuild.", ex); throw; } return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); }