public void Process(JObject command, Context context) { var entity = JSONUtil.GetToken(command, "#cds-retrieve-data"); if (entity == null) { entity = JSONUtil.GetToken(command, "entity"); } if (entity == null) { return; } //string optionset = null; //if (entity.Length == 0) { optionset = CommandEngine.GetCommandArgument(command, "Option Set"); } string into = CommandEngine.GetCommandArgument(command, "into"); //string env = CommandEngine.GetCommandArgument(command, "env"); CDSConnection cdsConnection = CDSConnection.FromCommand(command, context); if (cdsConnection == null) { return; } ColumnSet columns = new ColumnSet(true); if (command["fields"] != null) { string fieldlist = command["fields"].ToString(); if (fieldlist.Length > 0) { List <string> fields = fieldlist.Split(',').Select(p => p.Trim()).ToList(); columns = new ColumnSet(fields.ToArray()); } } //var cdsConnection = (CDSConnection)context.GetConnection(env); //if (optionset == null) //{ Console.WriteLine("Loading CDS Entity Data {0} into {1}", entity, into); var sub = cdsConnection.RetrieveEntityData(entity.ToString(), columns); context.Store(into, sub); //} //else //{ //Console.WriteLine("Loading CDS OptionSet {0} into {1}", entity, into); // var sub = cdsConnection.RetrieveOptionSet(entity, optionset); // context.Store(into, sub); //} }
public void Process(JObject command, Context context) { var file = JSONUtil.GetText(command, "#save-json"); if (file == null) { file = JSONUtil.GetText(command, "file"); } string set = CommandEngine.GetCommandArgument(command, "set"); string mode = JSONUtil.GetText(command, "mode"); var rawItem = command["item"]; file = context.ReplaceVariables(file); JToken item = null; if (set != null) { item = (JToken)context.Fetch(set); } else if (rawItem != null) { item = rawItem; } Console.WriteLine("Saving {0} as {1}", set, file); if (mode == "append") { JSONUtil.AppendToFile(item, file); } else { JSONUtil.WriteFile(item, file); } }