MobileCache m_mobileCache1;
m_mobileCache1 = new MobileCache(@"C:\user\MobileCache");
m_mobileCache1.Open();
Map mMap = new Map();
mMap.MapLayers.AddRange(m_mobileCache1);
if (m_mobileCache1.CacheExists)
{
m_mobileCache1.Close();
m_mobileCache1.DeleteCache();
}
MobileServiceConnection con = new MobileServiceConnection();
con.Url = @"http://server/arcgis/services/Test_Mobile_Services/Radiation_Data_V1_B11/MapServer/Mobileserver";
con.CreateCache(m_mobileCache1);
m_mobileCache1.Open();
MobileCacheSyncAgent agent = new MobileCacheSyncAgent(m_mobileCache1);
agent.MapDocumentConnection = con;
agent.DownloadExtent(m_mobileCache1.GetExtent(), 0, 0);
mMap.MapLayers.AddRange(m_mobileCache1);
MobileCache mobileCache1 = new MobileCache();
Map map1 = new Map();
MapControl mapControl1 = new MapControl();
MobileServiceConnection mobileServiceConnection1 = new MobileServiceConnection();
//mobileServiceConnection1.CreateCache("Rad_Data");
try
{
mobileCache1.StoragePath = @"C:\Akhil\ArcGIS_Mobile_Projects\P_Radiation_Data_V3_B1\Radiation_Data";
//Uncomment these lines if you are using your own service
mobileCache1.DeleteCache();
mobileServiceConnection1.Url = @"http://emapappdev/arcgis/services/Test_Mobile_Services/Radiation_Data/MapServer/MobileServer";
MobileCacheSyncAgent mobileSync = new MobileCacheSyncAgent(mobileCache1, mobileServiceConnection1);
MobileCacheSyncResults mobileResults = new MobileCacheSyncResults();
//get the schema to determine list of layers
mobileServiceConnection1.CreateCache(mobileCache1);
mobileCache1.Open();
mobileSync.Synchronize();
//map1.DataSources.Add(mobileCache1); <-- THIS DOES NOT WORK
//mapControl1.Map.Content = (mobileCache1); <-- THIS DOES NOT WORK
}
catch
{
MessageBox.Show("Cannot open map cache");
}
mapControl.Map.MapLayers.AddRange(mobileCache1);
MobileApplication.Current.Map.MapLayers.AddRange(mobileCache1);
MobileApplication.Current.Map........????
public static void Download_Data()
{
ESRI.ArcGIS.Mobile.Client.Windows.MessageBox.ShowDialog("This is where the automatic download of data occurs!");
// Create an instance of MobileCache, and set StoragePath
MobileCache mobileCache = new MobileCache();
mobileCache.StoragePath = @"C:\Akhil\ArcGIS_Mobile_Projects\P_Radiation_Data_V1_B1\Radiation_Data_V1";
try
{
if (mobileCache.CacheExists)
{
mobileCache.Close();
}
mobileCache.Open();
MobileServiceConnection con = new MobileServiceConnection();
con.Url = "http://emapappdev/arcgis/services/Test_Mobile_Services/Radiation_Data_V1/MapServer/MobileServer";
FeatureLayerSyncAgent agent0 = new FeatureLayerSyncAgent(mobileCache.FeatureLayers[0]);
agent0.MapDocumentConnection = con;
agent0.StateChanged += new EventHandler(agent_StateChanged);
agent0.Synchronize();
FeatureLayerSyncAgent agent1 = new FeatureLayerSyncAgent(mobileCache.FeatureLayers[1]);
agent1.MapDocumentConnection = con;
//agent1.StateChanged += new EventHandler(agent_StateChanged);
agent1.StateChanged += new EventHandler(agent_StateChanged);
agent1.Synchronize();
FeatureLayerSyncAgent agent2 = new FeatureLayerSyncAgent(mobileCache.FeatureLayers[2]);
agent2.MapDocumentConnection = con;
agent2.StateChanged += new EventHandler(agent_StateChanged);
agent2.Synchronize();
catch (Exception exception)
{
if (mobileCache.CacheExists)
{
if (mobileCache.IsOpen)
{
mobileCache.Close();
}
}
}
public static void Download_Data()
{
MobileCache m_mobileCache1;
m_mobileCache1 = new MobileCache(@"C:\Akhil\MobileCache");
MessageBox.Show("before opening mobile cache");
m_mobileCache1.Open();
Map mMap = new Map();
MessageBox.Show("new map");
//mMap.MapLayers.AddRange(m_mobileCache1);
// Delete the above line since your doing this at the end of your code
if (m_mobileCache1.CacheExists)
{
m_mobileCache1.Close();
m_mobileCache1.DeleteCache();
MessageBox.Show("deletes cache");
}
else
{
//You did a m_mobileCache1.Open(); twice if cache does not exist
// Once above and once below. You need to close it here since you are opening it below
m_mobileCache1.Close();
MessageBox.Show("closes cache");
}
MessageBox.Show("creating mobile connection");
MobileServiceConnection con = new MobileServiceConnection();
MessageBox.Show("after creating mobile connection");
con.Url = @"http://emapappdev/arcgis/services/Test_Mobile_Services/Radiation_Data_V1/MapServer/Mobileserver";
MessageBox.Show("sets the URL");
con.CreateCache(m_mobileCache1.StoragePath); // Per ESRI sample
m_mobileCache1.Open();
MessageBox.Show("opens cache");
MobileCacheSyncAgent agent = new MobileCacheSyncAgent(m_mobileCache1, con);
agent.MapDocumentConnection = con;
//agent.Synchronize(); // See if Synchronize works instead of line below
agent.DownloadExtent(m_mobileCache1.GetExtent(), 0, 0);
MessageBox.Show("after synch");
mMap.MapLayers.AddRange(m_mobileCache1);
MessageBox.Show("adds to map");
//LoadData();
//mMap.Refresh();
mMap.Invalidate();
}