コード例 #1
0
ファイル: CMRestoreSQLBackup.cs プロジェクト: vgrinin/gin
        private List <SqlParameterClass> InitFilelistParameters(IExecutionContext context)
        {
            List <SqlParameterClass> parameters = new List <SqlParameterClass>();

            string            absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);
            SqlParameterClass p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);

            parameters.Add(p);

            return(parameters);
        }
コード例 #2
0
        private List <SqlParameterClass> InitParameters(IExecutionContext context)
        {
            List <SqlParameterClass> parameters = new List <SqlParameterClass>();

            string absoluteDatabaseName = context.GetStringFrom(DatabaseName);

            context.Log.AddLogInformation("DatabaseName = '" + absoluteDatabaseName + "'");
            SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", absoluteDatabaseName, SqlDbType.VarChar, 255, ParameterDirection.Input);

            parameters.Add(p);

            string absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);

            context.Log.AddLogInformation("BackupFilePath = '" + absoluteBackupFilePath + "'");
            string backupName = Path.GetFileNameWithoutExtension(absoluteBackupFilePath);

            p = context.AddSqlParameterToContext("NAME", backupName, SqlDbType.VarChar, 255, ParameterDirection.Input);
            parameters.Add(p);
            p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 255, ParameterDirection.Input);
            parameters.Add(p);
            return(parameters);
        }
コード例 #3
0
ファイル: CMRestoreSQLBackup.cs プロジェクト: vgrinin/gin
        private List <SqlParameterClass> InitRestoreParameters(IExecutionContext context, string resultSetCtxName)
        {
            List <SqlParameterClass> parameters = new List <SqlParameterClass>();

            DataTable fileList    = (DataTable)context.GetResult(resultSetCtxName);
            var       files       = fileList.AsEnumerable();
            var       rows        = files.AsEnumerable();
            var       rowDataFile = rows.FirstOrDefault(r => (string)r["Type"] == "D");

            if (rowDataFile == null)
            {
                throw new Exception("Бэкап не содержит файла MDF базы данных");
            }
            var rowLogFile = rows.FirstOrDefault(r => (string)r["Type"] == "L");

            if (rowLogFile == null)
            {
                throw new Exception("Бэкап не содержит файла LDF журнала транзакций");
            }
            string ldfFileLogicalName  = (string)rowLogFile["LogicalName"];
            string mdfFileLogicalName  = (string)rowDataFile["LogicalName"];
            string ldfFilePhysicalName = (string)rowLogFile["PhysicalName"];
            string mdfFilePhysicalName = (string)rowDataFile["PhysicalName"];

            if (DataBaseFullPath != null)
            {
                string mdfFileOnlyName = Path.GetFileName(mdfFilePhysicalName);
                string ldfFileOnlyName = Path.GetFileName(ldfFilePhysicalName);

                DataBaseFullPath = context.GetStringFrom(DataBaseFullPath);

                mdfFilePhysicalName = Path.Combine(DataBaseFullPath, mdfFileOnlyName);
                ldfFilePhysicalName = Path.Combine(DataBaseFullPath, ldfFileOnlyName);
            }

            SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", DatabaseName, SqlDbType.VarChar, 1024, ParameterDirection.Input);

            parameters.Add(p);

            string absoluteSourcePath = context.GetStringFrom(BackupFilePath);

            p = context.AddSqlParameterToContext("FULLNAME", absoluteSourcePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);
            p = context.AddSqlParameterToContext("MDFLOGICALNAME", mdfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("MDFFILEPATH", mdfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("LDFLOGICALNAME", ldfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("LDFFILEPATH", ldfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            return(parameters);
        }
コード例 #4
0
ファイル: CMCreateSQLBackup.cs プロジェクト: vgrinin/gin
        private List<SqlParameterClass> InitParameters(IExecutionContext context)
        {
            List<SqlParameterClass> parameters = new List<SqlParameterClass>();

            string absoluteDatabaseName = context.GetStringFrom(DatabaseName);
            context.Log.AddLogInformation("DatabaseName = '" + absoluteDatabaseName + "'");
            SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", absoluteDatabaseName, SqlDbType.VarChar, 255, ParameterDirection.Input);
            parameters.Add(p);

            string absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);
            context.Log.AddLogInformation("BackupFilePath = '" + absoluteBackupFilePath + "'");
            string backupName = Path.GetFileNameWithoutExtension(absoluteBackupFilePath);
            p = context.AddSqlParameterToContext("NAME", backupName, SqlDbType.VarChar, 255, ParameterDirection.Input);
            parameters.Add(p);
            p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 255, ParameterDirection.Input);
            parameters.Add(p);
            return parameters;
        }
コード例 #5
0
ファイル: CMRestoreSQLBackup.cs プロジェクト: vgrinin/gin
        private List<SqlParameterClass> InitRestoreParameters(IExecutionContext context, string resultSetCtxName)
        {
            List<SqlParameterClass> parameters = new List<SqlParameterClass>();

            DataTable fileList = (DataTable)context.GetResult(resultSetCtxName);
            var files = fileList.AsEnumerable();
            var rows = files.AsEnumerable();
            var rowDataFile = rows.FirstOrDefault(r => (string)r["Type"] == "D");
            if (rowDataFile == null)
            {
                throw new Exception("Бэкап не содержит файла MDF базы данных");
            }
            var rowLogFile = rows.FirstOrDefault(r => (string)r["Type"] == "L");
            if (rowLogFile == null)
            {
                throw new Exception("Бэкап не содержит файла LDF журнала транзакций");
            }
            string ldfFileLogicalName = (string)rowLogFile["LogicalName"];
            string mdfFileLogicalName = (string)rowDataFile["LogicalName"];
            string ldfFilePhysicalName = (string)rowLogFile["PhysicalName"];
            string mdfFilePhysicalName = (string)rowDataFile["PhysicalName"];

            if (DataBaseFullPath != null)
            {
                string mdfFileOnlyName = Path.GetFileName(mdfFilePhysicalName);
                string ldfFileOnlyName = Path.GetFileName(ldfFilePhysicalName);

                DataBaseFullPath = context.GetStringFrom(DataBaseFullPath);

                mdfFilePhysicalName = Path.Combine(DataBaseFullPath, mdfFileOnlyName);
                ldfFilePhysicalName = Path.Combine(DataBaseFullPath, ldfFileOnlyName);
            }

            SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", DatabaseName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            string absoluteSourcePath = context.GetStringFrom(BackupFilePath);
            p = context.AddSqlParameterToContext("FULLNAME", absoluteSourcePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);
            p = context.AddSqlParameterToContext("MDFLOGICALNAME", mdfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("MDFFILEPATH", mdfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("LDFLOGICALNAME", ldfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            p = context.AddSqlParameterToContext("LDFFILEPATH", ldfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            return parameters;
        }
コード例 #6
0
ファイル: CMRestoreSQLBackup.cs プロジェクト: vgrinin/gin
        private List<SqlParameterClass> InitFilelistParameters(IExecutionContext context)
        {
            List<SqlParameterClass> parameters = new List<SqlParameterClass>();

            string absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);
            SqlParameterClass p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);
            parameters.Add(p);

            return parameters;
        }