Add option to fix all approval databases at once
Added Print Statements Corrected RestoreDeletedItem
This commit is contained in:
parent
27c6c39fbc
commit
7dbc0ddfe5
@ -163,9 +163,13 @@ BEGIN CATCH -- Catch Block
|
||||
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: PasteItemReplace Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: PasteItemReplace Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_ChronologyReport] Script Date: 03/20/2012 17:50:44 ******/
|
||||
GO
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
@ -347,6 +351,11 @@ and rpt.lastauditid is not null
|
||||
return
|
||||
end
|
||||
GO
|
||||
-- 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 [dbo].[PasteItemSiblingAfter] Script Date: 03/21/2012 15:25:31 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
@ -441,6 +450,11 @@ BEGIN CATCH -- Catch Block
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: PasteItemSiblingAfter Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: PasteItemSiblingAfter Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[PasteItemSiblingBefore] Script Date: 03/21/2012 15:26:23 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
@ -543,6 +557,11 @@ BEGIN CATCH -- Catch Block
|
||||
EXEC vlnErrorHandler
|
||||
END CATCH
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: PasteItemSiblingBefore Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: PasteItemSiblingBefore Error on Creation'
|
||||
GO
|
||||
|
||||
/****** Object: StoredProcedure [dbo].[getContentAuditsChronologyByItemID] Script Date: 03/21/2012 15:58:26 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
@ -596,6 +615,12 @@ begin
|
||||
order by OrdinalPath, contentid,auditid--actionwhen
|
||||
RETURN
|
||||
end
|
||||
go
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'StoredProcedure [getContentAuditsChronologyByItemID] Succeeded'
|
||||
ELSE PRINT 'StoredProcedure [getContentAuditsChronologyByItemID] Error on Creation'
|
||||
go
|
||||
|
||||
GO
|
||||
/****** Object: UserDefinedFunction [dbo].[vefn_FixSearchString] Script Date: 03/26/2012 09:31:13 ******/
|
||||
SET ANSI_NULLS ON
|
||||
@ -646,3 +671,80 @@ BEGIN
|
||||
RETURN '%' + @SearchString + '%'
|
||||
END
|
||||
GO
|
||||
-- Display the status
|
||||
IF (@@Error = 0) PRINT 'ScalerFunction [vefn_FixSearchString] Succeeded'
|
||||
ELSE PRINT 'ScalerFunction [vefn_FixSearchString] Error on Creation'
|
||||
go
|
||||
|
||||
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/*
|
||||
restoreDeletedItem 10133,1,10130,2
|
||||
select dbo.ve_GetPartContentID(10133)
|
||||
select dbo.ve_GetPartFromType(10133)
|
||||
select itemid from parts where contentid = 10126 and fromtype = 6
|
||||
SELECT ItemID FROM PartAudits WHERE DeleteStatus = 1
|
||||
|
||||
*/
|
||||
|
||||
ALTER PROCEDURE [dbo].[restoreDeletedItem]
|
||||
(
|
||||
@ItemID int,
|
||||
@DeleteID int,
|
||||
@CurrentID int,
|
||||
@Level int
|
||||
)
|
||||
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
DECLARE @PreviousID int
|
||||
DECLARE @NextID int
|
||||
DECLARE @ContentID int
|
||||
declare @fromtype int
|
||||
IF @Level = 0
|
||||
BEGIN
|
||||
SET @NextID = @CurrentID
|
||||
SELECT @PreviousID = PreviousID FROM Items WHERE ItemID = @CurrentID
|
||||
END
|
||||
IF @Level = 1
|
||||
BEGIN
|
||||
SELECT @NextID = ItemID FROM Items WHERE PreviousID = @CurrentID
|
||||
SET @PreviousID = @CurrentID
|
||||
END
|
||||
SELECT @ContentID = dbo.[ve_GetPartContentID](@ItemID)
|
||||
select @fromtype = dbo.[ve_GetPartFromType](@ItemID)
|
||||
if @level = 2
|
||||
begin
|
||||
select @NextID = itemid from parts where contentid = @contentid and fromtype = @fromtype
|
||||
end
|
||||
UPDATE tblParts SET DeleteStatus = 0 WHERE ItemID IN (SELECT ItemID FROM PartAudits WHERE DeleteStatus = @DeleteID)
|
||||
update tblparts set deletestatus = 0, itemid = @itemid where contentid = @contentid and fromtype = @fromtype
|
||||
UPDATE tblContents SET DeleteStatus = 0, ActionDTS = getdate() WHERE ContentID IN (SELECT ContentID FROM ContentAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblItems SET DeleteStatus = 0,PreviousID = CASE WHEN ItemID = @ItemID THEN @PreviousID ELSE PreviousID END
|
||||
WHERE ItemID IN (SELECT ItemID FROM ItemAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblGrids SET DeleteStatus = 0 WHERE ContentID IN (SELECT ContentID FROM ContentAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblEntries SET DeleteStatus = 0 WHERE DocID IN (SELECT DocID FROM EntryAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblAnnotations SET DeleteStatus = 0, ActionDTS = getdate() WHERE deletestatus = @deleteid -- ItemID in (SELECT ItemID FROM ItemAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblROUsages SET DeleteStatus = 0 WHERE deletestatus = @deleteid --ContentID IN (SELECT ContentID FROM ContentAudits WHERE DeleteStatus = @DeleteID)
|
||||
UPDATE tblTransitions SET DeleteStatus = 0 WHERE deletestatus = @deleteid --FromID IN (SELECT ContentID FROM ContentAudits WHERE DeleteStatus = @DeleteID)
|
||||
IF @NextID IS NOT NULL
|
||||
BEGIN
|
||||
UPDATE Items SET PreviousID = @ItemID WHERE ItemID = @NextID
|
||||
IF @ContentID IS NOT NULL
|
||||
BEGIN
|
||||
UPDATE Parts SET ItemID = @ItemID WHERE ItemID = @NextID and ContentID = @ContentID
|
||||
END
|
||||
END
|
||||
--else
|
||||
-- begin
|
||||
--update parts set itemid = @itemid where contentid = @contentid and fromtype = @fromtype
|
||||
-- end
|
||||
RETURN
|
||||
go
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: restoreDeletedItem Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: restoreDeletedItem Error on Creation'
|
||||
GO
|
||||
|
24
PROMS/DataLoader/frmLoader.Designer.cs
generated
24
PROMS/DataLoader/frmLoader.Designer.cs
generated
@ -71,6 +71,8 @@ namespace DataLoader
|
||||
this.countTokensToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.convertDbfSelectedInTreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fixAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.approvalDatabasesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sc.Panel1.SuspendLayout();
|
||||
this.sc.Panel2.SuspendLayout();
|
||||
this.sc.SuspendLayout();
|
||||
@ -236,7 +238,8 @@ namespace DataLoader
|
||||
this.fileToolStripMenuItem,
|
||||
this.processToolStripMenuItem,
|
||||
this.settingsToolStripMenuItem,
|
||||
this.oldToolStripMenuItem});
|
||||
this.oldToolStripMenuItem,
|
||||
this.fixAllToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(664, 24);
|
||||
@ -254,7 +257,7 @@ namespace DataLoader
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.exitToolStripMenuItem.Text = "E&xit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
@ -423,6 +426,21 @@ namespace DataLoader
|
||||
this.convertDbfSelectedInTreeToolStripMenuItem.Text = "Convert Dbf Selected In Tree";
|
||||
this.convertDbfSelectedInTreeToolStripMenuItem.Click += new System.EventHandler(this.convertDbfSelectedInTreeToolStripMenuItem_Click);
|
||||
//
|
||||
// fixAllToolStripMenuItem
|
||||
//
|
||||
this.fixAllToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.approvalDatabasesToolStripMenuItem});
|
||||
this.fixAllToolStripMenuItem.Name = "fixAllToolStripMenuItem";
|
||||
this.fixAllToolStripMenuItem.Size = new System.Drawing.Size(50, 20);
|
||||
this.fixAllToolStripMenuItem.Text = "Fix All";
|
||||
//
|
||||
// approvalDatabasesToolStripMenuItem
|
||||
//
|
||||
this.approvalDatabasesToolStripMenuItem.Name = "approvalDatabasesToolStripMenuItem";
|
||||
this.approvalDatabasesToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
|
||||
this.approvalDatabasesToolStripMenuItem.Text = "Approval Databases";
|
||||
this.approvalDatabasesToolStripMenuItem.Click += new System.EventHandler(this.approvalDatabasesToolStripMenuItem_Click);
|
||||
//
|
||||
// frmLoader
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -491,5 +509,7 @@ namespace DataLoader
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
|
||||
private System.Windows.Forms.ToolStripMenuItem load16BitApprovalToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fixesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fixAllToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem approvalDatabasesToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ using VEPROMS.CSLA.Library;
|
||||
using Config;
|
||||
using Volian.Controls.Library;
|
||||
using Volian.Base.Library;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
|
||||
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
|
||||
@ -823,6 +824,55 @@ namespace DataLoader
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void approvalDatabasesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
//MySettings.ConnectionString
|
||||
//"{DBName}", dbName
|
||||
string tmp = MySettings.ConnectionString.Replace("{DBName}", "master");
|
||||
SqlConnection cn = new SqlConnection(tmp);
|
||||
cn.Open();
|
||||
SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id(name + '..Items') is null then 'Not PROMS' when object_id(name + '..Revisions') is not null then 'Approval' when object_id(name + '..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
|
||||
DataSet ds = new DataSet();
|
||||
da.Fill(ds);
|
||||
cn.Close();
|
||||
List<string> cms = new List<string>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("The following databases will be fixed...\r\n");
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
if (dr["functionality"].ToString() == "Approval")
|
||||
{
|
||||
cms.Add(dr["name"].ToString());
|
||||
sb.Append("\r\n " + dr["name"].ToString());
|
||||
}
|
||||
}
|
||||
this.Cursor = Cursors.Default;
|
||||
if (MessageBox.Show(sb.ToString(), "Data Loader Fixes", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
|
||||
{
|
||||
int good = 0;
|
||||
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 databases complete. {0} Fixed, {1} Failures",good,bad);
|
||||
Status = String.Format("Fixing databases complete. {0} Fixed, {1} Failures", good, bad);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class MessageBuilder
|
||||
|
Loading…
x
Reference in New Issue
Block a user