public IActionResult ExportToJson(WPToJsonDTO value) { WPExportContentEngine engine = new WPExportContentEngine(value); var json = engine.DoWork(); byte[] jsonBytes = Encoding.ASCII.GetBytes(json); StringBuilder sb = new StringBuilder(); sb.Append("WPExportToJson_"); sb.Append($"{value.WPSourceDBName}"); sb.Append("_"); sb.Append($"{DateTime.UtcNow.ToString("yyyyMMddHHmm")}"); if (value.JSONIndented == false) { sb.Append(".min"); } sb.Append(".json"); Stream stream = new MemoryStream(jsonBytes); return(File(stream, "application/json", sb.ToString())); }
public WPExportContentEngine(WPToJsonDTO value) { _wpToJsonDTO = value; _wpQuery = new WPQuery(_wpToJsonDTO.WPSourceDBTablePrefix); }