コード例 #1
0
        private void BuildSwitchInstanceMenuItems()
        {
            var args = RDMPBootStrapper <RDMPMainForm> .ApplicationArguments;

            // somehow app was launched without populating the load args
            if (args == null)
            {
                return;
            }

            var origYamlFile = args.ConnectionStringsFileLoaded;

            //default settings were used if no yaml file was specified or the file specified did not exist
            var defaultsUsed = origYamlFile == null;

            // if defaults were not used then it is valid to switch to them
            switchToDefaultSettings.Enabled = !defaultsUsed;

            switchToDefaultSettings.Checked      = defaultsUsed;
            launchNewWithDefaultSettings.Checked = defaultsUsed;

            // load the yaml files in the RDMP binary directory
            var exeDir = UsefulStuff.GetExecutableDirectory();

            AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, exeDir);

            // also add yaml files from wherever they got their original yaml file
            if (origYamlFile?.FileLoaded != null && !exeDir.FullName.Equals(origYamlFile.FileLoaded.Directory.FullName))
            {
                AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, origYamlFile.FileLoaded.Directory);
            }
        }
コード例 #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);
            }
        }
コード例 #3
0
 private void openExeDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         UsefulStuff.GetInstance().ShowFolderInWindowsExplorer(UsefulStuff.GetExecutableDirectory());
     }
     catch (Exception exception)
     {
         ExceptionViewer.Show(exception);
     }
 }
コード例 #4
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}\"");
            }
        }
コード例 #5
0
        private void Run(Func <T> commandGetter)
        {
            ClearOutput();

            string expectedFileName = "rdmp" + (EnvironmentInfo.IsLinux ? "" : ".exe");

            // try in the location we ran from
            var binary = Path.Combine(UsefulStuff.GetExecutableDirectory().FullName, expectedFileName);

            if (!File.Exists(binary))
            {
                // the program that launched this code isn't rdmp.exe.  Maybe rdmp is in the current directory though
                binary = "./" + expectedFileName;
            }

            if (!File.Exists(binary))
            {
                MessageBox.ErrorQuery("Could not find rdmp binary", $"Could not find {binary}", "Ok");
                return;
            }
            var cmd  = new ExecuteCommandGenerateRunCommand(BasicActivator, commandGetter);
            var args = cmd.GetCommandText(true);

            process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = binary,
                    Arguments              = args,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };

            Task.Run(() =>
            {
                process.Start();

                while (!process.StandardOutput.EndOfStream)
                {
                    var line = process.StandardOutput.ReadLine().Trim();

                    lock (lockList)
                    {
                        consoleOutput.Insert(0, line);
                        Application.MainLoop.Invoke(() => _results.SetNeedsDisplay());
                    }
                }
            });
        }
コード例 #6
0
        public override void Execute()
        {
            base.Execute();

            // make runtime decision about the file to run on
            if (file == null && BasicActivator != null)
            {
                file = BasicActivator.SelectFile("Select plugin to prune")?.FullName;
            }

            if (file == null)
            {
                return;
            }

            var logger = LogManager.GetCurrentClassLogger();

            using (var zf = ZipFile.Open(file, ZipArchiveMode.Update))
            {
                var current = UsefulStuff.GetExecutableDirectory();

                logger.Info($"Reading RDMP core dlls in directory '{current}'");

                var rdmpCoreFiles = current.GetFiles("*.dll");

                string main    = $"^/?lib/{EnvironmentInfo.MainSubDir}/.*.dll";
                string windows = $"^/?lib/{EnvironmentInfo.WindowsSubDir}/.*.dll";

                var inMain    = new List <ZipArchiveEntry>();
                var inWindows = new List <ZipArchiveEntry>();

                foreach (var e in zf.Entries.ToArray())
                {
                    if (rdmpCoreFiles.Any(f => f.Name.Equals(e.Name)))
                    {
                        logger.Info($"Deleting '{e.FullName}'");
                        e.Delete();
                        continue;
                    }

                    if (Regex.IsMatch(e.FullName, main))
                    {
                        inMain.Add(e);
                    }
                    else if (Regex.IsMatch(e.FullName, windows))
                    {
                        inWindows.Add(e);
                    }
                }

                foreach (var dup in inWindows.Where(e => inMain.Any(o => o.Name.Equals(e.Name))).ToArray())
                {
                    logger.Info($"Deleting '{dup.FullName}' because it is already in 'main' subdir");
                    dup.Delete();
                }
            }

            if (BasicActivator != null)
            {
                BasicActivator.Show("Prune Completed");
            }
        }