public async Task ExportContentByKeyAsync(string authorization, string key, string outputFilePath, string excel = null)
        {
            if (string.IsNullOrEmpty(authorization))
            {
                throw new ArgumentNullException(nameof(authorization));
            }

            if (string.IsNullOrEmpty(outputFilePath))
            {
                throw new ArgumentNullException(nameof(outputFilePath));
            }

            var blipClient = _blipClientFactory.GetInstanceForBucket(authorization);

            //var key = "blip_portal:builder_working_flow";

            _logger.LogDebug("Bucket Export\n");

            var data = await blipClient.GetDocumentAsync(key, BucketNamespace.Document);

            if (data.HasValue)
            {
                var asString = JsonConvert.SerializeObject(data.Value.Value);
                var flow     = Path.Combine(outputFilePath, "bucket.json");
                _fileManagerService.CreateDirectoryIfNotExists(outputFilePath);
                using (var fw = new StreamWriter(flow, false, Encoding.UTF8))
                {
                    await fw.WriteAsync(asString);
                }
            }

            _logger.LogDebug("DONE\n");
        }
Пример #2
0
        public async override Task <int> RunAsync(string[] args)
        {
            if ((!FromAuthorization.IsSet) || (!ToAuthorization.IsSet))
            {
                throw new ArgumentNullException("You must provide from and to parameters for this action. Use '-f' [--from] (or '--fa' [--fromAuthorization]) and '-t' [--to] (or '--ta' [--toAuthorization]) parameters");
            }

            string fromAuthorization = FromAuthorization.Value;
            string toAuthorization   = ToAuthorization.Value;

            IBlipBucketClient sourceBlipBucketClient = _blipClientFactory.GetInstanceForBucket(fromAuthorization);
            IBlipBucketClient targetBlipBucketClient = _blipClientFactory.GetInstanceForBucket(toAuthorization);

            IBlipAIClient sourceBlipAIClient = _blipClientFactory.GetInstanceForAI(fromAuthorization);
            IBlipAIClient targetBlipAIClient = _blipClientFactory.GetInstanceForAI(toAuthorization);

            foreach (var content in Contents.Value)
            {
                //if IAModel handle in a different way
                if (content.Equals(BucketNamespace.AIModel))
                {
                    await CopyAIModelAsync(fromAuthorization, toAuthorization, sourceBlipAIClient, targetBlipAIClient);
                }
                else
                {
                    var documentKeysToCopy = await sourceBlipBucketClient.GetAllDocumentKeysAsync(content) ?? new DocumentCollection();

                    var documentPairsToCopy = await sourceBlipBucketClient.GetAllDocumentsAsync(documentKeysToCopy, content);

                    if (documentPairsToCopy != null)
                    {
                        foreach (var resourcePair in documentPairsToCopy)
                        {
                            await targetBlipBucketClient.AddDocumentAsync(resourcePair.Key, resourcePair.Value, content);
                        }
                    }
                }
            }

            return(0);
        }