Пример #1
0
        public void Can_create_worklist_with_SDE_workspace_from_definition_file()
        {
            XmlWorkListDefinition definition = XmlWorkItemStateRepository.Import(_path);

            IWorkList worklist = WorkListUtils.Create(definition);

            Assert.NotNull(worklist);

            Assert.AreEqual(2, worklist.Count());
        }
Пример #2
0
        public override IWorkList Get()
        {
            if (WorkList == null)
            {
                XmlWorkListDefinition definition = XmlWorkItemStateRepository.Import(_path);

                WorkList = WorkListUtils.Create(definition);
            }

            return(WorkList);
        }
Пример #3
0
        public static string GetXmlWorklistName(string worklistPath)
        {
            if (String.IsNullOrEmpty(worklistPath))
            {
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();
            XmlWorkListDefinition definition = helper.ReadFromFile(worklistPath);

            return(definition.Name);
        }
Пример #4
0
        public static string GetWorklistPath(string path)
        {
            if (!path.EndsWith("wl"))
            {
                return(path);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();

            XmlWorkListDefinition definition = helper.ReadFromFile(path);

            return(definition.Workspaces.Select(w => w.Path).FirstOrDefault());
        }
Пример #5
0
        public static string GetWorklistName([NotNull] string worklistDefinitionFile)
        {
            Assert.ArgumentNotNullOrEmpty(worklistDefinitionFile, nameof(worklistDefinitionFile));

            if (!File.Exists(worklistDefinitionFile))
            {
                _msg.Debug($"{worklistDefinitionFile} does not exist");
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();
            XmlWorkListDefinition definition = helper.ReadFromFile(worklistDefinitionFile);

            return(definition.Name);
        }
Пример #6
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;
            }
        }
Пример #7
0
        public static string GetIssueGeodatabasePath([NotNull] string worklistDefinitionFile)
        {
            Assert.ArgumentNotNullOrEmpty(worklistDefinitionFile, nameof(worklistDefinitionFile));

            if (!File.Exists(worklistDefinitionFile))
            {
                _msg.Debug($"{worklistDefinitionFile} does not exist");
                return(null);
            }

            string extension = Path.GetExtension(worklistDefinitionFile);

            if (!string.Equals(extension, ".iwl"))
            {
                _msg.Debug($"{worklistDefinitionFile} is no issue work list");
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();

            XmlWorkListDefinition       definition = helper.ReadFromFile(worklistDefinitionFile);
            List <XmlWorkListWorkspace> workspaces = definition.Workspaces;

            string result = workspaces[0].ConnectionString;

            if (workspaces.Count > 0)
            {
                _msg.Info(
                    $"There are many issue geodatabases in {worklistDefinitionFile} but only one is expected. Taking the first one {result}");
            }
            else
            {
                _msg.Debug($"Found issue geodatabase {result} in {worklistDefinitionFile}");
            }

            return(result);
        }