Пример #1
0
        private async void ChooseStepsWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Loaded -= ChooseStepsWindow_Loaded;
                if (OtManager == null)
                {
                    OtManager            = new OptimizationTemplateManager();
                    Mouse.OverrideCursor = Cursors.Wait;

                    await OtManager.LoadAsync(template.FilePath);

                    //treeView.ItemsSource = testdata;
                    treeView.LayoutUpdated += TreeView_LayoutUpdated;
                    treeView.ItemsSource    = OtManager.RootGroups;
                }
                else
                {
                    treeView.ItemsSource = OtManager.RootGroups;
                }
            }
            catch (Exception ex)
            {
                Log.Error("ChooseStepsWindow.ChooseStepsWindow_Loaded", ex.ToString());
            }
        }
Пример #2
0
        private async void RunOSOTTempaltePage_Loaded(object sender, RoutedEventArgs e)
        {
            Log.Debug("RunOSOTTempaltePage", "OSOT Page Loaded");
            Loaded -= RunOSOTTempaltePage_Loaded;
            //prepare: load the template with infinite progress asyncrounously
            SetProgress(INDEFINITE_PROGRESS, "loading the template...");


            optimizationTemplateManager = new OptimizationTemplateManager();
            //optimizationTemplateManager = new DummyOptimizationTemplateManager();

            //for debuging
            //SetProgress(INDEFINITE_PROGRESS, Directory.GetCurrentDirectory());
            //await Task.Delay(15000);

            //for smoother user experience
            await Task.Delay(250);

            optimizationTemplateManager.RunProgressChanged += OptimizationTemplateManager_RunProgressChanged;
            optimizationTemplateManager.RunCompleted       += OptimizationTemplateManager_RunCompleted;

            string templatePath = sessionParams.OSOTTemplateMetadata.FilePath;

            try
            {
                //the loading can fail; then we just need to finsihproceed to the next page
                await optimizationTemplateManager.LoadAsync(templatePath);

                switch (sessionParams.StepsChoiceOption)
                {
                case OSOTSessionState.StepsChoice.Default:
                    optimizationTemplateManager.RunDefaultStepsAsync();
                    break;

                case OSOTSessionState.StepsChoice.All:
                    optimizationTemplateManager.RunAllStepsAsync();
                    break;

                case OSOTSessionState.StepsChoice.Custom:
                    optimizationTemplateManager.RunSelectedStepsAsync(sessionParams.CustomStepsChoice);
                    break;
                }
            }
            catch (Exception ex)
            {
                OptimizationTemplateManager_RunCompleted(false);
            }
        }