/// <summary> /// Update Derived Attribute Values in this SKU /// </summary> /// <param name="sku"></param> /// <param name="derivedAttributes"></param> /// <param name="dc"></param> private void ProcessSku(Sku sku, IEnumerable <Attribute> derivedAttributes, AryaDbDataContext dc) { var derivedValues = sku.DerivedEntityDatas.Where(ded => ded.Active).ToDictionary(d => d.AttributeID, d => d); foreach (var att in derivedAttributes) { var value = sku.GetValuesForAttribute(dc, att, false).First().Value; if (derivedValues.ContainsKey(att.ID)) { if (derivedValues[att.ID].Value == value) { continue; //No change to the value, nothing to do here... } //Deactivate this value; we'll insert a new value later derivedValues[att.ID].Active = false; } if (string.IsNullOrWhiteSpace(value)) { continue; } sku.DerivedEntityDatas.Add(new DerivedEntityData(dc) { Attribute = att, Value = value }); ++_iValueCount; } ++_iSkuCount; }
private IEnumerable <EntityData> GetParentAttributeValues(SchemaInfo si, Sku sku) { var smi = si.SchemaMetaInfos.FirstOrDefault( a => a.Attribute.AttributeName == "Dependent Attribute" && a.Attribute.AttributeType == AttributeTypeEnum.SchemaMeta.ToString()); if (smi == null) // Dependent Meta Attirbute has not been defined { return(null); } var smd = smi.SchemaMetaDatas.SingleOrDefault(a => a.Active); if (smd == null) // No active Metavalues for Depedendent Attributes { return(null); } var parentAttributeName = smd.Value.ToLower().Trim(); return(String.IsNullOrEmpty(parentAttributeName) ? null : sku.GetValuesForAttribute(_db, parentAttributeName)); }
public AssetInfo GetAsset(Sku sku, string assetAttributeName, string assetUrl, string assetType) { if (sku == null) { return(null); } string image = sku.GetValuesForAttribute(assetAttributeName).Select(ed => ed.Value).FirstOrDefault() ?? string.Empty; if (string.IsNullOrEmpty(image)) { return(null); } string directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Arya"; string file = AryaTools.Instance.InstanceData.CurrentProject.ID + "_" + assetType + "_" + RemoveSpecialCharacters(image); //string optionalExtension = RxOptionalExtension.Matches(assetUrl)[0].Groups[1].Value; //if (!string.IsNullOrWhiteSpace(optionalExtension)) //{ // imageAttributeName = Path.ChangeExtension(imageAttributeName, optionalExtension); //} var imageFullFilename = directory + "\\" + file; if (File.Exists(imageFullFilename)) { return(new AssetInfo(image, imageFullFilename, assetType)); } if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var hourGlassFileName = directory + "\\hourglass.png"; string url = RxImageUrl.Replace(assetUrl, image); if (downloadingFiles.ContainsKey(url)) { return(new AssetInfo(image, hourGlassFileName, assetType)); } if (!downloadingFiles.ContainsKey(url)) { downloadingFiles.TryAdd(url, imageFullFilename); System.Threading.Tasks.Task.Factory.StartNew(() => DownloadWorkerMethod(url, imageFullFilename)); } return(new AssetInfo(image, hourGlassFileName, assetType)); }
private bool ToleranceMatch(Sku nodeSku, Sku checkSku, string attributeName, string rawTolerence, bool isOptional) { var baseUnitConversion = new BaseUnitConversion(CurrentDb); var nodeSkuEds = nodeSku.GetValuesForAttribute(CurrentDb, attributeName).ToList(); var checkSkuEds = checkSku.GetValuesForAttribute(CurrentDb, attributeName).ToList(); if ((!nodeSkuEds.Any() || !checkSkuEds.Any()) && isOptional) { return(true); } if (rawTolerence.Equals("=")) { var nodeSkuValues = nodeSkuEds.Select(v => v.Value.ToLower()).ToArray(); var checkSkuValues = checkSkuEds.Select(v => v.Value.ToLower()).ToArray(); return(nodeSkuValues.Intersect(checkSkuValues).Any()); } if (rawTolerence.Contains('=')) { var nodeSkuValues = nodeSkuEds.Select(v => v.Value.ToLower()).ToArray(); var checkSkuValues = checkSkuEds.Select(v => v.Value.ToLower()).ToArray(); return(IsLovTolerant(rawTolerence, nodeSkuValues, checkSkuValues)); } if (rawTolerence.StartsWith("+") || rawTolerence.StartsWith("-") || rawTolerence.StartsWith("~") || rawTolerence.StartsWith("0")) { var nodeSkuNumericValues = nodeSkuEds.Select(v => baseUnitConversion.GetBaseValue(v.Value, v.Uom)).ToList(); var checkSkuNumericValues = checkSkuEds.Select(v => baseUnitConversion.GetBaseValue(v.Value, v.Uom)).ToList(); if (nodeSkuNumericValues.Contains(int.MaxValue)) { nodeSkuNumericValues.Remove(int.MaxValue); } if (checkSkuNumericValues.Contains(int.MaxValue)) { checkSkuNumericValues.Remove(int.MaxValue); } return(nodeSkuNumericValues.Any(val => baseUnitConversion.IsTolerated(checkSkuNumericValues, val, rawTolerence))); } if (!string.IsNullOrEmpty(rawTolerence)) { var nodeSkuValues = nodeSkuEds.Select(v => v.Value.ToLower()).ToArray(); var checkSkuValues = checkSkuEds.Select(v => v.Value.ToLower()).ToArray(); return(nodeSkuValues.Contains(rawTolerence) & checkSkuValues.Contains(rawTolerence)); } return(false); }
private void ProcessAttributes(Sku sku, TaxonomyInfo taxonomy, string nodeType, string taxonomyString, IEnumerable <Tuple <Attribute, decimal, decimal> > attributeOrders) { // add static information to output lists var valueElements = new List <string>(); valueElements.Add(sku.ItemID); valueElements.Add(taxonomyString); valueElements.Add(nodeType); var blankElements = new List <string>(); if (_args.GenerateFileWithBlankValues) { blankElements.Add(sku.ItemID); blankElements.Add(taxonomyString); blankElements.Add(nodeType); } // add global attributes for (int i = 0; i < _globalAttributeNames.Count(); i++) { // get list of sub-attributes in this attribute, then collect their values var parts = _globalAttributeNames[i].Split(new[] { ',' }); var values = new List <EntityData>(); foreach (var att in parts) { values.AddRange(sku.GetValuesForAttribute(CurrentDb, att.Trim())); } if (_globalAttributeCount[i] == 0) { // if there's no specified number of columns for this attribute, string the values together var stringValue = values.Select(val => (val.Value + (_args.IncludeUoM ? " " + val.Uom : "")) .Trim()) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Aggregate(string.Empty, (current, val) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ",") + val)); valueElements.Add(stringValue); if (_args.GenerateFileWithBlankValues) { blankElements.Add(stringValue); } } else { // if there are multiple columns for this attribute, assign the values separately, limited by the count of collumns var listStringValue = values.Select(val => (val.Value + (_args.IncludeUoM ? " " + val.Uom : "")) .Trim()) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Take(_globalAttributeCount[i]) .ToList(); for (int j = 0; j < _globalAttributeCount[i]; j++) { if (j < listStringValue.Count) { valueElements.Add(listStringValue[j]); if (_args.GenerateFileWithBlankValues) { blankElements.Add(listStringValue[j]); } } else { valueElements.Add(""); if (_args.GenerateFileWithBlankValues) { blankElements.Add(""); } } } } } // collect data for each attribute bool writeBlankRow = false; foreach (var att in attributeOrders) { //Attribute,NavOrder,DisplayOrder var attributeOrder = att; var navOrder = att.Item2; var dispOrder = att.Item3; if (((_args.ExportNavigationAttributes && navOrder > 0) || (_args.ExportDisplayAttributes && dispOrder > 0) || (_args.ExportUnRankedAttributes && navOrder == 0 && dispOrder == 0))) { var entity = sku.GetValuesForAttribute(CurrentDb, attributeOrder.Item1.AttributeName); // concatenate the values into a comma-delimited string var value = entity.Aggregate(string.Empty, (current, ed) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + ed.Value); //display the uom once if there is one distinct uom, otherwise, output in the same order as the value (optional) string uom = String.Empty; if (_args.IncludeUoM) { var distinctUoms = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Uom)) .Select(ed => ed.Uom) .Distinct() .ToList(); uom = distinctUoms.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 1 into a comma-delimited string string field1 = String.Empty; if (_args.IncludeField1) { var distinctField1 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field1)) .Select(ed => ed.Field1) .Distinct() .ToList(); field1 = distinctField1.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 2 into a comma-delimited string string field2 = String.Empty; if (_args.IncludeField2) { var distinctField2 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field2)) .Select(ed => ed.Field2) .Distinct() .ToList(); field2 = distinctField2.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 3 into a comma-delimited string string field3 = String.Empty; if (_args.IncludeField3) { var distinctField3 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field3)) .Select(ed => ed.Field3) .Distinct() .ToList(); field3 = distinctField3.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 4 into a comma-delimited string string field4 = String.Empty; if (_args.IncludeField4) { var distinctField4 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field4)) .Select(ed => ed.Field4) .Distinct() .ToList(); field4 = distinctField4.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 5 into a comma-delimited string string field5 = String.Empty; if (_args.IncludeField5) { var distinctField5 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field5OrStatus)) .Select(ed => ed.Field5OrStatus) .Distinct() .ToList(); field5 = distinctField5.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // optionally, get the navigation data var rank = string.Empty; if (navOrder > 0 || dispOrder > 0) { if (_args.ExportNavigationAttributes) { rank = _args.ExportSuperSchema && taxonomy.IsLeafNode ? "S" : Decimal.Truncate(navOrder).ToString(CultureInfo.InvariantCulture); } if (_args.ExportDisplayAttributes) { if (_args.ExportNavigationAttributes) { rank += " • "; } rank += Decimal.Truncate(dispOrder).ToString(CultureInfo.InvariantCulture); } } // add attribute data to output list // append navigation data if (_args.ExportRanks) { valueElements.Add(rank); } // append attribute name valueElements.Add(attributeOrder.Item1.AttributeName); if (_args.ExportNewValueColumn) { valueElements.Add(""); } // append value data valueElements.Add(value); // append UoM data if (_args.IncludeUoM) { valueElements.Add(uom); } // append field 1 data if (_args.IncludeField1) { valueElements.Add(field1); } // append field 2 data if (_args.IncludeField2) { valueElements.Add(field2); } // append field 3 data if (_args.IncludeField3) { valueElements.Add(field3); } // append field 4 data if (_args.IncludeField4) { valueElements.Add(field4); } // append field 5 data if (_args.IncludeField5) { valueElements.Add(field5); } if (_args.GenerateFileWithBlankValues && string.IsNullOrWhiteSpace(value)) { // signal that there are blank values to be written writeBlankRow = true; // append navigation data if (_args.ExportRanks) { blankElements.Add(rank); } // append attribute name blankElements.Add(attributeOrder.Item1.AttributeName); if (_args.ExportNewValueColumn) { blankElements.Add(""); } // append value data - should be blank blankElements.Add(""); // append UoM data if (_args.IncludeUoM) { blankElements.Add(uom); } // append field 1 data if (_args.IncludeField1) { blankElements.Add(field1); } // append field 2 data if (_args.IncludeField2) { blankElements.Add(field2); } // append field 3 data if (_args.IncludeField3) { blankElements.Add(field3); } // append field 4 data if (_args.IncludeField4) { blankElements.Add(field4); } // append field 5 data if (_args.IncludeField5) { blankElements.Add(field5); } } } } _attributeTable.WriteDataRow(valueElements); if (_args.GenerateFileWithBlankValues && writeBlankRow) { _blankAttributeTable.WriteDataRow(blankElements); } }
private void ExtractAggregate(Sku sku, string attributeName, Stack <EntityDataGridView.ChangeItem> undoHistory, Guid changeId) { var values = sku.GetValuesForAttribute(attributeName); if (values.Count == 0) { return; } EntityData entityData = null; var newValue = string.Empty; var newAttributeNamePrefix = string.Empty; switch (RunTool) { case Tool.ExtractMinimumValue: newAttributeNamePrefix = "Minimum "; entityData = values.OrderBy(val => val.Value, new CompareForAlphaNumericSort()).First(); break; case Tool.ExtractMaximumValue: newAttributeNamePrefix = "Maximum "; entityData = values.OrderByDescending(val => val.Value, new CompareForAlphaNumericSort()).First(); break; case Tool.ExtractCountOfValues: newAttributeNamePrefix = "No of "; newValue = values.Count.ToString(); break; } var newAttribute = Attribute.GetAttributeFromName(string.Format("{0}{1}", newAttributeNamePrefix, attributeName), true); NewAttributeNames.Add(newAttribute.AttributeName); EntityData newEntityData; if (entityData != null) { newEntityData = new EntityData { Attribute = newAttribute, Value = entityData.Value, Uom = entityData.Uom, Field1 = entityData.Field1, Field2 = entityData.Field2, Field3 = entityData.Field3 //Field4 = BaseUnitConvertion.GetBaseUnitValueAsString(entityData.Value, entityData.Uom) } } ; else { newEntityData = new EntityData { Attribute = newAttribute, Value = newValue } }; var currentValue = sku.GetValuesForAttribute(newAttribute.AttributeName).FirstOrDefault(); if (currentValue != null) { currentValue.EntityInfo.EntityDatas.Add(newEntityData); currentValue.Active = false; } else { sku.EntityInfos.Add(new EntityInfo { EntityDatas = { newEntityData } }); } LastEntityDataCreated = newEntityData; if (!AryaTools.Instance.InstanceData.Dc.SkuAttributeValueCache.ContainsKey(newAttribute)) { AryaTools.Instance.InstanceData.Dc.SkuAttributeValueCache.Add(newAttribute, sku, new List <EntityData>()); } if (AryaTools.Instance.InstanceData.Dc.SkuAttributeValueCache.ContainsKeys(newAttribute, sku)) { AryaTools.Instance.InstanceData.Dc.SkuAttributeValueCache[newAttribute].Remove(sku); } // Add this to change history for Undo if (undoHistory != null) { undoHistory.Push(new EntityDataGridView.ChangeItem(currentValue ?? null, newEntityData, changeId)); } }
private void ProcessAttributes(Sku sku, string nodeType, string taxonomyString, IEnumerable <KeyValuePair <Attribute, SchemaData> > attributeOrders) { // add static information to output lists var valueElements = new List <string> { sku.ItemID, taxonomyString, nodeType }; // add global attributes for (int i = 0; i < _globalAttributeNames.Count(); i++) { // get list of sub-attributes in this attribute, then collect their values var parts = _globalAttributeNames[i].Split(new[] { ',' }); var values = new List <EntityData>(); foreach (var att in parts) { values.AddRange(sku.GetValuesForAttribute(CurrentDb, att.Trim())); } if (_globalAttributeCount[i] == 0) { // if there's no specified number of columns for this attribute, string the values together var stringValue = values.Select(val => val.Value) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Aggregate(string.Empty, (current, val) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ",") + val)); valueElements.Add(stringValue); } else { // if there are multiple columns for this attribute, assign the values separately, limited by the count of collumns var listStringValue = values.Select(val => val.Value) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Take(_globalAttributeCount[i]) .ToList(); for (int j = 0; j < _globalAttributeCount[i]; j++) { valueElements.Add(j < listStringValue.Count ? listStringValue[j] : ""); } } } // collect data for each attribute bool invalidValuesFound = false; foreach (var att in attributeOrders) { Attribute attribute = att.Key; SchemaData schemaData = att.Value; var entity = sku.GetValuesForAttribute(CurrentDb, attribute.AttributeName); var validator = new Validate(CurrentDb); IEnumerable <EntityData> invalidEntities = null; if (attribute.AttributeType != AttributeTypeEnum.Derived.ToString()) { invalidEntities = entity.Where(e => !validator.IsValidDataType(e, schemaData)); } if (invalidEntities == null || !invalidEntities.Any()) { continue; } invalidValuesFound = true; var value = entity.Aggregate(string.Empty, (current, ed) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ", ") + ed.Value)); //display the uom once if there is one distinct uom, otherwise, output in the same order as the value var distinctUoms = entity.Where(ed => ed.Uom != null).Select(ed => ed.Uom).Distinct().ToList(); string uom; switch (distinctUoms.Count) { case 0: { uom = string.Empty; break; } case 1: { uom = distinctUoms.First(); break; } default: { uom = entity.Aggregate(string.Empty, (current, u) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ", ") + u.Uom)); break; } } var rank = Decimal.Truncate(schemaData.NavigationOrder) + " • " + Decimal.Truncate(schemaData.DisplayOrder); // add attribute data to output list // append navigation data valueElements.Add(rank); // append attribute name valueElements.Add(attribute.AttributeName); // append value data valueElements.Add(value); // append UoM data valueElements.Add(uom); } if (invalidValuesFound) { _attributeTable.WriteDataRow(valueElements); } }
private void WriteAttributeDataToFile(Sku sku, string nodeType, IEnumerable <KeyValuePair <Attribute, SchemaData> > attributeOrders) { var itemHeader = string.Format("{1}{0}{2}{0}{3}", delimiter, sku.ItemID, sku.Taxonomy, nodeType); var itemGlobals = string.Empty; var itemAttributeValues = string.Empty; for (var iCtr = 0; iCtr < globalAttributeNames.Count(); iCtr++) { var headerCount = globalAttributeHeaders[iCtr].Split(':').Count() > 1 ? globalAttributeHeaders[iCtr].Split(':')[1].Trim() : string.Empty; int noOfHeaders; Int32.TryParse(headerCount, out noOfHeaders); var globalDelimiter = noOfHeaders == 0 ? ", " : "\t"; var parts = globalAttributeNames[iCtr].Split(new[] { ',' }); var values = new List <EntityData>(); foreach (var att in parts) { values.AddRange(sku.GetValuesForAttribute(att.Trim())); } var stringValue = values.Select(val => val.Value) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Aggregate(string.Empty, (current, val) => current + ((string.IsNullOrEmpty(current) ? string.Empty : globalDelimiter) + val)); if (noOfHeaders > 0) { var valuesWritten = new string[noOfHeaders]; var valuespresent = stringValue.Split(new[] { globalDelimiter }, StringSplitOptions.None); for (var i = 0; i < noOfHeaders; i++) { if (i < valuespresent.Count()) { valuesWritten[i] = valuespresent[i]; } else { valuesWritten[i] = string.Empty; } } stringValue = string.Join("\t", valuesWritten); } itemGlobals += delimiter + stringValue; } foreach (var att in attributeOrders) { var attribute = att.Key; var schemaData = att.Value; IEnumerable <EntityData> invalidEntities = null; var entity = sku.GetValuesForAttribute(attribute.AttributeName); if (attribute.AttributeType != "Derived") { invalidEntities = entity.Where(e => !Validate.IsValidDataType(e, schemaData)); } if (invalidEntities == null || !invalidEntities.Any()) { continue; } //if (!invalidEntities.Any()) // continue; //if (!invalidEntities.Any()) // continue; var value = entity.Aggregate(string.Empty, (current, ed) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ", ") + ed.Value)); //display the uom once if there is one distinct uom, otherwise, output in the same order as the value var distinctUoms = entity.Where(ed => ed.Uom != null).Select(ed => ed.Uom).Distinct().ToList(); string uom; switch (distinctUoms.Count) { case 0: uom = string.Empty; break; case 1: uom = distinctUoms.First(); break; default: uom = entity.Aggregate(string.Empty, (current, u) => current + ((string.IsNullOrEmpty(current) ? string.Empty : ", ") + u.Uom)); break; } var rank = Decimal.Truncate(schemaData.NavigationOrder) + " • " + Decimal.Truncate(schemaData.DisplayOrder); itemAttributeValues += string.Format("{0}{1}{0}{2}{0}{3}{0}{4}", delimiter, rank, attribute.AttributeName, value, uom); } if (!string.IsNullOrEmpty(itemAttributeValues)) { attributeDataFile.WriteLine(itemHeader + itemGlobals + itemAttributeValues); } }
private void WriteAttributeDataToFile(Sku sku, TaxonomyInfo taxonomy, string nodeType, string taxonomyString, IEnumerable <Tuple <Attribute, decimal, decimal> > attributeOrders) { var itemHeader = string.Format("{1}{0}{2}{0}{3}", _delimiter, sku.ItemID, taxonomyString, nodeType); var itemGlobals = string.Empty; var itemAttributeValues = string.Empty; var itemAttributeBlanks = string.Empty; for (var iCtr = 0; iCtr < _globalAttributeNames.Count(); iCtr++) { var headerCount = _globalAttributeHeaders[iCtr].Split(':').Count() > 1 ? _globalAttributeHeaders[iCtr].Split(':')[1].Trim() : string.Empty; int noOfHeaders; Int32.TryParse(headerCount, out noOfHeaders); var globalDelimiter = noOfHeaders == 0 ? ", " : "\t"; var parts = _globalAttributeNames[iCtr].Split(new[] { ',' }); var values = new List <EntityData>(); foreach (var att in parts) { values.AddRange(sku.GetValuesForAttribute(att.Trim())); } //TODO: do global UoMs need to be made optional? var stringValue = values.Select(val => (val.Value + " " + val.Uom).Trim()) .Distinct() .OrderBy(val => val, new CompareForAlphaNumericSort()) .Aggregate(string.Empty, (current, val) => current + ((string.IsNullOrEmpty(current) ? string.Empty : globalDelimiter) + val)); if (noOfHeaders > 0) { var valuesWritten = new string[noOfHeaders]; var valuespresent = stringValue.Split(new[] { globalDelimiter }, StringSplitOptions.None); for (var i = 0; i < noOfHeaders; i++) { if (i < valuespresent.Count()) { valuesWritten[i] = valuespresent[i]; } else { valuesWritten[i] = string.Empty; } } stringValue = string.Join("\t", valuesWritten); } itemGlobals += _delimiter + stringValue; } foreach (var att in attributeOrders) { //Attribute,NavOrder,DisplayOrder var attributeOrder = att; var navOrder = att.Item2; var dispOrder = att.Item3; if (((ExportNavigationAttributes && navOrder > 0) || (ExportDisplayAttributes && dispOrder > 0) || (ExportUnRankedAttributes && navOrder == 0 && dispOrder == 0))) { //CuttingTools project wide exception from Rebecca, to sort attributes with (Wire) suffix in descending. var ctSortExcp = taxonomy.Project.ProjectName == "CuttingTools" && attributeOrder.Item1.AttributeName.Contains("(Wire)"); // get the collection of values (in entity data objects) associated with this attribute/sku combination var entity = ctSortExcp ? sku.GetValuesForAttribute(attributeOrder.Item1.AttributeName, true, true) : sku.GetValuesForAttribute(attributeOrder.Item1.AttributeName); //if (!ValueFilterValid(entity, parsedSkuValueInclusions)) // continue; // concatenate the values into a comma-delimited string var value = entity.Aggregate(string.Empty, (current, ed) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + ed.Value); //display the uom once if there is one distinct uom, otherwise, output in the same order as the value (optional) var uom = String.Empty; if (IncludeUoM) { var distinctUoms = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Uom)) .Select(ed => ed.Uom) .Distinct() .ToList(); uom = distinctUoms.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 1 into a comma-delimited string var field1 = String.Empty; if (IncludeField1) { var distinctField1 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field1)) .Select(ed => ed.Field1) .Distinct() .ToList(); field1 = distinctField1.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 2 into a comma-delimited string var field2 = String.Empty; if (IncludeField2) { var distinctField2 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field2)) .Select(ed => ed.Field2) .Distinct() .ToList(); field2 = distinctField2.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 3 into a comma-delimited string var field3 = String.Empty; if (IncludeField3) { var distinctField3 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field3)) .Select(ed => ed.Field3) .Distinct() .ToList(); field3 = distinctField3.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 4 into a comma-delimited string var field4 = String.Empty; if (IncludeField4) { var distinctField4 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field4)) .Select(ed => ed.Field4) .Distinct() .ToList(); field4 = distinctField4.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // concatenate field 5 into a comma-delimited string var field5 = String.Empty; if (IncludeField5) { var distinctField5 = entity.Where(ed => !string.IsNullOrWhiteSpace(ed.Field5OrStatus)) .Select(ed => ed.Field5OrStatus) .Distinct() .ToList(); field5 = distinctField5.Aggregate(String.Empty, (current, next) => current + (string.IsNullOrEmpty(current) ? string.Empty : ", ") + next); } // optionally, get the navigation data var rank = string.Empty; if (navOrder > 0 || dispOrder > 0) { if (ExportNavigationAttributes) { rank = ExportSuperSchema && taxonomy.IsLeafNode ? "S" : Decimal.Truncate(navOrder).ToString(); } if (ExportDisplayAttributes) { if (ExportNavigationAttributes) { rank += " • "; } rank += Decimal.Truncate(dispOrder).ToString(); } } // append navigation data if (ExportRanks) { itemAttributeValues += string.Format("{0}{1}", _delimiter, rank); } // append attribute name itemAttributeValues += string.Format("{0}{1}", _delimiter, attributeOrder.Item1.AttributeName); if (ExportNewValueColumn) { itemAttributeValues += _delimiter; } // append value data itemAttributeValues += string.Format("{0}{1}", _delimiter, value); // append UoM data if (IncludeUoM) { itemAttributeValues += string.Format("{0}{1}", _delimiter, uom); } // append field 1 data if (IncludeField1) { itemAttributeValues += string.Format("{0}{1}", _delimiter, field1); } // append field 2 data if (IncludeField2) { itemAttributeValues += string.Format("{0}{1}", _delimiter, field2); } // append field 3 data if (IncludeField3) { itemAttributeValues += string.Format("{0}{1}", _delimiter, field3); } // append field 4 data if (IncludeField4) { itemAttributeValues += string.Format("{0}{1}", _delimiter, field4); } // append field 5 data if (IncludeField5) { itemAttributeValues += string.Format("{0}{1}", _delimiter, field5); } if (GenerateFileWithBlankValues && string.IsNullOrWhiteSpace(value)) { itemAttributeBlanks += string.Format("{0}{1}{0}{2}{0}{3}", _delimiter, rank, attributeOrder.Item1.AttributeName, value); if (IncludeUoM) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, uom); } if (IncludeField1) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, field1); } if (IncludeField2) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, field2); } if (IncludeField3) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, field3); } if (IncludeField4) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, field4); } if (IncludeField5) { itemAttributeBlanks += string.Format("{0}{1}", _delimiter, field5); } } } } _attributeDataFile.WriteLine(itemHeader + itemGlobals + itemAttributeValues); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.WriteLine(itemHeader + itemGlobals + itemAttributeBlanks); } }