Exit on SQL script failure
Added error handling to RunScript method Exit on SQL script failure Changed vefn_ChronologyReport Changed how check for prior existence of rofst
This commit is contained in:
parent
7f58611e6b
commit
635b88de4d
@ -12,7 +12,7 @@ namespace DataLoader
|
||||
{
|
||||
public bool BuildApprovedRevision()
|
||||
{
|
||||
frmMain.RunScript("PROMSApproveApprove.sql", frmMain.MySettings.DBName);
|
||||
if(!frmMain.RunScript("PROMSApproveApprove.sql", frmMain.MySettings.DBName)) return false;
|
||||
bool rv = false;
|
||||
using (Stage myStage = GetApprovedStage())
|
||||
{
|
||||
|
@ -2664,9 +2664,12 @@ IF (@@Error = 0) PRINT 'ScalarFunction Creation: vefn_CheckXML Succeeded'
|
||||
ELSE PRINT 'ScalarFunction Creation: vefn_CheckXML Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [vefn_ChronologyReport] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_ChronologyReport]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_ChronologyReport];
|
||||
DROP FUNCTION [vefn_ChronologyReport];
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 03/20/2012 17:50:44 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
@ -2859,9 +2862,9 @@ and ca.contentid in (select icontentid from @tmpTable)
|
||||
return
|
||||
end
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_ChronologyReport Succeeded'
|
||||
ELSE PRINT 'TableFunction Creation: vefn_ChronologyReport Error on Creation'
|
||||
-- Display the status of TableFunction creation
|
||||
IF (@@Error = 0) PRINT 'Function: vefn_ChronologyReport Succeeded'
|
||||
ELSE PRINT 'Function: vefn_ChronologyReport Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [vefn_FindExternalFromTransitions] ******/
|
||||
|
@ -2482,6 +2482,17 @@ IF (@@Error = 0) PRINT 'StoredProcedure [getContentAuditsChronologyByItemID] Suc
|
||||
ELSE PRINT 'StoredProcedure [getContentAuditsChronologyByItemID] Error on Creation'
|
||||
go
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_ChronologyReport]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
|
||||
DROP FUNCTION [vefn_ChronologyReport];
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 03/20/2012 17:50:44 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
/*
|
||||
select * from vefn_chronologyreport(2) where type > 0 order by contentid,auditid
|
||||
*/
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 05/18/2011 11:20:48 ******/
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
@ -2490,6 +2501,7 @@ go
|
||||
CREATE function [dbo].[vefn_ChronologyReport](@ProcItemID int)
|
||||
returns @Report table
|
||||
(
|
||||
src int,
|
||||
AuditID bigint,
|
||||
ContentID int,
|
||||
Number nvarchar(512),
|
||||
@ -2668,12 +2680,10 @@ and ca.contentid in (select icontentid from @tmpTable)
|
||||
return
|
||||
end
|
||||
GO
|
||||
|
||||
-- Display the status of Trigger alter
|
||||
-- Display the status of TableFunction creation
|
||||
IF (@@Error = 0) PRINT 'Function: vefn_ChronologyReport Succeeded'
|
||||
ELSE PRINT 'Function: vefn_ChronologyReport Error on Creation'
|
||||
|
||||
go
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [getAnnotationAuditsChronologyByItemID] ******/
|
||||
/*
|
||||
|
@ -55,10 +55,10 @@ namespace DataLoader
|
||||
// roDbpath = fstPath.Substring(0, fstPath.LastIndexOf('\\')) + @"\ro";
|
||||
|
||||
// first see if this rodb has been migrated (another dataset may have migrated it)
|
||||
rodb = RODb.GetByFolderPath(roDbpath);
|
||||
DirectoryInfo di = new DirectoryInfo(roDbpath);
|
||||
rodb = RODb.GetByFolderPath(di.FullName);
|
||||
if (rodb == null)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(roDbpath);
|
||||
|
||||
// There may be more than 1 'ro' as the 'ROName' field (ROName is derived from the ropath).
|
||||
// Get new name be incrementing, if so.
|
||||
|
@ -311,8 +311,8 @@ namespace DataLoader
|
||||
// if purge data, purge it all & reload folders & security.
|
||||
if (MySettings.PurgeExistingData)
|
||||
{
|
||||
RunScript("BuildVEPROMS.Sql", "Master");
|
||||
RunScript("PROMS2010.SQL", MySettings.DBName);
|
||||
if(!RunScript("BuildVEPROMS.Sql", "Master")) return;
|
||||
if(!RunScript("PROMS2010.SQL", MySettings.DBName)) return;
|
||||
Status = "Purging Data";
|
||||
ldr.ClearData();
|
||||
Status = "Loading Folders";
|
||||
@ -368,16 +368,29 @@ namespace DataLoader
|
||||
_MyLog.Fatal(ex.Message);
|
||||
}
|
||||
}
|
||||
public void RunScript(string scriptName, string dbName)
|
||||
public bool RunScript(string scriptName, string dbName)
|
||||
{
|
||||
bool ok = false;
|
||||
Status = String.Format("Running Script '{0}'", scriptName);
|
||||
string script = GetScript(scriptName);
|
||||
script = script.Replace("{DBName}", MySettings.DBName);
|
||||
script = script.Replace("{DBPath}", MySettings.DBPath);
|
||||
SQLScriptRunner ssr = new SQLScriptRunner(script, MySettings.ConnectionString.Replace("{DBName}", dbName));
|
||||
ssr.InfoMessage += new SQLScriptRunnerEvent(ssr_InfoMessage);
|
||||
ssr.Run();
|
||||
Status = String.Format("Script '{0}' Complete", scriptName);
|
||||
try
|
||||
{
|
||||
ssr.Run();
|
||||
Status = String.Format("Script '{0}' Complete", scriptName);
|
||||
ok = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddInfo("====****====");
|
||||
AddError(ex, "While processing database {0}", dbName);
|
||||
AddInfo("====****====");
|
||||
Status = String.Format("Script '{0}' Failed", scriptName);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
private void Backup(string suffix)
|
||||
{
|
||||
@ -798,14 +811,14 @@ namespace DataLoader
|
||||
Backup("_" + MySettings.Phase2Suffix);
|
||||
mb.Append("Phase 2 Backup Complete");
|
||||
// Phase 3 - Convert to Change Manager Version
|
||||
ConvertToChangeManager();
|
||||
if(!ConvertToChangeManager()) return;
|
||||
mb.Append("Conversion to Change Manager Complete");
|
||||
Status = "Backing up Phase 3 Data";
|
||||
Backup("_" + MySettings.Phase3Suffix);
|
||||
mb.Append("Phase 3 Backup Complete");
|
||||
//Phase 4 - Convert to Approval Version
|
||||
ConvertToApproval();
|
||||
FixProceduresAndFunctions();
|
||||
if(!ConvertToApproval()) return;
|
||||
if(!FixProceduresAndFunctions()) return;
|
||||
mb.Append("Conversion to Approval Complete");
|
||||
if (MySettings.LoadApproved)
|
||||
{
|
||||
@ -828,13 +841,13 @@ namespace DataLoader
|
||||
AddInfo(mb.ToString());
|
||||
MessageBox.Show(mb.ToString(), "Processing Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ConvertToChangeManager()
|
||||
private bool ConvertToChangeManager()
|
||||
{
|
||||
RunScript("PROMStoCM.sql", MySettings.DBName);
|
||||
return RunScript("PROMStoCM.sql", MySettings.DBName);
|
||||
}
|
||||
private void ConvertToApproval()
|
||||
private bool ConvertToApproval()
|
||||
{
|
||||
RunScript("PROMStoAPPR.sql", MySettings.DBName);
|
||||
return RunScript("PROMStoAPPR.sql", MySettings.DBName);
|
||||
}
|
||||
private void formatOnlyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -885,7 +898,7 @@ namespace DataLoader
|
||||
private void convertToChangeManagerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToChangeManager();
|
||||
if(!ConvertToChangeManager()) return;
|
||||
MyInfo = "Conversion to Change Manager Complete";
|
||||
if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
@ -899,7 +912,7 @@ namespace DataLoader
|
||||
private void convertToApprovalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ProcessTime = DateTime.Now;
|
||||
ConvertToApproval();
|
||||
if(!ConvertToApproval()) return;
|
||||
MyInfo = "Conversion to Approval Complete";
|
||||
if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
@ -939,7 +952,7 @@ namespace DataLoader
|
||||
}
|
||||
private void fixesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FixProceduresAndFunctions();
|
||||
if (!FixProceduresAndFunctions()) return;
|
||||
if (MessageBox.Show("Backup Database?", "Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
Status = "Backing up Data";
|
||||
@ -949,9 +962,9 @@ namespace DataLoader
|
||||
//Status = "Processing Complete";
|
||||
//MessageBox.Show("Fixed Stored Procedures", "Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void FixProceduresAndFunctions()
|
||||
private bool FixProceduresAndFunctions()
|
||||
{
|
||||
RunScript("PROMSFixes.sql", MySettings.DBName);
|
||||
return RunScript("PROMSFixes.sql", MySettings.DBName);
|
||||
}
|
||||
#endregion
|
||||
#region Settings Menu Items
|
||||
@ -1021,19 +1034,9 @@ namespace DataLoader
|
||||
int bad = 0;
|
||||
foreach (string s in cms)
|
||||
{
|
||||
try
|
||||
{
|
||||
AddInfo("\r\nFixing database {0}\r\n", s);
|
||||
RunScript("PROMSFixes.sql", s);
|
||||
good++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddInfo("====****====");
|
||||
AddError(ex, "While processing database {0}", s);
|
||||
AddInfo("====****====");
|
||||
bad++;
|
||||
}
|
||||
AddInfo("\r\nFixing database {0}\r\n", s);
|
||||
if (RunScript("PROMSFixes.sql", s)) good++;
|
||||
else bad++;
|
||||
}
|
||||
AddInfo("\r\nFixing databases complete. {0} Fixed, {1} Failures", good, bad);
|
||||
Status = String.Format("Fixing databases complete. {0} Fixed, {1} Failures", good, bad);
|
||||
|
Loading…
x
Reference in New Issue
Block a user