Пример #1
0
        /** -------------------------------------------------------------------- **/

        private void CallbackLoadSessionFromFile(object sender, EventArgs e)
        {
            OpenFileDialog Dialog = new OpenFileDialog();

            Dialog.Filter           = "SEO Macroscope session files (*.seomacroscope)|*.seomacroscope";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "seomacroscope";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Pathname = Dialog.FileName;

                if (File.Exists(Pathname))
                {
                    Cursor.Current = Cursors.WaitCursor;

                    try
                    {
                        MacroscopeSessionLoader SessionLoader = new MacroscopeSessionLoader();
                        MacroscopeJobMaster     JobMaster     = SessionLoader.Load(Pathname: Pathname);

                        if (JobMaster != null)
                        {
                            this.ScanReset(JobRunTimeMode: JobMaster.GetRunTimeMode());

                            JobMaster.InitializeAfterDeserialization(NewTaskController: this);
                            this.SetJobMaster(NewJobMaster: JobMaster);

                            this.SetIncludeExcludeUrls(NewIncludeExcludeUrls: JobMaster.GetIncludeExcludeUrls());
                            this.SetCustomFilters(NewCustomFilter: JobMaster.GetCustomFilter());
                            this.SetDataExtractors(NewDataExtractorCssSelectors: JobMaster.GetDataExtractorCssSelectors(), NewDataExtractorRegexes: JobMaster.GetDataExtractorRegexes(), NewDataExtractorXpaths: JobMaster.GetDataExtractorXpaths());

                            this.StartUrlString       = JobMaster.GetStartUrl();
                            this.textBoxStartUrl.Text = this.StartUrlString;
                            this.StartUrlDirty        = false;

                            this.SelectTabPage(TabName: MacroscopeConstants.tabPageStructureOverview);
                            this.msDisplayStructure.RefreshData(DocCollection: this.JobMaster.GetDocCollection());

                            this.ScanningControlsStopped();

                            this.DialogueBoxFeedback("SEO Macroscope session", "The SEO Macroscope session file was loaded successfully.");
                        }
                        else
                        {
                            this.DialogueBoxError("Error", "There was an error loading the SEO Macroscope session file.");
                        }
                    }
                    catch (Exception ex)
                    {
                        this.DialogueBoxError("Error", ex.Message);
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
                else
                {
                    this.DialogueBoxError("Error", "The SEO Macroscope session file specified could not be found");
                }
            }

            if (Dialog != null)
            {
                Dialog.Dispose();
            }
        }