protected Resolution GetResolution(Guid uniqueId) { try { SetEntityODATA <Resolution>(ODATA_RESOLUTION_CONTROLLER_NAME); ODataModel <Resolution> result = _httpClient.GetAsync <Resolution>().WithOData(string.Concat("$filter=UniqueId eq ", uniqueId)).ResponseToModel <ODataModel <Resolution> >(); return(result == null || result.Value == null || !result.Value.Any() ? null : result.Value.Single()); } catch (Exception ex) { throw ex; } }
public override int Count() { return(CurrentTenantExecutionWebAPI <Tenant, int>((tenant) => { WebApiHttpClient httpClient = GetWebAPIClient(CurrentTenant); string result = httpClient.GetAsync <Tenant>().WithRowQuery("/$count").ResponseToString(); return int.Parse(result); }, nameof(Count))); }
/// <summary> /// Applica le espressioni di trasformata del risultato /// </summary> public virtual IEnumerable <THeader> SetProjectionsHeaders(WebApiHttpClient httpClient, IODATAQueryManager odataQuery) { ODataModel <ICollection <THeader> > foundResults = httpClient.GetAsync <T>().WithRowQuery(odataQuery.Compile()).ResponseToModel <ODataModel <ICollection <THeader> > >(); if (foundResults == null || foundResults.Value == null) { return(Enumerable.Empty <THeader>()); } return(foundResults.Value); }
protected DocumentUnit GetProtocolId(Guid idArchiveChain) { try { SetEntityODATA <DocumentUnitChain>(ODATA_DOCUMENTUNITCHAIN_CONTROLLER_NAME); ODataModel <DocumentUnitChain> result = _httpClient.GetAsync <DocumentUnitChain>().WithOData(string.Concat("$filter=IdArchiveChain eq ", idArchiveChain, " and DocumentUnit/Environment eq 1&$expand=DocumentUnit&$select=DocumentUnit")).ResponseToModel <ODataModel <DocumentUnitChain> >(); return(result == null || result.Value == null || !result.Value.Any() ? null : result.Value.Single().DocumentUnit); } catch (Exception ex) { FileLogger.Error(LogName.WebAPIClientLog, ex.Message, ex); throw ex; } }
/// <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); }
public async Task <UDSRepository> GetCurrentUDSRepositoryAsync(string udsRepositoryName) { return(await ExecuteHelper(async() => { _httpClient.SetEntityODATA <UDSRepository>(); ODataModel <UDSRepository> currentRepository = (await _httpClient.GetAsync <UDSRepository>() .WithOData(string.Concat("$filter=Name eq \'", udsRepositoryName, "\' and ExpiredDate eq null and Status eq VecompSoftware.DocSuiteWeb.Entity.UDS.UDSRepositoryStatus\'", DocSuiteWeb.Entity.UDS.UDSRepositoryStatus.Confirmed, "\'&$orderby=version desc")) .ResponseToModelAsync <ODataModel <UDSRepository> >()); return currentRepository == null || currentRepository.Value == null || !currentRepository.Value.Any() ? null : currentRepository.Value.Single(); }, $"WebAPIClient.GetCurrentUDSRepositoryAsync -> GET entities error")); }