Here is an explanation on how metadata regarding a clientActivity interact with metadata specific to each MDT to produce a well formed and valued piece of information which will be used to actually execute the activity.

Overview

The clientActivityItem table owns a clientActivityItem_metadata field.
This field allows the storage of generic information about the activity.
For instance, if the activity is a SQL Execution activity, you would store in its clientActivityItem_metadata field the parameterized SQL request to be executed.

On the other hand, the clientActivityItemContext table owns a clientActivityItemContext_metadata field allowing to specify values for the parameters contained in the generic metadata.
To continue with the previous example of a SQL Execution activity, you would store in the clientActivityItemContext_metadata field the parameters value for a given MDT.


To sum up, each MDT will use the activity generic metadata (i.e. the clientActivityItem_metadata field) in relation with its own clientActivityItemContext_metadata field to produce a meaningful piece of information.
This piece of information will be used to properly execute the activity on the MDT.

Examples

SQL Execution on each MDT

If you want to execute a parameterized SQL request on each MDT, here is what the clientActivityItem_metadata should look like :
clientActivityItem_metadata field specifying a parameterized SQL request.
<metadata>
  <sqlScriptActivity>
     UPDATE Person SET
        FirstName = @FirstName,MiddleName = @MiddleName
      WHERE
        ID = @ID
  </sqlScriptActivity>
</metadata>
Notice the @ used to denote parameters ("@FirstName" etc.).

We now need to specify the the SQL request parameters value for each MDT.
We'll use the clientActivityItemContext_metadata field to do so :
clientActivityItemContext_metadata field of MDT #1 specifying parameters value for a parameterized SQL request.
<metadata>
  <sqlScriptContext>
    <parameters count="3">
      <parameter name="@FirstName" type="string">Griffin</parameter>
      <parameter name="@MiddleName" type="string">Bob</parameter>
      <parameter name="@ID" type="int">16878</parameter>
    </parameters>
  </sqlScriptContext>
</metadata>
clientActivityItemContext_metadata field of MDT #2 specifying parameters value for a parameterized SQL request.
<metadata>
  <sqlScriptContext>
    <parameters count="3">
      <parameter name="@FirstName" type="string">Moore</parameter>
      <parameter name="@MiddleName" type="string">Peter</parameter>
      <parameter name="@ID" type="int">3456</parameter>
    </parameters>
  </sqlScriptContext>
</metadata>

As you can see the generic metadata (clientActivityItem_metadata) is the same for every MDT, but the clientActivityItemContext_metadata is specific to each MDT.
Combining these two pieces of information, we are able to execute a properly formed and valued parameterized SQL request on each MDT.

SQL synchronization using a static HOST_NAME

If you want to perform a SQL synchronization with a unique HOST_NAME for every MDT, here is what the clientActivityItem_metadata should look like :
clientActivityItem_metadata field specifying a SQL synchronization using a static HOST_NAME value.
<metadata>
  <mergeSyncActivity dynamicHostName="false">
    <staticHostName>Static HOST_NAME value</staticHostName>
  </mergeSyncActivity>
</metadata>

Nevertheless, the SQL synchronization activity needs context metadata to specify the connection string to access the SQL CE database of each MDT.
So here are what context metadata should look like :
clientActivityContext_metadata field specifying the SQL CE connection string for MDT #1
<metadata>
  <mergeSyncContext>
    <connectionString>Data Source=C:\MyDB_A.sdf</connectionString>
  </mergeSyncContext>
</metadata>
clientActivityContext_metadata field specifying the SQL CE connection string for MDT #2
<metadata>
  <mergeSyncContext>
    <connectionString>Data Source=C:\MyDB_B.sdf</connectionString>
  </mergeSyncContext>
</metadata>

SQL synchronization using a dynamic HOST_NAME

If you want to specify a proper HOST_NAME for every MDT, here is what the clientActivityItem_metadata should look like :
clientActivityItem_metadata specifying a SQL synchronization using a dynamic HOST_NAME
<metadata>
  <mergeSyncActivity dynamicHostName="true" />
</metadata>
Moving on to the context metadata of each MDT. This time we add the HOST_NAME value to use.
clientActivityContext_metadata field specifying both the HOST_NAME value and the SQL CE connection string for MDT #1
<metadata>
  <mergeSyncContext>
    <hostName>MDT_3456</hostName>
    <connectionString>Data Source=C:\MyDB_A.sdf</connectionString>
  </mergeSyncContext>
</metadata>
clientActivityContext_metadata field specifying both the HOST_NAME value and the SQL CE connection string for MDT #2
<metadata>
  <mergeSyncContext>
    <hostName>MDT_98</hostName>
    <connectionString>Data Source=C:\MyDB_B.sdf</connectionString>
  </mergeSyncContext>
</metadata>

Last edited Mar 4, 2011 at 12:05 PM by Christophe_, version 2

Comments

No comments yet.