Пример #1
0
        private async Task DeleteModelAsync()
        {
            try
            {
                if (CurrentFormModel?.Id != null && !CurrentFormModel.IsPrebuiltModel)
                {
                    Guid modelId = CurrentFormModel.Id;

                    // delete Form Recognizer model
                    await this.formRecognizerService.DeleteCustomModelAsync(modelId);

                    // update local file with custom models
                    this.Models.Remove(CurrentFormModel);
                    await FormRecognizerDataLoader.SaveCustomModelsToFileAsync(this.Models.Where(x => !x.IsPrebuiltModel));

                    await FormRecognizerDataLoader.DeleteModelStorageFolderAsync(modelId);

                    // re-select the first item from collection
                    CurrentFormModel = this.Models.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure deleting model");
            }
        }
Пример #2
0
        private async void OnNewModelCreated(object sender, FormRecognizerViewModel e)
        {
            try
            {
                this.Models.Add(e);
                CurrentFormModel = this.Models.FirstOrDefault(m => m.Id == e.Id);

                // update local file with custom models
                await FormRecognizerDataLoader.SaveCustomModelsToFileAsync(this.Models.Where(x => !x.IsPrebuiltModel));
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure creating model");
            }
        }