コード例 #1
0
 public async Task EditAsync([FromBody] Book book)
 {
     if (ModelState.IsValid)
     {
         await CosmosDBRepository <Book> .UpdateItemAsync(book.Id, book, CollectionId);
     }
 }
コード例 #2
0
        public static async Task UpdateDocument(NewRequest <SmartDoc> newDocReq, CosmosDBRepository <SmartDoc> client)
        {
            //foreach (var step in newDocReq.RequestItem.CognitivePipelineActions)
            //{
            //    if (newDocReq.RequestItem.CognitivePipelineActions == null)
            //        newDocReq.RequestItem.CognitivePipelineActions = new List<ProcessingStep>();

            //    newDocReq.RequestItem.CognitivePipelineActions.Add(step);
            //}
            await client.UpdateItemAsync(newDocReq.ItemReferenceId, newDocReq.RequestItem);
        }
コード例 #3
0
        public async Task ValidateAndSaveWorkspace()
        {
            ValidateWorkspaceRereference();
            var validationMessage = ValidateWorkspacePolicy();

            if (string.IsNullOrEmpty(validationMessage))
            {
                await UploadTrainingFiles();

                await workspaceRepo.UpdateItemAsync(activeWorkspace.id, activeWorkspace);
            }
            else
            {
                throw new InvalidOperationException("Workspace is invalid. " + validationMessage);
            }
        }
コード例 #4
0
        public static async void Run([TimerTrigger("0/20 * * * * *")] TimerInfo myTimer, ILogger log)
        {
            try
            {
                // Get Connections
                var Repository = new CosmosDBRepository("VMManagement", "VM_Power_State", log);
                var Connection = new AzureConnection("11c4bafa-00bb-43f4-a42d-ed6f2663fbaf",
                                                     "92c95553-455f-4b53-8bcf-e2dfe4dbcb0b",
                                                     "A4LbQRKmqT:2x4Iu/h=yM=pDBuu9VVA1",
                                                     log);


                log.LogInformation("RUN-MESSAGE 1 (AW 0903): Got Connections");

                // Get Data
                var CosmosItems = await Repository.GetItemsAsync();


                log.LogInformation($"RUN-MESSAGE 2: Got {CosmosItems.Count} items from CosmosDB.");

                var AzureMachines = Connection.VirtualMachines;

                log.LogInformation($"RUN-MESSAGE 3: Got {AzureMachines.Count} items from Azure VMs.");

                // Check if any data needs updating
                var toBeUpdated = CompareItems(CosmosItems, AzureMachines, log);

                if (toBeUpdated.Any())
                {
                    log.LogInformation($"RUN-MESSAGE 5: Got {toBeUpdated.Count} items to be updated.");

                    foreach (var cosmosItem in toBeUpdated)
                    {
                        // Update any data requiring updates
                        await Repository.UpdateItemAsync(cosmosItem);
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogError(ex, $"ERROR-RUN in Function. Message: {ex.Message}; InnerException: {ex.InnerException}");
            }
        }