public override StandardReturType ValidateInput()
        {
            if (Input == null)
            {
                return(StandardReturType.NullInput());
            }
            foreach (var dp in Input)
            {
                if (dp == null || string.IsNullOrEmpty(dp.TypeName) || dp.Attributes == null)
                {
                    return(StandardReturType.NullInput());
                }

                var dataProvider = Reflection.CreateInstance <IExternalDataProvider>(dp.TypeName);
                if (dataProvider == null)
                {
                    return(StandardReturType.UnknownObject(dp.TypeName));
                }
                var propNames = dataProvider.ConfigurationKeys;
                foreach (var propInfo in propNames)
                {
                    var propName = propInfo.Name;
                    var prop     = dp.Attributes.FirstOrDefault(p => p.Name.ToLower() == propName.ToLower());
                    if (prop == null || (propInfo.Required && string.IsNullOrEmpty(prop.Value)))
                    {
                        return(StandardReturType.NullInput(propName));
                    }
                }
            }
            return(StandardReturType.OK());
        }
        public static StandardReturType ValidateChannel(ChannelBaseType notificationChannel)
        {
            if (notificationChannel == null)
            {
                return(StandardReturType.NullInput("NotificationChannel"));
            }

            if (notificationChannel is WebServiceChannelType)
            {
                if (string.IsNullOrEmpty((notificationChannel as WebServiceChannelType).WebServiceUrl))
                {
                    return(StandardReturType.NullInput("WebServiceUrl"));
                }
            }
            else if (notificationChannel is FileShareChannelType)
            {
                if (string.IsNullOrEmpty((notificationChannel as FileShareChannelType).Path))
                {
                    return(StandardReturType.NullInput("Path"));
                }
            }
            else
            {
                return(StandardReturType.UnknownObject("Unknown channel type"));
            }

            var dbChannel = Data.Channel.FromXmlType(notificationChannel);

            if (dbChannel == null)
            {
                return(StandardReturType.UnknownObject("NotificationChannel"));
            }

            var channel = Notifications.Channel.Create(dbChannel);

            try
            {
                if (channel == null || !channel.IsAlive())
                {
                    // TODO: Call StandardReturType.UnreachableChannel()
                    return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, "Unreachable channel"));
                }
            }
            catch (Exception ex)
            {
                Engine.Local.Admin.LogException(ex);
                // TODO: Call StandardReturType.UnreachableChannel()
                return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, "Unreachable channel"));
            }
            return(StandardReturType.OK());
        }
        public override StandardReturType ValidateInput()
        {
            if (string.IsNullOrEmpty(string.Format("{0}", TargetApplicationToken).Trim()))
            {
                return(StandardReturType.NullInput());
            }

            using (ApplicationDataContext context = new ApplicationDataContext())
            {
                var application = context.Applications.SingleOrDefault(app => app.Token == TargetApplicationToken);
                if (application == null)
                {
                    return(StandardReturType.UnknownObject("AppToken", TargetApplicationToken));
                }
            }
            return(StandardReturType.OK());
        }