Пример #1
0
        private void FileSchemaBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.HideLoadingIcon();
            try
            {
                if (e.Cancelled)
                {
                    if (this.openFileSchema == null)
                    {
                        //cancel file open
                        this.OpenFilePath = null;
                    }
                    return;
                }

                if (e.Error == null)
                {
                    this.openFileSchema = (Parquet.Data.Schema)e.Result;
                    var fields = this.openFileSchema.Fields;
                    if (fields != null && fields.Count > 0)
                    {
                        if (AppSettings.AlwaysSelectAllFields && sender?.GetType() != typeof(int)) //We send -1 from the field selection tooltip item so we can force the field selection form to be shown
                        {
                            this.SelectedFields = fields.Where(f => !FieldsToLoadForm.UnsupportedSchemaTypes.Contains(f.SchemaType)).Select(f => f.Name).ToList();
                        }
                        else
                        {
                            var fieldSelectionForm = new FieldsToLoadForm(fields, this.MainDataSource?.GetColumnNames() ?? new string[0]);
                            if (fieldSelectionForm.ShowDialog(this) == DialogResult.OK)
                            {
                                if (fieldSelectionForm.NewSelectedFields != null && fieldSelectionForm.NewSelectedFields.Count > 0)
                                {
                                    this.SelectedFields = fieldSelectionForm.NewSelectedFields;
                                }
                                else
                                {
                                    this.SelectedFields = fields.Select(f => f.Name).ToList(); //By default, show all fields
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new FileLoadException("The selected file doesn't have any fields");
                    }
                }
                else
                {
                    throw e.Error;
                }
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
            }
        }
Пример #2
0
        private void FileSchemaBackgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            this.HideLoadingIcon();
            try
            {
                if (e.Cancelled)
                {
                    if (this.openFileSchema == null)
                    {
                        //cancel file open
                        this.OpenFilePath = null;
                    }
                    return;
                }

                if (e.Error == null)
                {
                    this.openFileSchema = (Parquet.Data.Schema)e.Result;
                    string[] fields = this.openFileSchema.FieldNames;
                    if (fields != null && fields.Length > 0)
                    {
                        var fieldSelectionForm = new FieldsToLoadForm(fields, UtilityMethods.GetDataTableColumns(this.MainDataSource));
                        if (fieldSelectionForm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                        {
                            if (fieldSelectionForm.NewSelectedFields != null && fieldSelectionForm.NewSelectedFields.Count > 0)
                            {
                                this.SelectedFields = fieldSelectionForm.NewSelectedFields;
                            }
                            else
                            {
                                this.SelectedFields = new List <string>(fields); //By default, show all fields
                            }
                        }
                    }
                    else
                    {
                        throw new FileLoadException("The selected file doesn't have any fields");
                    }
                }
                else
                {
                    throw e.Error;
                }
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
            }
        }