Exemplo n.º 1
0
        /// <summary>
        /// Shows the error dialog.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="message">The message.</param>
        /// <param name="title">The title.</param>
        /// <param name="e">The exception.</param>
        /// <param name="msg">The message sink. Allows to log the error using the logger
        /// of the calling context.</param>
        public void ShowError(IWin32Window owner, string title, string message,
                              Exception e, IMsg msg)
        {
            Assert.ArgumentNotNullOrEmpty(title, nameof(title));
            Assert.ArgumentNotNullOrEmpty(message, nameof(message));

            if (msg == null)
            {
                msg = _msg;
            }

            // write to log
            if (e != null)
            {
                msg.Error(message, e);
            }
            else
            {
                msg.Error(message);
            }

            Show(owner,
                 MsgBase.ReplaceBreakTags(message), title,
                 MessageBoxButtons.OK,
                 MessageBoxIcon.Error,
                 MessageBoxDefaultButton.Button1);
        }
Exemplo n.º 2
0
        public async Task CreateWorkListAsync([NotNull] WorkEnvironmentBase environment)
        {
            try
            {
                // is this worklist already loaded?
                if (_registry.Exists(environment.GetWorklistId()))
                {
                    _msg.Debug("Worklist is already loaded");
                    return;
                }

                IWorkList workList = await environment.CreateWorkListAsync(this);

                RegisterObserver(new WorkListObserver());

                // wiring work list events, etc. is done in OnDrawComplete
                // register work list before creating the layer
                _registry.Add(workList);

                foreach (var observer in _observers)
                {
                    observer.WorkListAdded(workList);
                }

                CreateLayer(environment, workList.Name);
            }
            catch (Exception e)
            {
                _msg.Error("Create work list failed", e);
            }
        }
Exemplo n.º 3
0
        public override PluginTableTemplate OpenTable([NotNull] string name)
        {
            Assert.ArgumentNotNull(name, nameof(name));
            Assert.ArgumentCondition(_tableNames.Contains(name), $"Unknown table name {name}");

            // The given name is one of those returned by GetTableNames()
            _msg.Debug($"Open table '{name}'");

            ParseLayer(name, out string listName);

            _workList = WorkListRegistry.Instance.Get(name);

            if (_workList != null)
            {
                return(new WorkItemTable(_workList, listName));
            }

            var message = $"Cannot find data source of work list: {name}";

            _msg.Error(message);

            // The exception is not going to crash Pro. It results in a broken
            // data source of the work list layer.
            throw new ArgumentException(message);
        }
Exemplo n.º 4
0
        private void WorkList_WorkListChanged(object sender, WorkListChangedEventArgs e)
        {
            List <long> oids = e.Items;

            if (oids == null)
            {
                return;
            }

            try
            {
                var workList = (IWorkList)sender;

                Assert.True(_layersByWorklistName.ContainsKey(workList.Name),
                            $"sender of {nameof(WorkList_WorkListChanged)} is unknown");

                if (!_layersByWorklistName.ContainsKey(workList.Name))
                {
                    return;
                }

                FeatureLayer workListLayer = _layersByWorklistName[workList.Name];

                MapView.Active.Invalidate(new Dictionary <Layer, List <long> >
                {
                    { workListLayer, oids }
                });
            }
            catch (Exception exc)
            {
                _msg.Error("Error invalidating work list layer", exc);
            }
        }
Exemplo n.º 5
0
        protected override async void OnClick()
        {
            try
            {
                // performance test
                //QueuedTask.Run(() =>
                //{
                //	ProSuiteLogPaneViewModel.GenerateMockMessages(10000);
                //});

                // temporary solution for WorkList
                //await QueuedTask.Run(() =>
                //{
                //	var pane = FrameworkApplication.DockPaneManager.Find("esri_dataReviewer_evaluateFeaturesPane");
                //	bool visible = pane.IsVisible;
                //	pane.Activate();
                //});

                await ProSuiteToolsModule.Current.ShowSelectionWorkList();
            }
            catch (Exception ex)
            {
                _msg.Error(ex.Message);
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            try
            {
                IServiceHealth   health;
                Grpc.Core.Server server = Run(args, out health);

                _msg.Info("Type Q(uit) to stop the server.");

                while (true)
                {
                    // Avoid mindless spinning
                    Thread.Sleep(100);

                    if (System.Console.KeyAvailable)
                    {
                        if (System.Console.ReadKey(true).Key == ConsoleKey.Q)
                        {
                            _msg.Warn("Shutting down due to user input");
                            break;
                        }
                    }

                    // TODO: Uncomment after next pull
                    //if (health.IsAnyServiceUnhealthy())
                    //{
                    //	_msg.Warn("Shutting down due to service state NOT_SERVING");
                    //	break;
                    //}
                }

                if (server != null)
                {
                    GrpcServerUtils.GracefullyStop(server);
                }
            }
            catch (Exception ex)
            {
                _msg.Error("An error occurred in microservice.", ex);
                Environment.ExitCode = -1;
            }
            finally
            {
                _msg.Debug("License released, shutting down...");
            }
        }
Exemplo n.º 7
0
 private static void _dataGridView_DataError(object sender,
                                             DataGridViewDataErrorEventArgs e)
 {
     _msg.Error(
         string.Format(
             "Error displaying grid content (context: {0}; row: {1} column: {2})",
             e.Context, e.RowIndex, e.ColumnIndex),
         e.Exception);
     e.ThrowException = false;
 }
Exemplo n.º 8
0
 protected override async void OnClick()
 {
     try
     {
         await ProSuiteToolsModule.StartQAGPServerAsync(ProSuiteQAServiceType.GPLocal);
     }
     catch (Exception ex)
     {
         _msg.Error(ex.Message);
     }
 }
Exemplo n.º 9
0
        protected void HandleError(string message, Exception e, bool noMessageBox = false)
        {
            _msg.Error(message, e);

            if (noMessageBox)
            {
                return;
            }

            ErrorHandler.HandleError(message, null, _msg, "Error");
        }
Exemplo n.º 10
0
        /// <summary>
        /// Reads from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="currentVersion">The current version of the calling component
        /// (used to validate the stream version). Must be a non-negative integer.</param>
        /// <param name="versionedRead">Delegate to do the actual reading, based on the version of the stream.</param>
        /// <param name="releaseStream">if set to <c>true</c> the stream is released using Marshal.ReleaseComObject. This
        /// should only be done in calls from direct com interface implementations.</param>
        public static void Load([NotNull] IVariantStream stream,
                                int currentVersion,
                                [NotNull] Action <int> versionedRead,
                                bool releaseStream = false)
        {
            try
            {
                // assert inside try block to make sure assertion violations are visible
                Assert.ArgumentNotNull(stream, nameof(stream));
                Assert.ArgumentNotNull(versionedRead, nameof(versionedRead));
                Assert.True(currentVersion >= 0, "Invalid current version: {0}",
                            currentVersion);

                object versionObject = stream.Read();
                Assert.NotNull(versionObject, "Unable to read version from stream");

                var version = (int)versionObject;
                Assert.True(version >= 0 && version <= currentVersion,
                            "Unexpected version: {0}", version);

                versionedRead(version);
            }
            catch (Exception e)
            {
                var    comEx   = e as COMException;
                string message =
                    comEx == null
                                                ? $"Error reading from stream: {e.Message}"
                                                : $"Error reading from stream: {comEx.Message}; ErrorCode: {comEx.ErrorCode}";
                _msg.Error(message, e);
                throw;
            }
            finally
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                if (releaseStream && stream != null)
                {
                    Marshal.ReleaseComObject(stream);
                }
            }
        }
Exemplo n.º 11
0
 private void Invalidate()
 {
     try
     {
         _objectCache.Invalidate(_featureWorkspace);
     }
     catch (Exception e)
     {
         _msg.Error("Error invalidating object cache", e);
         throw;
     }
 }
Exemplo n.º 12
0
        public override async Task VerifyQuality(
            VerificationRequest request,
            IServerStreamWriter <VerificationResponse> responseStream,
            ServerCallContext context)
        {
            try
            {
                await StartRequest(request);

                Func <ITrackCancel, ServiceCallStatus> func =
                    trackCancel => VerifyQualityCore(request, responseStream, trackCancel);

                ServiceCallStatus result =
                    await GrpcServerUtils.ExecuteServiceCall(
                        func, context, _staThreadScheduler);

                _msg.InfoFormat("Verification {0}", result);
            }
            catch (Exception e)
            {
                _msg.Error($"Error verifying quality for request {request}", e);

                SendFatalException(e, responseStream);
                SetUnhealthy();
            }
            finally
            {
                EndRequest();
            }
        }
        public override async Task VerifyQuality(
            VerificationRequest request,
            IServerStreamWriter <VerificationResponse> responseStream,
            ServerCallContext context)
        {
            try
            {
                _msg.InfoFormat("Starting verification request from {0}", request.UserName);
                _msg.DebugFormat("Request details: {0}", request);

                if (Checkout3DAnalyst)
                {
                    // It must be re-checked out (but somehow it's enough to do it
                    // on the calling thread-pool thread!?)
                    Ensure3dAnalyst();
                }

                Func <ITrackCancel, ServiceCallStatus> func =
                    trackCancel => VerifyQualityCore(request, responseStream, trackCancel);

                ServiceCallStatus result =
                    await GrpcServerUtils.ExecuteServiceCall(
                        func, context, _singleStaThreadScheduler);

                _msg.InfoFormat("Verification {0}", result);
            }
            catch (Exception e)
            {
                _msg.Error($"Error verifying quality for request {request}", e);

                SendFatalException(e, responseStream);
                SetUnhealthy();
            }
        }
Exemplo n.º 14
0
        private void Verify([NotNull] ITest test, [NotNull] IEnumerable <IRow> rows)
        {
            Assert.ArgumentNotNull(test, nameof(test));
            Assert.ArgumentNotNull(rows, nameof(rows));

            try
            {
                ClearCurrentRow();

                test.Execute(rows);
            }
            catch (Exception e)
            {
                IList <InvolvedRow> involvedRows =
                    _currentRow != null
                                                ? (IList <InvolvedRow>) new[] { new InvolvedRow(_currentRow) }
                                                : new List <InvolvedRow>();

                IGeometry geometry = null;
                var       feature  = _currentRow as IFeature;
                if (feature != null)
                {
                    geometry = feature.ShapeCopy;
                }

                QualityCondition qualityCondition = GetQualityCondition(test);
                string           description      = string.Format("Error testing quality condition '{0}': {1}",
                                                                  qualityCondition.Name, e.Message);

                _msg.Error(description, e);

                var qaError = new QaError(test, description, involvedRows, geometry, null, null);

                ProcessQaError(qaError);

                _msg.Error(description, e);
                CancellationTokenSource.Cancel();
            }
        }
Exemplo n.º 15
0
        public void Callback()
        {
            if (_pending)
            {
                _msg.VerboseDebug("Callback already pending - ignored");
                return;
            }

            _expectedThreadId = Thread.CurrentThread.ManagedThreadId;

            if (_synchronizationContext == null)
            {
                // get the winforms synchronization context
                // NOTE: relying on the current synchronization context of the current thread is not sufficient,
                //       as this gets changed depending on previous winforms actions:
                //       - after showing a modal dialog, the synchronization context DOES NOT displatch back to the gui thread
                //       - after opening/activating a modeless form, it DOES dispatch back to the gui thread
                // -> better to set the expected synchronization context explicitly
                // NOTE: this must be done on the gui thread, otherwise even this synchronization context will not dispatch back to it
                _synchronizationContext = new WindowsFormsSynchronizationContext();
            }

            _msg.VerboseDebugFormat("Scheduling delayed processing (thread: {0})",
                                    Thread.CurrentThread.ManagedThreadId);

            try
            {
                _pending = true;

                _synchronizationContext.Post(delegate { TryExecuteProcedure(); }, null);
            }
            catch (Exception ex)
            {
                _pending = false;
                _msg.Error($"Error executing procedure via synchronization context: {ex.Message}",
                           ex);
            }
        }
Exemplo n.º 16
0
        protected void HandleError(string message, Exception e, bool noMessageBox = false)
        {
            _msg.Error(message, e);

            if (!noMessageBox)
            {
                Application.Current.Dispatcher.Invoke(
                    () =>
                {
                    MessageBox.Show(message, "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                });
            }
        }
Exemplo n.º 17
0
        protected override WorkListStatusSchema CreateStatusSchemaCore(FeatureClassDefinition definition)
        {
            int fieldIndex;

            try
            {
                fieldIndex = definition.FindField(_statusFieldName);

                if (fieldIndex < 0)
                {
                    throw new ArgumentException($"No field {_statusFieldName}");
                }
            }
            catch (Exception e)
            {
                _msg.Error($"Error find field {_statusFieldName} in {definition.GetName()}", e);
                throw;
            }

            return(new WorkListStatusSchema(_statusFieldName, fieldIndex,
                                            (int)IssueCorrectionStatus.NotCorrected,
                                            (int)IssueCorrectionStatus.Corrected));
        }
Exemplo n.º 18
0
        protected void RaiseChanged(CancelEventArgs e)
        {
            try
            {
                ElementValueChanged();
            }
            catch (Exception ex)
            {
                e.Cancel = true;

                ShowErrorMessages(ex.Message);

                _msg.Error(ex.Message, ex);
            }
        }
Exemplo n.º 19
0
        public static void HandleError([NotNull] string message,
                                       [CanBeNull] Exception exception,
                                       [CanBeNull] IMsg msg     = null,
                                       [CanBeNull] string title = null)
        {
            string caption = string.IsNullOrEmpty(title) ? _errortitle : title;

            if (msg == null)
            {
                msg = _msg;
            }

            // write to log
            if (exception != null)
            {
                msg.Error(message, exception);
            }
            else
            {
                msg.Error(message);
            }

            Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error);
        }
Exemplo n.º 20
0
        public static void HandleFailure([NotNull] string message,
                                         [CanBeNull] IMsg msg     = null,
                                         [CanBeNull] string title = null)
        {
            string caption = string.IsNullOrEmpty(title) ? _failuretitle : title;

            if (msg == null)
            {
                msg = _msg;
            }

            // write to log
            msg.Error(message);

            Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
        }
Exemplo n.º 21
0
        private static void Try([CanBeNull] string methodName,
                                [NotNull] Action procedure)
        {
            try
            {
                if (!string.IsNullOrEmpty(methodName))
                {
                    _msg.Debug(methodName);
                }

                procedure();
            }
            catch (Exception e)
            {
                _msg.Error(e.Message, e);
            }
        }
Exemplo n.º 22
0
        public static IWorkList Create([NotNull] XmlWorkListDefinition definition)
        {
            Assert.ArgumentNotNull(definition, nameof(definition));

            var descriptor = new ClassDescriptor(definition.TypeName, definition.AssemblyName);

            Type type = descriptor.GetInstanceType();

            Dictionary <Geodatabase, List <Table> > tablesByGeodatabase = GetTablesByGeodatabase(definition.Workspaces);

            IRepository         stateRepository;
            IWorkItemRepository repository;

            if (type == typeof(IssueWorkList))
            {
                stateRepository = new XmlWorkItemStateRepository(definition.Path, definition.Name, type, definition.CurrentIndex);
                repository      = new IssueItemRepository(tablesByGeodatabase, stateRepository);
            }
            else if (type == typeof(SelectionWorkList))
            {
                stateRepository = new XmlWorkItemStateRepository(definition.Path, definition.Name, type, definition.CurrentIndex);

                Dictionary <long, Table> tablesById =
                    tablesByGeodatabase.Values
                    .SelectMany(table => table)
                    .ToDictionary(table => new GdbTableIdentity(table).Id, table => table);

                Dictionary <Table, List <long> > oidsByTable = GetOidsByTable(definition.Items, tablesById);

                repository = new SelectionItemRepository(tablesByGeodatabase, oidsByTable, stateRepository);
            }
            else
            {
                throw new ArgumentException("Unkown work list type");
            }

            try
            {
                return(descriptor.CreateInstance <IWorkList>(repository, definition.Name));
            }
            catch (Exception e)
            {
                _msg.Error("Cannot create work list", e);
                throw;
            }
        }
Exemplo n.º 23
0
        public WorkItemStatus GetStatus([NotNull] Row row)
        {
            Assert.ArgumentNotNull(row, nameof(row));

            try
            {
                object value = row[_statusSchema.FieldIndex];

                return(GetStatus(value));
            }
            catch (Exception e)
            {
                _msg.Error($"Error get value from row {row} with index {_statusSchema.FieldIndex}", e);

                return(WorkItemStatus.Todo);
            }
        }
Exemplo n.º 24
0
 // TODO algr: temporary tests
 protected override async void OnClick()
 {
     try
     {
         var window = FrameworkApplication.ActiveWindow as IProjectWindow;
         var path   = window?.SelectedItems.First().Path;
         if (path != null)
         {
             _msg.Info($"Open worklist file {path}");
             await ProSuiteToolsModule.OpenIssuesWorklist(path);
         }
     }
     catch (Exception ex)
     {
         _msg.Error("Open WorkList error", ex);
     }
 }
Exemplo n.º 25
0
        private static T TryExecute <T>(Func <T> func,
                                        CancellationToken cancellationToken,
                                        string methodName)
        {
            T response = default;

            try
            {
                response = func();
            }
            catch (Exception e)
            {
                _msg.Error($"Error in {methodName}", e);
                //trackCancellationToken.Exception = e;
            }

            return(response);
        }
Exemplo n.º 26
0
        // every service provider is responsible for converting of input/output data (common data format converters?)
        #region Data converters

        private IReadOnlyList <string> PrepareGPToolParameters(ProSuiteQARequest parameters, ProSuiteQAToolType toolType)
        {
            try
            {
                var toolParams = parameters.RequestData?.ToString();
                if (toolParams == null)
                {
                    return(null);
                }

                var localParams = toolParams.Split(',');
                return(Geoprocessing.MakeValueArray(localParams));
            }
            catch (Exception ex)
            {
                _msg.Error(ex.Message);
            }
            return(null);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Executes a procedure in an edit operation
        /// </summary>
        /// <param name="workspace">The workspace in which the operation is executed</param>
        /// <param name="procedure">The operation.</param>
        /// <param name="state">The state.</param>
        /// <param name="description">The description for the edit operation.</param>
        /// <param name="trackCancel">The cancel tracker (optional).</param>
        /// <returns>
        ///     <c>true</c> if the operation succeeded, <c>false</c> if it was aborted.
        /// </returns>
        public bool Execute(IWorkspace workspace, Action <ITrackCancel> procedure,
                            EditStateInfo state, string description,
                            ITrackCancel trackCancel)
        {
            Assert.ArgumentNotNull(workspace, nameof(workspace));
            Assert.ArgumentNotNull(procedure, nameof(procedure));
            Assert.ArgumentNotNullOrEmpty(description, nameof(description));

            if (trackCancel != null)
            {
                Assert.True(trackCancel.Continue(), "Cancel tracker already cancelled");
            }

            using (EditWorkspace(workspace))
            {
                var editWs  = (IWorkspaceEdit)workspace;
                var editWs2 = workspace as IWorkspaceEdit2;                 // not implemented for shapefiles

                bool isBeingEdited     = editWs.IsBeingEdited();
                bool isInEditOperation = (editWs2 != null && editWs2.IsInEditOperation);

                if ((state & EditStateInfo.MustNotBeEditing) != 0)
                {
                    Assert.False(isBeingEdited, "Edit Session already open");
                }

                if ((state & EditStateInfo.MustBeEditing) != 0)
                {
                    Assert.True(isBeingEdited, "Edit Session not open");
                }

                if ((state & EditStateInfo.MustNotBeInOperation) != 0)
                {
                    if (isInEditOperation)
                    {
                        AbortEditOperation();
                        _msg.Warn("Rolled back unexpected existing edit operation");
                    }

                    isInEditOperation = false;
                }

                if ((state & EditStateInfo.MustBeInOperation) != 0)
                {
                    Assert.True(isInEditOperation, "Edit Session not in Operation");
                }

                _aborted = false;

                IWorkspaceEditEvents_Event workspaceEditEvents = null;

                try
                {
                    #region check reset current state

                    if (isInEditOperation)
                    {
                        if ((state & EditStateInfo.AbortExistingOperation) != 0)
                        {
                            Assert.True(
                                (state & EditStateInfo.StopExistingOperation) == 0,
                                "Cannot specify both " +
                                EditStateInfo.AbortExistingOperation + " and " +
                                EditStateInfo.StopExistingOperation);
                            AbortEditOperation();
                            isInEditOperation = false;
                        }
                        else if ((state & EditStateInfo.StopExistingOperation) != 0)
                        {
                            StopEditOperation(description);
                            isInEditOperation = false;
                        }
                    }

                    if (isBeingEdited)
                    {
                        if ((state & EditStateInfo.AbortExistingEditing) != 0)
                        {
                            Assert.True((state & EditStateInfo.StopExistingEditing) == 0,
                                        "Cannot specify both " +
                                        EditStateInfo.AbortExistingEditing + " and " +
                                        EditStateInfo.StopExistingEditing);

                            StopEditing(false);
                            isBeingEdited = false;
                        }
                        else if ((state & EditStateInfo.StopExistingEditing) != 0)
                        {
                            StopEditing(true);
                            isBeingEdited = false;
                        }
                    }

                    #endregion

                    if (!isBeingEdited)
                    {
                        StartEditing();
                    }

                    if (!isInEditOperation && (state & EditStateInfo.DontStartOperation) == 0)
                    {
                        StartEditOperation();
                    }

                    // this may fail (COM object that has been separated from its underlying RCW cannot be used)
                    workspaceEditEvents = (IWorkspaceEditEvents_Event)workspace;
                    workspaceEditEvents.OnAbortEditOperation += editEvents_OnAbortEditOperation;

                    procedure(trackCancel);

                    if (trackCancel != null && !trackCancel.Continue())
                    {
                        _msg.WarnFormat("Operation cancelled: {0}", description);

                        // cancel was called in procedure
                        if (!_aborted)
                        {
                            // The operation is not yet aborted. Abort it now.
                            AbortEditOperation();
                        }
                    }

                    if (!_aborted &&
                        (!isInEditOperation &&
                         (state & EditStateInfo.KeepOperation) == 0) ||
                        (state & EditStateInfo.StopOperation) != 0)
                    {
                        // if the edit operation violates rule engine rules, the edit operation won't succeed. However
                        // no exception is reported when calling StopEditOperation --> the OnAbort handler is mandatory
                        // to detect this situation.
                        StopEditOperation(description);
                    }

                    if ((!isBeingEdited &&
                         (state & EditStateInfo.KeepEditing) == 0) ||
                        (state & EditStateInfo.StopEditing) != 0)
                    {
                        StopEditing(true);
                    }

                    return(!_aborted);
                }
                catch (Exception ex)
                {
                    try                     // Clean up
                    {
                        var    comEx   = ex as COMException;
                        string message =
                            comEx == null
                                                                ? string.Format("Error executing operation: {0} ({1})",
                                                                                description, ex.Message)
                                                                : string.Format(
                                "Error executing operation: {0} ({1}; Error Code: {2})",
                                description, comEx.Message, comEx.ErrorCode);

                        _msg.Debug(message);

                        if (!isInEditOperation)
                        {
                            // if the error occurred in StopEditOperation(), then
                            // that edit operation might already be aborted -> check
                            if (editWs2 != null && editWs2.IsInEditOperation)
                            {
                                AbortEditOperation();
                            }
                        }

                        if (!isBeingEdited)
                        {
                            StopEditing(false);
                        }
                    }
                    catch (Exception e2)
                    {
                        // exception intentionally suppressed.
                        _msg.Error("Error cleaning up after failed gdb function", e2);
                    }

                    throw;
                }
                finally
                {
                    try
                    {
                        if (workspaceEditEvents != null)
                        {
                            workspaceEditEvents.OnAbortEditOperation -=
                                editEvents_OnAbortEditOperation;
                        }
                    }
                    catch (AccessViolationException e)
                    {
                        // exception intentionally suppressed.
                        _msg.Warn("Error unregistering event handler", e);
                    }
                }
            }
        }
Exemplo n.º 28
0
 public void ReportError(string text, Exception exception = null)
 {
     _msg.Error(text, exception);
 }
Exemplo n.º 29
0
        public static async Task <IList <FeatureLayer> > AddFeaturesToMap(string groupLayer, string path, string featureName = null, IList <string> layernames = null, bool select = true)
        {
            // is map visible?
            if (MapView.Active == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            // are data zipped?
            var featuresGdb = path.Replace("\n", string.Empty).Replace("\r", string.Empty).Replace(@"\\", @"\");

            if (string.Equals(Path.GetExtension(featuresGdb), ".zip", StringComparison.OrdinalIgnoreCase))
            {
                var extractDir = Path.GetDirectoryName(path);
                if (extractDir == null)
                {
                    return(null);
                }
                ZipFile.ExtractToDirectory(path, extractDir);
                featuresGdb = Path.Combine(extractDir, Path.GetFileNameWithoutExtension(path), featureName);
                if (!Directory.Exists(featuresGdb))
                {
                    return(null);
                }
            }

            var layerList = new List <FeatureLayer>();
            await QueuedTask.Run(async() =>
            {
                try
                {
                    // TODO remove previous error layers?

                    // TODO get layernames from workspace if null?

                    var newGroupLayer     = LayerFactory.Instance.CreateGroupLayer(MapView.Active.Map, 0, groupLayer);
                    Envelope commonExtent = null;

                    foreach (var layername in layernames)
                    {
                        var featureLayer = LayerFactory.Instance.CreateFeatureLayer(new Uri(Path.Combine(featuresGdb, layername)), newGroupLayer);
                        layerList.Add(featureLayer);
                        commonExtent = featureLayer.QueryExtent();
                    }

                    await MapView.Active.ZoomToAsync(commonExtent, TimeSpan.FromSeconds(0));
                    await MapView.Active.ZoomOutFixedAsync(TimeSpan.FromSeconds(0));

                    _msg.Info($"LayerUtils: QA error layers were added to map");

                    if (select)
                    {
                        SelectLayersInMap(layerList);
                        //SelectLayersInTOC(layerList);
                    }
                }
                catch (Exception ex)
                {
                    _msg.Error($"LayerUtils: {ex.Message}");
                }
            });

            return(layerList);
        }
Exemplo n.º 30
0
        private void Execute([NotNull] ICollection <ITest> nonContainerTests)
        {
            Assert.ArgumentNotNull(nonContainerTests, nameof(nonContainerTests));

            var testIndex = 0;
            int testCount = nonContainerTests.Count;

            foreach (ITest nonContainerTest in nonContainerTests)
            {
                // Execute ITest
                nonContainerTest.QaError    += test_QaError;
                nonContainerTest.TestingRow += test_TestingRow;

                try
                {
                    using (
                        UseProgressWatch(Step.ITestProcessing, Step.ITestProcessed, testIndex,
                                         testCount, nonContainerTest))
                    {
                        _totalErrorCount += ExecuteNonContainerTest(nonContainerTest);

                        _errorAdministrator.Clear();
                    }
                }
                catch (TestException exp)
                {
                    _msg.Error(string.Format("Non-container test execution failed: {0}",
                                             exp.Message), exp);

                    ReportErrorForFailedTest(exp.Test, null,
                                             string.Format("Test execution failed: {0}",
                                                           exp.Message));
                }
                catch (TestRowException exp)
                {
                    _msg.Error(string.Format("Non-container test execution failed for row: {0}",
                                             exp.Message), exp);

                    ReportErrorForFailedTest(exp.Test, new RowReference(exp.Row, recycled: false),
                                             string.Format("Test execution failed: {0}",
                                                           exp.Message));
                }
                catch (Exception exp)
                {
                    _msg.Error(string.Format("Non-container test execution failed: {0}",
                                             exp.Message), exp);

                    throw new TestContainerException(nonContainerTest, exp);
                }
                finally
                {
                    testIndex++;
                    nonContainerTest.QaError    -= test_QaError;
                    nonContainerTest.TestingRow -= test_TestingRow;
                }

                if (_stopExecute)
                {
                    return;
                }
            }
        }