IQA
Simple IQA query
Example of getting IQA results via SOA.
using Asi.Soa.ClientServices;
using Asi.Soa.Core.DataContracts;
EntityManager entityManager = new EntityManager();
string queryPath = "$/Common/Queries/Search/Contact/All";
var queryData = new QueryData("IQA");
queryData.AddCriteria(CriteriaData.Equal("QueryName", queryPath));
FindResultsData findResultsData = entityManager.Find(queryData);
if (findResultsData.Result.Count > 0)
{
GenericEntityData genericEntityData = findResultsData.Result[0] as GenericEntityData;
if (genericEntityData != null)
Console.WriteLine("First results name: {0}", genericEntityData.Properties[2].Value);
}
else
{
Console.WriteLine("No results found");
}
using System;
const string queryPath = "$/Common/Queries/Search/Contact/All";
HttpClient client = new HttpClient();
/*
Add proper authorization header to new HttpClient above
before making below request, see
https://developer.imis.com/v0.1/docs/accessing-the-rest-api#section-direct-access-oauth-20
for an example of how to perform this in C# project
*/
var queryResult = client.GetAsync($"api/iqa?QueryName={queryPath}").Result;
if (queryResult != null && queryResult.IsSuccessStatusCode)
{
Console.WriteLine("Query results: {0}", queryResult.Content.ReadAsStringAsync().Result);
}
Simple IQA query using a document version key
Example of getting IQA results via SOA using the query's document version key instead of the path.
using Asi.Soa.ClientServices;
using Asi.Soa.Core.DataContracts;
EntityManager entityManager = new EntityManager();
// Query DocumentVersionKey
string documentVersionKey = "5DE3FE0D-565C-4BB7-90F0-F8AC4C921422";
var queryData = new QueryData("IQA");
queryData.AddCriteria(CriteriaData.Equal("QueryDocumentVersionKey", documentVersionKey));
FindResultsData findResultsData = entityManager.Find(queryData);
if (findResultsData.Result.Count > 0)
{
GenericEntityData genericEntityData = findResultsData.Result[0] as GenericEntityData;
if (genericEntityData != null) Console.WriteLine("Name: {0}", genericEntityData.Properties[1].Value);
}
else
{
Console.WriteLine("No results found");
}
using System;
const string documentVersionKey = "5DE3FE0D-565C-4BB7-90F0-F8AC4C921422"; // Query DocumentVersionKey
HttpClient client = new HttpClient();
/*
Add proper authorization header to new HttpClient above
before making below request, see
https://developer.imis.com/v0.1/docs/accessing-the-rest-api#section-direct-access-oauth-20
for an example of how to perform this in C# project
*/
var queryResult = client
.GetAsync($"api/iqa?QueryDocumentVersionKey={documentVersionKey}").Result;
if (queryResult != null && queryResult.IsSuccessStatusCode)
{
Console.WriteLine("Query results: {0}", queryResult.Content.ReadAsStringAsync().Result);
}
IQA query with required parameter
Example for setting optional or required IQA query filters when getting IQA results.
using Asi.Soa.ClientServices;
using Asi.Soa.Core.DataContracts;
EntityManager entityManager = new EntityManager();
string queryPath = "$/ContactManagement/DefaultSystem/Queries/Advanced/Contact/LastName";
var queryData = new QueryData("IQA");
queryData.AddCriteria(CriteriaData.Equal("QueryName", queryPath));
// Any optional or required parameters can be defined in order
queryData.AddCriteria(CriteriaData.Equal("Parameter", "Baker"));
// If this query had a second optional or required filter for first name add another criteria like
queryData.AddCriteria(CriteriaData.Equal("Parameter", "Chris"));
// All filters set here need to have a CriteriaData of Equal,
// but the comparison operator defined in the query will be used (e.g. Starts With, Contains, etc.)
FindResultsData findResultsData = entityManager.Find(queryData);
if (findResultsData.Result.Count > 0)
{
GenericEntityData genericEntityData = findResultsData.Result[0] as GenericEntityData;
if (genericEntityData != null)
{
Console.WriteLine("Full Name: {0}", genericEntityData.Properties[2].Value);
}
}
else
{
Console.WriteLine("No results found");
}
using System;
const string queryPath = "$/Common/Queries/Search/Contact";
const string requiredParameter = "Last Name¶meter=eq:smith";
HttpClient client = new HttpClient();
/*
Add proper authorization header to new HttpClient above
before making below request, see
https://developer.imis.com/v0.1/docs/accessing-the-rest-api#section-direct-access-oauth-20
for an example of how to perform this in C# project
*/
var queryResult = client
.GetAsync($"api/iqa?QueryName={queryPath}/{requiredParameter}").Result;
if (queryResult != null && queryResult.IsSuccessStatusCode)
{
Console.WriteLine("Query results: {0}", queryResult.Content.ReadAsStringAsync().Result);
}
Updated 4 months ago