Example #1
0
        protected override void SaveRequestPreset(SearchConnection searchConnection, SearchQueryRequest searchRequest)
        {
            if (IsSavePreset())
            {
                SearchPreset newPreset = new SearchPreset();
                var          path      = GetPresetFilename(SavePreset);

                newPreset.Name = Path.GetFileNameWithoutExtension(path);
                newPreset.Path = path;

                if (!Path.IsPathRooted(SavePreset))
                {
                    newPreset.Path = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, newPreset.Path);
                }

                searchConnection.CopyFrom(searchRequest);

                newPreset.Connection = searchConnection;
                newPreset.Request    = SetSelectProperties(searchRequest);

                newPreset.Save();

                WriteInformation(new HostInformationMessage
                {
                    Message         = $"Preset saved to {newPreset.Path}",
                    ForegroundColor = Host.UI.RawUI.BackgroundColor,        // invert
                    BackgroundColor = Host.UI.RawUI.ForegroundColor,
                    NoNewLine       = false
                }, new[] { "PSHOST" });
            }
        }
Example #2
0
        internal void SaveHistoryItem()
        {
            var filename = $"history-{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.xml";
            var path     = Path.Combine(_mainWindow.HistoryFolderPath, filename);
            var preset   = new SearchPreset()
            {
                Request    = _mainWindow.GetSearchQueryRequestFromUi(),
                Connection = _mainWindow.GetSearchConnectionFromUi(),
                Path       = path,
                Name       = Path.GetFileNameWithoutExtension(filename)
            };

            var unused = preset.Save();
        }
Example #3
0
        private void SavePresetToFile(SearchConnection searchConnection, SearchQueryRequest searchQueryRequest)
        {
            if (!String.IsNullOrWhiteSpace(SavePreset))
            {
                SearchPreset newPreset = new SearchPreset();
                var          path      = GetPresetFilename(SavePreset);

                newPreset.Name = Path.GetFileNameWithoutExtension(path);
                newPreset.Path = path;

                if (!Path.IsPathRooted(SavePreset))
                {
                    newPreset.Path = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, newPreset.Path);
                }

                newPreset.Connection = searchConnection;
                newPreset.Request    = SetSelectProperties(searchQueryRequest);

                newPreset.Save();

                WriteVerbose("Configuration saved to " + newPreset.Path);
            }
        }