Exemplo n.º 1
0
        public HttpResponseMessage Export(int appId, int zoneId, string contentTypeIdsString, string entityIdsString, string templateIdsString)
        {
            Log.Add($"export content z#{zoneId}, a#{appId}, ids:{entityIdsString}, templId:{templateIdsString}");
            SecurityHelpers.ThrowIfNotAdmin(_user); // must happen inside here, as it's opened as a new browser window, so not all headers exist

            var contextZoneId = _zoneMapper.GetZoneId(_siteId);
            var currentApp    = CmsRuntime.ServiceProvider.Build <ImpExpHelpers>().Init(Log).GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId);
            var appRuntime    = CmsRuntime.Init(currentApp, true, Log);

            var fileName = $"2sxcContentExport_{currentApp.NameWithoutSpecialChars()}_{currentApp.VersionSafe()}.xml";
            var fileXml  = _xmlExporter.Init(zoneId, appId, appRuntime, false,
                                             contentTypeIdsString?.Split(';') ?? new string[0],
                                             entityIdsString?.Split(';') ?? new string[0],
                                             Log
                                             ).GenerateNiceXml();

            return(HttpFileHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml));
        }