Ejemplo n.º 1
0
        /// <summary>
        ///
        /// This method will return the sought ProductField of this Product, if one is already present.
        /// If it is not present, it will create one by default and return it after inserting into
        /// our collection.
        ///
        /// <param name="poField">The Field representing the ProductField that we want to retrieve</param>
        /// <returns>The ProductField that we want to retrieve from this Product</returns>
        /// </summary>
        public WonkaProductCadre GetProductField(WonkaRefCadre poField)
        {
            WonkaProductCadre SoughtField = null;

            if (ProductCadreIndex.Keys.Contains(poField.CadreId))
            {
                SoughtField = ProductCadreIndex[poField.CadreId];
            }
            else if (WonkaRefEnvironment.GetInstance().DoesFieldExist(poField.CadreId))
            {
                ProductCadreIndex[poField.CadreId] = new WonkaProductCadre();

                SoughtField = ProductCadreIndex[poField.CadreId];

                SoughtField.ProductId = this.ProductId;
                SoughtField.CadreId   = poField.CadreId;
                SoughtField.LockCd    = "N";

                SoughtField.LastTouchedSourceId =
                    (this.OwnerSourceIds != null) && (this.OwnerSourceIds.Count > 0) ? this.OwnerSourceIds.ElementAt(0) : 0;
            }
            else
            {
                throw new Exception("ERROR!  WonkaProduct::getProductField(const WonkaRefField&) : " +
                                    "Requested field does not exist: (" + poField.CadreName + ").");
            }

            return(SoughtField);
        }
Ejemplo n.º 2
0
        /// <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.ProductCadreIndex.GetEnumerator();
                while (iThatProductField.MoveNext())
                {
                    WonkaProductCadre ThatProductField = iThatProductField.Current.Value;

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

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

                ClearFields();

                this.ProductCadreIndex = ThatProduct.ProductCadreIndex;
            }

            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;
        }