About

I write code for Eagle Technology (Esri New Zealand distributor) based in Wellington, New Zealand. In my free time I play drums, do / watch MMA, drink beer and play video games.

Get GIS Jobs

3 comments

  1. Dave, reading your blog has been very interesting. I’m doing a lot of work with ArcGIS Mobile and have a quick question about the synchronization process. During the post, clearly we want to determine which layers have edits, but do you know if it is possible to determine the specific features? I need to process each feature and write in the post time onto every feature during the post and trying to determine exactly which one will be posted is challenging.

    Thanks

    1. Hi,

      you should be able to do this. If you get a reference to a FeatureLayer there is a property called HasEdits so you know if that particular layer has any edits outstanding. From there you could iterate through the features and use the GetStoredEditState method to check which features have edits.
      Cheers

  2. Hmm, interesting.

    What I actually ended up doing is getting the FeatureLayerInfo enumeration and from there getting the featurelist which is in an EditState.Added (in this application we’re not editing pre-existing, only adding new)

    Works well and very quick

    K

    private void btnPostData_Click(object sender, EventArgs e)
    {
    Cursor.Current = Cursors.WaitCursor;

    DateTime dtPost = DateTime.Now;
    IEnumerable efi = MobileApplication.Current.Project.EnumerateFeatureLayerInfos();

    foreach (FeatureLayerInfo fli in efi)
    {
    IList featList = fli.GetFeatures(EditState.Added);
    string batchnumber;
    string wrnumber = “”;

    foreach (Feature feat in featList)
    {
    feat.StartEditing();
    FeatureDataRow fdr = feat.FeatureDataRow;

    foreach (DataColumn dc in fdr.FeatureLayer.Columns)
    {
    if (dc.ColumnName.ToLower().Equals(“postuser”))
    fdr[dc.ColumnName] = Common.Utilities.UserTools.CurrentUserID();
    else if (dc.ColumnName.ToLower().Equals(“postdatatime”))
    fdr[dc.ColumnName] = dtPost;

    }
    feat.SaveEdits();
    feat.StopEditing();

    }
    if (fli.FeatureLayer.HasEdits)
    {
    var con = new MobileServiceConnection();
    con.Url = fli.MobileCacheInfo.MobileServiceConnection.Url;
    var agent = new FeatureLayerSyncAgent(fli.FeatureLayer, con);
    agent.SynchronizationDirection = SyncDirection.UploadOnly;
    agent.Synchronize();
    }
    }
    Cursor.Current = Cursors.Default;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s