/// <summary> /// The WordPressClient holds all connection infos and provides methods to call WordPress APIs. /// </summary> /// <param name="uri">URI for WordPress API endpoint, e.g. "http://demo.wp-api.org/wp-json/"</param> public WordPressClient(string uri) { if (string.IsNullOrWhiteSpace(uri)) { throw new ArgumentNullException(nameof(uri)); } if (!uri.EndsWith("/")) { uri += "/"; } _wordPressUri = uri; _httpHelper = new HttpHelper(WordPressUri); Posts = new Posts(ref _httpHelper, defaultPath); Comments = new Comments(ref _httpHelper, defaultPath); Tags = new Tags(ref _httpHelper, defaultPath); Users = new Users(ref _httpHelper, defaultPath); Media = new Media(ref _httpHelper, defaultPath); Categories = new Categories(ref _httpHelper, defaultPath); Pages = new Pages(ref _httpHelper, defaultPath); Taxonomies = new Taxonomies(ref _httpHelper, defaultPath); PostTypes = new PostTypes(ref _httpHelper, defaultPath); PostStatuses = new PostStatuses(ref _httpHelper, defaultPath); CustomRequest = new CustomRequest(ref _httpHelper); }
/// <summary> /// The WordPressClient holds all connection infos and provides methods to call WordPress APIs. /// </summary> /// <param name="httpClient">HttpClient with BaseAddress set which will be used for sending requests to the WordPress API endpoint.</param> /// <param name="defaultPath">Relative path to standard API endpoints, defaults to "wp/v2/"</param> public WordPressClient(HttpClient httpClient, string defaultPath = DEFAULT_PATH) { if (httpClient == null) { throw new ArgumentNullException(nameof(httpClient)); } string uri = httpClient.BaseAddress.ToString(); if (!uri.EndsWith("/", StringComparison.Ordinal)) { uri += "/"; } WordPressUri = uri; _defaultPath = defaultPath; _httpHelper = new HttpHelper(httpClient); Posts = new Posts(ref _httpHelper, _defaultPath); Comments = new Comments(ref _httpHelper, _defaultPath); Tags = new Tags(ref _httpHelper, _defaultPath); Users = new Users(ref _httpHelper, _defaultPath); Media = new Media(ref _httpHelper, _defaultPath); Categories = new Categories(ref _httpHelper, _defaultPath); Pages = new Pages(ref _httpHelper, _defaultPath); Taxonomies = new Taxonomies(ref _httpHelper, _defaultPath); PostTypes = new PostTypes(ref _httpHelper, _defaultPath); PostStatuses = new PostStatuses(ref _httpHelper, _defaultPath); CustomRequest = new CustomRequest(ref _httpHelper); }
public override void Run() { State = WorkerState.Working; StatusMessage = "Init"; StatusMessage = "Generating Child node list ... "; var selectedTaxonomy = Taxonomies[0].Taxonomy; MaximumProgress = Taxonomies.Cast <ExtendedTaxonomyInfo>().SelectMany(p => p.Taxonomy.AllLeafChildren).Distinct().Count(); CurrentProgress = 0; var selectedNode = new NatalieTaxonomy { NodeName = selectedTaxonomy.NodeName }; var topNode = GetTopNode(selectedNode, selectedTaxonomy); ExportTaxonomyNode(selectedNode, selectedTaxonomy); var project = new NatalieProject { ProjectName = selectedTaxonomy.Project.ProjectName, Taxonomy = new[] { topNode } }; var serializer = new XmlSerializer(typeof(NatalieProject)); using (TextWriter file = new StreamWriter(ExportFileName)) serializer.Serialize(file, project); StatusMessage = "Done."; State = WorkerState.Ready; }
public override void Run() { State = WorkerState.Working; StatusMessage = "Init"; fieldDelimiter = FieldDelimiter.GetValue().ToString(); var fi = new FileInfo(ExportFileName); var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); avfrFile = new StreamWriter(baseFileName + "_AVFR.txt", false, Encoding.UTF8); StatusMessage = "Generating Child node list ... "; var allChildren = Taxonomies.Cast <ExtendedTaxonomyInfo>().SelectMany(p => p.Taxonomy.AllLeafChildren).Distinct().ToList(); CurrentProgress = 0; MaximumProgress = allChildren.Count; avfrFile.WriteLine( "T1{0}T2{0}T3{0}T4{0}T5{0}T6{0}T7{0}AttributeName{0}Value{0}NodeSkuCount{0}ValueSkuCount{0}AttributeSkuCount{0}NavigationOrder{0}DisplayOrder{0}Attribute FillRate{0}Value FillRate", fieldDelimiter); foreach (var taxonomyInfo in allChildren) { WriteAVFRData(taxonomyInfo); CurrentProgress++; } avfrFile.Close(); avfrFile.Dispose(); StatusMessage = "Done."; State = WorkerState.Ready; }
public void CloseTaxonomy(TaxonomyItem taxonomyItem) { if (taxonomyItem.Taxonomy.IsValueCreated) { var taxonomy = taxonomyItem.Taxonomy.Value; Taxonomies.Remove(taxonomyItem); taxonomy.Dispose(); } }
public override void Run() { State = WorkerState.Working; _parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions); _parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions); _delimiter = FieldDelimiter.GetValue().ToString(); _currentDb = new SkuDataDbDataContext(); var dlo = new DataLoadOptions(); dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas); dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas); dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas); dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active)); dlo.AssociateWith <EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active || p.BeforeEntity)); dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active)); dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active)); _currentDb.LoadOptions = dlo; _currentDb.CommandTimeout = 2000; _currentDb.Connection.Open(); _currentDb.Connection.ChangeDatabase(AryaTools.Instance.InstanceData.Dc.Connection.Database); var fi = new FileInfo(ExportFileName); var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); _attributeFile = new StreamWriter(baseFileName + "_attributes.txt", false, Encoding.UTF8); _valueFile = new StreamWriter(baseFileName + "_values.txt", false, Encoding.UTF8); _skuFile = new StreamWriter(baseFileName + "_skus.txt", false, Encoding.UTF8); StatusMessage = "Init"; var allExportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = _currentDb.TaxonomyInfos.Where(p => allExportTaxonomyIds.Contains(p.ID)).ToList(); var allChildren = exportTaxonomies.SelectMany(p => p.AllChildren).Distinct().ToList(); var allLeafChildren = exportTaxonomies.SelectMany(p => p.AllLeafChildren).Distinct().ToList(); var maxDepth = 0; if (allChildren.Count == 0 && allLeafChildren.Count != 0) { maxDepth = allLeafChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } else if (allLeafChildren.Count == 0 && allChildren.Count != 0) { maxDepth = allChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } else if (allLeafChildren.Count != 0 && allChildren.Count != 0) { if (allLeafChildren.Count >= allChildren.Count) { maxDepth = allLeafChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length).Max(); } else { maxDepth = allChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length).Max(); } } else { StatusMessage = "There was no data to export."; MaximumProgress = 1; CurrentProgress = 1; State = WorkerState.Ready; } if (IgnoreT1Taxonomy) { maxDepth--; } for (var i = 1; i <= maxDepth; i++) { _attributeFile.Write("T" + i + "\t"); _valueFile.Write("T" + i + "\t"); _skuFile.Write("T" + i + "\t"); } _attributeFile.WriteLine( "Attribute{0}Node Sku Count{0}Attr. Sku Count{0}Fill Rate{0}Navigation Order{0}Display Order{0}Global", _delimiter); _valueFile.WriteLine( "Attribute{0}Value{0}Uom{0}Node Sku Count{0}Attr. Value Sku Count{0}Value Fill Rate{0}Attr. Fill Rate{0}Navigation Order{0}Display Order{0}Global", _delimiter); _skuFile.WriteLine( "Item Id{0}Node Attr. Count{0}Node Nav. Attr. Count{0}Node Disp. Attr. Count{0}Sku Attr. Count{0}Sku Nav. Attr. Count{0}Sku Disp. Attr. Count{0}Sku Attr. Fill Rate{0}Sku Nav. Attr. Fill Rate{0}Node Disp. Attr. Fill Rate", _delimiter); CurrentProgress = 0; if (allChildren.Count >= allLeafChildren.Count) { MaximumProgress = allChildren.Count; foreach (var child in allChildren) { WriteMetricsToFile(child, maxDepth); CurrentProgress++; } } else if (allChildren.Count < allLeafChildren.Count) { MaximumProgress = allLeafChildren.Count; foreach (var child in allLeafChildren) { WriteMetricsToFile(child, maxDepth); CurrentProgress++; } } _attributeFile.Close(); _valueFile.Close(); _skuFile.Close(); StatusMessage = "Done!"; State = WorkerState.Ready; }
public AttributeColumn(Attribute attribute, IEnumerable <TaxonomyInfo> taxonomies, IQueryable <EntityInfo> entities) { Entities = entities; Attribute = attribute; Taxonomies.AddRange(taxonomies); }
public void OpenTaxonomy(string path) { var taxonomyItem = new TaxonomyItem(path, p => new Taxonomy(p)); Taxonomies.Add(taxonomyItem); }
public void CreateNewTaxonomy(string path, string shortName) { var taxonomyItem = new TaxonomyItem(path, p => Taxonomy.CreateNew(p, shortName)); Taxonomies.Add(taxonomyItem); }
public IEnumerator <TaxonomyGroupModel> GetEnumerator() => Taxonomies.GetEnumerator();
public override void Run() { State = WorkerState.Working; _parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions); _parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions); _delimiter = FieldDelimiter.GetDbValue().ToString(); //Create new context _currentDb = new NatalieDbDataContext(); var dlo = new DataLoadOptions(); dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas); dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas); dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active)); dlo.AssociateWith <EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active)); dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active)); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active)); _currentDb.LoadOptions = dlo; _currentDb.CommandTimeout = 2000; _currentDb.Connection.Open(); _currentDb.Connection.ChangeDatabase(NatalieTools.Instance.InstanceData.Dc.Connection.Database); _separator = NatalieTools.Instance.InstanceData.CurrentProject.ListSeparator; StatusMessage = "Init"; var fi = new FileInfo(ExportFileName); _baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); //_taxonomyFile = new StreamWriter(_baseFileName + "_Classification.txt", false, Encoding.UTF8); //_taxonomyFile.WriteLine("ItemId{0}New Taxonomy{0}Node Type{0}Old Taxonomy", _delimiter); var exportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = _currentDb.TaxonomyInfos.Where(p => exportTaxonomyIds.Contains(p.ID)).ToList(); var allExportTaxonomies = exportTaxonomies.SelectMany(p => p.AllChildren2).Union(exportTaxonomies).Distinct().ToList(); var exportGroups = allExportTaxonomies.GroupBy(GetTaxPrefix).ToList(); CurrentProgress = 0; MaximumProgress = exportGroups.Count(); foreach (var grp in exportGroups) { WriteTaxonomyToFile(grp.Select(g => g), grp.Key); CurrentProgress++; } //_taxonomyFile.Close(); StatusMessage = "Done!"; State = WorkerState.Ready; }
public override void Run() { State = WorkerState.Working; parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions); parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions); //parsedSkuValueInclusions = ParseSkuValueInclusions(SkuValueInclusions); taxonomyAttributesCache = new Dictionary <Guid, List <KeyValuePair <Attribute, SchemaData> > >(); baseAttributeNames = new Dictionary <string, string>(); delimiter = FieldDelimiter.GetValue().ToString(); //Create new context currentDb = new SkuDataDbDataContext(); var dlo = new DataLoadOptions(); projectField1Name = AryaTools.Instance.InstanceData.CurrentProject.EntityField1Name ?? string.Empty; dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas); dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas); dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas); dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active)); dlo.AssociateWith <EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active)); dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active)); dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active)); currentDb.LoadOptions = dlo; currentDb.CommandTimeout = 2000; currentDb.Connection.Open(); currentDb.Connection.ChangeDatabase(AryaTools.Instance.InstanceData.Dc.Connection.Database); InitGlobals(GlobalAttributes.ToList()); StatusMessage = "Init"; var fi = new FileInfo(ExportFileName); var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); attributeDataFile = new StreamWriter(baseFileName + "_AttributeData.txt", false, Encoding.UTF8); attributeDataFile.Write("ItemId{0}Taxonomy{0}Node Type", delimiter); foreach (var attribute in globalAttributeHeaders) { string attributeHeader = null; var parts = attribute.Split(':'); var noOfHeaders = 0; if (parts.Count() > 1) { Int32.TryParse(parts[1].Trim(), out noOfHeaders); } if (parts.Count() == 2 && noOfHeaders > 0) { for (var i = 0; i < noOfHeaders; i++) { if (attributeHeader == null) { attributeHeader += parts[0].Trim() + (i + 1); } else { attributeHeader += "\t" + parts[0].Trim() + (i + 1); } } } else { attributeHeader = attribute; } attributeDataFile.Write("{0}{1}", delimiter, attributeHeader); } attributeDataFile.WriteLine("{0}Rank 1{0}Att 1{0}Val 1{0}Uom 1{0}[...]", delimiter); CurrentProgress = 0; if (SkuCollection != null && SkuCollection.Any()) { var taxonomies = (SkuCollection.Split(2000) .SelectMany(skus => currentDb.Skus.Where(s => skus.Contains(s.ItemID))) .GroupBy(s => s.Taxonomy)).ToList(); MaximumProgress = taxonomies.Count; foreach (var st in taxonomies) { WriteSkusToFile(st.Key, st.ToList()); CurrentProgress++; } } else { var allExportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = currentDb.TaxonomyInfos.Where(p => allExportTaxonomyIds.Contains(p.ID)).ToList(); var allExportChildTaxonomies = exportTaxonomies.SelectMany(p => p.AllChildren2).Distinct().ToList(); MaximumProgress = allExportChildTaxonomies.Count; foreach (var exportChildTaxonomy in allExportChildTaxonomies) { WriteTaxonomyToFile(exportChildTaxonomy); CurrentProgress++; } } attributeDataFile.Close(); StatusMessage = "Done!"; State = WorkerState.Ready; }
public override void Run() { var currentDb = new SkuDataDbDataContext(); currentDb.Connection.Open(); currentDb.Connection.ChangeDatabase(AryaTools.Instance.InstanceData.Dc.Connection.Database); var allExportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = currentDb.TaxonomyInfos.Where(p => allExportTaxonomyIds.Contains(p.ID)).ToList(); // var baseFileName = ExportFileName; var fi = new FileInfo(ExportFileName); var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); // initialize base file _schemaFile = new StreamWriter(baseFileName + ".txt", false, Encoding.UTF8); // initialize LOV file _lovFile = new StreamWriter(baseFileName + "_Lov.txt", false, Encoding.UTF8); // initialize Taxonomy file _taxFile = new StreamWriter(baseFileName + "_Tax.txt", false, Encoding.UTF8); StatusMessage = "Init"; State = WorkerState.Working; AryaTools.Instance.AllFillRates.UseBackgroundWorker = false; _delimiter = EnumExtensions.GetValue(FieldDelimiter).ToString(); _possibleMissingInSchemaAttributes = new List <string>(); Init(); var maxDepth = 0; var allChildren = exportTaxonomies.SelectMany(p => p.AllChildren).Distinct().ToList(); var allLeafChildren = exportTaxonomies.SelectMany(p => p.AllLeafChildren).Distinct().ToList(); if (allChildren.Count == 0 && allLeafChildren.Count != 0) { maxDepth = allLeafChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } else if (allLeafChildren.Count == 0 && allChildren.Count != 0) { maxDepth = allChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } else if (allLeafChildren.Count != 0 && allChildren.Count != 0) { if (allLeafChildren.Count >= allChildren.Count) { maxDepth = allLeafChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } else { maxDepth = allChildren.Select( child => child.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None).Length) .Max(); } } else { StatusMessage = "There was no data to export."; MaximumProgress = 1; CurrentProgress = 1; State = WorkerState.Ready; } if (IgnoreT1Taxonomy && maxDepth > 1) { maxDepth--; } _taxFile.Write("Taxonomy{0}", _delimiter); _schemaFile.Write("Taxonomy{0}", _delimiter); for (var i = 1; i <= maxDepth; i++) { _schemaFile.Write("T" + i + "\t"); _lovFile.Write("T" + i + "\t"); _taxFile.Write("T" + i + "\t"); } // _schemaFile.Write("Taxonomy{0}T1{0}T2{0}T3{0}T4{0}T5{0}T6{0}T7{0}T8{0}NodeType{0}Attribute", _delimiter); _schemaFile.Write("NodeType{0}Attribute", _delimiter); foreach (var schematus in _allSchemati) { _schemaFile.Write(_delimiter + schematus); } _schemaFile.WriteLine(); // _lovFile.Write("T1{0}T2{0}T3{0}T4{0}T5{0}T6{0}T7{0}T8{0}NodeType{0}AttributeName{0}NavigationOrder{0}DisplayOrder{0}Value",_delimiter); _lovFile.Write("NodeType{0}AttributeName{0}NavigationOrder{0}DisplayOrder{0}Value", _delimiter); if (ExportEnrichments) { _lovFile.Write("{0}EnrichmentImage{0}EnrichmentCopy", _delimiter); } _lovFile.WriteLine(); foreach (var metaAttribute in _taxMetaAttributes) { _taxFile.Write(_delimiter + metaAttribute.AttributeName); } _taxFile.WriteLine(); //if (ExportEnrichments) // _taxFile.Write("{0}EnrichmentImage{0}EnrichmentCopy", _delimiter); //_taxFile.WriteLine(); // create download folder, if requested if (ExportEnrichments && DownloadAssets) { _downloadDir = new DirectoryInfo(baseFileName + "_Assets"); _downloadDir.Create(); } var allTaxonomies = Taxonomies.Cast <ExtendedTaxonomyInfo>().ToList(); MaximumProgress = allTaxonomies.Sum(p => TaxonomyInfo.GetNodeCount(p.Taxonomy)) + 1; CurrentProgress = 0; // MaximumProgress = allChildren.Count; var mscFillRateHelper = new MSCFillRateHelper(); _fillRates = new List <Tuple <string, Guid, Guid, decimal> >(5000); if (ExportFillRates) { foreach (var exportTaxonomyInfo in allTaxonomies) { mscFillRateHelper.GetFillRates(exportTaxonomyInfo.Taxonomy.ID, AryaTools.Instance.InstanceData.CurrentProject.ProjectName); } } foreach (var exportTaxonomyInfo in allTaxonomies) { WriteTaxonomyToFile(exportTaxonomyInfo.Taxonomy, maxDepth); } CurrentProgress++; _schemaFile.Close(); _lovFile.Close(); _lovFile.Dispose(); _taxFile.Close(); var exceptionFileName = baseFileName + "_Exceptions.txt"; File.WriteAllLines(exceptionFileName, _possibleMissingInSchemaAttributes, Encoding.UTF8); AryaTools.Instance.AllFillRates.UseBackgroundWorker = true; StatusMessage = "Done!"; State = WorkerState.Ready; }
public override void Run() { State = WorkerState.Working; _parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions); _parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions); //parsedSkuValueInclusions = ParseSkuValueInclusions(SkuValueInclusions); _taxonomyAttributesCache = new Dictionary <Guid, List <Tuple <Attribute, decimal, decimal> > >(); _baseAttributeNames = new Dictionary <string, string>(); _delimiter = FieldDelimiter.GetValue().ToString(); //Create new context _currentDb = new SkuDataDbDataContext(); var dlo = new DataLoadOptions(); _projectField1Name = AryaTools.Instance.InstanceData.CurrentProject.EntityField1Name ?? string.Empty; dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas); dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas); dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active)); //dlo.AssociateWith<EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active)); dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active)); //dlo.AssociateWith<TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active)); _currentDb.LoadOptions = dlo; _currentDb.CommandTimeout = 2000; _currentDb.Connection.Open(); _currentDb.Connection.ChangeDatabase(AryaTools.Instance.InstanceData.Dc.Connection.Database); InitGlobals(GlobalAttributes); StatusMessage = "Init"; var fi = new FileInfo(ExportFileName); var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty); _taxonomyFile = new StreamWriter(baseFileName + "_Classification.txt", false, Encoding.UTF8); _taxonomyFile.WriteLine("ItemId{0}New Taxonomy{0}Node Type{0}Old Taxonomy", _delimiter); _attributeDataFile = new StreamWriter(baseFileName + "_AttributeData.txt", false, Encoding.UTF8); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile = new StreamWriter(baseFileName + "_AttributeBlanks.txt", false, Encoding.UTF8); } _attributeDataFile.Write("ItemId{0}Taxonomy{0}Node Type", _delimiter); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("ItemId{0}Taxonomy{0}Node Type", _delimiter); } foreach (var attribute in _globalAttributeHeaders) { string attributeHeader = null; var parts = attribute.Split(':'); var noOfHeaders = 0; if (parts.Count() > 1) { Int32.TryParse(parts[1].Trim(), out noOfHeaders); } if (parts.Count() == 2 && noOfHeaders > 0) { for (var i = 0; i < noOfHeaders; i++) { if (attributeHeader == null) { attributeHeader += parts[0].Trim() + (i + 1); } else { attributeHeader += "\t" + parts[0].Trim() + (i + 1); } } } else { attributeHeader = attribute; } _attributeDataFile.Write("{0}{1}", _delimiter, attributeHeader); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("{0}{1}", _delimiter, attributeHeader); } } if (ExportRanks) { _attributeDataFile.Write("{0}Rank 1", _delimiter); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("{0}Rank 1", _delimiter); } } _attributeDataFile.Write("{0}Att 1", _delimiter); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("{0}Att 1", _delimiter); } if (ExportNewValueColumn) { _attributeDataFile.Write("{0}New Value 1", _delimiter); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("{0}New Value 1", _delimiter); } } _attributeDataFile.Write("{0}Val 1", _delimiter); if (IncludeUoM) { _attributeDataFile.Write("{0}Uom 1", _delimiter); } if (IncludeField1) { _attributeDataFile.Write("{0}Field 1 1", _delimiter); } if (IncludeField2) { _attributeDataFile.Write("{0}Field 2 1", _delimiter); } if (IncludeField3) { _attributeDataFile.Write("{0}Field 3 1", _delimiter); } if (IncludeField4) { _attributeDataFile.Write("{0}Field 4 1", _delimiter); } if (IncludeField5) { _attributeDataFile.Write("{0}Field 5 1", _delimiter); } _attributeDataFile.WriteLine("{0}[...]", _delimiter); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Write("{0}Val 1", _delimiter); if (IncludeUoM) { _blankValuesAttributeDataFile.Write("{0}Uom 1", _delimiter); } if (IncludeField1) { _blankValuesAttributeDataFile.Write("{0}Field 1 1", _delimiter); } if (IncludeField2) { _blankValuesAttributeDataFile.Write("{0}Field 2 1", _delimiter); } if (IncludeField3) { _blankValuesAttributeDataFile.Write("{0}Field 3 1", _delimiter); } if (IncludeField4) { _blankValuesAttributeDataFile.Write("{0}Field 4 1", _delimiter); } if (IncludeField5) { _blankValuesAttributeDataFile.Write("{0}Field 5 1", _delimiter); } _blankValuesAttributeDataFile.WriteLine("{0}[...]", _delimiter); } var exportTaxonomyIds = Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList(); var exportTaxonomies = _currentDb.TaxonomyInfos.Where(p => exportTaxonomyIds.Contains(p.ID)).ToList(); var allExportTaxonomies = exportTaxonomies.SelectMany(p => p.AllChildren2).Union(exportTaxonomies).Distinct().ToList(); CurrentProgress = 0; MaximumProgress = allExportTaxonomies.Count; foreach (var exportChildTaxonomy in allExportTaxonomies) { WriteTaxonomyToFile(exportChildTaxonomy); CurrentProgress++; } _taxonomyFile.Close(); _attributeDataFile.Close(); if (GenerateFileWithBlankValues) { _blankValuesAttributeDataFile.Close(); } StatusMessage = "Done!"; State = WorkerState.Ready; }