private async Task Import(string[] args) { if (!args.Any()) { await Out.WriteLineAsync("No import target defined"); return; } var deliveryName = args[0].Trim(); string directory; if (!settings.TryGetChauffeurDirectory(out directory)) { return; } var file = fileSystem.Path.Combine(directory, deliveryName + ".xml"); if (!fileSystem.File.Exists(file)) { await Out.WriteLineFormattedAsync("Unable to located the import script '{0}'", deliveryName); return; } var xml = XDocument.Load(file); packagingService.ImportDataTypeDefinitions(xml.Elements().First()); await Out.WriteLineFormattedAsync("Data Type Definitions have been imported"); }
private async Task UnpackDataTypes(IEnumerable <XElement> elements) { foreach (var element in elements) { var name = (string)element.Attribute("Name"); await Out.WriteLineFormattedAsync("Importing DataType '{0}'", name); packagingService.ImportDataTypeDefinitions(new XElement("DataTypes", element)); var preValues = element.Element("PreValues"); if (preValues != null) { var pv = preValues.Elements("PreValue"); var dataType = dataTypeService.GetDataTypeDefinitionById(Guid.Parse(element.Attribute("Definition").Value)); dataTypeService.SavePreValues( dataType, pv.Select(xml => new { Alias = xml.Attribute("Alias").Value, xml.Attribute("Value").Value }) .ToDictionary(x => x.Alias, x => new PreValue(x.Value)) ); } } }
private async Task UnpackDataTypes(IEnumerable <XElement> elements) { foreach (var element in elements) { var name = (string)element.Attribute("Name"); await Out.WriteLineFormattedAsync("Importing DataType '{0}'", name); packagingService.ImportDataTypeDefinitions(new XElement("DataTypes", element)); } }
private IEnumerable <IDataType> InstallDataTypes(XElement dataTypeElements, int userId = 0) { if (string.Equals(Constants.Packaging.DataTypesNodeName, dataTypeElements.Name.LocalName) == false) { if (string.Equals(Constants.Packaging.DataTypeNodeName, dataTypeElements.Name.LocalName) == false) { throw new ArgumentException("Must be \"" + Constants.Packaging.DataTypeNodeName + "\" as root", "dataTypeElements"); } } return(_packagingService.ImportDataTypeDefinitions(dataTypeElements, userId)); }
public IEnumerable <IDataTypeDefinition> ImportDataTypeDefinitions(XElement element, int userId = 0, bool raiseEvents = true) { return(realPackagingService.ImportDataTypeDefinitions(element, userId, raiseEvents)); }