Пример #1
0
 /// <summary>
 /// Bulig error message
 /// </summary>
 /// <param name="res"></param>
 /// <param name="obj"></param>
 /// <param name="param"></param>
 /// <param name="first_message"></param>
 /// <returns></returns>
 public static ObjectResultData BuildErrorMessage(ObjectResultData res, object[] obj, MessageParameter param = null, bool first_message = true)
 {
     try
     {
         ValidatorUtil validator = new ValidatorUtil();
         return(BuildErrorMessage(res, validator, obj, param, first_message));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        /// <summary>
        /// Bulig error message
        /// </summary>
        /// <param name="res"></param>
        /// <param name="validator"></param>
        /// <param name="obj"></param>
        /// <param name="param"></param>
        /// <param name="first_message"></param>
        /// <returns></returns>
        public static ObjectResultData BuildErrorMessage(ObjectResultData res, ValidatorUtil validator, object[] obj = null, MessageParameter param = null, bool first_message = true)
        {
            try
            {
                if (obj != null)
                {
                    foreach (object o in obj)
                    {
                        if (o != null)
                        {
                            validator.Validate(o);
                            validator.ValidateAtLeast1Field(o);
                        }
                    }
                }
                if (validator.IsValid == false)
                {
                    List <ValidateMessage> msgLst = validator.ConvertToMessage();
                    foreach (ValidateMessage msg in msgLst)
                    {
                        string[] pm = null;
                        if (param != null)
                        {
                            pm = param.GetParameter(msg.Code);
                        }
                        else if (msg.Params != null)
                        {
                            pm = new string[] { CommonUtil.TextList(msg.Params.ToArray()) }
                        }
                        ;

                        MessageUtil.MessageList msgCode;
                        if (Enum.TryParse <MessageUtil.MessageList>(msg.Code, out msgCode))
                        {
                            res.AddErrorMessage(msg.Controller, msg.Screen, msg.Module, msgCode, pm, msg.Controls == null ? null : msg.Controls.ToArray());
                        }

                        if (first_message == true)
                        {
                            break;
                        }
                    }
                }

                return(res);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
 /// <summary>
 /// Bulig error message
 /// </summary>
 /// <param name="res"></param>
 /// <param name="controller"></param>
 /// <param name="obj"></param>
 /// <param name="param"></param>
 /// <param name="first_message"></param>
 /// <returns></returns>
 public static ObjectResultData BuildErrorMessage(ObjectResultData res, Controller controller, object[] obj = null, MessageParameter param = null, bool first_message = true)
 {
     try
     {
         if (controller == null)
         {
             return(null);
         }
         ValidatorUtil validator = new ValidatorUtil(controller);
         return(BuildErrorMessage(res, validator, obj, param, first_message));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
        /// <summary>
        /// Bulig error message
        /// </summary>
        /// <param name="validator"></param>
        /// <param name="obj"></param>
        /// <param name="param"></param>
        /// <param name="first_message"></param>
        /// <returns></returns>
        public static ObjectResultData BuildErrorMessage(ValidatorUtil validator, object[] obj, MessageParameter param = null, bool first_message = true)
        {
            try
            {
                ObjectResultData result = new ObjectResultData();
                BuildErrorMessage(result, validator, obj, param, first_message);

                if (result.IsError == false)
                {
                    return(null);
                }

                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }