Пример #1
0
        public IEnumerable <IFeature> SaveResults(
            [NotNull] IGdbTransaction transaction,
            [NotNull] IWorkspace editWorkspace,
            [NotNull] string undoMessage,
            [CanBeNull] Action <IEnumerable <KeyValuePair <IFeature, IList <IFeature> > > >
            onResultsSaved = null,
            [CanBeNull] ITrackCancel trackCancel = null)
        {
            var resultFeatures = new List <IFeature>();

            transaction.Execute(
                editWorkspace,
                delegate { StoreResultFeatures(resultFeatures, onResultsSaved); },
                undoMessage,
                trackCancel);

            return(resultFeatures);
        }
Пример #2
0
        public static bool Execute([NotNull] IProcessingContext context,
                                   [NotNull] IProcessingFeedback feedback,
                                   [NotNull] IEnumerable <IGdbProcess> processes,
                                   [CanBeNull] string actionName)
        {
            Assert.ArgumentNotNull(context, nameof(context));
            Assert.ArgumentNotNull(feedback, nameof(feedback));
            Assert.ArgumentNotNull(processes, nameof(processes));

            IGdbTransaction transaction = context.GetTransaction();
            IWorkspace      workspace   = context.GetWorkspace();

            // TODO - Consider: transient processes: execute a list of ProcessDescriptors;
            // TODO - for each descriptor, instantiate and configure a GdbProcess.

            return(transaction.Execute(
                       workspace,
                       () => Execute(context, feedback, processes),
                       actionName ?? GetActionName(processes)));
        }
        public ICollection <IObject> ChangeIssueType(
            [NotNull] IGdbTransaction transaction,
            [NotNull] IEnumerable <IObject> issueObjects,
            ErrorType newIssueType)
        {
            Assert.ArgumentNotNull(transaction, nameof(transaction));
            Assert.ArgumentNotNull(issueObjects, nameof(issueObjects));

            List <IObject> issueObjectList = issueObjects.ToList();
            var            modifiedObjects = new List <IObject>();

            if (issueObjectList.Count == 0)
            {
                return(modifiedObjects);
            }

            IDictionary <IObjectClass, IList <IObject> > objectsByClass =
                GdbObjectUtils.GroupObjectsByClass(issueObjectList);

            IWorkspace workspace = DatasetUtils.GetUniqueWorkspace(objectsByClass.Keys);

            if (workspace == null)
            {
                return(modifiedObjects);
            }

            transaction.Execute(
                workspace,
                delegate
            {
                foreach (KeyValuePair <IObjectClass, IList <IObject> > pair in objectsByClass)
                {
                    IObjectClass issueClass = pair.Key;
                    bool isFeatureClass     = issueClass is IFeatureClass;

                    int fieldIndexErrorType = issueClass.Fields.FindField(FieldNameErrorType);

                    foreach (IObject issueObject in pair.Value)
                    {
                        if (!CanChangeTo(newIssueType, issueObject, fieldIndexErrorType))
                        {
                            continue;
                        }

                        if (newIssueType == ErrorType.Allowed &&
                            isFeatureClass &&
                            IsTableIssueStoredWithReferenceGeometry(issueObject))
                        {
                            // move to issue table without geometry
                            IssueDatasetWriter issueWriter =
                                IssueDatasets.GetIssueWriterNoGeometry();
                            ITable issueTable = issueWriter.Table;

                            IRow row = issueTable.CreateRow();
                            GdbObjectUtils.CopyAttributeValues(issueObject, row);

                            RemoveReferenceGeometryFlag(row);

                            int fieldIndexCopiedErrorType =
                                issueTable.FindField(FieldNameErrorType);
                            row.set_Value(fieldIndexCopiedErrorType, (int)newIssueType);
                            row.Store();

                            modifiedObjects.Add((IObject)row);

                            issueObject.Delete();
                        }
                        else
                        {
                            issueObject.set_Value(fieldIndexErrorType, (int)newIssueType);
                            issueObject.Store();

                            modifiedObjects.Add(issueObject);
                        }
                    }
                }
            }, "Changing issue type");

            return(modifiedObjects);
        }