private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType, IDictionary <string, string> parameters) { var o = process.Output(); switch (exportType) { case "xlsx": var folder = Common.GetAppFolder(); if (!_appDataFolder.DirectoryExists(folder)) { _appDataFolder.CreateDirectory(folder); } var fileName = Common.GetSafeFileName(user, _slugService.Slugify(part.Title()), "xlsx"); o.Provider = "excel"; o.File = _appDataFolder.MapPath(_appDataFolder.Combine(folder, fileName)); break; case "geojson": o.Stream = true; o.Provider = "geojson"; o.File = _slugService.Slugify(part.Title()) + ".geojson"; break; case "kml": o.Stream = true; o.Provider = "kml"; o.File = _slugService.Slugify(part.Title()) + ".kml"; break; default: //csv o.Stream = true; o.Provider = "file"; o.Delimiter = ","; o.File = _slugService.Slugify(part.Title()) + ".csv"; break; } parameters["page"] = "0"; foreach (var entity in process.Entities) { entity.Page = 0; entity.Fields.RemoveAll(f => f.System); foreach (var field in entity.GetAllFields()) { if (field.Alias == Common.BatchValueFieldName) { field.Output = false; } field.T = string.Empty; // because short-hand has already been expanded field.Output = field.Output && field.Export == "defer" || field.Export == "true"; } } }
private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType, IDictionary <string, string> parameters) { var o = process.Output(); switch (exportType) { case "xlsx": if (!_appDataFolder.DirectoryExists(Common.FileFolder)) { _appDataFolder.CreateDirectory(Common.FileFolder); } var fileName = $"{user}-{_clock.UtcNow.ToString(FileTimestamp)}-{_slugService.Slugify(part.Title())}.xlsx"; o.Provider = "excel"; o.File = _appDataFolder.MapPath(_appDataFolder.Combine(Common.FileFolder, fileName)); break; case "geojson": o.Stream = true; o.Provider = "geojson"; o.File = _slugService.Slugify(part.Title()) + ".geojson"; break; case "kml": o.Stream = true; o.Provider = "kml"; o.File = _slugService.Slugify(part.Title()) + ".kml"; break; default: //csv o.Stream = true; o.Provider = "file"; o.Delimiter = ","; o.File = _slugService.Slugify(part.Title()) + ".csv"; break; } parameters["page"] = "0"; foreach (var entity in process.Entities) { entity.Page = 0; entity.Fields.RemoveAll(f => f.System); foreach (var field in entity.GetAllFields()) { field.Output = field.Output && field.Export == "defer" || field.Export == "true"; } } }
private void ConvertToExport(Process process, PipelineConfigurationPart part, IDictionary <string, string> parameters) { var fileName = _slugService.Slugify(part.Title()) + ".csv"; var o = process.Output(); o.Provider = "file"; o.Delimiter = ","; o.File = fileName; parameters["page"] = "0"; foreach (var entity in process.Entities) { entity.Page = 0; foreach (var field in entity.GetAllFields()) { field.T = ""; if (field.Output && field.Raw && field.Transforms.Any()) { var lastTransform = field.Transforms.Last(); if (lastTransform.Method.In("tag", "razor")) { var firstParameter = lastTransform.Parameters.First(); field.Transforms.Remove(lastTransform); field.T = "copy(" + firstParameter.Field + ")"; } } } } }
public Process Resolve(PipelineConfigurationPart part, string input, string output) { Logger.Information("Resolving Process for Part: {0}", part == null ? "null" : part.Title()); var marker = part.PlaceHolderStyle[0]; var prefix = part.PlaceHolderStyle[1]; var suffix = part.PlaceHolderStyle[2]; var modifier = new ParameterModifier(new PlaceHolderReplacer(marker, prefix, suffix), "parameters", "name", "value"); switch (input) { case "json": switch (output) { case "json": Logger.Information("Resolving Process with {0} input, and {1} output.", input, output); return(new Process( new FormParameterModifier(new DateMathModifier()), new FastJsonParser(), new JsonSerializer(), _orchard.WorkContext.Resolve <FieldTransformShorthandCustomizer>(), _orchard.WorkContext.Resolve <ValidateShorthandCustomizer>(), modifier )); default: // xml Logger.Information("Resolving Process with {0} input, and {1} output.", input, output); return(new Process( new FormParameterModifier(new DateMathModifier()), new FastJsonParser(), new XmlSerializer(), _orchard.WorkContext.Resolve <FieldTransformShorthandCustomizer>(), _orchard.WorkContext.Resolve <ValidateShorthandCustomizer>(), modifier )); } default: switch (output) { case "json": Logger.Information("Resolving Process with {0} input, and {1} output.", input, output); return(new Process( new FormParameterModifier(new DateMathModifier()), new NanoXmlParser(), new JsonSerializer(), _orchard.WorkContext.Resolve <FieldTransformShorthandCustomizer>(), _orchard.WorkContext.Resolve <ValidateShorthandCustomizer>(), modifier )); default: // xml Logger.Information("Resolving Process with {0} input, and {1} output.", input, output); return(new Process( new FormParameterModifier(new DateMathModifier()), new NanoXmlParser(), new XmlSerializer(), _orchard.WorkContext.Resolve <FieldTransformShorthandCustomizer>(), _orchard.WorkContext.Resolve <ValidateShorthandCustomizer>(), modifier )); } } }
private void ConvertToExport(string user, Process process, PipelineConfigurationPart part, string exportType) { var o = process.Output(); switch (exportType) { case "xlsx": var folder = Common.GetAppFolder(); if (!_appDataFolder.DirectoryExists(folder)) { _appDataFolder.CreateDirectory(folder); } var fileName = Common.GetSafeFileName(user, _slugService.Slugify(part.Title()), "xlsx"); o.Provider = "excel"; o.File = _appDataFolder.MapPath(_appDataFolder.Combine(folder, fileName)); break; case "geojson": o.Stream = true; o.Provider = "geojson"; o.File = _slugService.Slugify(part.Title()) + ".geo.json"; var suppress = new HashSet <string>() { Common.BatchValueFieldName, part.MapColorField, part.MapPopUpField }; var coordinates = new HashSet <string>() { part.MapLatitudeField, part.MapLongitudeField }; foreach (var entity in process.Entities) { foreach (var field in entity.GetAllFields()) { if (suppress.Contains(field.Alias)) { field.Output = false; field.Property = false; field.Alias += "Suppressed"; } else if (coordinates.Contains(field.Alias)) { field.Property = field.Export == "true"; } else { field.Property = field.Property || field.Output && field.Export == "defer" || field.Export == "true"; } } } break; case "map": o.Stream = true; o.Provider = "geojson"; o.File = _slugService.Slugify(part.Title()) + ".geo.json"; var mapFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { part.MapColorField, "geojson-color" }, { part.MapPopUpField, "geojson-description" }, { part.MapLatitudeField, "latitude" }, { part.MapLongitudeField, "longitude" }, { Common.BatchValueFieldName, Common.BatchValueFieldName } }; ConfineData(process, mapFields); break; case "json": o.Stream = true; o.Provider = "json"; o.File = _slugService.Slugify(part.Title()) + ".json"; break; case "calendar": o.Stream = true; o.Provider = "json"; o.File = _slugService.Slugify(part.Title()) + ".json"; var calendarFields = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { { part.CalendarIdField, "id" }, { part.CalendarTitleField, "title" }, { part.CalendarUrlField, "url" }, { part.CalendarClassField, "class" }, { part.CalendarStartField, "start" }, { part.CalendarEndField, "end" }, { Common.BatchValueFieldName, Common.BatchValueFieldName } }; ConfineData(process, calendarFields); break; case "kml": o.Stream = true; o.Provider = "kml"; o.File = _slugService.Slugify(part.Title()) + ".kml"; break; default: // csv o.Stream = true; o.Provider = "file"; o.Delimiter = ","; o.TextQualifier = "\""; o.File = _slugService.Slugify(part.Title()) + ".csv"; break; } // common foreach (var entity in process.Entities) { entity.Fields.RemoveAll(f => f.System); foreach (var field in entity.GetAllFields()) { field.T = string.Empty; // because short-hand has already been expanded switch (exportType) { case "map": case "calendar": case "geojson": // already been modified break; default: if (field.Alias == Common.BatchValueFieldName) { field.Output = false; } field.Output = field.Output && field.Export == "defer" || field.Export == "true"; break; } } } }