Exemplo n.º 1
0
        private async Task <CosmosContainer> GetContainer()
        {
            try
            {
                await cosmosClient.GetDatabase(SingleTon.getResources("DatabaseId")).CreateContainerIfNotExistsAsync(new ContainerProperties()
                {
                    Id = SingleTon.getResources("ContainerId"), PartitionKeyPath = "/Name", IndexingPolicy = new IndexingPolicy()
                    {
                        Automatic = true, IndexingMode = IndexingMode.Consistent
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            CosmosContainer container = null;

            try
            {
                container = cosmosClient.GetContainer(SingleTon.getResources("DatabaseId"), SingleTon.getResources("ContainerId"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(container);
        }
Exemplo n.º 2
0
        public async static Task <string> UploadImage(Stream picture, string name)
        {
            BlobContainerClient blobContainerClient = new BlobContainerClient(SingleTon.getResources("connectionStringBlob"), "images");
            BlobClient          BC = blobContainerClient.GetBlobClient(name);
            await BC.UploadAsync(picture, new BlobHttpHeaders()
            {
                ContentType = "image/jpeg"
            });                                                                                 // a extenstion detecting system should be created

            return(blobContainerClient.GetBlobClient(name).Uri.ToString());
        }
Exemplo n.º 3
0
 private async Task <CosmosDatabase> GetDB()
 {
     try
     {
         await cosmosClient.CreateDatabaseIfNotExistsAsync(SingleTon.getResources("DatabaseId"));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(cosmosClient.GetDatabase(SingleTon.getResources("DatabaseId")));
 }
Exemplo n.º 4
0
 public async Task CreateSQLConnector()
 {
     cosmosClient = new CosmosClient(SingleTon.getResources("EndpointUrl"), SingleTon.getResources("AuthorizationKey"));
     await GetDB();
     await GetContainer();
 }