예제 #1
0
        private void WriteTaxonomyToFile(TaxonomyInfo taxonomy)
        {
            StatusMessage = string.Format("{1}{0}Reading Node", Environment.NewLine, taxonomy);
            IQueryable <Sku> allSkus;

            if (taxonomy.NodeType == TaxonomyInfo.NodeTypeDerived)
            {
                if (!ExportCrossListNodes)
                {
                    return;
                }

                var cl = Query.FetchCrossListObject(taxonomy);
                if (cl == null)
                {
                    return;
                }
                allSkus =
                    Query.GetFilteredSkus(cl.TaxonomyIDFilter, cl.ValueFilters, cl.AttributeTypeFilters,
                                          cl.MatchAllTerms).Distinct();
            }
            else
            {
                allSkus = from sku in currentDb.Skus
                          where sku.SkuInfos.Any(si => si.Active && si.TaxonomyInfo == taxonomy)
                          select sku;
            }

            StatusMessage = string.Format("{1}{0}Filtering SKUs", Environment.NewLine, taxonomy);
            var skus = GetFilteredSkuList(allSkus, true, parsedSkuInclusions, parsedSkuExclusions).ToList();

            WriteSkusToFile(taxonomy, skus);
        }
예제 #2
0
        private void ProcessTaxonomyChildren(TaxonomyInfo node)
        {
            try
            {
                var children = from td in node.ChildTaxonomyDatas where td.Active select td.TaxonomyInfo;

                foreach (var child in children)
                {
                    ProcessTaxonomyNode(node, child);
                }
            }
            catch (Exception exception)
            {
                var message = string.Empty;
                var ex      = exception;
                while (ex != null)
                {
                    message += ex.Message + Environment.NewLine;
                    message += ex.StackTrace + Environment.NewLine;
                    ex       = ex.InnerException;
                }
                CurrentLogWriter.Warn("There was a problem processing children for node." + Environment.NewLine +
                                      message);
            }
        }
예제 #3
0
파일: FrmTree.cs 프로젝트: ewin66/Arya
        private void ReturnTaxonomy(TaxonomyInfo taxonomyInfo)
        {
            if (_oldWorkerTimerState)
            {
                taxonomyTree.updateNodeTimer.Start();
            }

            _pnlSpecialButtons.Visible = false;
            Refresh();

            taxonomyTree.OnTaxonomySelected = _oldOnTaxonomySelected;
            taxonomyTree.OnTaxonomyOpen     = _oldOnTaxonomyOpen;

            taxonomyTree.ShowAllMenuOptions = true;
            taxonomyTree.OnCustomAction     = null;

            DialogResult = (taxonomyInfo == null && taxonomyTree.CustomActionMinLevel > 0) ||
                           (taxonomyInfo != null && taxonomyInfo.Equals(CancelledTaxonomy))
                ? DialogResult.Cancel
                : DialogResult.OK;
            taxonomyMenuStrip.Enabled = true;
            ControlBox = true;

            TaxonomySelected(this, EventArgs.Empty);
            TaxonomySelected = null;
        }
예제 #4
0
        private string GetTn(TaxonomyInfo taxonomy, string columnName)
        {
            if (!_rxCol.IsMatch(columnName))
            {
                return(string.Empty);
            }

            var col       = _rxCol.Match(columnName).Value;
            var resultInt = int.Parse(col);
            var taxParts  = taxonomy.ToStringParts().ToList();

            if (Args.IgnoreT1Taxonomy)
            {
                taxParts.RemoveAt(0);
            }
            return(taxParts.Count >= resultInt ? taxParts[resultInt - 1] : string.Empty);
            //int resultInt;
            //if (int.TryParse(columnName.Substring(columnName.Length - 1, 1), out resultInt)) //comupute n
            //{
            //    var taxParts = taxonomy.ToString().Split(TaxonomyInfo.DELIMITER[0]);
            //    if (taxParts.Count() >= resultInt)
            //        return taxParts[resultInt - 1];
            //}
            //return string.Empty;
        }
예제 #5
0
        private void ProcessTaxonomySkus(TaxonomyInfo node)
        {
            try
            {
                //Must use independent DataContext to conserve memory
                using (var dc = new AryaDbDataContext(Arguments.ProjectId, Arguments.UserId))
                {
                    var allSkus = from si in dc.SkuInfos
                                  where si.Active && si.TaxonomyID == node.ID
                                  let sku = si.Sku
                                            where sku.SkuType == Sku.ItemType.Product.ToString()
                                            select sku;

                    var skus = ((AdvancedExportArgs)Arguments).GetFilteredSkuList(allSkus).Select(s => s.ID).ToList();

                    skus.AsParallel().ForAll(ProcessSku);
                    //skus.ForEach(ProcessSku);
                }
            }
            catch (Exception exception)
            {
                var message = string.Empty;
                var ex      = exception;
                while (ex != null)
                {
                    message += ex.Message + Environment.NewLine;
                    message += ex.StackTrace + Environment.NewLine;
                    ex       = ex.InnerException;
                }
                CurrentLogWriter.Warn("There was a problem processing skus in node." + Environment.NewLine + message);
            }
        }
예제 #6
0
        private string GetTaxMetaAttributeValue(AryaDbDataContext dc, string taxMetaAttributeName,
                                                TaxonomyInfo taxonomy)
        {
            var taxMetaData =
                (dc.TaxonomyMetaDatas.FirstOrDefault(
                     tmd =>
                     tmd.TaxonomyMetaInfo.TaxonomyID.Equals(taxonomy.ID) &&
                     tmd.TaxonomyMetaInfo.MetaAttributeID.Equals(AllTaxMetaAttributes[taxMetaAttributeName].ID) &&
                     tmd.Active));
            string value = taxMetaData == null ? string.Empty : taxMetaData.Value;

            if (String.Compare(taxMetaAttributeName, Resources.TaxonomyEnrichmentImageAttributeName,
                               StringComparison.OrdinalIgnoreCase) == 0)
            {
                var imageMgr = new ImageManager(dc, Args.ProjectId, value)
                {
                    LocalDirectory  = ArgumentDirectoryPath,
                    RemoteImageGuid = value
                };
                //if (!Directory.Exists(imageMgr.LocalDirectory))
                //    Directory.CreateDirectory(imageMgr.LocalDirectory);
                if (Args.DownloadAssets)
                {
                    imageMgr.DownloadImage(taxonomy.ID);
                }
                value = imageMgr.OriginalFileName;
            }
            return(value);
        }
예제 #7
0
        public double?GetFillRate(TaxonomyInfo taxonomy, Attribute attribute, Filter filter)
        {
            var fillRateObject = FillRates.FirstOrDefault(fr => fr.Taxonomy.Equals(taxonomy));

            if (fillRateObject == null)
            {
                fillRateObject = new FillRate(taxonomy, null, null, FillRate.DataState.Active, DateTime.Now);
                FillRates.Add(fillRateObject);
                if (UseBackgroundWorker)
                {
                    EnqueWork(fillRateObject, attribute, filter);
                    return(double.MinValue);
                }
            }

            double?fillRateValue = fillRateObject.TryGetFillRate(attribute, filter);

            if (fillRateValue == null)
            {
                if (UseBackgroundWorker)
                {
                    EnqueWork(fillRateObject, attribute, filter);
                    return(double.MinValue);
                }
                fillRateValue = fillRateObject.FetchFillRate(attribute, filter);
            }

            if (double.IsNaN((double)fillRateValue))
            {
                return(null);
            }

            //return string.Format("{0:0.00}", fillRateValue);
            return(Math.Round((double)fillRateValue, 2));
        }
예제 #8
0
        private void WriteSkusToFile(TaxonomyInfo taxonomy, List <Sku> skus)
        {
            var iCtr     = 0;
            var noOfSkus = skus.Count;

            skus.ForEach(sku =>
            {
                StatusMessage = string.Format("{1}{0}{2} of {3} SKUs", Environment.NewLine, taxonomy,
                                              (++iCtr), noOfSkus);

                if (taxonomy.NodeType == TaxonomyInfo.NodeTypeDerived)
                {
                    var originalTaxonomy = sku.Taxonomy;
                    var attributes       = GetExportAttributes(originalTaxonomy);
                    WriteAttributeDataToFile(sku, "Cross List", attributes);
                }
                else
                {
                    var attributes = GetExportAttributes(taxonomy);
                    WriteAttributeDataToFile(sku, TaxonomyInfo.NodeTypeRegular, attributes);
                }
            });

            StatusMessage = string.Format("{1}{0}({2} of {3})", Environment.NewLine, taxonomy, iCtr, noOfSkus);
        }
예제 #9
0
        //private void ProcessTaxonomyNodeTrail(TaxonomyInfo node)
        //{
        //    var nodeTrail = TaxonomyNodeAuditTrail.FromValue(node.ID);
        //    var nodeHistory = node.TaxonomyDatas;
        //    foreach (var td in nodeHistory)
        //        nodeTrail.TaxonomyNodeAuditTrailRecords.Add(TaxonomyNodeAuditTrailRecord.FromValues(td));
        //    var tmds = from tmi in node.TaxonomyMetaInfos
        //               from tmd in tmi.TaxonomyMetaDatas
        //               select tmd;
        //    foreach (var tmd in tmds)
        //    {
        //        var trailRecord = TaxonomyNodeAuditTrailRecord.FromValues(tmd);
        //        if (trailRecord != null)
        //            nodeTrail.TaxonomyNodeAuditTrailRecords.Add(trailRecord);
        //    }
        //    nodeTrail.TaxonomyNodeAuditTrailRecords.Sort(
        //        (t1, t2) => t1.AuditTrailTimestamp.Timestamp.CompareTo(t2.AuditTrailTimestamp.Timestamp));
        //    nodeTrail.TaxonomyNodeAuditTrailRecords[0].AuditTrailTimestamp.ActionType =
        //        TimestampRecordTypeActionType.Created;
        //    nodeTrail.SerializeObject(GetSaveFilePath("NodeHistory", node.ID.ToString()));
        //}

        private void ProcessTaxonomySchemas(TaxonomyInfo node)
        {
            try
            {
                var schemas = from sch in node.SchemaInfos
                              where sch.SchemaDatas.Any(sd => sd.Active)
                              orderby sch.Attribute.AttributeName
                              select sch;

                schemas.ForEach(ProcessSchema);

                //if (ExportAuditTrail)
                //    ProcessSchemaTrails(node);
            }
            catch (Exception exception)
            {
                var message = string.Empty;
                var ex      = exception;
                while (ex != null)
                {
                    message += ex.Message + Environment.NewLine;
                    message += ex.StackTrace + Environment.NewLine;
                    ex       = ex.InnerException;
                }
                CurrentLogWriter.Warn("There was a problem processing schema for node." + Environment.NewLine + message);
            }
        }
 public CompareColumnPropertyForDisplayOrder(TaxonomyInfo taxonomy, IDictionary <string, Attribute> allAttributes,
                                             bool sortNavigationOrders, bool sortDisplayOrders)
 {
     _taxonomy             = taxonomy;
     _allAttributes        = allAttributes;
     _sortNavigationOrders = sortNavigationOrders;
     _sortDisplayOrders    = sortDisplayOrders;
 }
예제 #11
0
        private void ProcessTaxonomyNode(TaxonomyInfo node)
        {
            StatusMessage = string.Format("Processing {0}", node);

            ProcessTaxonomySkus(node); //First SKUs, then Schema and LOV
            ProcessTaxonomySchemas(node);
            ProcessTaxonomyChildren(node);
        }
예제 #12
0
        private void ProcessTaxonomy(TaxonomyInfo taxonomy)
        {
            // get attributes for this taxonomy
            var toleranceTaxAttributes =
                (from si in taxonomy.SchemaInfos
                 let opt = (from smi in si.SchemaMetaInfos
                            where smi.Attribute.AttributeName.Equals("Is Optional")
                            from smd in smi.SchemaMetaDatas
                            where smd.Active
                            select smd.Value).FirstOrDefault()
                           let att = si.Attribute
                                     let tol =
                     (from smi in si.SchemaMetaInfos
                      where smi.Attribute.AttributeName.Equals(Tolerance)
                      from smd in smi.SchemaMetaDatas
                      where smd.Active
                      select smd.Value).FirstOrDefault()
                     let isOptional = opt != null && (opt.Equals("Yes"))
                                      select new ToleranceAttribute(att, tol, isOptional)).Where(t => !String.IsNullOrEmpty(t.Tolerance)).ToList();

            if (!toleranceTaxAttributes.Any())
            {
                return;
            }

            IQueryable <Sku> skuQuery = CurrentDb.Skus;

            foreach (var ta in toleranceTaxAttributes.Where(b => !b.IsOptional))
            {
                var attName = ta.Attr.AttributeName;
                skuQuery =
                    skuQuery.Where(
                        ei =>
                        ei.EntityInfos.Any(
                            e => e.EntityDatas.Any(ed => ed.Attribute.AttributeName == attName && ed.Active)));
            }

            var filteredSkus = skuQuery.Where(si => si.SkuInfos.FirstOrDefault(a => a.Active).TaxonomyID == taxonomy.ID).ToList();
            var nodeSkus     = taxonomy.SkuInfos.Where(s => s.Active).Select(s => s.Sku);

            var matchedSkus = new Dictionary <Sku, List <Sku> >();

            foreach (var sku in nodeSkus)
            {
                if (!filteredSkus.Contains(sku))
                {
                    continue;
                }
                AddToleratedSkus(toleranceTaxAttributes, filteredSkus, matchedSkus, sku);
            }

            WriteToleranceRows(matchedSkus);
            if (_args.ExportNif)
            {
                WriteInterchangeRecords(matchedSkus);
            }
        }
예제 #13
0
        private void ProcessTaxonomyChildren(TaxonomyInfo node)
        {
            var children = from td in node.ChildTaxonomyDatas where td.Active select td.TaxonomyInfo;

            foreach (var child in children)
            {
                ProcessTaxonomyNode(child);
            }
        }
예제 #14
0
파일: FrmTree.cs 프로젝트: ewin66/Arya
 public FrmTree(TaxonomyInfo defaultTaxonomy)
 {
     InitializeComponent();
     DisplayStyle.SetDefaultFont(this);
     Icon = Resources.AryaLogoIcon;
     skuViewToolStripMenuItem.Checked = true;
     taxonomyTree.ShowEnrichments     = false;
     taxonomyTree.SelectedTaxonomy    = defaultTaxonomy;
     OrderNodesBy = NodeOrder.NodeType;
 }
예제 #15
0
        public Taxonomy Deserialize(BasketRepository basketRepository, TaxonomyInfo taxonomyInfo)
        {
            var result = new Taxonomy(taxonomyInfo.Id);
            var xml    = taxonomyInfo.DefinitionXml;

            using (var reader = XmlReader.Create(new StringReader(xml)))
            {
                this.xmlDeserializer.ReadTaxonomy(basketRepository, reader, result);
            }
            return(result);
        }
예제 #16
0
        static void OpenInNewTab(TaxonomyInfo taxonomy)
        {
            var skuQuery = from si in AryaTools.Instance.InstanceData.Dc.SkuInfos
                           let sku = si.Sku
                                     where
                                     si.Active && sku.Project.Equals(AryaTools.Instance.InstanceData.CurrentProject) &&
                                     taxonomy.Equals(si.TaxonomyInfo)
                                     select sku;

            AryaTools.Instance.Forms.SkuForm.LoadTab(
                skuQuery, taxonomy, taxonomy.TaxonomyData.NodeName, taxonomy.ToString());
        }
예제 #17
0
        private string GetTaxPrefix(TaxonomyInfo tax)
        {
            var parts =
                tax.ToString().Split(new[] { TaxonomyInfo.Delimiter }, StringSplitOptions.RemoveEmptyEntries).ToList();
            var noOfLevels = GroupSkusBy == GroupSkusByNodeLevel.Level2
                ? 2
                : GroupSkusBy == GroupSkusByNodeLevel.Level2 ? 3 : 99;

            parts = parts.Take(noOfLevels).ToList();
            var taxPrefix = parts.Aggregate((full, current) => full + TaxonomyInfo.Delimiter + current);

            return(taxPrefix);
        }
예제 #18
0
        public void SetFormType(QueryFormType qft, TaxonomyInfo crossListNode = null)
        {
            _selectedCrossListNodeFromTreeView = crossListNode;

            switch (qft)
            {
            case QueryFormType.QueryView:
                Text = "Query View";
                btnCrossList.Visible        = false;
                txtBoxCrossListNode.Visible = false;
                break;

            case QueryFormType.CrossListDefinition:
                Text = "Cross List Definition";
                btnCrossList.Visible        = true;
                txtBoxCrossListNode.Visible = true;
                txtBoxCrossListNode.Text    = _selectedCrossListNodeFromTreeView.ToString();

                var derivedTaxonomy = _selectedCrossListNodeFromTreeView.DerivedTaxonomies.FirstOrDefault();
                if (derivedTaxonomy != null)
                {
                    PopulateQueryView(derivedTaxonomy.Expression.DeSerializeXElement());
                }
                //if (
                //    AryaTools.Instance.InstanceData.Dc.DerivedTaxonomies.Any(
                //        t => t.TaxonomyID == SelectedCrossListNodeFromTreeView.ID))
                //{
                //    var cl =
                //        AryaTools.Instance.InstanceData.Dc.DerivedTaxonomies.Where(
                //            t => t.TaxonomyID == SelectedCrossListNodeFromTreeView.ID).Select(ex => ex.Expression).
                //            Single().DeSerializeXElement();
                //    PopulateQueryView(cl);
                //}
                break;

            case QueryFormType.SkuGroup:
                Text = "Sku Group Definition";
                btnCrossList.Visible        = true;
                txtBoxCrossListNode.Visible = true;
                txtBoxCrossListNode.Text    = SelectedSkuGroupForQueryView.Criterion.Name.ToString();

                //var skuGroup = _selectedCrossListNodeFromTreeView.DerivedTaxonomies.FirstOrDefault();
                if (SelectedSkuGroupForQueryView.Criterion != null)
                {
                    PopulateQueryView(SelectedSkuGroupForQueryView.Criterion.DeSerializeXElement());
                    SelectedSkuGroupForQueryView = null;
                }

                break;
            }
        }
예제 #19
0
        private static object GetSortKey(TaxonomyInfo taxonomy, Attribute attribute, Field fieldName, Attribute metaAttribute, double defaultOrder)
        {
            if (fieldName == Field.MetaAttribute)
            {
                //return SchemaAttribute.GetValue(taxonomy, attribute, new SchemaAttribute
                return(SchemaAttribute.GetMetaAttributeValue(attribute, metaAttribute, taxonomy));
            }

            if (fieldName == Field.AttributeName)
            {
                return(attribute.AttributeName);
            }

            double navOrder  = defaultOrder;
            double dispOrder = defaultOrder;
            string dataType  = string.Empty;
            bool   inSchema  = false;

            try
            {
                var si = taxonomy.SchemaInfos.Where(a => a.Attribute == attribute).FirstOrDefault();
                var sd = si.SchemaDatas.Where(a => a.Active).FirstOrDefault();
                if (sd != null)
                {
                    navOrder  = (int)sd.NavigationOrder == 0 ? navOrder : (int)sd.NavigationOrder;
                    dispOrder = (int)sd.DisplayOrder == 0 ? dispOrder : (int)sd.DisplayOrder;
                    dataType  = sd.DataType;
                    inSchema  = sd.InSchema;
                }
            }
            catch
            {
            }

            switch (fieldName)
            {
            case Field.DisplayOrder:
                return(dispOrder);

            case Field.NavigationOrder:
                return(navOrder);

            case Field.DataType:
                return(dataType);

            case Field.InSchema:
                return(inSchema ? "Yes" : "No");
            }

            return(null); //Control should never get here!!!
        }
예제 #20
0
        private static NatalieTaxonomy GetTopNode(NatalieTaxonomy node, TaxonomyInfo ti)
        {
            if (ti.TaxonomyData.ParentTaxonomyInfo == null)
            {
                return(node);
            }

            var parentTaxonomy = ti.TaxonomyData.ParentTaxonomyInfo;
            var parent         = new NatalieTaxonomy {
                NodeName = parentTaxonomy.NodeName, Taxonomies = new[] { node }
            };

            return(GetTopNode(parent, parentTaxonomy));
        }
예제 #21
0
        public Taxonomy DeserializeTaxonomy(
            TaxonomyInfo taxonomyInfo,
            BasketRepository basketRepository,
            CountryRepository countryRepository
            )
        {
            var taxonomy = new Taxonomy(taxonomyInfo.Id);

            using (var reader = XmlReader.Create(new StringReader(taxonomyInfo.DefinitionXml)))
            {
                this.xmlDeserializer.DeserializeTaxonomy(reader, basketRepository, countryRepository, taxonomy);
            }
            return(taxonomy);
        }
예제 #22
0
        public FrmAttributeBuilder(string expression, int maxLength, IEnumerable <string> attributes,
                                   IEnumerable <Sku> sampleSkus, TaxonomyInfo sourceTaxonomy, bool isInherited,
                                   string derivedAttributeName = null) : this()
        {
            _sampleSkus                 = sampleSkus;
            AttributeExpression         = expression;
            MaxLength                   = maxLength;
            numUDExpressionLength.Value = MaxLength;
            attributes.OrderBy(att => att).ForEach(_attributeNames.Add);
            _sourceTaxonomy = sourceTaxonomy;

            var descriptionText = string.Empty;

            if (_sourceTaxonomy != null)
            {
                descriptionText = "Source Taxonomy:" + Environment.NewLine + sourceTaxonomy;
            }

            if (!string.IsNullOrEmpty(expression))
            {
                descriptionText += Enumerable.Repeat(Environment.NewLine, 2).Aggregate((a, b) => a + b) + "Expression:" +
                                   Environment.NewLine + expression + Environment.NewLine;
            }

            if (string.IsNullOrWhiteSpace(descriptionText) || string.IsNullOrWhiteSpace(expression))
            {
                lblExpressionDescription.Visible = false;
                btnAccept.Text                = Accept;
                dgvAttributes.Enabled         = true;
                dgvConstructs.Enabled         = true;
                numUDExpressionLength.Enabled = true;
            }
            else
            {
                lblExpressionDescription.Text = descriptionText;
                numUDExpressionLength.Enabled = false;
            }

            btnEditInherited.Visible = isInherited;

            if (!string.IsNullOrEmpty(derivedAttributeName))
            {
                Text = "Attribute Builder : " + derivedAttributeName.Trim();
            }
            else
            {
                Text = "Attribute Builder";
            }
        }
예제 #23
0
        //�Public�Methods�(1)�

        public bool ExecuteOnBuildView(TaxonomyInfo currentTaxonomy, Stack <EntityDataGridView.ChangeItem> undoHistory, bool createNewEntityDatas)
        {
            bool refreshColumns = false;

            if (!HasChange())
            {
                return(false);
            }

            List <EntityData> entityDatas = GetEntityDatas();
            List <Sku>        blanks      = GetBlanks();

            refreshColumns = ChangeOrCreateEntities(entityDatas, blanks, undoHistory, createNewEntityDatas);
            return(refreshColumns);
        }
        private void ProcessNodeComponents(TaxonomyInfo node)
        {
            // get list of SKUs for this taxonomy
            var allSkus = node.GetSkus(_args.ExportCrossListNodes);

            if (!allSkus.Any())
            {
                return;
            }

            // filter skus based on sku inclusions and exclusions, then include only Product skus.
            var skus = _args.GetFilteredSkuList(allSkus).ToList();

            ProcessSchema(node);
            ProcessSkus(node, skus);
        }
예제 #25
0
 private string GetColumnValue(AryaDbDataContext dc, TaxonomyInfo taxonomyInfo, string columnName)
 {
     if (_taxColumns.Contains(columnName))
     {
         if (columnName == "Taxonomy")
         {
             return(taxonomyInfo.ToString(Args.IgnoreT1Taxonomy));
         }
         return(GetTn(taxonomyInfo, columnName));
     }
     if (columnName == "NodeDescription")
     {
         return(taxonomyInfo.TaxonomyData.NodeDescription);
     }
     return(GetTaxMetaAttributeValue(dc, columnName, taxonomyInfo));
 }
예제 #26
0
        private void lnkLimitTaxonomyFromSearchResults_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var taxFilter = new List <TaxonomyInfo>();

            foreach (DataGridViewCell cell in dgvTaxonomyResults.SelectedCells)
            {
                TaxonomyInfo tax = ((SearchResult)cell.OwningRow.DataBoundItem).Taxonomy;
                if (!taxFilter.Contains(tax))
                {
                    taxFilter.Add(tax);
                }
            }

            TaxonomyFilters  = taxFilter;
            _includeChildren = false;
            PopulateSelection(TaxonomyFilters, _valueSelection, _includeChildren);
        }
예제 #27
0
        private string GetTn(TaxonomyInfo taxonomy, string columnName)
        {
            if (!_rxCol.IsMatch(columnName))
            {
                return(string.Empty);
            }

            var col       = _rxCol.Match(columnName).Value;
            var resultInt = int.Parse(col);
            var taxParts  = taxonomy.ToStringParts().ToList();

            if (Args.IgnoreT1Taxonomy)
            {
                taxParts.RemoveAt(0);
            }
            return(taxParts.Count >= resultInt ? taxParts[resultInt - 1] : string.Empty);
        }
예제 #28
0
        public string ProcessCalculatedAttribute(Attribute att, TaxonomyInfo tax,
                                                 bool getDefaultForNullTaxonomy = true)
        {
            if (tax == null)
            {
                var globalDerivedAttribute = att.DerivedAttributes.FirstOrDefault(p => p.TaxonomyID == Guid.Empty);

                if (globalDerivedAttribute != null)
                {
                    return(ProcessCalculatedAttribute(globalDerivedAttribute.Expression,
                                                      globalDerivedAttribute.MaxResultLength));
                }

                tax = _sku.Taxonomy;
                if (tax == null || !getDefaultForNullTaxonomy)
                {
                    return(String.Empty);
                }
            }

            var calculatedAttribute =
                att.DerivedAttributes.FirstOrDefault(da => da.TaxonomyInfo != null && da.TaxonomyID == tax.ID);

            if (calculatedAttribute == null && att.DerivedAttributes.Any(da => da.TaxonomyInfo == null))
            {
                calculatedAttribute = att.DerivedAttributes.First(da => da.TaxonomyInfo == null);
            }

            //I wonder why we are setting the calculatedAttribute to NULL if an Active InSchema SchemaData exists
            //if (calculatedAttribute != null)
            //{
            //    if (sourceTaxonomy != null)
            //    {
            //        var schemaInfo = sourceTaxonomy.SchemaInfos.SingleOrDefault(p => p.AttributeID == att.ID);
            //        if (schemaInfo != null && !schemaInfo.SchemaDatas.Any(sd => sd.Active && sd.InSchema))
            //            calculatedAttribute = null;
            //    }
            //}

            if (calculatedAttribute == null)
            {
                return(ProcessCalculatedAttribute(att, tax.TaxonomyData.ParentTaxonomyInfo, false));
            }

            return(ProcessCalculatedAttribute(calculatedAttribute.Expression, calculatedAttribute.MaxResultLength));
        }
예제 #29
0
        private IEnumerable <Attribute> GetAttributes(AryaDbDataContext dc, TaxonomyInfo currentTaxonomyInfo)
        {
            var attributes = new List <Attribute>();

            if (Args.LeafNodesOnly && !currentTaxonomyInfo.IsLeafNode)
            {
                return(attributes);
            }
            if (currentTaxonomyInfo.GetSkus(Args.ExportCrossListNodes).Any(t => t.SkuType == "Product") || Args.ExportEmptyNodes)
            {
                if (!currentTaxonomyInfo.IsLeafNode)
                {
                    var schemaInfos = new List <SchemaInfo>();
                    schemaInfos.AddRange(
                        currentTaxonomyInfo.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();

                    attributes = (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
                {
                    attributes = (from si in dc.SchemaInfos
                                  where si.TaxonomyID == currentTaxonomyInfo.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();
                }
                return(attributes);
            }


            return(attributes);
        }
예제 #30
0
파일: Validate.cs 프로젝트: ewin66/Arya
        public IEnumerable <string> GetLovs(Attribute attribute, TaxonomyInfo taxonomy, Sku sku = null)
        {
            if (attribute == null || taxonomy == null)
            {
                return(null);
            }

            IEnumerable <string> lov;
            var node = taxonomy;

            do
            {
                lov  = GetLovsForNode(attribute, node, sku);
                node = node.TaxonomyData.ParentTaxonomyInfo;
            } while (lov == null && node != null);

            return(lov);
        }