Пример #1
0
        public async Task <string> ImportRtModel(string tenantId, string rtModelFilePath)
        {
            ArgumentValidation.ValidateString(nameof(tenantId), tenantId);
            ArgumentValidation.ValidateExistingFile(nameof(rtModelFilePath), rtModelFilePath);

            var request = new RestRequest("models/ImportRt", Method.POST);

            request.AddQueryParameter("tenantId", tenantId);

            if (Path.GetExtension(rtModelFilePath)?.ToLower() == ".zip")
            {
                request.AddFile("file", rtModelFilePath, contentType: "application/zip");
            }
            else if (Path.GetExtension(rtModelFilePath)?.ToLower() == ".json")
            {
                request.AddFile("file", rtModelFilePath, contentType: "application/json");
            }
            else
            {
                throw new ServiceClientException($"'{rtModelFilePath}' is not a supported file.");
            }

            IRestResponse <string> response = await Client.ExecuteAsync <string>(request);

            ValidateResponse(response);

            return(response.Data);
        }
Пример #2
0
        public async Task ExportRtModelAsync(IOspSession session, OspObjectId queryId, string filePath,
                                             CancellationToken?cancellationToken)
        {
            ArgumentValidation.Validate(nameof(session), session);
            ArgumentValidation.Validate(nameof(queryId), queryId);
            ArgumentValidation.ValidateExistingFile(nameof(filePath), filePath);

            var exporter = new ExportRtModel(this);
            await exporter.Export(session, queryId, filePath, cancellationToken);
        }
Пример #3
0
        public async Task ImportCkModelAsync(IOspSession systemSession, string tenantId, ScopeIds scopeId,
                                             string filePath, CancellationToken?cancellationToken)
        {
            ArgumentValidation.Validate(nameof(systemSession), systemSession);
            ArgumentValidation.ValidateString(nameof(tenantId), tenantId);
            ArgumentValidation.ValidateExistingFile(nameof(filePath), filePath);

            var databaseContext = await CreateDatabaseContextByTenantAsync(systemSession, tenantId);

            using var session = await databaseContext.StartSessionAsync();

            session.StartTransaction();

            var importer = new ImportCkModel(databaseContext);
            await importer.Import(session, filePath, scopeId, cancellationToken);

            await session.CommitTransactionAsync();

            await UnloadTenantCachesAsync(tenantId);
        }