public static GetAttachmentHttpResponseMessage ( string fileName, string fileType, Stream fileContent ) : |
||
fileName | string | |
fileType | string | |
fileContent | Stream | |
return |
public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid) { EnsureUserIsAdmin(); var appWrapper = new SxcAppWrapper(appId); var zipExport = new ZipExport(zoneId, appId); var fileName = string.Format("2sxcApp_{0}_{1}.zip", appWrapper.GetNameWithoutSpecialChars(), appWrapper.GetVersion()); using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid)) { var fileBytes = fileStream.ToArray(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes))); } }
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 appWrapper = AppBasedOnUserPermissions(appId, zoneId); var fileName = $"2sxcContentExport_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}.xml"; var fileXml = new ToSxcXmlExporter().Init(zoneId, appId, false, contentTypeIdsString?.Split(';') ?? new string[0], entityIdsString?.Split(';') ?? new string[0], Log ).GenerateNiceXml(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml)); }
public HttpResponseMessage ExportContent(int appId, int zoneId, string contentTypeIdsString, string entityIdsString, string templateIdsString) { EnsureUserIsAdmin(); var appWrapper = new SxcAppWrapper(appId); var fileName = string.Format("2sxcContentExport_{0}_{1}.xml", appWrapper.GetNameWithoutSpecialChars(), appWrapper.GetVersion()); var fileXml = new XmlExporter ( zoneId, appId, false, contentTypeIdsString == null ? new string[0] : contentTypeIdsString.Split(';'), entityIdsString == null ? new string[0] : entityIdsString.Split(';') ).GenerateNiceXml(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml)); }
public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid) { EnsureUserIsAdmin(); var appWrapper = (UserInfo.IsSuperUser) ? new SxcAppWrapper(zoneId, appId) // only super-user may switch to another zone for export : new SxcAppWrapper(appId); var zipExport = new ZipExport(zoneId, appId); var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : ""; var fileName = $"2sxcApp_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}{addOnWhenContainingContent}.zip"; using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid)) { var fileBytes = fileStream.ToArray(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes))); } }
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 appWrapper = AppBasedOnUserPermissions(appId, zoneId); var zipExport = new ZipExport(zoneId, appId, appWrapper.App.Folder, appWrapper.App.PhysicalPath, Log); var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : ""; var fileName = $"2sxcApp_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}{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 HttpResponseMessage ExportContent(int appId, int zoneId, string contentTypeIdsString, string entityIdsString, string templateIdsString) { EnsureUserIsAdmin(); var appWrapper = (UserInfo.IsSuperUser) ? new SxcAppWrapper(zoneId, appId) // only super-user may switch to another zone for export : new SxcAppWrapper(appId); var fileName = $"2sxcContentExport_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}.xml"; var fileXml = new XmlExporter ( zoneId, appId, false, contentTypeIdsString?.Split(';') ?? new string[0], entityIdsString?.Split(';') ?? new string[0] ).GenerateNiceXml(); return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml)); }