public HttpResponseMessage ExportContent(int appId, int zoneId, string contentTypeIdsString, string entityIdsString, string templateIdsString) { Log.Add($"export content z#{zoneId}, a#{appId}, ids:{entityIdsString}, templId:{templateIdsString}"); EnsureUserIsAdmin(); var currentApp = SxcAppForWebApi.AppBasedOnUserPermissions(zoneId, appId, UserInfo, Log);// AppWithRestrictedZoneChange(appId, zoneId); var appRuntime = new AppRuntime(currentApp, true, Log); var fileName = $"2sxcContentExport_{currentApp.NameWithoutSpecialChars()}_{currentApp.VersionSafe()}.xml"; var fileXml = new DnnXmlExporter().Init(zoneId, appId, appRuntime, false, contentTypeIdsString?.Split(';') ?? new string[0], entityIdsString?.Split(';') ?? new string[0], Log ).GenerateNiceXml(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml)); }
public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid) { Log.Add($"export app z#{zoneId}, a#{appId}, incl:{includeContentGroups}, reset:{resetAppGuid}"); EnsureUserIsAdmin(); // must happen inside here, as it's opened as a new browser window, so not all headers exist var currentApp = SxcAppForWebApi.AppBasedOnUserPermissions(zoneId, appId, UserInfo, Log); // AppWithRestrictedZoneChange(appId, zoneId); var zipExport = new ZipExport(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log); var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : ""; var fileName = $"2sxcApp_{currentApp.NameWithoutSpecialChars()}_{currentApp.VersionSafe()}{addOnWhenContainingContent}.zip"; Log.Add($"file name:{fileName}"); using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid)) { var fileBytes = fileStream.ToArray(); Log.Add("will stream so many bytes:" + fileBytes.Length); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes))); } }
public dynamic GetContentInfo(int appId, int zoneId, string scope) { Log.Add($"get content info for z#{zoneId}, a#{appId}, scope:{scope} super?:{UserInfo.IsSuperUser}"); var currentApp = SxcAppForWebApi.AppBasedOnUserPermissions(zoneId, appId, UserInfo, Log);// AppWithRestrictedZoneChange(appId, zoneId); var cms = new CmsRuntime(currentApp, Log, true, false); var contentTypes = cms.ContentTypes.FromScope(scope); var entities = cms.Entities.All; var templates = cms.Views.GetAll(); return(new { ContentTypes = contentTypes.Select(c => new { Id = c.ContentTypeId, c.Name, c.StaticName, Templates = templates.Where(t => t.ContentType == c.StaticName).Select(t => new { t.Id, t.Name }), Entities = entities .Where(e => e.Type.ContentTypeId == c.ContentTypeId) .Select(e => new { Title = e.GetBestTitle(), Id = e.EntityId }) }), TemplatesWithoutContentTypes = templates.Where(t => !string.IsNullOrEmpty(t.ContentType)).Select(t => new { t.Id, t.Name }) }); }