Exemplo n.º 1
0
        public string ShowWorklist([NotNull] WorkEnvironmentBase environment, [NotNull] string path)
        {
            Assert.ArgumentNotNull(environment, nameof(environment));
            Assert.ArgumentNotNullOrEmpty(path, nameof(path));

            IWorkList worklist;

            string name = WorkListUtils.GetName(path).ToLower();

            if (_registry.Exists(name))
            {
                worklist = _registry.Get(name);
            }
            else
            {
                var factory = new XmlBasedWorkListFactory(path, name);

                if (_registry.TryAdd(factory))
                {
                    _msg.Debug($"Add work list {name} from file {path}");
                }

                worklist = _registry.Get(name);
            }

            Assert.NotNull(worklist);

            if (!_viewsByWorklistName.ContainsKey(worklist.Name))
            {
                var item = ProjectItemUtils.Get <WorklistItem>(Path.GetFileName(path));

                if (item == null)
                {
                    Assert.True(ProjectItemUtils.TryAdd(path, out item), $"Cannot add item {path}");
                    Assert.NotNull(item);
                }

                _viewsByWorklistName.Add(worklist.Name, new WorkListObserver(worklist, item));

                Uri uri = WorkListUtils.GetDatasource(GetProject().HomeFolderPath, name,
                                                      environment.FileSuffix);
                FeatureLayer layer = AddLayer(uri, name, item.Name);

                // use item name as layer name (and as view display name as well)
                LayerUtils.ApplyRenderer(layer, environment.GetLayerDocument());
            }

            return(Assert.NotNullOrEmpty(worklist.Name));
        }
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);
            }
        }