Пример #1
0
 public StandardReturType CreateDataProviders(ProviderMethod <TInputElement, TOutputElement, Element, object, TInterface> providerMethod, out IEnumerable <TInterface> dataProviders)
 {
     dataProviders = providerMethod.CreateDataProviders(this.LocalDataProviderOption);
     if (dataProviders == null || dataProviders.FirstOrDefault() == null)
     {
         Local.Admin.AddNewLog(TraceEventType.Warning, BrokerContext.Current.WebMethodMessageName, TextMessages.NoDataProvidersFound, null, null);
         return(StandardReturType.Create(HttpErrorCode.DATASOURCE_UNAVAILABLE));
     }
     return(StandardReturType.OK());
 }
Пример #2
0
        /// <summary>
        /// Gets the result for an array of input items
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="header">Header tokens</param>
        /// <param name="input">Array of input items</param>
        /// <returns>Composite result for the operation</returns>
        public TOutput GetBatch <TOutput>(MethodHeader header, TInputElement[] input)
            where TOutput : IBasicOutput <TOutputElement[]>, new()
        {
            try
            {
                // Validate
                var ret = BaseValidate <TOutput>(header, input);

                if (!StandardReturType.IsSucceeded(ret))
                {
                    return new TOutput()
                           {
                               StandardRetur = ret
                           }
                }
                ;

                // Data providers
                IEnumerable <TInterface> dataProviders;
                // TODO: Create an execution plan here
                var providerMethod = new ProviderMethod <TInputElement, TOutputElement, Element, object, TInterface>();

                ret = CreateDataProviders(providerMethod, out dataProviders);

                if (!StandardReturType.IsSucceeded(ret))
                {
                    return new TOutput()
                           {
                               StandardRetur = ret
                           }
                }
                ;

                // Call data providers
                var allElements = providerMethod.CallDataProviders(dataProviders, input);

                // Aggregate
                return(Aggregate <TOutput>(allElements));
            }
            catch (Exception ex)
            {
                Local.Admin.LogException(ex);
                return(new TOutput()
                {
                    StandardRetur = StandardReturType.UnspecifiedError()
                });
            }
        }
Пример #3
0
        public RegistreringType1[] Run(IDataProvider[] dataProviders, string[] input)
        {
            //ConnectinPoint<string,int> conn = (s)=> 0;

            var uuidCaller = new ProviderMethod <string, PersonIdentifier, Element <string, PersonIdentifier>, object, IReversePersonMappingDataProvider>();
            var readCaller = new ProviderMethod <PersonIdentifier, RegistreringType1, Element <PersonIdentifier, RegistreringType1>, ApplicationHeader, IReadDataProvider>();
            var nonCaller  = new ProviderMethod <RegistreringType1, RegistreringType1, Element <RegistreringType1, RegistreringType1>, object, INon>();
            var geoCaller  = new ProviderMethod <AdresseType, GeographicCoordinateTupleType, Element <AdresseType, GeographicCoordinateTupleType>, object, IGeoLocator>();


            var ret = uuidCaller
                      .Cascade <RegistreringType1>(input, dataProviders, readCaller);

            var ret2 = uuidCaller
                       .MethodExpression(dataProviders, input)
                       .Cascade <string, PersonIdentifier, PersonIdentifier, RegistreringType1>(dataProviders, readCaller, s => s)
                       .Cascade <string, RegistreringType1, RegistreringType1, RegistreringType1>(dataProviders, nonCaller, s => s);

            return(null);
        }