Ejemplo n.º 1
0
        private static ScriptPackage LoadPackage(string path)
        {
            if (!File.Exists(path))
                ExitProgram("File '" + path + "' does not exist.", true);

            ScriptPackage package = new ScriptPackage();
            package.Load(_packageFile);
            return package;
        }
        private void LoadScriptPackage_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog packageLoad = new OpenFileDialog();
            packageLoad.Filter = SCRIPT_PACKAGE_FILTER;
            packageLoad.CheckFileExists = true;

            if (packageLoad.ShowDialog() != true)
                return;

            ScriptPackage package = new ScriptPackage();
            package.Load(packageLoad.FileName);

            this.Scripts.Clear();
            foreach (Script script in package.Scripts)
            {
                DatabaseConnection matchingConnection = (from connection in DatabaseConnections
                                                         where connection.ConnectionString == script.Connection.ConnectionString
                                                         select connection).FirstOrDefault();

                if (matchingConnection == null)
                {
                    matchingConnection = new DatabaseConnection("[PACKAGE] " + script.Connection.ConnectionName, script.Connection.ConnectionString);
                    this.DatabaseConnections.Add(matchingConnection);
                }

                script.Connection = matchingConnection;
                this.Scripts.Add(new ScriptWrapper(script));
            }
        }