Select to view content in your preferred language

Automatically refreshing a Windows Mobile package when GDB domains change

7189
2
Jump to solution
09-11-2012 04:29 AM
AlanTonkin
Regular Contributor
Hi,

Hopefully someone from ESRI will be able to answer this question for me.

We are running ArcGIS Server 10.1 & ArcGIS for Mobile 3.0 with ArcSDE 10.1 on Microsoft SQL 2008.

I have an SDE database purely for my mobile data layers that has quite a few domains created. They are coded value domains. Majority of them are static and don't change (things like gender, yes/no, positive/negative lookup values etc). However, there a few domains whose values could be changing on a daily basis as they represent patients captured using a web application into a non-spatial SQL database table.

Due to the lack of relational database table support in the out-of-the-box ArcGIS Mobile application, the only way to provide this list of updated patients is to recreate/refresh the coded value domain using the "Table To Domain" geoprocessing tool. This I have achieved with no problem at all.

I have published a service that references 3 point feature classes from my SDE database & there are fields in all 3 feature classes that reference these domains that change daily. I have also created a mobile project in Mobile Project Center that has the published service as an operational layer. I then shared this mobile project to our ArcGIS Server and the project is downloadable when connecting to our ArcGIS Server using Trimble Juno SC devices. There is no problem capturing features and synchronizing the updates with the server.

The field staff using the Juno devices have been instructed to delete the project off the device at the end of every day when they have been out in the field (after synchronizing) and re-downloading the mobile project from the server every morning. Currently the domains are refreshed in the evening as the intention was to provide the updated patient lookup values with the mobile project that they download in the morning.

The trouble is that there doesn't appear to be a way to automate the refreshing of the change to the domains in the mobile project that the users download from our ArcGIS Server without manually running Mobile Project Center, opening the mobile project, re-packaging and re-sharing to our ArcGIS Server. Only then does the change to the schema get effected into the .wmpk file that is retrieved by the Juno devices.

If anyone could shed any light on an automated (scriptable) solution, I would be very grateful.

Alan
0 Kudos
1 Solution

Accepted Solutions
AlanTonkin
Regular Contributor
Hi all,

I discovered that when i was running the above Python script in the Idle GUI, it was using the wrong version of the python executable. I have both 32-bit & 64-bit versions on my machine since my OS is 64-bit. When running with the correct python executable, the script executes correctly!

Cheers 😄

View solution in original post

0 Kudos
2 Replies
AlanTonkin
Regular Contributor
Hi all,

Shortly after posting I discovered that the mobile cache files (MapSchema.bin, MobileCache.db & MobileCache.db-journal) could be refreshed/recreated using the CreateMobileCache geoprocessing tool found under the Mobile toolbox (this toolbox had to be added in ArcCatalog).

The folder "C:\arcgisserver\directories\arcgismobile\WindowsMobile\Projects" contains a sub-folder with a long multi-character name that corresponds to a specific mobile project. In my case it is "15db82b9bdba47aba3b3b2c337249d0f". In this folder, the [project name].wmpk file can be found as well as a folder called esriinfo. In the esriinfo folder, there are 3 sub-folders and an xml file. The sub-folders are mobilecaches, project & thumbnail. In the mobilecaches folder there will be as many sub-folders in this folder as there are mobile services in your operational layers in MPC. In my case I only have a single service. The folder is named after the service name. In this folder you will find the three mobile cache files. When running the geoprocessing tool mentioned above, you can output the mobile cache files to the mobilecaches folder & the existing folder & files will be overwritten or you can output them elsewhere and manually copy them across.

However, when a mobile device connects to your ArcGIS Server, it retrieves the [project name].wmpk file. This file is nothing more than a ZIP file. If you are familiar and confident with changing file extensions, then you can rename the file to [project name].zip and open the zip file with WinZip/WinRAR/7zip etc. The zip file contains the same folder structure as mentioned above (esriinfo\...). Locate the mobilecaches folder and the sub-folder in there with the name of your service. Here you will find the three mobile cache files. You can drag & drop your updated mobile cache files here to update the ones in the zip file. Once the zip file has been closed, rename the zip file back to [project name].wmpk

I still have one stumbling block though as far as the automation of the above process. It lies with the Create Mobile Cache geoprocessing tool. When run from ArcCatalog/ArcMap it works perfectly but since I am trying to automate the above I am scripting the process using Python. I have created a python script shown below:


[INDENT]#Name: CreateMobileCache_mobile.py
# Purpose: Create mobile cache to reflect latest changes to GDB domains referenced by SDE feature class layers in the map document

# Import system modules
import arcpy

arcpy.ImportToolbox("C:\\Program Files (x86)\\ArcGIS\\Mobile3.0\\ArcToolbox\\Toolboxes\\Mobile Tools.tbx")

try:
    #Set local parameters
    mxdName = "C:\\ArcGISData\\MDRTB\\ArcMapMXDs\\MDRTB_MOBILE_SDE.mxd"
    fldName = "C:\\arcgisserver\\directories\\arcgismobile\\WindowsMobile\\Projects\\15db82b9bdba47aba3b3b2c337249d0f\\esriinfo\\mobilecaches"

    # Process: Create the mobile map cache using the map document
    arcpy.CreateMobileCache_mobile( mxdName,fldName,"#","#","#" )

except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message[/INDENT]


I get the following error when running the script:

[INDENT]Line 18
CreateMobileCache() takes no arguments (5 given)[/INDENT]


This doesn't make sense as the geoprocessing tool requires at LEAST 2 parameters to work and its saying that it doesn't take any?

If I don't add the line arcpy.ImportToolbox(...) then running the script fails with the following error:

'module' object has no attribute 'CreateMobileCache_mobile'

It would seem that Python doesn't know where the python scripts are that correspond to the two mobile geoprocessing tools. Is there somewhere that the path to these python scripts can be added so that Python knows where to find them as it does for all other ArcGIS geoprocessing tools? Maybe if this was added then I wouldn't be getting the first error listed.

Could anyone with a bit more knowledge about Python scripting shed some light on this please???

Alan
0 Kudos
AlanTonkin
Regular Contributor
Hi all,

I discovered that when i was running the above Python script in the Idle GUI, it was using the wrong version of the python executable. I have both 32-bit & 64-bit versions on my machine since my OS is 64-bit. When running with the correct python executable, the script executes correctly!

Cheers 😄
0 Kudos