Exemple #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));
        }
Exemple #2
0
        //private void UnregisterViewModel(IWorkList workList)
        //{
        //	SelectionWorkListVm vm = GetObserverByWorklistName(workList.Name) as SelectionWorkListVm;

        //	if (vm != null)
        //	{
        //		UnregisterObserver(vm);
        //	}
        //}

        private async Task OnProjectOpendedAsync(ProjectEventArgs e)
        {
            // todo daro:
            // 1) Check all existing project items.
            // 2) Add a work list factory to registry for every work list project item found in custom project items
            //	  (Use work list factory because we do not want to create a work list for EVERY work list project item.
            //	   Only create a work list (from a work list factory / work list custom project item) if a layer requests a work
            //	   list as a data source
            // order of method calls:
            // 1. Module.Initialize
            // 2. OnProjectOpenedAsync
            // 3. OnProjectOpened
            // 4. Pluggable Datasource Open()

            // todo daro: later this is replaced with custom project items

            // todo daro QueuedTask needed?
            await QueuedTask.Run(() =>
            {
                // todo daro: use ConfigurationUtils?
                // todo daro: revise!
                foreach (string path in GetDefinitionFiles())
                //foreach (var path in ProjectRepository.Current.GetProjectFileItems(ProjectItemType.WorkListDefinition))
                {
                    string workListName = WorkListUtils.GetName(path);
                    var factory         = new XmlBasedWorkListFactory(path, workListName);

                    Assert.True(_registry.TryAdd(factory),
                                $"work list {factory.Name} already added");
                }
            });
        }