DD-engine Development - Hassle-free Integration
Implement simple requierments with only a few lines of code. And for more complex usecases pull out all the stops.
Firs you need a method, that realizes access to an index. For this purpose a Pool object has to be created. Additionally in our example a missing index will be directly created.
Code...
public ListPool GetPool(bool reloaded) {
DirectoryInfo di = new DirectoryInfo(_PoolDirectory);
PoolFactory factory = PoolFactory.GetFactory(di.FullName);
Pool pool = factory.GetPool(_PoolName, reloaded);
if (pool == null) // if you want to grant an instance...
pool = CreateMyPool(factory, _PoolName);
return (ListPool)pool;
}
Well, how does the method to create the Pool object looks like? And how will the search index be build?
Code...
public static ListPool CreateMyPool(PoolFactory factory) {
DataTable myData = GetAllDataForNewIndex();
ListPool pool = (ListPool)factory.CreatePool(_PoolName,
PoolType.ListPool,
CachingType.ExpressionList);
foreach(DataRow row in myData.Rows)
row["DDE_ID"] = pool.Add(row["Name"].ToString());
pool.Save();
return pool;
}
Or use the second integration path storing data id to index:
Code...
public static ListPool CreateMyPool(PoolFactory factory) {
DataTable myData = GetAllDataForNewIndex();
ListPool pool = (ListPool)factory.CreatePool(_PoolName,
PoolType.ListPool,
CachingType.ExpressionList);
foreach(DataRow row in myData.Rows)
pool.Add(row["Name"].ToString(),
row["CustomerID"]);
pool.Save();
return pool;
}
After the pool object is prepared, we are able to complete the example implementation.Let's take the text from a search inputbox and process a first request.
Code...
public void btnRequest_Click(object sender, EventArgs e) {
try{
ListPool pool = GetPool(false);
ListRequest req = new ListRequest(txtSearchText.Text,
" ");
PoolAgent agent = pool.GetAgent();
agent.Find(req);
dgrResults.DataSource = req.Result.Tables[pool.Name];
dgrResults.DataBind();
}
catch(DDEException E){
}
catch(Exception E){
}
}
Although we did not use any parameters to control DD-engine's search mechanism, you will see exiting excellent results. No need to code an own search method ever again.