public static ResponseFile ExportSitePackage(Context context, SiteSettings ss) { var sitePackage = GetSitePackage( context: context, ss: ss); if (sitePackage == null) { return(null); } var useIndentOption = Parameters.SitePackage.UseIndentOptionOnExport != OptionTypes.Disabled && context.QueryStrings.Bool("UseIndentOption"); var file = new ResponseFile( fileContent: sitePackage.RecordingJson( context: context, formatting: useIndentOption ? Formatting.Indented : Formatting.None), fileDownloadName: ExportUtilities.FileName( context: context, sitePackage.Sites.FirstOrDefault()?.Title, extension: "json")); return(file); }
public static ResponseFile ExportSitePackage(Context context, SiteSettings ss) { if (!Parameters.SitePackage.Export || !context.CanManageSite(ss: ss)) { return(null); } var useIndentOption = context.QueryStrings.Bool("UseIndentOption"); var includeSitePermission = context.QueryStrings.Bool("IncludeSitePermission"); var includeRecordPermission = context.QueryStrings.Bool("IncludeRecordPermission"); var includeColumnPermission = context.QueryStrings.Bool("IncludeColumnPermission"); string sitePackagesSelectableAll = Regex.Replace( context.QueryStrings.Data("SitePackagesSelectableAll"), @"[^0-9-,(true|false)]", ""); var sites = new List <SelectedSite>(); sitePackagesSelectableAll.Split(',') .ForEach(e => sites.Add(new SelectedSite() { SiteId = e.Split_1st('-').ToLong(), IncludeData = e.Split_2nd('-').ToBool() })); if (ExceededExportLimit( context: context, sites: sites)) { return(null); } foreach (var site in sites) { var currentSs = ss.SiteId == site.SiteId ? ss : SiteSettingsUtilities.Get( context: context, siteId: site.SiteId); if (site.IncludeData && (context.ContractSettings.Export == false || !context.CanExport(ss: currentSs))) { return(null); } } var sitePackage = new SitePackage( context: context, siteList: sites, includeSitePermission: includeSitePermission, includeRecordPermission: includeRecordPermission, includeColumnPermission: includeColumnPermission); var file = new ResponseFile( fileContent: sitePackage.RecordingJson( context: context, formatting: useIndentOption ? Formatting.Indented : Formatting.None), fileDownloadName: ExportUtilities.FileName( context: context, sitePackage.Sites.FirstOrDefault()?.Title, extension: "json")); return(file); }