public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            var properties = new CsvDataContextDriverProperties(cxInfo);
            if (isNewConnection)
            {
                properties.Files = "#Drag&Drop or type file paths, or directory paths with pattern like *.csv or **.csv (** will recurse subdirectory)\nc:\\*.csv";
            }

            bool? result = new ConnectionDialog(properties).ShowDialog();
            if (result == true)
            {
                cxInfo.DisplayName = GetConnectionDescription(cxInfo);
                return true;
            }
            return false;
        }
Пример #2
0
        // ReSharper restore StringLiteralTypo

        public override string GetConnectionDescription(IConnectionInfo cxInfo)
        {
            var parsedFiles       = new CsvDataContextDriverProperties(cxInfo).ParsedFiles.EnumFiles().ToImmutableList();
            var parsedFilesCount  = parsedFiles.Count;
            var dateTime          = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}";
            var filesAndTotalSize = $"{"file".ToQuantity(parsedFilesCount)} {parsedFiles.GetHumanizedFileSize()}";

            return($"{parsedFiles.GetLongestCommonPrefixPath()}{GetFilesCountString()}");

            string GetFilesCountString() =>
            parsedFilesCount switch
            {
                0 => $"({dateTime}, no files)",
                _ => $" ({dateTime}, {filesAndTotalSize})"
            };
        }
Пример #3
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            var properties = new CsvDataContextDriverProperties(cxInfo);

            if (isNewConnection)
            {
                properties.Files = "#Drag&Drop or type file paths, or directory paths with pattern like *.csv or **.csv (** will recurse subdirectory)\nc:\\*.csv";
            }

            bool?result = new ConnectionDialog(properties).ShowDialog();

            if (result == true)
            {
                cxInfo.DisplayName = GetConnectionDescription(cxInfo);
                return(true);
            }
            return(false);
        }
Пример #4
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, ConnectionDialogOptions connectionDialogOptions)
        {
            var properties = new CsvDataContextDriverProperties(cxInfo);

            if (connectionDialogOptions.IsNewConnection)
            {
                properties.Files = string.Join(Environment.NewLine,
                                               "# Drag&drop (use Ctrl to add files)",
                                               "# Type file paths, or directory paths with pattern like *.csv or **.csv (** will recurse subdirectories)",
                                               "# Press Ctrl+Shift+V to insert from clipboard and proceed",
                                               $"{FileUtils.GetDefaultDrive()}*.csv");
            }

            if (new ConnectionDialog(properties).ShowDialog() != true)
            {
                return(false);
            }

            cxInfo.DisplayName = GetConnectionDescription(cxInfo);

            return(true);
        }
Пример #5
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, ConnectionDialogOptions connectionDialogOptions)
        {
            var properties = new CsvDataContextDriverProperties(cxInfo);

            if (connectionDialogOptions.IsNewConnection)
            {
                properties.Files =
                    $"{FileExtensions.InlineComment} Drag&drop here (from add files/folder dialogs as well). Ctrl adds files. Alt toggles * and ** masks.".JoinNewLine(
                        $"{FileExtensions.InlineComment} {ConnectionDialog.WildcardsToolTip}.",
                        $"{FileExtensions.InlineComment} Ctrl+V (Ctrl+Alt+V) pastes from clipboard, appends {FileExtensions.DefaultMask} ({FileExtensions.DefaultRecursiveMask}) to folders.",
                        $"{FileExtensions.InlineComment} Ctrl+Shift+V (Ctrl+Shift+Alt+V) clears, pastes from clipboard, appends {FileExtensions.DefaultMask} ({FileExtensions.DefaultRecursiveMask}) to folders and proceeds.",
                        string.Empty, string.Empty);
            }

            if (new ConnectionDialog(properties).ShowDialog() != true)
            {
                return(false);
            }

            cxInfo.DisplayName = GetConnectionDescription(cxInfo);

            return(true);
        }
Пример #6
0
 public ConnectionDialog(CsvDataContextDriverProperties properties)
 {
     this.properties = properties;
 }
 public ConnectionDialog(CsvDataContextDriverProperties properties)
 {
     this.properties = properties;
 }