Language
Navigationslinks überspringen
Home
DD-engine
ITX console
Consulting
Contact
Data Digger engine - Logo
Navigationslinks überspringen > DD-engine > Developers
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...
// application write access to poolDirectory must be
// granted, to create index data
public ListPool GetPool(bool reloaded) {
   DirectoryInfo di = new DirectoryInfo(_PoolDirectory);
   // check directory here...
   // then load pool factory (handling pool cluster)
   PoolFactory factory = PoolFactory.GetFactory(di.FullName);
   // load a pool (data of single index)
   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) {
   // get the right data from somewhere...
   DataTable myData = GetAllDataForNewIndex();
   // create a new empty pool obect using the factory object
   ListPool pool = (ListPool)factory.CreatePool(_PoolName,
                                PoolType.ListPool,
                                CachingType.ExpressionList);
   // now learn the data
   foreach(DataRow row in myData.Rows)
      row["DDE_ID"] = pool.Add(row["Name"].ToString());
   // make index changes persistent
   pool.Save();
   // save changes to data table here...
   // then...
   return pool;
}
Or use the second integration path storing data id to index:
Code...
public static ListPool CreateMyPool(PoolFactory factory) {
   // get the right data from somewhere...
   DataTable myData = GetAllDataForNewIndex();
   // create a new empty pool obect using the factory object
   ListPool pool = (ListPool)factory.CreatePool(_PoolName,
                                PoolType.ListPool,
                                CachingType.ExpressionList);
   // now learn the data and use your own custom ID
   foreach(DataRow row in myData.Rows)
      pool.Add(row["Name"].ToString(),
               row["CustomerID"]);
   // make index changes persistent
   pool.Save();
   // then...
   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{
      // first get index
      ListPool pool = GetPool(false);
      // create your request with blank as text separator
      ListRequest req = new ListRequest(txtSearchText.Text,
                                        " ");
      // call an agent...
      PoolAgent agent = pool.GetAgent();
      // ...and make him process your request
      agent.Find(req);
      // display results with datagrid
      dgrResults.DataSource = req.Result.Tables[pool.Name];
      dgrResults.DataBind();
   }
   catch(DDEException E){
      // insert retrieval exception handling here
   }
   catch(Exception E){
      // insert common exception handling here
   }
}

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.

Email Info