Beispiel #1
0
        private static string ToConnectionString(DatabaseConnectionInfo db)
        {
            var csb = new SqlConnectionStringBuilder
            {
                DataSource = db.Server,
                UserID = db.User,
                Password = db.Password
            };

            return csb.ToString();
        }
Beispiel #2
0
        public static IProcessExecutionResult SqlCmdExec(DatabaseConnectionInfo db, string script)
        {
            var args = string.Format(@"-r 1 -S ""{0}"" -U ""{1}"" -P ""{2}""", db.Server, db.User, db.Password);
            var input = new MemoryStream();
            var writer = new StreamWriter(input);
            writer.WriteLine(script);
            writer.WriteLine("GO");
            writer.WriteLine("exit");
            writer.Flush();

            input.Position = 0;

            return ProcessUtils.Exec("sqlcmd", args, input);
        }
Beispiel #3
0
        public static IReadOnlyCollection<Tuple<string, string>> GetLogicalAndPhysicalNamesFromBackupFile(DatabaseConnectionInfo db, string backupFile)
        {
            using (var f = new SqlCommandFactory(ToConnectionString(db), null))
            using (var cmd = f.CreateCommand(null))
            {
                cmd.CommandText = "RESTORE FILELISTONLY FROM DISK = @path";
                cmd.Parameters.Add("@path", SqlDbType.NVarChar).Value = backupFile;

                var result = new List<Tuple<string, string>>();
                using (var r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        var logicalName = (string)r["LogicalName"];
                        var physicalName = (string)r["PhysicalName"];

                        result.Add(Tuple.Create(logicalName, physicalName));
                    }
                }

                return result;
            }
        }
 public BranchComponent(BranchInfo branchInfo, DatabaseConnectionInfo dbConnection) :
     base(string.Format("Branch {0}", branchInfo.Name))
 {
     mBranchInfo = branchInfo;
     mDbConnection = dbConnection;
 }
Beispiel #5
0
            public SqlCommandExecutionResult(DatabaseConnectionInfo db, string name, string script, IEnumerable<SqlParameter> parameters)
            {
                mFactory = new SqlCommandFactory(ToConnectionString(db), OnMessage);
                mCommand = mFactory.CreateCommand(name);
                mCommand.CommandText = script;
                mOutput = new BlockingCollection<ProcessOutputLine>();

                foreach (var sqlParameter in parameters)
                {
                    mCommand.Parameters.Add(sqlParameter);
                }
            }
Beispiel #6
0
 public static IProcessExecutionResult Exec(DatabaseConnectionInfo db, string script, IEnumerable<SqlParameter> parameters)
 {
     return new SqlCommandExecutionResult(db, db.Name, script, parameters);
 }
Beispiel #7
0
 public static IProcessExecutionResult Exec(DatabaseConnectionInfo db, string script)
 {
     return Exec(db, script, Enumerable.Empty<SqlParameter>());
 }
 public ReleaseComponent(BranchInfo branchInfo, string releaseDir, DatabaseConnectionInfo dbConnection) :
     base(string.Format("Release '{0}'", Path.GetFileName(releaseDir)))
 {
     mReleaseInfo = new ReleaseInfo(branchInfo, releaseDir);
     mDbConnection = dbConnection;
 }
 public ScriptsComponent(ReleaseInfo releaseInfo, DatabaseConnectionInfo dbConnection)
 {
     mReleaseInfo = releaseInfo;
     mScriptsPath = Path.Combine(releaseInfo.Path, "Scripts");
     mDatabaseConnection = dbConnection;
 }