コード例 #1
0
        /// <summary>
        /// Fire Model Change.
        ///	Call modelChange method of added validators
        /// </summary>
        /// <param name="po">persistent objects</param>
        /// <param name="changeType">ModalValidatorVariables.CHANGETYPE_*</param>
        /// <returns>error message or NULL for no veto</returns>
        public String FireModelChange(PO po, int changeType)
        {
            if (po == null || _modelChangeListeners.Count == 0)
            {
                return(null);
            }
            //
            String propertyName        = po.Get_TableName() + po.GetAD_Client_ID();
            List <ModelValidator> list = null;

            if (_modelChangeListeners.ContainsKey(propertyName))
            {
                list = new List <ModelValidator>();
                list = _modelChangeListeners[propertyName];
            }
            if (list == null || list.Count == 0)
            {
                return(null);
            }

            //
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    ModelValidator validator = (ModelValidator)list[i];
                    if (validator.GetAD_Client_ID() == po.GetAD_Client_ID())
                    {
                        String error = validator.ModelChange(po, changeType);
                        if (error != null && error.Length > 0)
                        {
                            return(error);
                        }
                    }
                }
                catch (Exception e)
                {
                    String error = e.Message;
                    if (error == null)
                    {
                        error = e.ToString();
                    }
                    return(error);
                }
            }
            return(null);
        }