Ejemplo n.º 1
0
        protected async void AssignFeaturesToRecord()
        {
            #region Assign features to active record
            string errorMessage = await QueuedTask.Run(() =>
            {
                //check for selected layer
                if (MapView.Active.GetSelectedLayers().Count == 0)
                {
                    return("Please select a source feature layer in the table of contents.");
                }
                //first get the feature layer that's selected in the table of contents
                var srcFeatLyr          = MapView.Active.GetSelectedLayers().OfType <FeatureLayer>().FirstOrDefault();
                var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <ParcelLayer>().FirstOrDefault();
                if (myParcelFabricLayer == null)
                {
                    return("No parcel layer found in the map.");
                }
                try
                {
                    var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
                    if (theActiveRecord == null)
                    {
                        return("There is no Active Record. Please set the active record and try again.");
                    }
                    var editOper = new EditOperation()
                    {
                        Name            = "Assign Features to Record",
                        ProgressMessage = "Assign Features to Record...",
                        ShowModalMessageAfterFailure = true,
                        SelectNewFeatures            = true,
                        SelectModifiedFeatures       = false
                    };
                    //add parcel type layers and their feature ids to a new KeyValuePair
                    var ids            = new List <long>(srcFeatLyr.GetSelection().GetObjectIDs());
                    var kvp            = new KeyValuePair <MapMember, List <long> >(srcFeatLyr, ids);
                    var sourceFeatures = new List <KeyValuePair <MapMember, List <long> > > {
                        kvp
                    };

                    editOper.AssignFeaturesToRecord(myParcelFabricLayer, sourceFeatures, theActiveRecord);
                    if (!editOper.Execute())
                    {
                        return(editOper.ErrorMessage);
                    }
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
                return("");
            });

            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage, "Assign Features To Record.");
            }
            #endregion
        }
Ejemplo n.º 2
0
        protected async void AssignFeaturesToRecord()
        {
            await QueuedTask.Run(async() =>
            {
                //check for selected layer
                if (MapView.Active.GetSelectedLayers().Count == 0)
                {
                    System.Windows.MessageBox.Show("Please select a source feature layer in the table of contents", "Assign Features To Record");
                    return;
                }

                //first get the feature layer that's selected in the table of contents
                var srcFeatLyr          = MapView.Active.GetSelectedLayers().First() as FeatureLayer;
                var layers              = MapView.Active.Map.GetLayersAsFlattenedList();
                var myParcelFabricLayer = layers.FirstOrDefault(l => l is ParcelLayer) as ParcelLayer;
                if (myParcelFabricLayer == null)
                {
                    return;
                }

                var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
                if (theActiveRecord == null)
                {
                    System.Windows.MessageBox.Show("There is no Active Record. Please set the active record and try again.", "Copy Line Features To");
                    return;
                }
                #region Assign features to active record
                var guid     = theActiveRecord.Guid;
                var editOper = new EditOperation()
                {
                    Name            = "Assign Features to Record",
                    ProgressMessage = "Assign Features to Record...",
                    ShowModalMessageAfterFailure = true,
                    SelectNewFeatures            = true,
                    SelectModifiedFeatures       = false
                };
                //add parcel type layers and their feature ids to a new KeyValuePair
                MapMember mapMemberSource = srcFeatLyr as MapMember;
                var ids            = new List <long>(srcFeatLyr.GetSelection().GetObjectIDs());
                var kvp            = new KeyValuePair <MapMember, List <long> >(mapMemberSource, ids);
                var sourceFeatures = new List <KeyValuePair <MapMember, List <long> > > {
                    kvp
                };

                editOper.AssignFeaturesToRecord(myParcelFabricLayer, sourceFeatures, guid, ParcelRecordAttribute.CreatedByRecord);
                await editOper.ExecuteAsync();
                #endregion
            });
        }