Ejemplo n.º 1
0
        public static StandardReturType Validate <TOutput, TItem>(FacadeMethodInfo <TOutput, TItem> facade) where TOutput : class, IBasicOutput <TItem>, new()
        {
            // Initialize context
            try
            {
                BrokerContext.Initialize(facade.ApplicationToken, facade.UserToken);
            }
            catch (Exception ex)
            {
                return(StandardReturType.InvalidApplicationToken(facade.ApplicationToken));
            }

            // Validate
            StandardReturType validationRet = facade.ValidateInput();

            if (!StandardReturType.IsSucceeded(validationRet))
            {
                Local.Admin.AddNewLog(TraceEventType.Error, BrokerContext.Current.WebMethodMessageName, TextMessages.InvalidInput, null, null);
                if (validationRet == null)
                {
                    validationRet = StandardReturType.UnspecifiedError("Validation failed");
                }
                return(validationRet);
            }
            return(StandardReturType.OK());
        }
Ejemplo n.º 2
0
        public virtual StandardReturType BaseValidate <TOutput>(MethodHeader header, TInputElement[] input)
        {
            // Initialize context
            try
            {
                BrokerContext.Initialize(header.ApplicationToken, header.UserToken);
            }
            catch (Exception ex)
            {
                return(StandardReturType.InvalidApplicationToken(header.ApplicationToken));
            }

            // Validate input
            if (input == null || input.Length == 0)
            {
                return(StandardReturType.NullInput());
            }

            var ret = Validate(input);

            if (ret == null)
            {
                ret = StandardReturType.UnspecifiedError("Validation failed");
            }

            return(ret);
        }