Example #1
0
        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();
        }
Example #2
0
        /// <summary>
        ///    Method for creating a new preview control showing the sheets of given excel file.
        /// </summary>
        /// <param name="sourceFile">Full path and name of the excel source file.</param>
        private void createSourceFilePreviewControl(string sourceFile)
        {
            sourceFilePreviewControlPanel.Controls.Clear();
            columnMappingControlPanel.Controls.Clear();
            cleanColumnMappingControls();
            _columnMappingControls.Clear();

            _sourceFilePreviewControl = new SourceFilePreviewControl(sourceFile, _rangesCache, _importer)
            {
                Dock = DockStyle.Fill
            };
            _sourceFilePreviewControl.SheetSelected += (s, e) => OnEvent(() => layoutColumnMappingControl(e.SheetData));

            sourceFilePreviewControlPanel.Controls.Add(_sourceFilePreviewControl);
            layoutColumnMappingControl(_sourceFilePreviewControl.SelectedSheetData);
        }