Example #1
0
 private async static Task DeleteItem(DocumentServiceDefinition.DocumentServiceDefinitionClient documentClient)
 {
     var input = new DeleteItemRequest {
         Id = 9
     };
     var reply = await documentClient.DeleteItemAsync(input);
 }
Example #2
0
        private async static Task DownloadItem(DocumentServiceDefinition.DocumentServiceDefinitionClient documentClient)
        {
            var input = new DownloadItemRequest {
                Id = 9
            };

            string tempFileName  = $@"C:\Users\molnar.zsolt\DokuStore\temp_{DateTime.UtcNow.ToString("yyyyMMdd_HHmmss")}.tmp";
            string finalFileName = tempFileName;

            using (var reply = documentClient.DownloadItem(input))
            {
                await using (Stream fs = File.OpenWrite(tempFileName))
                {
                    await foreach (DataChunkResponse chunkMsg in reply.ResponseStream.ReadAllAsync().ConfigureAwait(false))
                    {
                        //Int64 totalSize = chunkMsg.FileSize;
                        string tempFinalFilePath = chunkMsg.FileName;

                        if (!string.IsNullOrEmpty(tempFinalFilePath))
                        {
                            finalFileName = chunkMsg.FileName;
                        }

                        fs.Write(chunkMsg.Chunk.ToByteArray());
                    }
                }
            }
            if (finalFileName != tempFileName)
            {
                File.Move(tempFileName, finalFileName);
            }
        }
Example #3
0
 private async static Task CreateItem(DocumentServiceDefinition.DocumentServiceDefinitionClient documentClient)
 {
     var input = new CreateItemRequest {
         Name = "ChildOfRoot", TypeId = 1, ProjectId = 1, ParentId = 9
     };
     var reply = await documentClient.CreateItemAsync(input);
 }
Example #4
0
        private async static Task TestDocumentService(GrpcChannel channel)
        {
            var documentClient = new DocumentServiceDefinition.DocumentServiceDefinitionClient(channel);

            // await CreateItem(documentClient);
            //await DeleteItem(documentClient);
            await DownloadItem(documentClient);
        }