예제 #1
0
        public async void Execute(object parameter)
        {
            _isWorking = true;
            OnCanExecuteChanged();
            var task = Task.Run(() =>
            {
                try
                {
                    var model = GetModel(parameter).ConfigurationModel;
                    var json  = model.ToJson();
                    FilePickerHelper.SaveFile(json, "json");
                }
                catch (Exception e)
                {
                    NotifyUser.NotifyUserByNotification(
                        new Notification()
                    {
                        Title   = "Ooooops!",
                        Message =
                            $"Something happend during generation of your code.",
                        Exception = e
                    });
                }
                finally
                {
                    _isWorking = false;
                }
            });
            await task;

            task.Dispose();
            OnCanExecuteChanged();
        }
        public override async void Execute(object parameter)
        {
            _isSaving = true;
            OnCanExecuteChanged();
            var task = Task.Run(() =>
            {
                try
                {
                    var model = ViewModel.GetTrainedModel();
                    FilePickerHelper.SaveFile(model.ToJson(), "mementoModelJson");
                }
                catch (Exception e)
                {
                    NotifyUser.NotifyUserByNotification(
                        new Notification()
                    {
                        Title   = "SDK model to json error",
                        Message =
                            $"Something happend during generation of your code.",
                        Exception = e
                    });
                }
                finally
                {
                    _isSaving = false;
                    App.RunInUiThread(OnCanExecuteChanged);
                }
            });
            await task;

            task.Dispose();
        }
예제 #3
0
        private async void SaveFile(NetModelCreator paModelCreator)
        {
            _isSaving = true;
            CanExecuteChanged?.Invoke(this, EventArgs.Empty);
            await Task.Run(() =>
            {
                try
                {
                    var model = paModelCreator.GenerateModel();
                    var json  = model.ToJson();
                    FilePickerHelper.SaveFile(json, ViewModels.NetBuilderViewModel.CleanNetModel);
                }
                catch (Exception e)
                {
                    NotifyUser.NotifyUserByNotification(new Notification()
                    {
                        Title     = "Something happend during saving model.",
                        Message   = $"Make sure you have all permissions to write.",
                        Exception = e
                    });
                }
            });

            _isSaving = false;
            CanExecuteChanged?.Invoke(this, EventArgs.Empty);
        }
        public override async void Execute(object parameter)
        {
            _isSaving = true;
            var task = Task.Run(() =>
            {
                try
                {
                    var model = ViewModel.GetTrainedModel();
                    if (model == null)
                    {
                        return;
                    }
                    var trainedModel = new TrainedNetModel((MementoConfigurationModel)model.Clone())
                    {
                        ModelName       = ViewModel.Model.ModelName,
                        DataSetMetaData = ViewModel.DataSetModel.MetaData
                    };
                    FilePickerHelper.SaveFile(trainedModel.ToJson(), NetBuilderViewModel.DirtyNetModel);
                }
                catch (Exception e)
                {
                    NotifyUser.NotifyUserByNotification(
                        new Notification()
                    {
                        Title   = "Ooooops!",
                        Message =
                            $"Something happend during generation of your code.",
                        Exception = e
                    });
                }
                finally
                {
                    _isSaving = false;
                    App.RunInUiThread(OnCanExecuteChanged);
                }
            });
            await task;

            task.Dispose();
        }
예제 #5
0
 public override void Execute(object parameter)
 {
     try
     {
         var model = ViewModel.GetTrainedModel();
         if (model == null)
         {
             return;
         }
         var generator = new CplusPlusCodeGenerator(model);
         generator.GenerateCode();
         FilePickerHelper.SaveFile(generator.Result, "h");
     }
     catch (Exception e)
     {
         NotifyUser.NotifyUserByNotification(
             new Notification()
         {
             Title     = "Ooooops!",
             Message   = $"Something happend during generation of your code.",
             Exception = e
         });
     }
 }