示例#1
0
        /// <summary>
        ///
        /// This method will apply the arithmetic 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;

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

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

            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!");
            }

            string sTargetData =
                TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId);

            if (sTargetData == null)
            {
                sTargetData = string.Empty;
            }

            RefreshCache(poTransactionRecord, poCurrentRecord);

            WonkaPrdGroup TempProductGroup = null;

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

            TempProductGroup[0][nAttrId] = Convert.ToString(CalculateValue());

            if (poErrorMessage != null)
            {
                poErrorMessage.Clear();
                poErrorMessage.Append(GetVerboseError(TargetRecord));
            }

            return(bResult);
        }
示例#2
0
        /// <summary>
        ///
        /// This method will apply the domain 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;

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

            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!");
            }

            string sTargetData =
                TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId);

            if (sTargetData == null)
            {
                sTargetData = "";
            }

            RefreshCache(poTransactionRecord, poCurrentRecord);

            if (DomainCache.Contains(sTargetData))
            {
                bResult = true;
            }
            else
            {
                bResult = false;
            }

            if (poErrorMessage != null)
            {
                poErrorMessage.Clear();
                poErrorMessage.Append(GetVerboseError(TargetRecord));
            }

            return(bResult);
        }
示例#3
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;

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

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

            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!");
            }

            string sTargetData =
                TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId);

            if (sTargetData == null)
            {
                sTargetData = string.Empty;
            }

            RefreshCache(poTransactionRecord, poCurrentRecord);

            WonkaPrdGroup TempProductGroup = null;

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

            if ((CustomOpDelegate == null) && (CustomOpSource.CustomOpDelegate != null))
            {
                CustomOpDelegate = CustomOpSource.CustomOpDelegate;
            }

            if (CustomOpDelegate != null)
            {
                string[] CustomOpArgs = new string[4];

                for (int idx = 0; idx < 4; ++idx)
                {
                    if (idx < DomainCache.Count())
                    {
                        CustomOpArgs[idx] = DomainCache.ElementAt(idx);
                    }
                    else
                    {
                        CustomOpArgs[idx] = string.Empty;
                    }
                }

                string sCustomOpResult =
                    CustomOpDelegate(CustomOpArgs[0], CustomOpArgs[1], CustomOpArgs[2], CustomOpArgs[3]);

                // NOTE: If the result is empty, we consider the rule's invocation as a failure
                if (!String.IsNullOrEmpty(sCustomOpResult))
                {
                    TempProductGroup[0][nAttrId] = sCustomOpResult;
                    bResult = true;
                }

                if (poErrorMessage != null)
                {
                    poErrorMessage.Clear();
                    poErrorMessage.Append(GetVerboseError(TargetRecord));
                }
            }

            return(bResult);
        }
示例#4
0
        /// <summary>
        ///
        /// This method will apply the arithmetic limit rule to either the incoming 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., the already existing record)</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;

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

            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!");
            }

            string sTargetData =
                TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId);

            if (!String.IsNullOrEmpty(sTargetData))
            {
                RefreshMinAndMax(poTransactionRecord, poCurrentRecord);

                try
                {
                    double dTargetValue = Convert.ToDouble(sTargetData);

                    if ((this.MaxValue >= dTargetValue) && (dTargetValue >= this.MinValue))
                    {
                        bResult = true;
                    }
                    else
                    {
                        bResult = false;
                    }

                    if (poErrorMessage != null)
                    {
                        poErrorMessage.Clear();
                        poErrorMessage.Append(GetVerboseError(TargetRecord));
                    }
                }
                catch (Exception ex)
                {
                    bResult = false;

                    if (poErrorMessage != null)
                    {
                        poErrorMessage.Clear();
                        poErrorMessage.Append(ex.ToString());
                    }
                }
            }

            return(bResult);
        }