Exemplo n.º 1
0
        public static List <Attribute> GetCalculatedAttributes(TaxonomyInfo taxonomy)
        {
            List <Attribute> calculatedAttributes;

            if (taxonomy == null || taxonomy.TaxonomyData == null)
            {
                calculatedAttributes = (from att in AryaTools.Instance.InstanceData.Dc.DerivedAttributes
                                        where
                                        att.TaxonomyInfo == null &&
                                        att.Attribute.Project.Equals(AryaTools.Instance.InstanceData.CurrentProject)
                                        select att.Attribute).ToList();
            }
            else
            {
                calculatedAttributes = (from att in AryaTools.Instance.InstanceData.Dc.DerivedAttributes
                                        where
                                        att.TaxonomyInfo.Equals(taxonomy) &&
                                        att.Attribute.ProjectID == AryaTools.Instance.InstanceData.CurrentProject.ID
                                        select att.Attribute).ToList();

                var parentAttributes =
                    GetCalculatedAttributes(taxonomy.TaxonomyData.ParentTaxonomyInfo)
                    .Where(att => !calculatedAttributes.Select(ca => ca.ID).Contains(att.ID));
                calculatedAttributes.AddRange(parentAttributes);
            }

            return(calculatedAttributes);
        }
Exemplo n.º 2
0
        public List <Sku> this[TaxonomyInfo index]
        {
            get

            {
                return(this.SkuGroups.SelectMany(s => s.Sku.SkuInfos.Where(a => a.Active)).Where(t => t.TaxonomyInfo == index).Select(s => s.Sku).ToList());
            }
        }
Exemplo n.º 3
0
        private HashSet <string> GetInSchemaAttributes(TaxonomyInfo taxonomy)
        {
            var inSchemaAttributes = new HashSet <string>(from si in taxonomy.SchemaInfos
                                                          let sd = si.SchemaData
                                                                   where sd != null && sd.InSchema
                                                                   select si.Attribute.AttributeName);

            return(inSchemaAttributes);
        }
Exemplo n.º 4
0
        internal HashSet <string> GetRankedAttributes(TaxonomyInfo taxonomy)
        {
            var rankedAttributes = new HashSet <string>(from si in taxonomy.SchemaInfos
                                                        let sd = si.SchemaData
                                                                 where
                                                                 sd != null && (sd.NavigationOrder > 0 || sd.DisplayOrder > 0)
                                                                 select si.Attribute.AttributeName);

            return(rankedAttributes);
        }
Exemplo n.º 5
0
        private string GetValue(Attribute taxMetaAttribute, TaxonomyInfo taxonomy)
        {
            var taxMetaData = (from tmd in AryaTools.Instance.InstanceData.Dc.TaxonomyMetaDatas
                               where
                               tmd.TaxonomyMetaInfo.TaxonomyID.Equals(taxonomy.ID) &&
                               tmd.TaxonomyMetaInfo.MetaAttributeID.Equals(taxMetaAttribute.ID) &&
                               tmd.Active
                               select tmd).FirstOrDefault();

            return(taxMetaData == null ? string.Empty : taxMetaData.Value);
        }
Exemplo n.º 6
0
        private void WriteTaxMetaValue(TaxonomyInfo taxonomy)
        {
            foreach (var taxMetaAttribute in _taxMetaAttributes)
            {
                var    rawAttributeValue   = GetValue(taxMetaAttribute, taxonomy);
                string finalAttributeValue = rawAttributeValue;

                if (ExportEnrichments)
                {
                    if (taxMetaAttribute.ToString() == Resources.TaxonomyEnrichmentCopyAttributeName)
                    {
                        // replace carriage returns with "|"
                        if (!String.IsNullOrEmpty(rawAttributeValue))
                        {
                            var returnChar =
                                AryaTools.Instance.InstanceData.CurrentProject.ProjectPreferences.ReturnSeparator ?? "|";
                            finalAttributeValue = rawAttributeValue.Replace("\r", String.Empty).Replace("\n", returnChar);
                        }
                    }
                    else if (taxMetaAttribute.ToString() == Resources.TaxonomyEnrichmentImageAttributeName)
                    {
                        using (var dc =
                                   new AryaDbDataContext(AryaTools.Instance.InstanceData.CurrentProject.ID,
                                                         AryaTools.Instance.InstanceData.CurrentUser.ID))
                        {
                            var imageMgr = new ImageManager(dc, AryaTools.Instance.InstanceData.CurrentProject.ID)
                            {
                                ImageSku = dc.Skus.FirstOrDefault(s => s.ItemID == rawAttributeValue)
                            };

                            // retrieve Enrichment Image, if it exists
                            if (DownloadAssets)
                            {
                                imageMgr.LocalDirectory = _downloadDir.ToString();
                                imageMgr.DownloadImage(taxonomy.ID);
                                finalAttributeValue = imageMgr.LocalImageName;
                            }
                            else
                            {
                                finalAttributeValue = imageMgr.RemoteImageUrl;
                            }
                        }
                    }
                }

                _taxFile.Write("{0}{1}", _delimiter, finalAttributeValue);
            }
            _taxFile.WriteLine();
        }
Exemplo n.º 7
0
        internal void LoadQuery(string queryDescription, List <TaxonomyInfo> taxonomyNodes)
        {
            dgvAttributes.DataSource   = null;
            dgvListOfValues.DataSource = null;
            chkShowLovs.Checked        = false;
            lblStatus.Text             = string.Format("Loading {0}...", queryDescription);

            Show();
            BringToFront();

            _queryDescription = queryDescription;

            _taxonomyNodes = taxonomyNodes;

            _taxonomy = _taxonomyNodes.Count == 1 ? _taxonomyNodes[0] : null;

            //_entities = from ed in AryaTools.Instance.InstanceData.Dc.EntityDatas
            //            join ei in AryaTools.Instance.InstanceData.Dc.EntityInfos on ed.EntityID equals
            //                ei.ID
            //            join si in AryaTools.Instance.InstanceData.Dc.SkuInfos on ei.SkuID equals si.SkuID
            //            where
            //                ed.Active && si.Active &&
            //                taxonomyNodes.Select(p => p.ID).ToList().Contains(si.TaxonomyID)
            //            select ei;

            _entities = from si in AryaTools.Instance.InstanceData.Dc.SkuInfos
                        where si.Active && taxonomyNodes.Select(t => t.ID).Contains(si.TaxonomyID)
                        from ei in si.Sku.EntityInfos
                        where ei.EntityDatas.Any(ed => ed.Active)
                        select ei;

            //_entities = from si in AryaTools.Instance.InstanceData.Dc.SkuInfos
            //            join ei in AryaTools.Instance.InstanceData.Dc.EntityInfos on si.Sku equals ei.Sku
            //            where
            //                si.Active && taxonomyNodes.Select(tn => tn.ID).Contains(si.TaxonomyID)
            //                && ei.EntityDatas.Any(ed => ed.Active)
            //            select ei;

            ShowHideRankColumns();

            _workerThread = new Thread(GetColumnProperties)
            {
                IsBackground = true
            };
            _workerThread.Start();
            workerThreadTimer.Start();
        }
Exemplo n.º 8
0
        // Internal Methods (1) 

        internal void LoadQuery(IQueryable <Sku> skuQuery, string queryDescription,
                                List <TaxonomyInfo> taxonomyNodes = null)
        {
            dgvAttributes.DataSource   = null;
            dgvListOfValues.DataSource = null;
            chkShowLovs.Checked        = false;
            lblStatus.Text             = string.Format("Loading {0}...", queryDescription);

            Show();
            BringToFront();

            _skuQuery         = skuQuery;
            _queryDescription = queryDescription;

            //_entities = _skuQuery.SelectMany(sku => sku.EntityInfos);
            _entities = from sku in _skuQuery
                        join ei in AryaTools.Instance.InstanceData.Dc.EntityInfos on sku.ID equals ei.SkuID
                        select ei;

            if (taxonomyNodes == null)
            {
                _taxonomyNodes = (from sku in _skuQuery
                                  join si in AryaTools.Instance.InstanceData.Dc.SkuInfos on sku.ID equals si.SkuID
                                  join ti in AryaTools.Instance.InstanceData.Dc.TaxonomyInfos on si.TaxonomyID equals ti.ID
                                  where si.Active
                                  select ti).Distinct().ToList();
            }
            else
            {
                _taxonomyNodes = taxonomyNodes;
            }

            _taxonomy = _taxonomyNodes.Count == 1 ? _taxonomyNodes[0] : null;
            ShowHideRankColumns();

            _workerThread = new Thread(GetColumnProperties)
            {
                IsBackground = true
            };
            _workerThread.Start();
            workerThreadTimer.Start();
        }
Exemplo n.º 9
0
        public static int GetNodeCount(TaxonomyInfo taxonomy)
        {
            IEnumerable <TaxonomyInfo> childTaxonomyInfos;
            var count = 0;

            if (taxonomy != null)
            {
                childTaxonomyInfos =
                    taxonomy.ChildTaxonomyDatas.Where(td => td.Active).Select(td => td.TaxonomyInfo).ToList();
                count = childTaxonomyInfos.Count();
            }
            else
            {
                childTaxonomyInfos = GetLevel1Nodes().ToList();
            }

            count += childTaxonomyInfos.Sum(childNode => GetNodeCount(childNode));

            return(count);
        }
Exemplo n.º 10
0
        public FrmAttributeView(List <AttributeColumn> columns, List <TaxonomyInfo> taxonomies) : this()
        {
            _showMvColumn    = false;
            _columnVisiblity = columns.ToDictionary(c => c.Attribute, c => c.Visible);
            _dsAttributes    =
                columns.Where(
                    col => Framework.Data.AryaDb.Attribute.NonMetaAttributeTypes.Contains(col.AttributeType))
                .ToList();
            _taxonomyNodes = taxonomies;

            _taxonomy = _taxonomyNodes == null || _taxonomyNodes.Count != 1 ? null : _taxonomyNodes[0];

            ShowHideRankColumns();

            chkAll.Visible          = true;
            colLocalVisible.Visible = true;
            lblStatus.Visible       = false;
            flpLOvOptions.Visible   = false;
            dgvListOfValues.Visible = false;
            Width = AttributesOnlyWidth;
            tblAttributeViewMain.ColumnStyles[0].SizeType = SizeType.Percent;
            tblAttributeViewMain.ColumnStyles[0].Width    = 100F;

            StartPosition = FormStartPosition.CenterParent;

            Init();

            var attributeColumn = dgvAttributes.Columns["colAttributeName"];

            if (attributeColumn != null)
            {
                attributeColumn.ReadOnly = true;
            }
            //prepare for show hide attribute window
            tblAttributeViewMain.RowCount = 4;
            btnApply.Visible         = true;
            btnSavePrefs.Visible     = false;
            btnCheckSpelling.Enabled = false;
        }
Exemplo n.º 11
0
 public bool IsChildOf(TaxonomyInfo nodeToTest)
 {
     return(TaxonomyData.ParentTaxonomyInfo != null &&
            (TaxonomyData.ParentTaxonomyInfo == nodeToTest ||
             TaxonomyData.ParentTaxonomyInfo.IsChildOf(nodeToTest)));
 }
Exemplo n.º 12
0
        private void WriteTaxonomyToFile(TaxonomyInfo taxonomy, int taxonomyMaxDepth)
        {
            var ignoreT1taxonomy = taxonomy.ToString();

            if (IgnoreT1Taxonomy)
            {
                ignoreT1taxonomy = taxonomy.ToString().Substring(taxonomy.ToString().IndexOf('>') + 1);
            }

            if (string.IsNullOrEmpty(taxonomy.ToString()))
            {
                return;
            }

            if (_processedTaxonomies.Contains(taxonomy))
            {
                return;
            }
            _processedTaxonomies.Add(taxonomy);

            if (!LeafNodesOnly || taxonomy.HasSkus || ExportAllSchemaNodes)
            {
                StatusMessage = string.Format("{1}{0}Reading Node", Environment.NewLine, taxonomy);

                List <Attribute> atts;

                if (ExportSuperSchema && !taxonomy.IsLeafNode)
                {
                    var schemaInfos = new List <SchemaInfo>();
                    schemaInfos.AddRange(taxonomy.SchemaInfos.Where(si => si.SchemaDatas.Any(sd => sd.Active)).ToList());
                    if (ExportSuperSchema)
                    {
                        foreach (var leaf in taxonomy.AllLeafChildren)
                        {
                            schemaInfos.AddRange(
                                leaf.SchemaInfos.Where(si => si.SchemaDatas.Any(sd => sd.Active)).ToList());
                        }
                    }
                    var schemaAttributes =
                        schemaInfos.Where(p => p.SchemaData.InSchema)
                        .Select(p => new { p.Attribute, p.SchemaData })
                        .ToList();

                    atts = (from att in schemaAttributes
                            group att by att.Attribute
                            into grp
                            let minRank = grp.Min(p => GetRank(p.SchemaData, SortOrder.OrderbyDisplayNavigation))
                                          orderby minRank
                                          select grp.Key).Distinct().ToList();
                }
                else
                {
                    atts = (from si in AryaTools.Instance.InstanceData.Dc.SchemaInfos
                            where si.TaxonomyID == taxonomy.ID
                            let sd = si.SchemaDatas.FirstOrDefault(sd => sd.Active)
                                     where sd != null
                                     let inSchema = sd.InSchema
                                                    where inSchema
                                                    let navRank = sd == null || sd.NavigationOrder == 0 ? decimal.MaxValue : sd.NavigationOrder
                                                                  let dispRank = sd == null || sd.DisplayOrder == 0 ? decimal.MaxValue : sd.DisplayOrder
                                                                                 orderby navRank, dispRank
                            select si.Attribute).ToList();

                    var currentTaxonomyString = ignoreT1taxonomy;

                    var possibleMissingAttributes = (from si in AryaTools.Instance.InstanceData.Dc.SchemaInfos
                                                     where si.TaxonomyID == taxonomy.ID
                                                     let sd = si.SchemaDatas.FirstOrDefault(sd => sd.Active)
                                                              where sd != null && !sd.InSchema && (sd.NavigationOrder > 0 || sd.DisplayOrder > 0)
                                                              select si.Attribute.AttributeName).ToList()
                                                    .Select(p => currentTaxonomyString + "\t" + p)
                                                    .ToList();

                    _possibleMissingInSchemaAttributes.AddRange(possibleMissingAttributes);
                }

                var isLeafNode = taxonomy.IsLeafNode;

                //if a node has no schema, just skip it.
                if ((atts.Count == 0 && ExportAllSchemaNodes) || (LeafNodesOnly && isLeafNode == false))
                {
                    StatusMessage = string.Format("{1}{0}, Fetching Child Nodes", Environment.NewLine, taxonomy);
                    var taxonomies =
                        taxonomy.ChildTaxonomyDatas.Where(td => td.Active)
                        .Select(td => td.TaxonomyInfo)
                        .OrderBy(tax => tax.ToString());

                    foreach (var tax in taxonomies)
                    {
                        WriteTaxonomyToFile(tax, taxonomyMaxDepth);
                    }
                    CurrentProgress++;
                    return;
                }

                var taxonomyString = ignoreT1taxonomy;
                var taxParts       = ignoreT1taxonomy.Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.None);
                var taxonomyParts  = new string[taxonomyMaxDepth];

                _taxFile.Write("{1}{0}", _delimiter, taxonomyString);
                for (var i = 0; i < taxonomyMaxDepth; i++)
                {
                    taxonomyParts[i] = i < taxParts.Length ? taxParts[i].Trim() : string.Empty;
                    _taxFile.Write(taxonomyParts[i] + "\t");
                }

                // write to taxonomy file
                // _taxFile.WriteLine("{9}{0}{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}", _delimiter, taxonomyString);

                WriteTaxMetaValue(taxonomy);

                _schemaFile.WriteLine("{1}{0}", _delimiter, taxonomyString);
                foreach (var attribute in atts)
                {
                    _schemaFile.Write("{1}{0}", _delimiter, taxonomyString);
                    for (var i = 0; i < taxonomyMaxDepth; i++)
                    {
                        taxonomyParts[i] = i < taxParts.Length ? taxParts[i].Trim() : string.Empty;
                        _schemaFile.Write(taxonomyParts[i] + "\t");
                    }

                    _schemaFile.Write("{1}{0}{2}", _delimiter,
                                      (taxonomy.NodeType == "Derived") ? "Cross List" : TaxonomyInfo.NodeTypeRegular, attribute);

                    foreach (var schematus in _allSchemati)
                    {
                        object value = null;

                        if (schematus.AttributeType == SchemaAttribute.SchemaAttributeType.FillRate)
                        {
                            if (_fillRates.Count > 0)
                            {
                                var data =
                                    _fillRates.FirstOrDefault(
                                        p =>
                                        p.Item1 == schematus.FillRateSchemaAttribute.GetFilterName() &&
                                        p.Item2 == taxonomy.ID && p.Item3 == attribute.ID);

                                value = data == null ? "0" : data.Item4.ToString(CultureInfo.InvariantCulture);
                            }
                            else
                            {
                                value = SchemaAttribute.GetValue(taxonomy, attribute, schematus);
                            }
                        }
                        else
                        {
                            if (ExportSuperSchema && !isLeafNode)
                            {
                                if (schematus.AttributeType == SchemaAttribute.SchemaAttributeType.Meta)
                                {
                                    if (schematus.MetaSchemaAttribute.AttributeName.Equals("Sample Values",
                                                                                           StringComparison.OrdinalIgnoreCase) &&
                                        schematus.MetaSchemaAttribute.AttributeName.Equals("Restricted UOM",
                                                                                           StringComparison.OrdinalIgnoreCase))
                                    {
                                        value = string.Empty;
                                    }
                                }
                                else
                                {
                                    var allChildren = taxonomy.AllLeafChildren.ToList();
                                    allChildren.Add(taxonomy);

                                    var attribute2 = attribute;
                                    var schematus1 = schematus;
                                    var bestValue  = (from child in allChildren
                                                      let childValue = SchemaAttribute.GetValue(child, attribute2, schematus1)
                                                                       where childValue != null
                                                                       group child by childValue
                                                                       into grp
                                                                       orderby grp.Count() descending
                                                                       select grp.Key).FirstOrDefault();

                                    value = bestValue;
                                }
                            }
                            else
                            {
                                value = SchemaAttribute.GetValue(taxonomy, attribute, schematus);
                            }
                        }

                        value = value ?? string.Empty;

                        if ((schematus.PrimarySchemaAttribute == "Navigation Order" ||
                             schematus.PrimarySchemaAttribute == "Display Order"))
                        {
                            decimal result;
                            if (Decimal.TryParse(value.ToString(), out result) && result > 0)
                            {
                                value = string.Format("{0:0.##}", value);
                            }
                        }
                        else if (schematus.AttributeType == SchemaAttribute.SchemaAttributeType.Meta &&
                                 schematus.MetaSchemaAttribute.AttributeName == Resources.SchemaEnrichmentImageAttributeName &&
                                 !String.IsNullOrEmpty(value.ToString()))
                        {
                            using (var dc = new AryaDbDataContext(AryaTools.Instance.InstanceData.CurrentProject.ID, AryaTools.Instance.InstanceData.CurrentUser.ID))
                            {
                                var imageMgr = new ImageManager(dc, AryaTools.Instance.InstanceData.CurrentProject.ID)
                                {
                                    RemoteImageGuid = value.ToString()
                                };
                                if (DownloadAssets)
                                {
                                    imageMgr.LocalDirectory = _downloadDir.ToString();
                                    imageMgr.DownloadImage(taxonomy.ID, attribute.ID);
                                    value = imageMgr.LocalImageName;
                                }
                                else
                                {
                                    value = imageMgr.RemoteImageUrl;
                                }
                            }
                        }

                        var value2 = value.ToString();

                        if (value2.Length > 0)
                        {
                            _schemaFile.Write(_delimiter
                                              + value2.Replace("\n", string.Empty).Replace("\r", string.Empty));
                        }
                        else
                        {
                            _schemaFile.Write(_delimiter + value2);
                        }
                    }
                    _schemaFile.WriteLine();

                    var schemaData =
                        attribute.SchemaInfos.Where(p => p.TaxonomyID == taxonomy.ID && p.SchemaData != null)
                        .Select(p => p.SchemaData)
                        .FirstOrDefault();

                    if (schemaData != null)
                    {
                        var attribute1 = attribute;

                        foreach (var lov in schemaData.SchemaInfo.ListOfValues.Where(lov => lov.Active))
                        {
                            for (var j = 0; j < taxonomyMaxDepth; j++)
                            {
                                taxonomyParts[j] = j < taxParts.Length ? taxParts[j].Trim() : string.Empty;
                                _lovFile.Write(taxonomyParts[j] + "\t");
                            }
                            //_lovFile.WriteLine(
                            //    "{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}{0}{10}{0}{11}{0}{12}{0}{13}",
                            //    _delimiter, taxParts[0], taxParts[1], taxParts[2], taxParts[3], taxParts[4], taxParts[5],
                            //    taxParts[6], taxParts[7], (taxonomy.NodeType == "Derived") ? "Cross List" : TaxonomyInfo.NodeTypeRegular,
                            //    attribute1.AttributeName,
                            //    schemaData.NavigationOrder == 0
                            //        ? string.Empty
                            //        : string.Format("{0:0.##}", schemaData.NavigationOrder),
                            //    schemaData.DisplayOrder == 0
                            //        ? string.Empty
                            //        : string.Format("{0:0.##}", schemaData.DisplayOrder), lov.Value);

                            _lovFile.Write("{1}{0}{2}{0}{3}{0}{4}{0}{5}", _delimiter,
                                           (taxonomy.NodeType == "Derived") ? "Cross List" : TaxonomyInfo.NodeTypeRegular,
                                           attribute1.AttributeName,
                                           schemaData.NavigationOrder == 0
                                    ? string.Empty
                                    : string.Format("{0:0.##}", schemaData.NavigationOrder),
                                           schemaData.DisplayOrder == 0
                                    ? string.Empty
                                    : string.Format("{0:0.##}", schemaData.DisplayOrder), lov.Value);

                            if (ExportEnrichments)
                            {
                                using (
                                    var dc =
                                        new AryaDbDataContext(AryaTools.Instance.InstanceData.CurrentProject.ID,
                                                              AryaTools.Instance.InstanceData.CurrentUser.ID))
                                {
                                    var imageMgr = new ImageManager(dc, AryaTools.Instance.InstanceData.CurrentProject.ID)
                                    {
                                        ImageSku = dc.Skus.FirstOrDefault(s => s.ItemID == lov.EnrichmentImage)
                                    };
                                    string lovImage;
                                    if (DownloadAssets)
                                    {
                                        imageMgr.LocalDirectory = _downloadDir.ToString();
                                        imageMgr.DownloadImage(taxonomy.ID, attribute.ID, lov.ID);
                                        lovImage = imageMgr.LocalImageName;
                                    }
                                    else
                                    {
                                        lovImage = imageMgr.RemoteImageUrl;
                                    }

                                    _lovFile.Write("{0}{1}{0}{2}", _delimiter, lovImage, lov.EnrichmentCopy);
                                }
                            }

                            _lovFile.WriteLine();
                        }
                    }
                }
            }

            StatusMessage = string.Format("{1}{0}, Fetching Child Nodes", Environment.NewLine, taxonomy);
            var taxs =
                taxonomy.ChildTaxonomyDatas.Where(td => td.Active)
                .Select(td => td.TaxonomyInfo)
                .OrderBy(tax => tax.ToString());

            foreach (var tax in taxs)
            {
                WriteTaxonomyToFile(tax, taxonomyMaxDepth);
            }
            CurrentProgress++;
        }
Exemplo n.º 13
0
        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;
        }