or
var dp =
new
DialogParameters
{
CancelButtonContent =
"Cancel"
,
Content = msg.ToString(),
DialogStartupLocation = WindowStartupLocation.CenterOwner,
Header =
"Continue?"
,
OkButtonContent =
"Continue"
,
Owner = Window.GetWindow(
this
),
Closed = (dpSender, dpArgs) =>
{
if
(dpArgs.DialogResult ==
true
)
(DataContext
as
PvaAvaCaptureViewModel).ImportGridCommand.Execute(fileInfo);
}
};
RadWindow.Confirm(dp);
using System.Data.SqlClient;
CREATE PROCEDURE SP_UpgradeDatabaseTest @RegressionRunID int
AS
BEGIN
DECLARE @CMDSQL varchar(1000),
@DatabaseID int,
@DatabaseName varchar(250),
@CurrentLocation varchar(250),
@TargetLocation varchar(250),
@Result int
SET @TargetLocation = 'C:\UpgradeDatabaseTest\'
-- Tidy up previous run... detach databases
DECLARE Database_cursor CURSOR
FOR
SELECT name FROM sys.databases
JOIN DatabasesForUpgrading ON name = DatabaseName
OPEN Database_cursor
FETCH NEXT FROM Database_cursor
INTO @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_detach_db @DatabaseName
FETCH NEXT FROM Database_cursor INTO @DatabaseName
END
CLOSE Database_cursor
DEALLOCATE Database_cursor
EXEC master..xp_cmdshell 'Del C:\UpgradeDatabaseTest\*.mdf'
EXEC master..xp_cmdshell 'Del C:\UpgradeDatabaseTest\*.ldf'
-- Get list of databases to upgrade, copy, attach, and upgrade
DECLARE Database_cursor CURSOR FOR SELECT DatabaseID, DatabaseName, Location FROM DatabasesForUpgrading WHERE Upgrade =1
OPEN Database_cursor
FETCH NEXT FROM Database_cursor
INTO @DatabaseID,
@DatabaseName,
@CurrentLocation
WHILE @@FETCH_STATUS = 0
BEGIN
-- copy database to expected location
DECLARE @PassedVariable VARCHAR(100)
SET @CurrentLocation = @CurrentLocation + RTRIM(@DatabaseName) + '*.*'
SET @CMDSQL = 'C:\NR_UpgradeDatabaseDBRepository\CopyFiles.bat ' + @CurrentLocation + ' ' + @TargetLocation
EXEC master..xp_cmdshell @CMDSQL
-- Attach Database to Server
SELECT @CMDSQL = 'CREATE DATABASE ' + @DatabaseName +
' ON (FILENAME = ''' + @TargetLocation + @DatabaseName + '.mdf''' + '),
(FILENAME = ''' + @TargetLocation + @DatabaseName + '_Log.ldf'')
FOR ATTACH'
EXECUTE (@CMDSQL)
-- Run Upgrade Database
SET @CMDSQL = '"c:\program files (x86)\Athene\Data Management\Upgrade Database" DW-E5530,' + @DatabaseName
EXEC master..xp_cmdshell @CMDSQL
--Check Result of upgrade
SET @CMDSQL = 'findstr /c:"The database has been updated" c:\programdata\metron\logs\*' + @DatabaseName + '*.log'
EXEC @Result = master..xp_cmdshell @CMDSQL
IF @Result = 0
-- Success
INSERT RR_UpgradeDatabase (RegressionRunID, DatabaseID, Result)
VALUES (@RegressionRunID, @DatabaseID, 1)
ELSE
-- Failure
INSERT RR_UpgradeDatabase (RegressionRunID, DatabaseID, Result)
VALUES (@RegressionRunID, @DatabaseID, 0)
FETCH NEXT FROM Database_cursor
INTO @DatabaseID,
@DatabaseName,
@CurrentLocation
END
CLOSE Database_cursor
DEALLOCATE Database_cursor
END