コード例 #1
0
ファイル: WonkaPrdExtensions.cs プロジェクト: anegg0/Wonka
        public static void SetAttribute(this WonkaProduct poTargetProduct, WonkaRefAttr poTargetAttr, string psTargetValue)
        {
            if (poTargetProduct.GetProductGroup(poTargetAttr.GroupId).GetRowCount() <= 0)
            {
                poTargetProduct.GetProductGroup(poTargetAttr.GroupId).AppendRow();
            }

            poTargetProduct.GetProductGroup(poTargetAttr.GroupId)[0][poTargetAttr.AttrId] = psTargetValue;
        }
コード例 #2
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
        public WonkaProductEnumerator(WonkaProduct poProduct)
        {
            if (poProduct == null)
            {
                throw new Exception("ERROR!  Product provided is null.");
            }

            moProduct = poProduct;
            moGrpEnum = moProduct.ProductGroups.GetEnumerator();
        }
コード例 #3
0
        public static bool SetAttribute(this WonkaProduct poTargetProduct, WonkaRefAttr poTargetAttr, string psTargetValue)
        {
            bool bSuccess = true;

            if (poTargetProduct.GetProductGroup(poTargetAttr.GroupId).GetRowCount() <= 0)
            {
                poTargetProduct.GetProductGroup(poTargetAttr.GroupId).AppendRow();
            }

            poTargetProduct.GetProductGroup(poTargetAttr.GroupId)[0][poTargetAttr.AttrId] = psTargetValue;

            return(bSuccess);
        }
コード例 #4
0
        public static string GetAttributeValue(this WonkaProduct poTargetProduct, WonkaRefAttr poTargetAttr)
        {
            string sAttrValue = "";

            if (poTargetProduct.HasProductGroup(poTargetAttr.GroupId))
            {
                if (poTargetProduct.GetProductGroup(poTargetAttr.GroupId)[0].ContainsKey(poTargetAttr.AttrId))
                {
                    sAttrValue = poTargetProduct.GetProductGroup(poTargetAttr.GroupId)[0][poTargetAttr.AttrId];
                }
            }

            return(sAttrValue);
        }
コード例 #5
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
        /// <summary>
        ///
        /// This method will update all contents of this Product with those of the provided one.
        ///
        /// <param name="poThatProduct">The Product from which we will copy our sought data</param>
        /// <param name="pbMergeFlag">Indicator of whether the provided data should completely overlay or merge with the contents of this Product</param>
        /// <returns>None</returns>
        /// </summary>
        public void Update(WonkaProduct ThatProduct, bool pbMergeFlag = true)
        {
            if (pbMergeFlag)
            {
                foreach (WonkaPrdGroup ThatPrdGroup in ThatProduct)
                {
                    this.Update(ThatPrdGroup, pbMergeFlag);
                }

                var iThatProductField = ThatProduct.ProductFieldIndex.GetEnumerator();
                while (iThatProductField.MoveNext())
                {
                    WonkaProductField ThatProductField = iThatProductField.Current.Value;

                    if (this.ProductFieldIndex.Keys.Contains(ThatProductField.FieldId))
                    {
                        this.ProductFieldIndex[ThatProductField.FieldId] = ThatProductField;
                    }
                }
            }
            else
            {
                ClearData();

                foreach (WonkaPrdGroup ThatPrdGroup in ThatProduct)
                {
                    this.Update(ThatPrdGroup, pbMergeFlag);
                }

                ClearFields();

                this.ProductFieldIndex = ThatProduct.ProductFieldIndex;
            }

            ClearErrors();
            this.ProductErrors = ThatProduct.ProductErrors;

            this.ResequenceGroups = ThatProduct.ResequenceGroups;

            this.IsAppendFasttrackEnabled = ThatProduct.IsAppendFasttrackEnabled;
            this.IsBatch = ThatProduct.IsBatch;
            this.IsGroupAppendEnabled  = ThatProduct.IsGroupAppendEnabled;
            this.IsGroupReplaceEnabled = ThatProduct.IsGroupReplaceEnabled;
            this.ProductId             = ThatProduct.ProductId;

            this.OwnerSourceIds = ThatProduct.OwnerSourceIds;
            this.TransactionId  = ThatProduct.TransactionId;
        }
コード例 #6
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
        /// <summary>
        ///
        /// This method will iterate through a list of Products and nullify (i.e., assign an empty value)
        /// every Attribute indicated in the TargetAttributes list.
        ///
        /// NOTE: This method will nullify Attributes only for the first DataRow of the Group.
        ///
        /// <param name="poProducts">The product list that we are iterating through</param>
        /// <param name="poTargetAttributes">The Attributes that we intend to nullify</param>
        /// <returns>None</returns>
        /// </summary>
        public static void Nullify(List <WonkaProduct> poProducts, HashSet <int> poTargetAttributes)
        {
            string sNullifyValue = "";

            Dictionary <int, string> ApplyValues = new Dictionary <int, string>();

            foreach (int nTempAttrId in poTargetAttributes)
            {
                ApplyValues[nTempAttrId] = sNullifyValue;
            }

            foreach (WonkaProduct TempProduct in poProducts)
            {
                WonkaProduct.PopulateProduct(TempProduct, ApplyValues);
            }
        }
コード例 #7
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
        /// <summary>
        ///
        /// This method will assign the Attribute values for a new DataRow
        /// created for their respective Group.
        ///
        /// <param name="poProduct">The Product that we are assigning these Attribute values</param>
        /// <param name="poAttrValues">The Attribute values that we are going to set inside the provided Product</param>
        /// <returns>None</returns>
        /// </summary>
        public static void PopulateProductGroup(WonkaProduct poProduct, int pnGroupId, Dictionary <int, string> poAttrValues)
        {
            WonkaPrdGroup        TempPrdGroup = poProduct.ProductGroups[pnGroupId];
            WonkaPrdGroupDataRow TempDataRow  = TempPrdGroup.AppendRow();

            var iAttrValueEnum = poAttrValues.GetEnumerator();

            while (iAttrValueEnum.MoveNext())
            {
                int    nAttrId    = iAttrValueEnum.Current.Key;
                string sAttrValue = iAttrValueEnum.Current.Value;

                WonkaRefAttr TempAttribute = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nAttrId);

                if (TempAttribute.GroupId != pnGroupId)
                {
                    continue;
                }

                TempDataRow.SetData(nAttrId, sAttrValue);
            }
        }
コード例 #8
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
        /// <summary>
        ///
        /// This method will assign the Attribute values specifically to the first DataRow
        /// of their respective Group.
        ///
        /// NOTE: This method will nullify Attributes only for the first DataRow of the Group.
        ///
        /// <param name="poProduct">The Product that we are assigning these Attribute values</param>
        /// <param name="poAttrValues">The Attribute values that we are going to set inside the provided Product</param>
        /// <returns>None</returns>
        /// </summary>
        public static void PopulateProduct(WonkaProduct poProduct, Dictionary <int, string> poAttrValues)
        {
            var iAttrValueEnum = poAttrValues.GetEnumerator();

            while (iAttrValueEnum.MoveNext())
            {
                int    nAttrId    = iAttrValueEnum.Current.Key;
                string sAttrValue = iAttrValueEnum.Current.Value;

                WonkaRefAttr  TempAttribute = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nAttrId);
                WonkaPrdGroup TempPrdGroup  = poProduct.ProductGroups[TempAttribute.GroupId];

                if (TempPrdGroup.GetRowCount() <= 0)
                {
                    TempPrdGroup.AppendRow();
                }

                WonkaPrdGroupDataRow GrpDataRow = TempPrdGroup.GetRow(0);

                GrpDataRow.SetData(nAttrId, sAttrValue);
            }
        }
コード例 #9
0
ファイル: WonkaProduct.cs プロジェクト: crazyants/Wonka
 public WonkaProduct(WonkaProduct poThatProduct) : this()
 {
     Update(poThatProduct);
 }