Пример #1
0
        public IList <WebAPIDto <T> > GetAll()
        {
            List <WebAPIDto <T> > items   = new List <WebAPIDto <T> >();
            ICollection <T>       results = null;

            foreach (IWebAPITenantConfiguration <T, TDao> configuration in _daoConfigurations)
            {
                try
                {
                    WebAPIImpersonatorFacade.ImpersonateDao <TDao, T>(configuration.Dao, (impersonationType, dao) =>
                    {
                        results = dao.GetAll();
                        items.AddRange(results.Select(s => _mapper.TransformDTO(s, configuration.Tenant)));
                    });
                }
                catch (Exception ex)
                {
                    FileLogger.Error(Logger, string.Format(ERROR_MESSAGE, "GetAll", configuration.Tenant.TenantName), ex);
                    throw new WebAPIException <List <WebAPIDto <T> > >(ex.Message, ex)
                          {
                              Results = items, TenantName = configuration.Tenant.TenantName
                          };
                }
            }
            return(items);
        }
Пример #2
0
        /// <summary>
        /// Crea la DoSearch con i metodi standard.
        /// Se non implementati, vengono usati quelli standard
        /// </summary>
        public ICollection <WebAPIDto <T> > DoSearch()
        {
            ICollection <WebAPIDto <T> > elements = CurrentTenantExecutionWebAPI <T>((tenant, results) =>
            {
                WebApiHttpClient httpClient   = GetWebAPIClient(tenant);
                IODATAQueryManager odataQuery = GetODataQuery();
                odataQuery = DecorateFinder(odataQuery);
                if (EnableTopOdata)
                {
                    odataQuery = odataQuery.Top(DocSuiteContext.Current.DefaultODataTopQuery);
                }
                odataQuery = AttachFilterExpressions(odataQuery);
                ODataModel <ICollection <T> > foundResults = httpClient.GetAsync <T>().WithRowQuery(odataQuery.Compile()).ResponseToModel <ODataModel <ICollection <T> > >();
                if (foundResults == null || foundResults.Value == null)
                {
                    return(new List <WebAPIDto <T> >());
                }
                foundResults.Value.ToList().ForEach(x => results.Add(_mapper.TransformDTO(x, tenant)));
                return(results);
            }, FinalizeDoSearch, "DoSearch");

            return(elements);
        }
Пример #3
0
        /// <summary>
        /// Crea la DoSearchHeader con i metodi standard.
        /// Se non implementati, vengono usati quelli standard
        /// </summary>
        public ICollection <WebAPIDto <THeader> > DoSearchHeader()
        {
            ICollection <WebAPIDto <THeader> > searchHeaderList = CurrentTenantExecutionWebAPI <THeader>((tenant, results) =>
            {
                WebApiHttpClient httpClient   = GetWebAPIClient(tenant);
                IODATAQueryManager odataQuery = GetODataQuery();
                odataQuery = DecorateFinder(odataQuery);
                if (EnableTopOdata)
                {
                    odataQuery = odataQuery.Top(DocSuiteContext.Current.DefaultODataTopQuery);
                }
                odataQuery = AttachFilterExpressions(odataQuery);
                SetProjectionsHeaders(httpClient, odataQuery).ToList().ForEach(x => results.Add(_headerMapper.TransformDTO(x, tenant)));
                return(results);
            }, FinalizeDoSearchHeader, "DoSearchHeader");

            return(searchHeaderList);
        }