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