Ejemplo n.º 1
0
        private void AddMenuItemsForSwitchingToInstancesInYamlFilesOf(ConnectionStringsYamlFile origYamlFile, DirectoryInfo dir)
        {
            foreach (var yaml in dir.GetFiles("*.yaml"))
            {
                // if the yaml file is invalid bail out early
                if (!ConnectionStringsYamlFile.TryLoadFrom(yaml, out var connectionStrings))
                {
                    continue;
                }

                bool isSameAsCurrent = origYamlFile?.FileLoaded == null ? false : yaml.FullName.Equals(origYamlFile.FileLoaded.FullName);

                var launchNew = new ToolStripMenuItem(connectionStrings.Name ?? yaml.Name, null, (s, e) => { LaunchNew(connectionStrings); })
                {
                    Checked     = isSameAsCurrent,
                    ToolTipText = connectionStrings.Description ?? yaml.FullName
                };

                var switchTo = new ToolStripMenuItem(connectionStrings.Name ?? yaml.Name, null, (s, e) => { SwitchTo(connectionStrings); })
                {
                    Enabled     = !isSameAsCurrent,
                    Checked     = isSameAsCurrent,
                    ToolTipText = connectionStrings.Description ?? yaml.FullName
                };

                launchAnotherInstanceToolStripMenuItem.DropDownItems.Add(launchNew);
                switchToInstanceToolStripMenuItem.DropDownItems.Add(switchTo);
            }
        }
Ejemplo n.º 2
0
        private void btnCreateYamlFile_Click(object sender, EventArgs e)
        {
            try
            {
                var toSerialize = new ConnectionStringsYamlFile()
                {
                    CatalogueConnectionString  = tbCatalogueConnectionString.Text,
                    DataExportConnectionString = tbDatabasePrefix.Text,
                };

                var serializer = new Serializer();
                var yaml       = serializer.Serialize(toSerialize);

                var sfd = new SaveFileDialog();
                sfd.Filter           = "Yaml|*.yaml";
                sfd.Title            = "Save yaml";
                sfd.InitialDirectory = UsefulStuff.GetExecutableDirectory().FullName;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(sfd.FileName, yaml);
                }
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
        }
Ejemplo n.º 3
0
        private void LaunchNew(ConnectionStringsYamlFile yaml)
        {
            var exeName = Path.Combine(UsefulStuff.GetExecutableDirectory().FullName, Process.GetCurrentProcess().ProcessName);

            if (yaml == null)
            {
                Process.Start(exeName);
            }
            else
            {
                Process.Start(exeName, $"--{nameof(RDMPCommandLineOptions.ConnectionStringsFile)} \"{yaml.FileLoaded.FullName}\"");
            }
        }
Ejemplo n.º 4
0
        private void SwitchTo(ConnectionStringsYamlFile yaml)
        {
            LaunchNew(yaml);

            Application.Exit();
        }