コード例 #1
0
ファイル: ImporterView.cs プロジェクト: ktseow/OSPSuite.Core
        public void StartImport(string sourceFile, ImportTableConfiguration configuration, Mode mode)
        {
            var metaDataCategories = configuration.MetaDataCategories;

            _mode        = mode;
            _columnInfos = configuration.ColumnInfos;

            var importDataTable = _importMapper.ConvertToImportDataTable(metaDataCategories, _columnInfos);

            if (importDataTable == null)
            {
                throw new InvalidArgumentException("Could not map to import table");
            }

            MaximizeBox = true;
            namingImportPanel.FillWith(_namingView);
            _importer              = new Presentation.Services.Importer.Importer(_dataRepositoryMapper, _columnInfos, _importerTask, _dialogCreator);
            _importDataTable       = importDataTable;
            _columnMappingControls = new Dictionary <string, ColumnMappingControl>();

            // Page Source
            _openSourceFileControl = new OpenSourceFileControl(_dialogCreator, sourceFile)
            {
                Dock = DockStyle.Fill
            };

            openSourceFileControlPanel.FillWith(_openSourceFileControl);
            _openSourceFileControl.OnOpenSourceFile += openSourceFileEvent;
            xtraTabControl.SelectedPageChanged      += (s, e) => OnEvent(() => changeTabs(e.Page, e.PrevPage));
            xtraTabControl.SelectedTabPage.Appearance.Header.Font = Fonts.SelectedTabHeaderFont;

            _rangesCache = new Cache <string, Rectangle>();

            createSourceFilePreviewControl(sourceFile);
            btnImport.Click      += (s, e) => OnEvent(importData);
            btnSelectRange.Click += (s, e) => OnEvent(selectRange);
            btnImportAll.Click   += (s, e) => OnEvent(importAllData);

            FormClosing += onFormClosing;

            // Page Imports
            _dataSetControl = new DataSetControl(_imports, _columnInfos, true);
            panelImportedTabs.FillWith(_dataSetControl);
            _dataSetControl.MissingRequiredData   += (s, e) => OnEvent(() => enableOKButton(false));
            _dataSetControl.RequiredDataCompleted += (s, e) => OnEvent(() => enableOKButton(true));
            _dataSetControl.TableDeleted          += (s, e) => OnEvent(enableImportsPage);
            enableImportsPage();

            enableOKButton(false);
        }
コード例 #2
0
ファイル: ImporterView.cs プロジェクト: ktseow/OSPSuite.Core
        private void cleanMemory()
        {
            _namingView = null;
            if (_openSourceFileControl != null)
            {
                _openSourceFileControl.OnOpenSourceFile -= openSourceFileEvent;
                _openSourceFileControl = null;
            }

            if (_imports != null)
            {
                foreach (ImportDataTable table in _imports.Tables)
                {
                    table.MetaData?.Dispose();
                    table.Dispose();
                }
                _imports.Dispose();
            }
            if (_importDataTable != null)
            {
                _importDataTable.MetaData?.Dispose();
                _importDataTable.Dispose();
            }

            CleanUpHelper.ReleaseEvents(_dataSetControl);
            _dataSetControl?.Dispose();
            CleanUpHelper.ReleaseEvents(_sourceFilePreviewControl);
            _sourceFilePreviewControl?.Dispose();
            CleanUpHelper.ReleaseControls(Controls);
            Controls.Clear();

            _imports = null;
            _openSourceFileControl    = null;
            _sourceFilePreviewControl = null;
            _columnMappingControl     = null;
            _dataSetControl           = null;
            _importDataTable          = null;
            _importer             = null;
            _presenter            = null;
            _dataRepositoryMapper = null;
            _importMapper         = null;
            _columnInfos          = null;

            cleanColumnMappingControls();
            _columnMappingControls?.Clear();
            _columnMappingControls = null;

            columnMappingControlPanel.Controls.Clear();
        }