Пример #1
0
        /// <summary>
        ///
        /// This method will serialize a ProductGroup within a Product instance.
        ///
        /// </summary>
        /// <param name="poTmpPrdGroup">The target ProductGroup being serialized</param>
        /// <param name="poProductListBuilder">The buffer that is holding the written WONKA-XML message</param>
        /// <returns>None</returns>
        private void AppendProductGroup(WonkaPrdGroup poTmpPrdGroup, StringBuilder poProductListBuilder)
        {
            WonkaRefEnvironment WonkaRefEnv = WonkaRefEnvironment.GetInstance();

            if (poTmpPrdGroup.GetRowCount() > 0)
            {
                string sTmpAttrValue = null;

                foreach (WonkaPrdGroupDataRow TempDataRow in poTmpPrdGroup)
                {
                    poProductListBuilder.Append("\n      <" + poTmpPrdGroup.MasterGroup.GroupName + ">");

                    foreach (int nTmpAttrId in TempDataRow.Keys)
                    {
                        sTmpAttrValue = TempDataRow[nTmpAttrId];

                        if (!String.IsNullOrEmpty(sTmpAttrValue))
                        {
                            WonkaRefAttr TempAttribute = WonkaRefEnv.GetAttributeByAttrId(nTmpAttrId);

                            poProductListBuilder.Append("\n        <" + TempAttribute.AttrName + ">");
                            poProductListBuilder.Append(WrapWithCData(sTmpAttrValue));
                            poProductListBuilder.Append("</" + TempAttribute.AttrName + ">");
                        }
                    }

                    poProductListBuilder.Append("\n      </" + poTmpPrdGroup.MasterGroup.GroupName + ">");
                }
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// This method will apply the assignment rule to either the transaction record or the current (i.e., database)
        /// record, using the other record as a reference.
        ///
        /// <param name="poTransactionRecord">The incoming record</param>
        /// <param name="poCurrentRecord">The current record (i.e., in the database)</param>
        /// <param name="poErrorMessage">The buffer that will contain an error message if the rule fails</param>
        /// <returns>Indicates whether or not the target product passed the rule successfully</returns>
        /// </summary>
        public override bool Execute(WonkaProduct poTransactionRecord,
                                     WonkaProduct poCurrentRecord,
                                     StringBuilder poErrorMessage)
        {
            bool bResult      = false;
            bool bAssignValue = true;

            int nAttrId  = TargetAttribute.AttrId;
            int nGroupId = TargetAttribute.GroupId;

            WonkaProduct        TargetRecord = null;
            WonkaRefEnvironment WonkaRefEnv  = WonkaRefEnvironment.GetInstance();

            if (poTransactionRecord == null)
            {
                throw new Exception("ERROR!  The new Product is null.");
            }

            if (poCurrentRecord == null)
            {
                throw new Exception("ERROR!  The old Product is null.");
            }

            if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD)
            {
                TargetRecord = poTransactionRecord;
            }
            else if (RecordOfInterest == TARGET_RECORD.TRID_OLD_RECORD)
            {
                TargetRecord = poCurrentRecord;
            }
            else
            {
                throw new Exception("ERROR!  The target record is none!");
            }

            if (DefaultAssignment)
            {
                WonkaPrdGroup TempProductGroup = null;

                if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD)
                {
                    TempProductGroup = poTransactionRecord.GetProductGroup(nGroupId);
                }
                else
                {
                    TempProductGroup = poCurrentRecord.GetProductGroup(nGroupId);
                }

                string sCurrentValue = string.Empty;

                if (TempProductGroup.GetRowCount() > 0)
                {
                    if (TempProductGroup[0].ContainsKey(nAttrId))
                    {
                        sCurrentValue = TempProductGroup[0][nAttrId];
                    }
                }

                if (!string.IsNullOrEmpty(sCurrentValue))
                {
                    bAssignValue = false;
                }
            }

            if (bAssignValue)
            {
                RefreshAssignValue(poTransactionRecord, poCurrentRecord);

                WonkaPrdGroup TempProductGroup = null;

                if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD)
                {
                    TempProductGroup = poTransactionRecord.GetProductGroup(nGroupId);
                }
                else
                {
                    TempProductGroup = poCurrentRecord.GetProductGroup(nGroupId);
                }

                TempProductGroup[0][nAttrId] = AssignValue;
            }

            return(bResult);
        }