Beispiel #1
0
        public CremaDataSet GetTableCategoryData(string repositoryPath, string localPath, long revision)
        {
            var tempPath = PathUtility.GetTempPath(true);

            try
            {
                var revisionValue = revision == -1 ? this.Revision : revision;
                var repoUri       = this.GetUri(repositoryPath, revisionValue);
                var categoryUri   = this.GetUri(localPath, revisionValue);
                var categoryPath  = this.Export(categoryUri, tempPath);
                var baseUri       = this.GetDataBaseUri($"{repoUri}", $"{categoryUri}");

                var files = DirectoryUtility.GetAllFiles(categoryPath, "*" + CremaSchema.XmlExtension);
                foreach (var item in files)
                {
                    var relativeItemUri = UriUtility.MakeRelative(categoryPath, item);
                    var itemUri         = UriUtility.Combine(UriUtility.GetDirectoryName(categoryUri), $"{relativeItemUri}@{revisionValue}");
                    var xmlInfo         = new CremaXmlReadInfo(item);
                    var schemaUri       = UriUtility.Combine(UriUtility.GetDirectoryName(itemUri), $"{xmlInfo.RelativeSchemaPath}@{revisionValue}");
                    var schemaPath      = new Uri(UriUtility.Combine(Path.GetDirectoryName(item), xmlInfo.RelativeSchemaPath)).LocalPath;
                    if (File.Exists(schemaPath) == false)
                    {
                        this.Export(schemaUri, tempPath);
                    }
                    ExportTypes(schemaUri, schemaPath);
                }

                void ExportTypes(Uri schemaUri, string schemaPath)
                {
                    var xsdInfo = new CremaSchemaReadInfo(schemaPath);

                    foreach (var item in xsdInfo.RelativeTypePaths)
                    {
                        var typeUri  = UriUtility.Combine(UriUtility.GetDirectoryName(schemaUri), $"{item}@{revisionValue}");
                        var typePath = new Uri(UriUtility.Combine(Path.GetDirectoryName(schemaPath), item)).LocalPath;
                        if (File.Exists(typePath) == false)
                        {
                            this.Export(typeUri, tempPath);
                        }
                    }
                }

                var pureBaseUri         = $"{baseUri}".Replace($"@{revisionValue}", string.Empty);
                var pureCategoryUri     = $"{categoryUri}".Replace($"@{revisionValue}", string.Empty);
                var dataBaseRelativeUri = UriUtility.MakeRelativeOfDirectory(pureCategoryUri, pureBaseUri);
                var dataBasePath        = UriUtility.Combine(new Uri(categoryPath), dataBaseRelativeUri).LocalPath;
                return(CremaDataSet.ReadFromDirectory(dataBasePath));
            }
            finally
            {
                DirectoryUtility.Delete(tempPath);
            }
        }
Beispiel #2
0
        public CremaDataSet GetTableData(string repositoryPath, string tableXmlPath, string tableSchemaPath, long revision)
        {
            var tempPath = PathUtility.GetTempPath(true);

            try
            {
                var revisionValue = revision == -1 ? this.Revision : revision;
                var repoUri       = this.GetUri(repositoryPath, revisionValue);
                var xmlUri        = this.GetUri(tableXmlPath, revisionValue);
                var baseUri       = this.GetDataBaseUri($"{repoUri}", $"{xmlUri}");

                var xmlPath = this.Export(xmlUri, tempPath);
                var xmlInfo = new CremaXmlReadInfo(xmlPath);

                var schemaUri  = UriUtility.Combine(UriUtility.GetDirectoryName(xmlUri), xmlInfo.RelativeSchemaPath + "@" + revisionValue);
                var schemaPath = this.Export(schemaUri, tempPath);

                var xsdInfo = new CremaSchemaReadInfo(schemaPath);

                foreach (var item in xsdInfo.RelativeTypePaths)
                {
                    var typeUri = UriUtility.Combine(UriUtility.GetDirectoryName(schemaUri), $"{item}@{revisionValue}");
                    this.Export(typeUri, tempPath);
                }

                var pureBaseUri     = $"{baseUri}".Replace($"@{revisionValue}", string.Empty);
                var pureTableXmlUri = $"{xmlUri}".Replace($"@{revisionValue}", string.Empty);

                var dataBaseRelativeUri = UriUtility.MakeRelativeOfDirectory(pureTableXmlUri, pureBaseUri);
                var dataBasePath        = UriUtility.Combine(new Uri(xmlPath), dataBaseRelativeUri).LocalPath;
                return(CremaDataSet.ReadFromDirectory(dataBasePath));
            }
            finally
            {
                DirectoryUtility.Delete(tempPath);
            }
        }